diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend/Rewrite')
6 files changed, 39 insertions, 48 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/FrontendActions.cpp index 13d410e..2e76e2e 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/FrontendActions.cpp @@ -9,13 +9,12 @@ #include "clang/Rewrite/Frontend/FrontendActions.h" #include "clang/AST/ASTConsumer.h" -#include "clang/Basic/FileManager.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/Utils.h" #include "clang/Lex/Preprocessor.h" -#include "clang/Parse/Parser.h" +#include "clang/Lex/PreprocessorOptions.h" #include "clang/Rewrite/Frontend/ASTConsumers.h" #include "clang/Rewrite/Frontend/FixItRewriter.h" #include "clang/Rewrite/Frontend/Rewriters.h" diff --git a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/HTMLPrint.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/HTMLPrint.cpp index f5fad34..11e431d 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/HTMLPrint.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/HTMLPrint.cpp @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -#include "clang/Rewrite/Frontend/ASTConsumers.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" @@ -21,7 +20,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Rewrite/Core/HTMLRewrite.h" #include "clang/Rewrite/Core/Rewriter.h" -#include "llvm/Support/MemoryBuffer.h" +#include "clang/Rewrite/Frontend/ASTConsumers.h" #include "llvm/Support/raw_ostream.h" using namespace clang; @@ -65,7 +64,7 @@ void HTMLPrinter::HandleTranslationUnit(ASTContext &Ctx) { // Format the file. FileID FID = R.getSourceMgr().getMainFileID(); const FileEntry* Entry = R.getSourceMgr().getFileEntryForID(FID); - const char* Name; + 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 // cases. diff --git a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp index b761c34..d953da2 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -68,7 +68,7 @@ private: CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported) override; - void WriteLineInfo(const char *Filename, int Line, + void WriteLineInfo(StringRef Filename, int Line, SrcMgr::CharacteristicKind FileType, StringRef Extra = StringRef()); void WriteImplicitModuleImport(const Module *Mod); @@ -102,7 +102,7 @@ InclusionRewriter::InclusionRewriter(Preprocessor &PP, raw_ostream &OS, /// markers depending on what mode we're in, including the \p Filename and /// \p Line we are located at, using the specified \p EOL line separator, and /// any \p Extra context specifiers in GNU line directives. -void InclusionRewriter::WriteLineInfo(const char *Filename, int Line, +void InclusionRewriter::WriteLineInfo(StringRef Filename, int Line, SrcMgr::CharacteristicKind FileType, StringRef Extra) { if (!ShowLineMarkers) @@ -406,7 +406,7 @@ bool InclusionRewriter::Process(FileID FileId, bool Invalid; const MemoryBuffer &FromFile = *SM.getBuffer(FileId, &Invalid); assert(!Invalid && "Attempting to process invalid inclusion"); - const char *FileName = FromFile.getBufferIdentifier(); + StringRef FileName = FromFile.getBufferIdentifier(); Lexer RawLex(FileId, &FromFile, PP.getSourceManager(), PP.getLangOpts()); RawLex.SetCommentRetentionState(false); diff --git a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index ad21751..e7bfced 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -863,9 +863,9 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) { CDecl = CatDecl->getClassInterface(); std::string RecName = CDecl->getName(); RecName += "_IMPL"; - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get(RecName.c_str())); + RecordDecl *RD = + RecordDecl::Create(*Context, TTK_Struct, TUDecl, SourceLocation(), + SourceLocation(), &Context->Idents.get(RecName)); QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD)); unsigned UnsignedIntSize = static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy)); @@ -5301,11 +5301,9 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, // Initialize the block descriptor. std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA"; - VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get(DescData.c_str()), - Context->VoidPtrTy, nullptr, - SC_Static); + VarDecl *NewVD = VarDecl::Create( + *Context, TUDecl, SourceLocation(), SourceLocation(), + &Context->Idents.get(DescData), Context->VoidPtrTy, nullptr, SC_Static); UnaryOperator *DescRefExpr = new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false, Context->VoidPtrTy, @@ -6350,8 +6348,7 @@ static void Write_method_list_t_initializer(RewriteModernObjC &RewriteObj, Result += "\t{(struct objc_selector *)\""; Result += (MD)->getSelector().getAsString(); Result += "\""; Result += ", "; - std::string MethodTypeString; - Context->getObjCEncodingForMethodDecl(MD, MethodTypeString); + std::string MethodTypeString = Context->getObjCEncodingForMethodDecl(MD); Result += "\""; Result += MethodTypeString; Result += "\""; Result += ", "; if (!MethodImpl) @@ -6390,8 +6387,9 @@ static void Write_prop_list_t_initializer(RewriteModernObjC &RewriteObj, else Result += "\t{\""; Result += PropDecl->getName(); Result += "\","; - std::string PropertyTypeString, QuotePropertyTypeString; - Context->getObjCEncodingForPropertyDecl(PropDecl, Container, PropertyTypeString); + std::string PropertyTypeString = + Context->getObjCEncodingForPropertyDecl(PropDecl, Container); + std::string QuotePropertyTypeString; RewriteObj.QuoteDoublequotes(PropertyTypeString, QuotePropertyTypeString); Result += "\""; Result += QuotePropertyTypeString; Result += "\""; if (i == e-1) @@ -6720,8 +6718,9 @@ static void Write__extendedMethodTypes_initializer(RewriteModernObjC &RewriteObj Result += "{\n"; for (unsigned i = 0, e = Methods.size(); i < e; i++) { ObjCMethodDecl *MD = Methods[i]; - std::string MethodTypeString, QuoteMethodTypeString; - Context->getObjCEncodingForMethodDecl(MD, MethodTypeString, true); + std::string MethodTypeString = + Context->getObjCEncodingForMethodDecl(MD, true); + std::string QuoteMethodTypeString; RewriteObj.QuoteDoublequotes(MethodTypeString, QuoteMethodTypeString); Result += "\t\""; Result += QuoteMethodTypeString; Result += "\""; if (i == e-1) @@ -7522,9 +7521,9 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { CDecl = CatDecl->getClassInterface(); std::string RecName = CDecl->getName(); RecName += "_IMPL"; - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get(RecName.c_str())); + RecordDecl *RD = RecordDecl::Create( + *Context, TTK_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/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index 5967e40..e842e59 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -4426,11 +4426,9 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, // Initialize the block descriptor. std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA"; - VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get(DescData.c_str()), - Context->VoidPtrTy, nullptr, - SC_Static); + VarDecl *NewVD = VarDecl::Create( + *Context, TUDecl, SourceLocation(), SourceLocation(), + &Context->Idents.get(DescData), Context->VoidPtrTy, nullptr, SC_Static); UnaryOperator *DescRefExpr = new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false, Context->VoidPtrTy, @@ -5126,8 +5124,7 @@ void RewriteObjCFragileABI::RewriteObjCProtocolMetaData( else Result += "\t ,{(struct objc_selector *)\""; Result += (*I)->getSelector().getAsString(); - std::string MethodTypeString; - Context->getObjCEncodingForMethodDecl((*I), MethodTypeString); + std::string MethodTypeString = Context->getObjCEncodingForMethodDecl(*I); Result += "\", \""; Result += MethodTypeString; Result += "\"}\n"; @@ -5164,8 +5161,7 @@ void RewriteObjCFragileABI::RewriteObjCProtocolMetaData( else Result += "\t ,{(struct objc_selector *)\""; Result += (*I)->getSelector().getAsString(); - std::string MethodTypeString; - Context->getObjCEncodingForMethodDecl((*I), MethodTypeString); + std::string MethodTypeString = Context->getObjCEncodingForMethodDecl(*I); Result += "\", \""; Result += MethodTypeString; Result += "\"}\n"; @@ -5650,14 +5646,12 @@ void RewriteObjCFragileABI::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *ID InstanceMethods.push_back(Setter); } RewriteObjCMethodsMetaData(InstanceMethods.begin(), InstanceMethods.end(), - true, "CATEGORY_", FullCategoryName.c_str(), - Result); - + true, "CATEGORY_", FullCategoryName, Result); + // Build _objc_method_list for class's class methods if needed RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(), - false, "CATEGORY_", FullCategoryName.c_str(), - Result); - + false, "CATEGORY_", FullCategoryName, Result); + // Protocols referenced in class declaration? // Null CDecl is case of a category implementation with no category interface if (CDecl) @@ -5776,9 +5770,9 @@ void RewriteObjCFragileABI::RewriteObjCMethodsMetaData(MethodIterator MethodBegi Result += "{\n\t0, " + utostr(NumMethods) + "\n"; Result += "\t,{{(SEL)\""; - Result += (*MethodBegin)->getSelector().getAsString().c_str(); - std::string MethodTypeString; - Context->getObjCEncodingForMethodDecl(*MethodBegin, MethodTypeString); + Result += (*MethodBegin)->getSelector().getAsString(); + std::string MethodTypeString = + Context->getObjCEncodingForMethodDecl(*MethodBegin); Result += "\", \""; Result += MethodTypeString; Result += "\", (void *)"; @@ -5786,9 +5780,9 @@ void RewriteObjCFragileABI::RewriteObjCMethodsMetaData(MethodIterator MethodBegi Result += "}\n"; for (++MethodBegin; MethodBegin != MethodEnd; ++MethodBegin) { Result += "\t ,{(SEL)\""; - Result += (*MethodBegin)->getSelector().getAsString().c_str(); - std::string MethodTypeString; - Context->getObjCEncodingForMethodDecl(*MethodBegin, MethodTypeString); + Result += (*MethodBegin)->getSelector().getAsString(); + std::string MethodTypeString = + Context->getObjCEncodingForMethodDecl(*MethodBegin); Result += "\", \""; Result += MethodTypeString; Result += "\", (void *)"; diff --git a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteTest.cpp b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteTest.cpp index 722c5e8..b0791f4 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteTest.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/Rewrite/RewriteTest.cpp @@ -11,12 +11,12 @@ // //===----------------------------------------------------------------------===// -#include "clang/Rewrite/Frontend/Rewriters.h" #include "clang/Lex/Preprocessor.h" #include "clang/Rewrite/Core/TokenRewriter.h" +#include "clang/Rewrite/Frontend/Rewriters.h" #include "llvm/Support/raw_ostream.h" -void clang::DoRewriteTest(Preprocessor &PP, raw_ostream* OS) { +void clang::DoRewriteTest(Preprocessor &PP, raw_ostream *OS) { SourceManager &SM = PP.getSourceManager(); const LangOptions &LangOpts = PP.getLangOpts(); |