aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Frontend/Rewrite
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/Rewrite')
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/Rewrite/FixItRewriter.cpp3
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/Rewrite/FrontendActions.cpp21
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/Rewrite/HTMLPrint.cpp2
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp145
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp226
-rw-r--r--contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp134
6 files changed, 260 insertions, 271 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/FixItRewriter.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
index 4fe64b96cb15..567bac576adb 100644
--- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/FixItRewriter.cpp
@@ -93,7 +93,8 @@ bool FixItRewriter::WriteFixedFiles(
}
for (iterator I = buffer_begin(), E = buffer_end(); I != E; ++I) {
- const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first);
+ OptionalFileEntryRef Entry =
+ Rewrite.getSourceMgr().getFileEntryRefForID(I->first);
int fd;
std::string Filename =
FixItOpts->RewriteFilename(std::string(Entry->getName()), fd);
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/FrontendActions.cpp
index 5351ff0593ed..cf5a9437e89e 100644
--- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -77,7 +77,7 @@ public:
SmallString<128> Path(Filename);
llvm::sys::path::replace_extension(Path,
NewSuffix + llvm::sys::path::extension(Path));
- return std::string(Path.str());
+ return std::string(Path);
}
};
@@ -88,7 +88,7 @@ public:
llvm::sys::fs::createTemporaryFile(llvm::sys::path::filename(Filename),
llvm::sys::path::extension(Filename).drop_front(), fd,
Path);
- return std::string(Path.str());
+ return std::string(Path);
}
};
} // end anonymous namespace
@@ -165,10 +165,11 @@ RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
if (std::unique_ptr<raw_ostream> OS =
CI.createDefaultOutputFile(false, InFile, "cpp")) {
if (CI.getLangOpts().ObjCRuntime.isNonFragile())
- return CreateModernObjCRewriter(
- std::string(InFile), std::move(OS), CI.getDiagnostics(),
- CI.getLangOpts(), CI.getDiagnosticOpts().NoRewriteMacros,
- (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo));
+ return CreateModernObjCRewriter(std::string(InFile), std::move(OS),
+ CI.getDiagnostics(), CI.getLangOpts(),
+ CI.getDiagnosticOpts().NoRewriteMacros,
+ (CI.getCodeGenOpts().getDebugInfo() !=
+ llvm::codegenoptions::NoDebugInfo));
return CreateObjCRewriter(std::string(InFile), std::move(OS),
CI.getDiagnostics(), CI.getLangOpts(),
CI.getDiagnosticOpts().NoRewriteMacros);
@@ -185,7 +186,7 @@ RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
void RewriteMacrosAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
std::unique_ptr<raw_ostream> OS =
- CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+ CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
if (!OS) return;
RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
@@ -194,7 +195,7 @@ void RewriteMacrosAction::ExecuteAction() {
void RewriteTestAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
std::unique_ptr<raw_ostream> OS =
- CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
+ CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
if (!OS) return;
DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -231,7 +232,7 @@ public:
assert(OS && "loaded module file after finishing rewrite action?");
(*OS) << "#pragma clang module build ";
- if (isValidIdentifier(MF->ModuleName))
+ if (isValidAsciiIdentifier(MF->ModuleName))
(*OS) << MF->ModuleName;
else {
(*OS) << '"';
@@ -270,7 +271,7 @@ public:
bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
if (!OutputStream) {
OutputStream =
- CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
+ CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
if (!OutputStream)
return false;
}
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/HTMLPrint.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/HTMLPrint.cpp
index 1388c2e1faab..69baa8f59108 100644
--- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/HTMLPrint.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/HTMLPrint.cpp
@@ -62,7 +62,7 @@ void HTMLPrinter::HandleTranslationUnit(ASTContext &Ctx) {
// Format the file.
FileID FID = R.getSourceMgr().getMainFileID();
- const FileEntry* Entry = R.getSourceMgr().getFileEntryForID(FID);
+ OptionalFileEntryRef Entry = R.getSourceMgr().getFileEntryRefForID(FID);
StringRef Name;
// In some cases, in particular the case where the input is from stdin,
// there is no entry. Fall back to the memory buffer for a name in those
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
index 3f2a78127477..1462058003b3 100644
--- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -14,11 +14,11 @@
#include "clang/Rewrite/Frontend/Rewriters.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
-#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Pragma.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/raw_ostream.h"
+#include <optional>
using namespace clang;
using namespace llvm;
@@ -31,10 +31,8 @@ class InclusionRewriter : public PPCallbacks {
struct IncludedFile {
FileID Id;
SrcMgr::CharacteristicKind FileType;
- const DirectoryLookup *DirLookup;
- IncludedFile(FileID Id, SrcMgr::CharacteristicKind FileType,
- const DirectoryLookup *DirLookup)
- : Id(Id), FileType(FileType), DirLookup(DirLookup) {}
+ IncludedFile(FileID Id, SrcMgr::CharacteristicKind FileType)
+ : Id(Id), FileType(FileType) {}
};
Preprocessor &PP; ///< Used to find inclusion directives.
SourceManager &SM; ///< Used to read and manage source files.
@@ -57,8 +55,7 @@ class InclusionRewriter : public PPCallbacks {
public:
InclusionRewriter(Preprocessor &PP, raw_ostream &OS, bool ShowLineMarkers,
bool UseLineDirectives);
- void Process(FileID FileId, SrcMgr::CharacteristicKind FileType,
- const DirectoryLookup *DirLookup);
+ void Process(FileID FileId, SrcMgr::CharacteristicKind FileType);
void setPredefinesBuffer(const llvm::MemoryBufferRef &Buf) {
PredefinesBuffer = Buf;
}
@@ -76,9 +73,10 @@ private:
SrcMgr::CharacteristicKind FileType) override;
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
- CharSourceRange FilenameRange, const FileEntry *File,
- StringRef SearchPath, StringRef RelativePath,
- const Module *Imported,
+ CharSourceRange FilenameRange,
+ OptionalFileEntryRef File, StringRef SearchPath,
+ StringRef RelativePath, const Module *SuggestedModule,
+ bool ModuleImported,
SrcMgr::CharacteristicKind FileType) override;
void If(SourceLocation Loc, SourceRange ConditionRange,
ConditionValueKind ConditionValue) override;
@@ -93,8 +91,10 @@ private:
bool EnsureNewline);
void CommentOutDirective(Lexer &DirectivesLex, const Token &StartToken,
const MemoryBufferRef &FromFile, StringRef EOL,
- unsigned &NextToWrite, int &Lines);
+ unsigned &NextToWrite, int &Lines,
+ const IncludedFile *Inc = nullptr);
const IncludedFile *FindIncludeAtLocation(SourceLocation Loc) const;
+ StringRef getIncludedFileName(const IncludedFile *Inc) const;
const Module *FindModuleAtLocation(SourceLocation Loc) const;
const Module *FindEnteredModule(SourceLocation Loc) const;
bool IsIfAtLocationTrue(SourceLocation Loc) const;
@@ -162,8 +162,7 @@ void InclusionRewriter::FileChanged(SourceLocation Loc,
return;
FileID Id = FullSourceLoc(Loc, SM).getFileID();
auto P = FileIncludes.insert(
- std::make_pair(LastInclusionLocation,
- IncludedFile(Id, NewFileType, PP.GetCurDirLookup())));
+ std::make_pair(LastInclusionLocation, IncludedFile(Id, NewFileType)));
(void)P;
assert(P.second && "Unexpected revisitation of the same include directive");
LastInclusionLocation = SourceLocation();
@@ -186,18 +185,15 @@ void InclusionRewriter::FileSkipped(const FileEntryRef & /*SkippedFile*/,
/// FileChanged() or FileSkipped() is called after this (or neither is
/// called if this #include results in an error or does not textually include
/// anything).
-void InclusionRewriter::InclusionDirective(SourceLocation HashLoc,
- const Token &/*IncludeTok*/,
- StringRef /*FileName*/,
- bool /*IsAngled*/,
- CharSourceRange /*FilenameRange*/,
- const FileEntry * /*File*/,
- StringRef /*SearchPath*/,
- StringRef /*RelativePath*/,
- const Module *Imported,
- SrcMgr::CharacteristicKind FileType){
- if (Imported) {
- auto P = ModuleIncludes.insert(std::make_pair(HashLoc, Imported));
+void InclusionRewriter::InclusionDirective(
+ SourceLocation HashLoc, const Token & /*IncludeTok*/,
+ StringRef /*FileName*/, bool /*IsAngled*/,
+ CharSourceRange /*FilenameRange*/, OptionalFileEntryRef /*File*/,
+ StringRef /*SearchPath*/, StringRef /*RelativePath*/,
+ const Module *SuggestedModule, bool ModuleImported,
+ SrcMgr::CharacteristicKind FileType) {
+ if (ModuleImported) {
+ auto P = ModuleIncludes.insert(std::make_pair(HashLoc, SuggestedModule));
(void)P;
assert(P.second && "Unexpected revisitation of the same include directive");
} else
@@ -256,28 +252,13 @@ bool InclusionRewriter::IsIfAtLocationTrue(SourceLocation Loc) const {
return false;
}
-/// Detect the likely line ending style of \p FromFile by examining the first
-/// newline found within it.
-static StringRef DetectEOL(const MemoryBufferRef &FromFile) {
- // Detect what line endings the file uses, so that added content does not mix
- // the style. We need to check for "\r\n" first because "\n\r" will match
- // "\r\n\r\n".
- const char *Pos = strchr(FromFile.getBufferStart(), '\n');
- if (!Pos)
- return "\n";
- if (Pos - 1 >= FromFile.getBufferStart() && Pos[-1] == '\r')
- return "\r\n";
- if (Pos + 1 < FromFile.getBufferEnd() && Pos[1] == '\r')
- return "\n\r";
- return "\n";
-}
-
void InclusionRewriter::detectMainFileEOL() {
- Optional<MemoryBufferRef> FromFile = *SM.getBufferOrNone(SM.getMainFileID());
+ std::optional<MemoryBufferRef> FromFile =
+ *SM.getBufferOrNone(SM.getMainFileID());
assert(FromFile);
if (!FromFile)
return; // Should never happen, but whatever.
- MainEOL = DetectEOL(*FromFile);
+ MainEOL = FromFile->getBuffer().detectEOL();
}
/// Writes out bytes from \p FromFile, starting at \p NextToWrite and ending at
@@ -304,30 +285,47 @@ void InclusionRewriter::OutputContentUpTo(const MemoryBufferRef &FromFile,
StringRef TextToWrite(FromFile.getBufferStart() + WriteFrom,
WriteTo - WriteFrom);
+ // count lines manually, it's faster than getPresumedLoc()
+ Line += TextToWrite.count(LocalEOL);
if (MainEOL == LocalEOL) {
OS << TextToWrite;
- // count lines manually, it's faster than getPresumedLoc()
- Line += TextToWrite.count(LocalEOL);
- if (EnsureNewline && !TextToWrite.endswith(LocalEOL))
- OS << MainEOL;
} else {
// Output the file one line at a time, rewriting the line endings as we go.
StringRef Rest = TextToWrite;
while (!Rest.empty()) {
- StringRef LineText;
- std::tie(LineText, Rest) = Rest.split(LocalEOL);
+ // Identify and output the next line excluding an EOL sequence if present.
+ size_t Idx = Rest.find(LocalEOL);
+ StringRef LineText = Rest.substr(0, Idx);
OS << LineText;
- Line++;
- if (!Rest.empty())
+ if (Idx != StringRef::npos) {
+ // An EOL sequence was present, output the EOL sequence for the
+ // main source file and skip past the local EOL sequence.
OS << MainEOL;
+ Idx += LocalEOL.size();
+ }
+ // Strip the line just handled. If Idx is npos or matches the end of the
+ // text, Rest will be set to an empty string and the loop will terminate.
+ Rest = Rest.substr(Idx);
}
- if (TextToWrite.endswith(LocalEOL) || EnsureNewline)
- OS << MainEOL;
}
+ if (EnsureNewline && !TextToWrite.ends_with(LocalEOL))
+ OS << MainEOL;
+
WriteFrom = WriteTo;
}
+StringRef
+InclusionRewriter::getIncludedFileName(const IncludedFile *Inc) const {
+ if (Inc) {
+ auto B = SM.getBufferOrNone(Inc->Id);
+ assert(B && "Attempting to process invalid inclusion");
+ if (B)
+ return llvm::sys::path::filename(B->getBufferIdentifier());
+ }
+ return StringRef();
+}
+
/// Print characters from \p FromFile starting at \p NextToWrite up until the
/// inclusion directive at \p StartToken, then print out the inclusion
/// inclusion directive disabled by a #if directive, updating \p NextToWrite
@@ -337,7 +335,8 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex,
const Token &StartToken,
const MemoryBufferRef &FromFile,
StringRef LocalEOL,
- unsigned &NextToWrite, int &Line) {
+ unsigned &NextToWrite, int &Line,
+ const IncludedFile *Inc) {
OutputContentUpTo(FromFile, NextToWrite,
SM.getFileOffset(StartToken.getLocation()), LocalEOL, Line,
false);
@@ -349,12 +348,21 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex,
// OutputContentUpTo() would not output anything anyway.
return;
}
- OS << "#if 0 /* expanded by -frewrite-includes */" << MainEOL;
+ if (Inc) {
+ OS << "#if defined(__CLANG_REWRITTEN_INCLUDES) ";
+ if (isSystem(Inc->FileType))
+ OS << "|| defined(__CLANG_REWRITTEN_SYSTEM_INCLUDES) ";
+ OS << "/* " << getIncludedFileName(Inc);
+ } else {
+ OS << "#if 0 /*";
+ }
+ OS << " expanded by -frewrite-includes */" << MainEOL;
OutputContentUpTo(FromFile, NextToWrite,
SM.getFileOffset(DirectiveToken.getLocation()) +
DirectiveToken.getLength(),
LocalEOL, Line, true);
- OS << "#endif /* expanded by -frewrite-includes */" << MainEOL;
+ OS << (Inc ? "#else /* " : "#endif /*") << getIncludedFileName(Inc)
+ << " expanded by -frewrite-includes */" << MainEOL;
}
/// Find the next identifier in the pragma directive specified by \p RawToken.
@@ -371,8 +379,7 @@ StringRef InclusionRewriter::NextIdentifierName(Lexer &RawLex,
/// Use a raw lexer to analyze \p FileId, incrementally copying parts of it
/// and including content of included files recursively.
void InclusionRewriter::Process(FileID FileId,
- SrcMgr::CharacteristicKind FileType,
- const DirectoryLookup *DirLookup) {
+ SrcMgr::CharacteristicKind FileType) {
MemoryBufferRef FromFile;
{
auto B = SM.getBufferOrNone(FileId);
@@ -384,7 +391,7 @@ void InclusionRewriter::Process(FileID FileId,
Lexer RawLex(FileId, FromFile, PP.getSourceManager(), PP.getLangOpts());
RawLex.SetCommentRetentionState(false);
- StringRef LocalEOL = DetectEOL(FromFile);
+ StringRef LocalEOL = FromFile.getBuffer().detectEOL();
// Per the GNU docs: "1" indicates entering a new file.
if (FileId == SM.getMainFileID() || FileId == PP.getPredefinesFileID())
@@ -418,26 +425,32 @@ void InclusionRewriter::Process(FileID FileId,
case tok::pp_include:
case tok::pp_include_next:
case tok::pp_import: {
- CommentOutDirective(RawLex, HashToken, FromFile, LocalEOL, NextToWrite,
- Line);
+ SourceLocation Loc = HashToken.getLocation();
+ const IncludedFile *Inc = FindIncludeAtLocation(Loc);
+ CommentOutDirective(RawLex, HashToken, FromFile, LocalEOL,
+ NextToWrite, Line, Inc);
if (FileId != PP.getPredefinesFileID())
WriteLineInfo(FileName, Line - 1, FileType, "");
StringRef LineInfoExtra;
- SourceLocation Loc = HashToken.getLocation();
if (const Module *Mod = FindModuleAtLocation(Loc))
WriteImplicitModuleImport(Mod);
- else if (const IncludedFile *Inc = FindIncludeAtLocation(Loc)) {
+ else if (Inc) {
const Module *Mod = FindEnteredModule(Loc);
if (Mod)
OS << "#pragma clang module begin "
<< Mod->getFullModuleName(true) << "\n";
// Include and recursively process the file.
- Process(Inc->Id, Inc->FileType, Inc->DirLookup);
+ Process(Inc->Id, Inc->FileType);
if (Mod)
OS << "#pragma clang module end /*"
<< Mod->getFullModuleName(true) << "*/\n";
+ // There's no #include, therefore no #if, for -include files.
+ if (FromFile != PredefinesBuffer) {
+ OS << "#endif /* " << getIncludedFileName(Inc)
+ << " expanded by -frewrite-includes */" << LocalEOL;
+ }
// Add line marker to indicate we're returning from an included
// file.
@@ -559,7 +572,7 @@ void clang::RewriteIncludesInInput(Preprocessor &PP, raw_ostream *OS,
Rewrite->handleModuleBegin(Tok);
} while (Tok.isNot(tok::eof));
Rewrite->setPredefinesBuffer(SM.getBufferOrFake(PP.getPredefinesFileID()));
- Rewrite->Process(PP.getPredefinesFileID(), SrcMgr::C_User, nullptr);
- Rewrite->Process(SM.getMainFileID(), SrcMgr::C_User, nullptr);
+ Rewrite->Process(PP.getPredefinesFileID(), SrcMgr::C_User);
+ Rewrite->Process(SM.getMainFileID(), SrcMgr::C_User);
OS->flush();
}
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index 9d5366bb161e..3849e4040b53 100644
--- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -24,6 +24,7 @@
#include "clang/Lex/Lexer.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -272,10 +273,9 @@ namespace {
std::string SStr;
llvm::raw_string_ostream S(SStr);
New->printPretty(S, nullptr, PrintingPolicy(LangOpts));
- const std::string &Str = S.str();
// If replacement succeeded or warning disabled return with no warning.
- if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, Str)) {
+ if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, SStr)) {
ReplacedNodes[Old] = New;
return;
}
@@ -464,15 +464,15 @@ namespace {
std::string SynthesizeByrefCopyDestroyHelper(VarDecl *VD, int flag);
std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
- StringRef funcName, std::string Tag);
- std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
- StringRef funcName, std::string Tag);
- std::string SynthesizeBlockImpl(BlockExpr *CE,
- std::string Tag, std::string Desc);
- std::string SynthesizeBlockDescriptor(std::string DescTag,
- std::string ImplTag,
- int i, StringRef funcName,
- unsigned hasCopy);
+ StringRef funcName,
+ const std::string &Tag);
+ std::string SynthesizeBlockFunc(BlockExpr *CE, int i, StringRef funcName,
+ const std::string &Tag);
+ std::string SynthesizeBlockImpl(BlockExpr *CE, const std::string &Tag,
+ const std::string &Desc);
+ std::string SynthesizeBlockDescriptor(const std::string &DescTag,
+ const std::string &ImplTag, int i,
+ StringRef funcName, unsigned hasCopy);
Stmt *SynthesizeBlockCall(CallExpr *Exp, const Expr* BlockExp);
void SynthesizeBlockLiterals(SourceLocation FunLocStart,
StringRef FunName);
@@ -585,13 +585,13 @@ namespace {
CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty,
CastKind Kind, Expr *E) {
TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation());
- return CStyleCastExpr::Create(*Ctx, Ty, VK_RValue, Kind, E, nullptr,
+ return CStyleCastExpr::Create(*Ctx, Ty, VK_PRValue, Kind, E, nullptr,
FPOptionsOverride(), TInfo,
SourceLocation(), SourceLocation());
}
bool ImplementationIsNonLazy(const ObjCImplDecl *OD) const {
- IdentifierInfo* II = &Context->Idents.get("load");
+ const IdentifierInfo *II = &Context->Idents.get("load");
Selector LoadSel = Context->Selectors.getSelector(0, &II);
return OD->getClassMethod(LoadSel) != nullptr;
}
@@ -599,8 +599,8 @@ namespace {
StringLiteral *getStringLiteral(StringRef Str) {
QualType StrType = Context->getConstantArrayType(
Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr,
- ArrayType::Normal, 0);
- return StringLiteral::Create(*Context, Str, StringLiteral::Ascii,
+ ArraySizeModifier::Normal, 0);
+ return StringLiteral::Create(*Context, Str, StringLiteralKind::Ordinary,
/*Pascal=*/false, StrType, SourceLocation());
}
};
@@ -633,7 +633,7 @@ static bool IsHeaderFile(const std::string &Filename) {
return false;
}
- std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
+ std::string Ext = Filename.substr(DotPos + 1);
// C header: .h
// C++ header: .hh or .H;
return Ext == "h" || Ext == "hh" || Ext == "H";
@@ -852,7 +852,7 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
if (D->isBitField())
IvarT = GetGroupRecordTypeForObjCIvarBitfield(D);
- if (!isa<TypedefType>(IvarT) && IvarT->isRecordType()) {
+ if (!IvarT->getAs<TypedefType>() && IvarT->isRecordType()) {
RecordDecl *RD = IvarT->castAs<RecordType>()->getDecl();
RD = RD->getDefinition();
if (RD && !RD->getDeclName().getAsIdentifierInfo()) {
@@ -863,9 +863,9 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
CDecl = CatDecl->getClassInterface();
std::string RecName = std::string(CDecl->getName());
RecName += "_IMPL";
- RecordDecl *RD =
- RecordDecl::Create(*Context, TTK_Struct, TUDecl, SourceLocation(),
- SourceLocation(), &Context->Idents.get(RecName));
+ RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
+ SourceLocation(), SourceLocation(),
+ &Context->Idents.get(RecName));
QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD));
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
@@ -1957,15 +1957,15 @@ Stmt *RewriteModernObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
// @try -> try
ReplaceText(startLoc, 1, "");
- for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
- ObjCAtCatchStmt *Catch = S->getCatchStmt(I);
+ for (ObjCAtCatchStmt *Catch : S->catch_stmts()) {
VarDecl *catchDecl = Catch->getCatchParamDecl();
startLoc = Catch->getBeginLoc();
bool AtRemoved = false;
if (catchDecl) {
QualType t = catchDecl->getType();
- if (const ObjCObjectPointerType *Ptr = t->getAs<ObjCObjectPointerType>()) {
+ if (const ObjCObjectPointerType *Ptr =
+ t->getAs<ObjCObjectPointerType>()) {
// Should be a pointer to a class.
ObjCInterfaceDecl *IDecl = Ptr->getObjectType()->getInterface();
if (IDecl) {
@@ -2107,12 +2107,12 @@ RewriteModernObjC::SynthesizeCallToFunctionDecl(FunctionDecl *FD,
QualType pToFunc = Context->getPointerType(msgSendType);
ImplicitCastExpr *ICE =
ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay,
- DRE, nullptr, VK_RValue, FPOptionsOverride());
+ DRE, nullptr, VK_PRValue, FPOptionsOverride());
const auto *FT = msgSendType->castAs<FunctionType>();
CallExpr *Exp =
CallExpr::Create(*Context, ICE, Args, FT->getCallResultType(*Context),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
return Exp;
}
@@ -2580,7 +2580,7 @@ Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
std::string prettyBufS;
llvm::raw_string_ostream prettyBuf(prettyBufS);
Exp->getString()->printPretty(prettyBuf, nullptr, PrintingPolicy(LangOpts));
- Preamble += prettyBuf.str();
+ Preamble += prettyBufS;
Preamble += ",";
Preamble += utostr(Exp->getString()->getByteLength()) + "};\n";
@@ -2591,7 +2591,7 @@ Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation());
Expr *Unop = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), DRE, UO_AddrOf,
- Context->getPointerType(DRE->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(DRE->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
// cast to NSConstantString *
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(),
@@ -2694,7 +2694,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) {
auto *FT = msgSendType->castAs<FunctionType>();
CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
ReplaceStmt(Exp, CE);
return CE;
}
@@ -2720,7 +2720,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) {
std::string NSArrayFName("__NSContainer_literal");
FunctionDecl *NSArrayFD = SynthBlockInitFunctionDecl(NSArrayFName);
DeclRefExpr *NSArrayDRE = new (Context) DeclRefExpr(
- *Context, NSArrayFD, false, NSArrayFType, VK_RValue, SourceLocation());
+ *Context, NSArrayFD, false, NSArrayFType, VK_PRValue, SourceLocation());
SmallVector<Expr*, 16> InitExprs;
unsigned NumElements = Exp->getNumElements();
@@ -2815,7 +2815,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) {
const FunctionType *FT = msgSendType->castAs<FunctionType>();
CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
ReplaceStmt(Exp, CE);
return CE;
}
@@ -2841,7 +2841,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral
std::string NSDictFName("__NSContainer_literal");
FunctionDecl *NSDictFD = SynthBlockInitFunctionDecl(NSDictFName);
DeclRefExpr *NSDictDRE = new (Context) DeclRefExpr(
- *Context, NSDictFD, false, NSDictFType, VK_RValue, SourceLocation());
+ *Context, NSDictFD, false, NSDictFType, VK_PRValue, SourceLocation());
SmallVector<Expr*, 16> KeyExprs;
SmallVector<Expr*, 16> ValueExprs;
@@ -2967,7 +2967,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral
const FunctionType *FT = msgSendType->castAs<FunctionType>();
CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
ReplaceStmt(Exp, CE);
return CE;
}
@@ -2977,9 +2977,9 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral
// };
QualType RewriteModernObjC::getSuperStructType() {
if (!SuperStructDecl) {
- SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- &Context->Idents.get("__rw_objc_super"));
+ SuperStructDecl = RecordDecl::Create(
+ *Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
+ SourceLocation(), &Context->Idents.get("__rw_objc_super"));
QualType FieldTypes[2];
// struct objc_object *object;
@@ -3005,9 +3005,9 @@ QualType RewriteModernObjC::getSuperStructType() {
QualType RewriteModernObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
- ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- &Context->Idents.get("__NSConstantStringImpl"));
+ ConstantStringDecl = RecordDecl::Create(
+ *Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
+ SourceLocation(), &Context->Idents.get("__NSConstantStringImpl"));
QualType FieldTypes[4];
// struct objc_object *receiver;
@@ -3177,7 +3177,7 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla
FunctionDecl::Create(*Context, TUDecl, SourceLocation(), SourceLocation(),
ID, FuncType, nullptr, SC_Extern, false, false);
DeclRefExpr *DRE = new (Context)
- DeclRefExpr(*Context, FD, false, castType, VK_RValue, SourceLocation());
+ DeclRefExpr(*Context, FD, false, castType, VK_PRValue, SourceLocation());
CallExpr *STCE =
CallExpr::Create(*Context, DRE, MsgExprs, castType, VK_LValue,
SourceLocation(), FPOptionsOverride());
@@ -3242,16 +3242,11 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
SmallVector<Expr*, 4> InitExprs;
// set the receiver to self, the first argument to all methods.
- InitExprs.push_back(
- NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
- CK_BitCast,
- new (Context) DeclRefExpr(*Context,
- CurMethodDef->getSelfDecl(),
- false,
- Context->getObjCIdType(),
- VK_RValue,
- SourceLocation()))
- ); // set the 'receiver'.
+ InitExprs.push_back(NoTypeInfoCStyleCastExpr(
+ Context, Context->getObjCIdType(), CK_BitCast,
+ new (Context) DeclRefExpr(*Context, CurMethodDef->getSelfDecl(), false,
+ Context->getObjCIdType(), VK_PRValue,
+ SourceLocation()))); // set the 'receiver'.
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
SmallVector<Expr*, 8> ClsExprs;
@@ -3291,7 +3286,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
//
SuperRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf,
- Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
SuperRep = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(superType),
@@ -3309,7 +3304,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
// struct __rw_objc_super *
SuperRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf,
- Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
}
MsgExprs.push_back(SuperRep);
@@ -3339,15 +3334,11 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface();
SmallVector<Expr*, 4> InitExprs;
- InitExprs.push_back(
- NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
- CK_BitCast,
- new (Context) DeclRefExpr(*Context,
- CurMethodDef->getSelfDecl(),
- false,
- Context->getObjCIdType(),
- VK_RValue, SourceLocation()))
- ); // set the 'receiver'.
+ InitExprs.push_back(NoTypeInfoCStyleCastExpr(
+ Context, Context->getObjCIdType(), CK_BitCast,
+ new (Context) DeclRefExpr(*Context, CurMethodDef->getSelfDecl(), false,
+ Context->getObjCIdType(), VK_PRValue,
+ SourceLocation()))); // set the 'receiver'.
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
SmallVector<Expr*, 8> ClsExprs;
@@ -3387,7 +3378,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
//
SuperRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf,
- Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
SuperRep = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(superType),
@@ -3399,9 +3390,8 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
SourceLocation());
TypeSourceInfo *superTInfo
= Context->getTrivialTypeSourceInfo(superType);
- SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
- superType, VK_RValue, ILE,
- false);
+ SuperRep = new (Context) CompoundLiteralExpr(
+ SourceLocation(), superTInfo, superType, VK_PRValue, ILE, false);
}
MsgExprs.push_back(SuperRep);
break;
@@ -3543,7 +3533,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
const FunctionType *FT = msgSendType->castAs<FunctionType>();
CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
Stmt *ReplacingStmt = CE;
if (MsgSendStretFlavor) {
// We have the method which returns a struct/union. Must also generate
@@ -3638,7 +3628,7 @@ bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCContainerDecl *IDecl,
/// It handles elaborated types, as well as enum types in the process.
bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type,
std::string &Result) {
- if (isa<TypedefType>(Type)) {
+ if (Type->getAs<TypedefType>()) {
Result += "\t";
return false;
}
@@ -3684,8 +3674,7 @@ bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type,
Result += " {\n";
for (const auto *EC : ED->enumerators()) {
Result += "\t"; Result += EC->getName(); Result += " = ";
- llvm::APSInt Val = EC->getInitVal();
- Result += Val.toString(10);
+ Result += toString(EC->getInitVal(), 10);
Result += ",\n";
}
Result += "\t} ";
@@ -3734,7 +3723,7 @@ void RewriteModernObjC::RewriteObjCFieldDecl(FieldDecl *fieldDecl,
void RewriteModernObjC::RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDecl,
std::string &Result) {
QualType Type = fieldDecl->getType();
- if (isa<TypedefType>(Type))
+ if (Type->getAs<TypedefType>())
return;
if (Type->isArrayType())
Type = Context->getBaseElementType(Type);
@@ -3792,10 +3781,9 @@ QualType RewriteModernObjC::SynthesizeBitfieldGroupStructType(
SmallVectorImpl<ObjCIvarDecl *> &IVars) {
std::string StructTagName;
ObjCIvarBitfieldGroupType(IV, StructTagName);
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct,
- Context->getTranslationUnitDecl(),
- SourceLocation(), SourceLocation(),
- &Context->Idents.get(StructTagName));
+ RecordDecl *RD = RecordDecl::Create(
+ *Context, TagTypeKind::Struct, Context->getTranslationUnitDecl(),
+ SourceLocation(), SourceLocation(), &Context->Idents.get(StructTagName));
for (unsigned i=0, e = IVars.size(); i < e; i++) {
ObjCIvarDecl *Ivar = IVars[i];
RD->addDecl(FieldDecl::Create(*Context, RD, SourceLocation(), SourceLocation(),
@@ -4048,7 +4036,7 @@ static bool HasLocalVariableExternalStorage(ValueDecl *VD) {
std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName,
- std::string Tag) {
+ const std::string &Tag) {
const FunctionType *AFT = CE->getFunctionType();
QualType RT = AFT->getReturnType();
std::string StructRef = "struct " + Tag;
@@ -4142,9 +4130,8 @@ std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
return S;
}
-std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
- StringRef funcName,
- std::string Tag) {
+std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(
+ BlockExpr *CE, int i, StringRef funcName, const std::string &Tag) {
std::string StructRef = "struct " + Tag;
std::string S = "static void __";
@@ -4186,8 +4173,9 @@ std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
return S;
}
-std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
- std::string Desc) {
+std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE,
+ const std::string &Tag,
+ const std::string &Desc) {
std::string S = "\nstruct " + Tag;
std::string Constructor = " " + Tag;
@@ -4301,10 +4289,9 @@ std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta
return S;
}
-std::string RewriteModernObjC::SynthesizeBlockDescriptor(std::string DescTag,
- std::string ImplTag, int i,
- StringRef FunName,
- unsigned hasCopy) {
+std::string RewriteModernObjC::SynthesizeBlockDescriptor(
+ const std::string &DescTag, const std::string &ImplTag, int i,
+ StringRef FunName, unsigned hasCopy) {
std::string S = "\nstatic struct " + DescTag;
S += " {\n size_t reserved;\n";
@@ -4426,7 +4413,7 @@ void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
llvm::raw_string_ostream constructorExprBuf(SStr);
GlobalConstructionExp->printPretty(constructorExprBuf, nullptr,
PrintingPolicy(LangOpts));
- globalBuf += constructorExprBuf.str();
+ globalBuf += SStr;
globalBuf += ";\n";
InsertText(FunLocStart, globalBuf);
GlobalConstructionExp = nullptr;
@@ -4580,11 +4567,9 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
Expr *RHSExp = CEXPR->getRHS();
Stmt *RHSStmt = SynthesizeBlockCall(Exp, RHSExp);
Expr *CONDExp = CEXPR->getCond();
- ConditionalOperator *CondExpr =
- new (Context) ConditionalOperator(CONDExp,
- SourceLocation(), cast<Expr>(LHSStmt),
- SourceLocation(), cast<Expr>(RHSStmt),
- Exp->getType(), VK_RValue, OK_Ordinary);
+ ConditionalOperator *CondExpr = new (Context) ConditionalOperator(
+ CONDExp, SourceLocation(), cast<Expr>(LHSStmt), SourceLocation(),
+ cast<Expr>(RHSStmt), Exp->getType(), VK_PRValue, OK_Ordinary);
return CondExpr;
} else if (const ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(BlockExp)) {
CPT = IRE->getType()->getAs<BlockPointerType>();
@@ -4600,7 +4585,7 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__block_impl"));
QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
@@ -4654,7 +4639,7 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
BlkExprs.push_back(*I);
}
CallExpr *CE =
- CallExpr::Create(*Context, PE, BlkExprs, Exp->getType(), VK_RValue,
+ CallExpr::Create(*Context, PE, BlkExprs, Exp->getType(), VK_PRValue,
SourceLocation(), FPOptionsOverride());
return CE;
}
@@ -5283,7 +5268,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
FD = SynthBlockInitFunctionDecl(Tag);
DeclRefExpr *DRE = new (Context)
- DeclRefExpr(*Context, FD, false, FType, VK_RValue, SourceLocation());
+ DeclRefExpr(*Context, FD, false, FType, VK_PRValue, SourceLocation());
SmallVector<Expr*, 4> InitExprs;
@@ -5305,7 +5290,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
const_cast<ASTContext &>(*Context),
new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy,
VK_LValue, SourceLocation()),
- UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), VK_RValue,
+ UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), VK_PRValue,
OK_Ordinary, SourceLocation(), false, FPOptionsOverride());
InitExprs.push_back(DescRefExpr);
@@ -5323,9 +5308,10 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
if (HasLocalVariableExternalStorage(*I)) {
QualType QT = (*I)->getType();
QT = Context->getPointerType(QT);
- Exp = UnaryOperator::Create(
- const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, QT, VK_RValue,
- OK_Ordinary, SourceLocation(), false, FPOptionsOverride());
+ Exp = UnaryOperator::Create(const_cast<ASTContext &>(*Context), Exp,
+ UO_AddrOf, QT, VK_PRValue, OK_Ordinary,
+ SourceLocation(), false,
+ FPOptionsOverride());
}
} else if (isTopLevelBlockPointerType((*I)->getType())) {
FD = SynthBlockInitFunctionDecl((*I)->getName());
@@ -5340,9 +5326,10 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
if (HasLocalVariableExternalStorage(*I)) {
QualType QT = (*I)->getType();
QT = Context->getPointerType(QT);
- Exp = UnaryOperator::Create(
- const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, QT, VK_RValue,
- OK_Ordinary, SourceLocation(), false, FPOptionsOverride());
+ Exp = UnaryOperator::Create(const_cast<ASTContext &>(*Context), Exp,
+ UO_AddrOf, QT, VK_PRValue, OK_Ordinary,
+ SourceLocation(), false,
+ FPOptionsOverride());
}
}
@@ -5357,9 +5344,9 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
RewriteByRefString(RecName, Name, ND, true);
IdentifierInfo *II = &Context->Idents.get(RecName.c_str()
+ sizeof("struct"));
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- II);
+ RecordDecl *RD =
+ RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
+ SourceLocation(), SourceLocation(), II);
assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -5367,22 +5354,21 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
Exp = new (Context) DeclRefExpr(*Context, FD, false, FD->getType(),
VK_LValue, SourceLocation());
bool isNestedCapturedVar = false;
- if (block)
- for (const auto &CI : block->captures()) {
- const VarDecl *variable = CI.getVariable();
- if (variable == ND && CI.isNested()) {
- assert (CI.isByRef() &&
- "SynthBlockInitExpr - captured block variable is not byref");
- isNestedCapturedVar = true;
- break;
- }
+ for (const auto &CI : block->captures()) {
+ const VarDecl *variable = CI.getVariable();
+ if (variable == ND && CI.isNested()) {
+ assert(CI.isByRef() &&
+ "SynthBlockInitExpr - captured block variable is not byref");
+ isNestedCapturedVar = true;
+ break;
}
+ }
// captured nested byref variable has its address passed. Do not take
// its address again.
if (!isNestedCapturedVar)
Exp = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), Exp, UO_AddrOf,
- Context->getPointerType(Exp->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(Exp->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_BitCast, Exp);
InitExprs.push_back(Exp);
@@ -5409,7 +5395,7 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
NewRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), NewRep, UO_AddrOf,
- Context->getPointerType(NewRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(NewRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_BitCast,
NewRep);
@@ -6734,7 +6720,7 @@ static void Write_IvarOffsetVar(RewriteModernObjC &RewriteObj,
std::string &Result,
ArrayRef<ObjCIvarDecl *> Ivars,
ObjCInterfaceDecl *CDecl) {
- // FIXME. visibilty of offset symbols may have to be set; for Darwin
+ // FIXME. visibility of offset symbols may have to be set; for Darwin
// this is what happens:
/**
if (Ivar->getAccessControl() == ObjCIvarDecl::Private ||
@@ -6866,7 +6852,7 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl,
std::vector<ObjCMethodDecl *> InstanceMethods, ClassMethods;
std::vector<ObjCMethodDecl *> OptInstanceMethods, OptClassMethods;
for (auto *MD : PDecl->instance_methods()) {
- if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
+ if (MD->getImplementationControl() == ObjCImplementationControl::Optional) {
OptInstanceMethods.push_back(MD);
} else {
InstanceMethods.push_back(MD);
@@ -6874,7 +6860,7 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl,
}
for (auto *MD : PDecl->class_methods()) {
- if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
+ if (MD->getImplementationControl() == ObjCImplementationControl::Optional) {
OptClassMethods.push_back(MD);
} else {
ClassMethods.push_back(MD);
@@ -7497,7 +7483,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
VK_LValue, SourceLocation());
BinaryOperator *addExpr = BinaryOperator::Create(
*Context, castExpr, DRE, BO_Add,
- Context->getPointerType(Context->CharTy), VK_RValue, OK_Ordinary,
+ Context->getPointerType(Context->CharTy), VK_PRValue, OK_Ordinary,
SourceLocation(), FPOptionsOverride());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(),
@@ -7507,7 +7493,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
if (D->isBitField())
IvarT = GetGroupRecordTypeForObjCIvarBitfield(D);
- if (!isa<TypedefType>(IvarT) && IvarT->isRecordType()) {
+ if (!IvarT->getAs<TypedefType>() && IvarT->isRecordType()) {
RecordDecl *RD = IvarT->castAs<RecordType>()->getDecl();
RD = RD->getDefinition();
if (RD && !RD->getDeclName().getAsIdentifierInfo()) {
@@ -7519,8 +7505,8 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
std::string RecName = std::string(CDecl->getName());
RecName += "_IMPL";
RecordDecl *RD = RecordDecl::Create(
- *Context, TTK_Struct, TUDecl, SourceLocation(), SourceLocation(),
- &Context->Idents.get(RecName));
+ *Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
+ SourceLocation(), &Context->Idents.get(RecName));
QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD));
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index 543b3b09a9cc..bf5176a2b6fb 100644
--- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -491,7 +491,7 @@ namespace {
CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty,
CastKind Kind, Expr *E) {
TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation());
- return CStyleCastExpr::Create(*Ctx, Ty, VK_RValue, Kind, E, nullptr,
+ return CStyleCastExpr::Create(*Ctx, Ty, VK_PRValue, Kind, E, nullptr,
FPOptionsOverride(), TInfo,
SourceLocation(), SourceLocation());
}
@@ -499,8 +499,8 @@ namespace {
StringLiteral *getStringLiteral(StringRef Str) {
QualType StrType = Context->getConstantArrayType(
Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr,
- ArrayType::Normal, 0);
- return StringLiteral::Create(*Context, Str, StringLiteral::Ascii,
+ ArraySizeModifier::Normal, 0);
+ return StringLiteral::Create(*Context, Str, StringLiteralKind::Ordinary,
/*Pascal=*/false, StrType, SourceLocation());
}
};
@@ -569,7 +569,7 @@ static bool IsHeaderFile(const std::string &Filename) {
return false;
}
- std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
+ std::string Ext = Filename.substr(DotPos + 1);
// C header: .h
// C++ header: .hh or .H;
return Ext == "h" || Ext == "hh" || Ext == "H";
@@ -2024,13 +2024,13 @@ RewriteObjC::SynthesizeCallToFunctionDecl(FunctionDecl *FD,
QualType pToFunc = Context->getPointerType(msgSendType);
ImplicitCastExpr *ICE =
ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay,
- DRE, nullptr, VK_RValue, FPOptionsOverride());
+ DRE, nullptr, VK_PRValue, FPOptionsOverride());
const auto *FT = msgSendType->castAs<FunctionType>();
CallExpr *Exp =
CallExpr::Create(*Context, ICE, Args, FT->getCallResultType(*Context),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
return Exp;
}
@@ -2357,7 +2357,7 @@ void RewriteObjC::SynthMsgSendFunctionDecl() {
void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
SmallVector<QualType, 16> ArgTys;
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("objc_super"));
QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -2400,7 +2400,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
IdentifierInfo *msgSendIdent =
&Context->Idents.get("objc_msgSendSuper_stret");
SmallVector<QualType, 16> ArgTys;
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("objc_super"));
QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -2518,7 +2518,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
DeclRefExpr(*Context, NewVD, false, strType, VK_LValue, SourceLocation());
Expr *Unop = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), DRE, UO_AddrOf,
- Context->getPointerType(DRE->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(DRE->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
// cast to NSConstantString *
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(),
@@ -2531,7 +2531,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
// struct objc_super { struct objc_object *receiver; struct objc_class *super; };
QualType RewriteObjC::getSuperStructType() {
if (!SuperStructDecl) {
- SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
+ SuperStructDecl = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("objc_super"));
QualType FieldTypes[2];
@@ -2559,9 +2559,9 @@ QualType RewriteObjC::getSuperStructType() {
QualType RewriteObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
- ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- &Context->Idents.get("__NSConstantStringImpl"));
+ ConstantStringDecl = RecordDecl::Create(
+ *Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
+ SourceLocation(), &Context->Idents.get("__NSConstantStringImpl"));
QualType FieldTypes[4];
// struct objc_object *receiver;
@@ -2617,7 +2617,7 @@ CallExpr *RewriteObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavo
const auto *FT = msgSendType->castAs<FunctionType>();
CallExpr *STCE =
- CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue,
+ CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_PRValue,
SourceLocation(), FPOptionsOverride());
return STCE;
}
@@ -2670,16 +2670,11 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
SmallVector<Expr*, 4> InitExprs;
// set the receiver to self, the first argument to all methods.
- InitExprs.push_back(
- NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
- CK_BitCast,
- new (Context) DeclRefExpr(*Context,
- CurMethodDef->getSelfDecl(),
- false,
- Context->getObjCIdType(),
- VK_RValue,
- SourceLocation()))
- ); // set the 'receiver'.
+ InitExprs.push_back(NoTypeInfoCStyleCastExpr(
+ Context, Context->getObjCIdType(), CK_BitCast,
+ new (Context) DeclRefExpr(*Context, CurMethodDef->getSelfDecl(), false,
+ Context->getObjCIdType(), VK_PRValue,
+ SourceLocation()))); // set the 'receiver'.
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
SmallVector<Expr*, 8> ClsExprs;
@@ -2721,7 +2716,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
//
SuperRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf,
- Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
SuperRep = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(superType),
@@ -2739,7 +2734,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
// struct objc_super *
SuperRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf,
- Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
}
MsgExprs.push_back(SuperRep);
@@ -2766,15 +2761,11 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface();
SmallVector<Expr*, 4> InitExprs;
- InitExprs.push_back(
- NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
- CK_BitCast,
- new (Context) DeclRefExpr(*Context,
- CurMethodDef->getSelfDecl(),
- false,
- Context->getObjCIdType(),
- VK_RValue, SourceLocation()))
- ); // set the 'receiver'.
+ InitExprs.push_back(NoTypeInfoCStyleCastExpr(
+ Context, Context->getObjCIdType(), CK_BitCast,
+ new (Context) DeclRefExpr(*Context, CurMethodDef->getSelfDecl(), false,
+ Context->getObjCIdType(), VK_PRValue,
+ SourceLocation()))); // set the 'receiver'.
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
SmallVector<Expr*, 8> ClsExprs;
@@ -2817,7 +2808,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
//
SuperRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), SuperRep, UO_AddrOf,
- Context->getPointerType(SuperRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(SuperRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
SuperRep = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(superType),
@@ -2829,9 +2820,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
SourceLocation());
TypeSourceInfo *superTInfo
= Context->getTrivialTypeSourceInfo(superType);
- SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
- superType, VK_RValue, ILE,
- false);
+ SuperRep = new (Context) CompoundLiteralExpr(
+ SourceLocation(), superTInfo, superType, VK_PRValue, ILE, false);
}
MsgExprs.push_back(SuperRep);
break;
@@ -2973,7 +2963,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
const auto *FT = msgSendType->castAs<FunctionType>();
CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
- VK_RValue, EndLoc, FPOptionsOverride());
+ VK_PRValue, EndLoc, FPOptionsOverride());
Stmt *ReplacingStmt = CE;
if (MsgSendStretFlavor) {
// We have the method which returns a struct/union. Must also generate
@@ -3003,14 +2993,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
Context->IntTy,
SourceLocation());
BinaryOperator *lessThanExpr = BinaryOperator::Create(
- *Context, sizeofExpr, limit, BO_LE, Context->IntTy, VK_RValue,
+ *Context, sizeofExpr, limit, BO_LE, Context->IntTy, VK_PRValue,
OK_Ordinary, SourceLocation(), FPOptionsOverride());
// (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...))
- ConditionalOperator *CondExpr =
- new (Context) ConditionalOperator(lessThanExpr,
- SourceLocation(), CE,
- SourceLocation(), STCE,
- returnType, VK_RValue, OK_Ordinary);
+ ConditionalOperator *CondExpr = new (Context) ConditionalOperator(
+ lessThanExpr, SourceLocation(), CE, SourceLocation(), STCE, returnType,
+ VK_PRValue, OK_Ordinary);
ReplacingStmt = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
CondExpr);
}
@@ -3056,7 +3044,7 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
*Context, VD, false, getProtocolType(), VK_LValue, SourceLocation());
Expr *DerefExpr = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), DRE, UO_AddrOf,
- Context->getPointerType(DRE->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(DRE->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, DerefExpr->getType(),
CK_BitCast,
@@ -3749,11 +3737,9 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
Expr *RHSExp = CEXPR->getRHS();
Stmt *RHSStmt = SynthesizeBlockCall(Exp, RHSExp);
Expr *CONDExp = CEXPR->getCond();
- ConditionalOperator *CondExpr =
- new (Context) ConditionalOperator(CONDExp,
- SourceLocation(), cast<Expr>(LHSStmt),
- SourceLocation(), cast<Expr>(RHSStmt),
- Exp->getType(), VK_RValue, OK_Ordinary);
+ ConditionalOperator *CondExpr = new (Context) ConditionalOperator(
+ CONDExp, SourceLocation(), cast<Expr>(LHSStmt), SourceLocation(),
+ cast<Expr>(RHSStmt), Exp->getType(), VK_PRValue, OK_Ordinary);
return CondExpr;
} else if (const ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(BlockExp)) {
CPT = IRE->getType()->getAs<BlockPointerType>();
@@ -3769,7 +3755,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__block_impl"));
QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
@@ -3823,7 +3809,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
BlkExprs.push_back(*I);
}
CallExpr *CE =
- CallExpr::Create(*Context, PE, BlkExprs, Exp->getType(), VK_RValue,
+ CallExpr::Create(*Context, PE, BlkExprs, Exp->getType(), VK_PRValue,
SourceLocation(), FPOptionsOverride());
return CE;
}
@@ -4422,7 +4408,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
// Simulate a constructor call...
FD = SynthBlockInitFunctionDecl(Tag);
DeclRefExpr *DRE = new (Context)
- DeclRefExpr(*Context, FD, false, FType, VK_RValue, SourceLocation());
+ DeclRefExpr(*Context, FD, false, FType, VK_PRValue, SourceLocation());
SmallVector<Expr*, 4> InitExprs;
@@ -4444,7 +4430,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
const_cast<ASTContext &>(*Context),
new (Context) DeclRefExpr(*Context, NewVD, false, Context->VoidPtrTy,
VK_LValue, SourceLocation()),
- UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), VK_RValue,
+ UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), VK_PRValue,
OK_Ordinary, SourceLocation(), false, FPOptionsOverride());
InitExprs.push_back(DescRefExpr);
@@ -4462,9 +4448,10 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
if (HasLocalVariableExternalStorage(*I)) {
QualType QT = (*I)->getType();
QT = Context->getPointerType(QT);
- Exp = UnaryOperator::Create(
- const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, QT, VK_RValue,
- OK_Ordinary, SourceLocation(), false, FPOptionsOverride());
+ Exp = UnaryOperator::Create(const_cast<ASTContext &>(*Context), Exp,
+ UO_AddrOf, QT, VK_PRValue, OK_Ordinary,
+ SourceLocation(), false,
+ FPOptionsOverride());
}
} else if (isTopLevelBlockPointerType((*I)->getType())) {
FD = SynthBlockInitFunctionDecl((*I)->getName());
@@ -4479,9 +4466,10 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
if (HasLocalVariableExternalStorage(*I)) {
QualType QT = (*I)->getType();
QT = Context->getPointerType(QT);
- Exp = UnaryOperator::Create(
- const_cast<ASTContext &>(*Context), Exp, UO_AddrOf, QT, VK_RValue,
- OK_Ordinary, SourceLocation(), false, FPOptionsOverride());
+ Exp = UnaryOperator::Create(const_cast<ASTContext &>(*Context), Exp,
+ UO_AddrOf, QT, VK_PRValue, OK_Ordinary,
+ SourceLocation(), false,
+ FPOptionsOverride());
}
}
InitExprs.push_back(Exp);
@@ -4495,9 +4483,9 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
RewriteByRefString(RecName, Name, ND, true);
IdentifierInfo *II = &Context->Idents.get(RecName.c_str()
+ sizeof("struct"));
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- II);
+ RecordDecl *RD =
+ RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
+ SourceLocation(), SourceLocation(), II);
assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -4520,7 +4508,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
if (!isNestedCapturedVar)
Exp = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), Exp, UO_AddrOf,
- Context->getPointerType(Exp->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(Exp->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_BitCast, Exp);
InitExprs.push_back(Exp);
@@ -4539,7 +4527,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
SourceLocation(), FPOptionsOverride());
NewRep = UnaryOperator::Create(
const_cast<ASTContext &>(*Context), NewRep, UO_AddrOf,
- Context->getPointerType(NewRep->getType()), VK_RValue, OK_Ordinary,
+ Context->getPointerType(NewRep->getType()), VK_PRValue, OK_Ordinary,
SourceLocation(), false, FPOptionsOverride());
NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_BitCast,
NewRep);
@@ -5833,9 +5821,9 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
std::string(clsDeclared->getIdentifier()->getName());
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName);
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- II);
+ RecordDecl *RD =
+ RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
+ SourceLocation(), SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
@@ -5874,9 +5862,9 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
std::string(clsDeclared->getIdentifier()->getName());
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName);
- RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
- SourceLocation(), SourceLocation(),
- II);
+ RecordDecl *RD =
+ RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
+ SourceLocation(), SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,