diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-03-16 16:52:15 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-03-16 16:52:15 +0000 |
commit | 1033b7c1e32962948b01a25145829f17bc70a8de (patch) | |
tree | 52aebaff3a47b97dbac434530524c30967468412 /lib/Frontend | |
parent | 27c39af73c0d7d0b97e57b3a905040d4cefc9708 (diff) | |
download | FreeBSD-src-1033b7c1e32962948b01a25145829f17bc70a8de.zip FreeBSD-src-1033b7c1e32962948b01a25145829f17bc70a8de.tar.gz |
Update clang to r98631.
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 9 | ||||
-rw-r--r-- | lib/Frontend/CacheTokens.cpp | 34 | ||||
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 4 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/HTMLDiagnostics.cpp | 34 | ||||
-rw-r--r-- | lib/Frontend/Makefile | 2 | ||||
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/PCHReaderDecl.cpp | 7 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 47 | ||||
-rw-r--r-- | lib/Frontend/PCHWriterDecl.cpp | 9 | ||||
-rw-r--r-- | lib/Frontend/PrintPreprocessedOutput.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/RewriteMacros.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/RewriteObjC.cpp | 169 | ||||
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 20 |
14 files changed, 216 insertions, 128 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 63cf98d..3bf1fab 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -35,8 +35,9 @@ #include "llvm/System/Path.h" using namespace clang; -ASTUnit::ASTUnit(bool _MainFileIsAST) - : MainFileIsAST(_MainFileIsAST), ConcurrencyCheckValue(CheckUnlocked) { +ASTUnit::ASTUnit(Diagnostic &Diag, bool _MainFileIsAST) + : SourceMgr(Diag), MainFileIsAST(_MainFileIsAST), + ConcurrencyCheckValue(CheckUnlocked) { } ASTUnit::~ASTUnit() { ConcurrencyCheckValue = CheckLocked; @@ -146,7 +147,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, RemappedFile *RemappedFiles, unsigned NumRemappedFiles, bool CaptureDiagnostics) { - llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true)); + llvm::OwningPtr<ASTUnit> AST(new ASTUnit(Diags, true)); AST->OnlyLocalDecls = OnlyLocalDecls; AST->HeaderInfo.reset(new HeaderSearch(AST->getFileManager())); @@ -311,7 +312,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI, "FIXME: AST inputs not yet supported here!"); // Create the AST unit. - AST.reset(new ASTUnit(false)); + AST.reset(new ASTUnit(Diags, false)); AST->OnlyLocalDecls = OnlyLocalDecls; AST->OriginalSourceFile = Clang.getFrontendOpts().Inputs[0].second; diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp index c845d56..02d6cec 100644 --- a/lib/Frontend/CacheTokens.cpp +++ b/lib/Frontend/CacheTokens.cpp @@ -196,6 +196,11 @@ class PTHWriter { Out.write(Ptr, NumBytes); } + void EmitString(llvm::StringRef V) { + ::Emit16(Out, V.size()); + EmitBuf(V.data(), V.size()); + } + /// EmitIdentifierTable - Emits two tables to the PTH file. The first is /// a hashtable mapping from identifier strings to persistent IDs. /// The second is a straight table mapping from persistent IDs to string data @@ -214,7 +219,7 @@ public: : Out(out), PP(pp), idcount(0), CurStrOffset(0) {} PTHMap &getPM() { return PM; } - void GeneratePTH(const std::string *MainFile = 0); + void GeneratePTH(const std::string &MainFile); }; } // end anonymous namespace @@ -295,7 +300,7 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) { } if (Tok.is(tok::identifier)) { - Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok)); + PP.LookUpIdentifierInfo(Tok); EmitToken(Tok); continue; } @@ -321,7 +326,6 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) { } IdentifierInfo* II = PP.LookUpIdentifierInfo(Tok); - Tok.setIdentifierInfo(II); tok::PPKeywordKind K = II->getPPKeywordID(); ParsingPreprocessorDirective = true; @@ -344,7 +348,7 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) { L.setParsingPreprocessorDirective(false); assert(!Tok.isAtStartOfLine()); if (Tok.is(tok::identifier)) - Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok)); + PP.LookUpIdentifierInfo(Tok); break; } @@ -436,7 +440,7 @@ Offset PTHWriter::EmitCachedSpellings() { return SpellingsOff; } -void PTHWriter::GeneratePTH(const std::string *MainFile) { +void PTHWriter::GeneratePTH(const std::string &MainFile) { // Generate the prologue. Out << "cfe-pth"; Emit32(PTHManager::Version); @@ -447,9 +451,8 @@ void PTHWriter::GeneratePTH(const std::string *MainFile) { Emit32(0); // Write the name of the MainFile. - if (MainFile && !MainFile->empty()) { - Emit16(MainFile->length()); - EmitBuf(MainFile->data(), MainFile->length()); + if (!MainFile.empty()) { + EmitString(MainFile); } else { // String with 0 bytes. Emit16(0); @@ -471,7 +474,7 @@ void PTHWriter::GeneratePTH(const std::string *MainFile) { if (!P.isAbsolute()) continue; - const llvm::MemoryBuffer *B = C.getBuffer(); + const llvm::MemoryBuffer *B = C.getBuffer(PP.getDiagnostics()); if (!B) continue; FileID FID = SM.createFileID(FE, SourceLocation(), SrcMgr::C_User); @@ -533,15 +536,8 @@ void clang::CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS) { const SourceManager &SrcMgr = PP.getSourceManager(); const FileEntry *MainFile = SrcMgr.getFileEntryForID(SrcMgr.getMainFileID()); llvm::sys::Path MainFilePath(MainFile->getName()); - std::string MainFileName; - if (!MainFilePath.isAbsolute()) { - llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory(); - P.appendComponent(MainFilePath.str()); - MainFileName = P.str(); - } else { - MainFileName = MainFilePath.str(); - } + MainFilePath.makeAbsolute(); // Create the PTHWriter. PTHWriter PW(*OS, PP); @@ -558,18 +554,18 @@ void clang::CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS) { // Generate the PTH file. PP.getFileManager().removeStatCache(StatCache); - PW.GeneratePTH(&MainFileName); + PW.GeneratePTH(MainFilePath.str()); } //===----------------------------------------------------------------------===// +namespace { class PTHIdKey { public: const IdentifierInfo* II; uint32_t FileOffset; }; -namespace { class PTHIdentifierTableTrait { public: typedef PTHIdKey* key_type; diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 25b804a..3bc5661 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -185,7 +185,7 @@ void CompilerInstance::createFileManager() { // Source Manager void CompilerInstance::createSourceManager() { - SourceMgr.reset(new SourceManager()); + SourceMgr.reset(new SourceManager(getDiagnostics())); } // Preprocessor @@ -294,6 +294,8 @@ void CompilerInstance::createCodeCompletionConsumer() { getFrontendOpts().DebugCodeCompletionPrinter, getFrontendOpts().ShowMacrosInCodeCompletion, llvm::outs())); + if (!CompletionConsumer) + return; if (CompletionConsumer->isOutputBinary() && llvm::sys::Program::ChangeStdoutToBinary()) { diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 64a42bc..5798f2f 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -474,6 +474,8 @@ static void LangOptsToArgs(const LangOptions &Opts, Res.push_back("-fcatch-undefined-behavior"); if (Opts.WritableStrings) Res.push_back("-fwritable-strings"); + if (Opts.ConstStrings) + Res.push_back("-Wwrite-strings"); if (!Opts.LaxVectorConversions) Res.push_back("-fno-lax-vector-conversions"); if (Opts.AltiVec) @@ -1162,6 +1164,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, Opts.PascalStrings = Args.hasArg(OPT_fpascal_strings); Opts.Microsoft = Args.hasArg(OPT_fms_extensions); Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings); + Opts.ConstStrings = Args.hasArg(OPT_Wwrite_strings); if (Args.hasArg(OPT_fno_lax_vector_conversions)) Opts.LaxVectorConversions = 0; if (Args.hasArg(OPT_fno_threadsafe_statics)) diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp index f695254..da99cb8 100644 --- a/lib/Frontend/HTMLDiagnostics.cpp +++ b/lib/Frontend/HTMLDiagnostics.cpp @@ -40,13 +40,13 @@ class HTMLDiagnostics : public PathDiagnosticClient { std::vector<const PathDiagnostic*> BatchedDiags; public: HTMLDiagnostics(const std::string& prefix, const Preprocessor &pp); - + virtual ~HTMLDiagnostics() { FlushDiagnostics(NULL); } - + virtual void FlushDiagnostics(llvm::SmallVectorImpl<std::string> *FilesMade); virtual void HandlePathDiagnostic(const PathDiagnostic* D); - + virtual llvm::StringRef getName() const { return "HTMLDiagnostics"; } @@ -108,7 +108,7 @@ HTMLDiagnostics::FlushDiagnostics(llvm::SmallVectorImpl<std::string> *FilesMade) ReportDiag(*D, FilesMade); delete D; } - + BatchedDiags.clear(); } @@ -294,7 +294,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, llvm::raw_fd_ostream os(H.c_str(), ErrorMsg); if (!ErrorMsg.empty()) { - (llvm::errs() << "warning: could not create file '" << F.str() + (llvm::errs() << "warning: could not create file '" << F.str() << "'\n").flush(); return; } @@ -439,10 +439,10 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, { FullSourceLoc L = MP->getLocation().asLocation().getInstantiationLoc(); assert(L.isFileID()); - std::pair<const char*, const char*> BufferInfo = L.getBufferData(); - const char* MacroName = L.getDecomposedLoc().second + BufferInfo.first; - Lexer rawLexer(L, PP.getLangOptions(), BufferInfo.first, - MacroName, BufferInfo.second); + llvm::StringRef BufferInfo = L.getBufferData(); + const char* MacroName = L.getDecomposedLoc().second + BufferInfo.data(); + Lexer rawLexer(L, PP.getLangOptions(), BufferInfo.begin(), + MacroName, BufferInfo.end()); Token TheTok; rawLexer.LexFromRawLexer(TheTok); @@ -502,19 +502,13 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, } static void EmitAlphaCounter(llvm::raw_ostream& os, unsigned n) { - llvm::SmallVector<char, 10> buf; - - do { - unsigned x = n % ('z' - 'a'); - buf.push_back('a' + x); - n = n / ('z' - 'a'); - } while (n); + unsigned x = n % ('z' - 'a'); + n /= 'z' - 'a'; - assert(!buf.empty()); + if (n > 0) + EmitAlphaCounter(os, n); - for (llvm::SmallVectorImpl<char>::reverse_iterator I=buf.rbegin(), - E=buf.rend(); I!=E; ++I) - os << *I; + os << char('a' + x); } unsigned HTMLDiagnostics::ProcessMacroPiece(llvm::raw_ostream& os, diff --git a/lib/Frontend/Makefile b/lib/Frontend/Makefile index a630b01..9e1a864 100644 --- a/lib/Frontend/Makefile +++ b/lib/Frontend/Makefile @@ -11,7 +11,7 @@ LEVEL = ../../../.. LIBRARYNAME := clangFrontend BUILD_ARCHIVE = 1 -CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include +CPP.Flags += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include include $(LEVEL)/Makefile.common diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 267f4c1..49eb2a0 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -2628,7 +2628,7 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { unsigned StrLen = (((unsigned) StrLenPtr[0]) | (((unsigned) StrLenPtr[1]) << 8)) - 1; IdentifiersLoaded[ID - 1] - = &PP->getIdentifierTable().get(Str, Str + StrLen); + = &PP->getIdentifierTable().get(Str, StrLen); } return IdentifiersLoaded[ID - 1]; diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index a3f5eac..f847bec 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -131,10 +131,11 @@ void PCHDeclReader::VisitTagDecl(TagDecl *TD) { TD->setTagKind((TagDecl::TagKind)Record[Idx++]); TD->setDefinition(Record[Idx++]); TD->setEmbeddedInDeclarator(Record[Idx++]); - TD->setTypedefForAnonDecl( - cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++]))); TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); TD->setTagKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); + // FIXME: maybe read optional qualifier and its range. + TD->setTypedefForAnonDecl( + cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++]))); } void PCHDeclReader::VisitEnumDecl(EnumDecl *ED) { @@ -168,6 +169,7 @@ void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { TypeSourceInfo *TInfo = Reader.GetTypeSourceInfo(Record, Idx); if (TInfo) DD->setTypeSourceInfo(TInfo); + // FIXME: read optional qualifier and its range. } void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) { @@ -411,6 +413,7 @@ void PCHDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { void PCHDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { VisitVarDecl(PD); PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); + PD->setHasInheritedDefaultArg(Record[Idx++]); } void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index eed3cc1..c256b41 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -565,7 +565,7 @@ void PCHWriter::WriteBlockInfoBlock() { RECORD(EXT_VECTOR_DECLS); RECORD(COMMENT_RANGES); RECORD(VERSION_CONTROL_BRANCH_REVISION); - + // SourceManager Block. BLOCK(SOURCE_MANAGER_BLOCK); RECORD(SM_SLOC_FILE_ENTRY); @@ -710,24 +710,17 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) { unsigned FileAbbrevCode = Stream.EmitAbbrev(FileAbbrev); llvm::sys::Path MainFilePath(MainFile->getName()); - std::string MainFileName; - if (!MainFilePath.isAbsolute()) { - llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory(); - P.appendComponent(MainFilePath.str()); - MainFileName = P.str(); - } else { - MainFileName = MainFilePath.str(); - } + MainFilePath.makeAbsolute(); - const char *MainFileNameStr = MainFileName.c_str(); + const char *MainFileNameStr = MainFilePath.c_str(); MainFileNameStr = adjustFilenameForRelocatablePCH(MainFileNameStr, isysroot); RecordData Record; Record.push_back(pch::ORIGINAL_FILE_NAME); Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr); } - + // Repository branch/version information. BitCodeAbbrev *RepoAbbrev = new BitCodeAbbrev(); RepoAbbrev->Add(BitCodeAbbrevOp(pch::VERSION_CONTROL_BRANCH_REVISION)); @@ -758,9 +751,9 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) { Record.push_back(LangOpts.ObjC1); // Objective-C 1 support enabled. Record.push_back(LangOpts.ObjC2); // Objective-C 2 support enabled. - Record.push_back(LangOpts.ObjCNonFragileABI); // Objective-C + Record.push_back(LangOpts.ObjCNonFragileABI); // Objective-C // modern abi enabled. - Record.push_back(LangOpts.ObjCNonFragileABI2); // Objective-C enhanced + Record.push_back(LangOpts.ObjCNonFragileABI2); // Objective-C enhanced // modern abi enabled. Record.push_back(LangOpts.PascalStrings); // Allow Pascal strings @@ -1048,7 +1041,7 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, for (unsigned I = 1, N = SourceMgr.sloc_entry_size(); I != N; ++I) { // Get this source location entry. const SrcMgr::SLocEntry *SLoc = &SourceMgr.getSLocEntry(I); - + // Record the offset of this source-location entry. SLocEntryOffsets.push_back(Stream.GetCurrentBitNo()); @@ -1079,13 +1072,8 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, // Turn the file name into an absolute path, if it isn't already. const char *Filename = Content->Entry->getName(); llvm::sys::Path FilePath(Filename, strlen(Filename)); - std::string FilenameStr; - if (!FilePath.isAbsolute()) { - llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory(); - P.appendComponent(FilePath.str()); - FilenameStr = P.str(); - Filename = FilenameStr.c_str(); - } + FilePath.makeAbsolute(); + Filename = FilePath.c_str(); Filename = adjustFilenameForRelocatablePCH(Filename, isysroot); Stream.EmitRecordWithBlob(SLocFileAbbrv, Record, Filename); @@ -1101,7 +1089,8 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, // We add one to the size so that we capture the trailing NULL // that is required by llvm::MemoryBuffer::getMemBuffer (on // the reader side). - const llvm::MemoryBuffer *Buffer = Content->getBuffer(); + const llvm::MemoryBuffer *Buffer + = Content->getBuffer(PP.getDiagnostics()); const char *Name = Buffer->getBufferIdentifier(); Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record, llvm::StringRef(Name, strlen(Name) + 1)); @@ -1998,9 +1987,9 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls, // Build a record containing all of the static unused functions in this file. RecordData UnusedStaticFuncs; - for (unsigned i=0, e = SemaRef.UnusedStaticFuncs.size(); i !=e; ++i) + for (unsigned i=0, e = SemaRef.UnusedStaticFuncs.size(); i !=e; ++i) AddDeclRef(SemaRef.UnusedStaticFuncs[i], UnusedStaticFuncs); - + // Build a record containing all of the locally-scoped external // declarations in this header file. Generally, this record will be // empty. @@ -2063,7 +2052,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls, WriteDecl(Context, DOT.getDecl()); } Stream.ExitBlock(); - + WritePreprocessor(PP); WriteMethodPool(SemaRef); WriteIdentifierTable(PP); @@ -2105,7 +2094,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls, // Write the record containing unused static functions. if (!UnusedStaticFuncs.empty()) Stream.EmitRecord(pch::UNUSED_STATIC_FUNCS, UnusedStaticFuncs); - + // Write the record containing locally-scoped external definitions. if (!LocallyScopedExternalDecls.empty()) Stream.EmitRecord(pch::LOCALLY_SCOPED_EXTERNAL_DECLS, @@ -2206,7 +2195,7 @@ void PCHWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record) { AddTypeRef(TInfo->getType(), Record); TypeLocWriter TLW(*this, Record); for (TypeLoc TL = TInfo->getTypeLoc(); !TL.isNull(); TL = TL.getNextTypeLoc()) - TLW.Visit(TL); + TLW.Visit(TL); } void PCHWriter::AddTypeRef(QualType T, RecordData &Record) { @@ -2227,14 +2216,14 @@ void PCHWriter::AddTypeRef(QualType T, RecordData &Record) { ID = NextTypeID++; DeclTypesToEmit.push(T); } - + // Encode the type qualifiers in the type reference. Record.push_back((ID << Qualifiers::FastWidth) | FastQuals); return; } assert(!T.hasLocalQualifiers()); - + if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr())) { pch::TypeID ID = 0; switch (BT->getKind()) { diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 0774797..7917280 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -127,9 +127,10 @@ void PCHDeclWriter::VisitTagDecl(TagDecl *D) { Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding Record.push_back(D->isDefinition()); Record.push_back(D->isEmbeddedInDeclarator()); - Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record); Writer.AddSourceLocation(D->getRBraceLoc(), Record); Writer.AddSourceLocation(D->getTagKeywordLoc(), Record); + // FIXME: maybe write optional qualifier and its range. + Writer.AddDeclRef(D->getTypedefForAnonDecl(), Record); } void PCHDeclWriter::VisitEnumDecl(EnumDecl *D) { @@ -165,6 +166,7 @@ void PCHDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) { void PCHDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) { VisitValueDecl(D); Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record); + // FIXME: write optional qualifier and its range. } void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) { @@ -398,6 +400,7 @@ void PCHDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) { VisitVarDecl(D); Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding + Record.push_back(D->hasInheritedDefaultArg()); Code = pch::DECL_PARM_VAR; @@ -412,7 +415,8 @@ void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) { D->getPCHLevel() == 0 && D->getStorageClass() == 0 && !D->hasCXXDirectInitializer() && // Can params have this ever? - D->getObjCDeclQualifier() == 0) + D->getObjCDeclQualifier() == 0 && + !D->hasInheritedDefaultArg()) AbbrevToUse = Writer.getParmVarDeclAbbrev(); // Check things we know are true of *every* PARM_VAR_DECL, which is more than @@ -496,6 +500,7 @@ void PCHWriter::WriteDeclsBlockAbbrevs() { Abv->Add(BitCodeAbbrevOp(0)); // HasInit // ParmVarDecl Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier + Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg ParmVarDeclAbbrev = Stream.EmitAbbrev(Abv); } diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index be5bb0d..44e0e13 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -61,7 +61,7 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI, if (MI.tokens_empty() || !MI.tokens_begin()->hasLeadingSpace()) OS << ' '; - llvm::SmallVector<char, 128> SpellingBuffer; + llvm::SmallString<128> SpellingBuffer; for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end(); I != E; ++I) { if (I->hasLeadingSpace()) diff --git a/lib/Frontend/RewriteMacros.cpp b/lib/Frontend/RewriteMacros.cpp index 0bcbd4f..954e8e2 100644 --- a/lib/Frontend/RewriteMacros.cpp +++ b/lib/Frontend/RewriteMacros.cpp @@ -79,7 +79,7 @@ static void LexRawTokensFromMainFile(Preprocessor &PP, // up the indentifier info. This is important for equality comparison of // identifier tokens. if (RawTok.is(tok::identifier) && !RawTok.getIdentifierInfo()) - RawTok.setIdentifierInfo(PP.LookUpIdentifierInfo(RawTok)); + PP.LookUpIdentifierInfo(RawTok); RawTokens.push_back(RawTok); } while (RawTok.isNot(tok::eof)); diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 378b422..79aecce 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -89,6 +89,7 @@ namespace { FunctionDecl *MsgSendFpretFunctionDecl; FunctionDecl *GetClassFunctionDecl; FunctionDecl *GetMetaClassFunctionDecl; + FunctionDecl *GetSuperClassFunctionDecl; FunctionDecl *SelGetUidFunctionDecl; FunctionDecl *CFStringFunctionDecl; FunctionDecl *SuperContructorFunctionDecl; @@ -133,7 +134,8 @@ namespace { llvm::SmallPtrSet<ValueDecl *, 8> BlockByRefDeclsPtrSet; llvm::DenseMap<ValueDecl *, unsigned> BlockByRefDeclNo; llvm::SmallPtrSet<ValueDecl *, 8> ImportedBlockDecls; - + llvm::SmallPtrSet<VarDecl *, 8> ImportedLocalExternalDecls; + llvm::DenseMap<BlockExpr *, std::string> RewrittenBlockExprs; // This maps a property to it's assignment statement. @@ -271,7 +273,7 @@ namespace { void RewriteTypeOfDecl(VarDecl *VD); void RewriteObjCQualifiedInterfaceTypes(Expr *E); bool needToScanForQualifiers(QualType T); - ObjCInterfaceDecl *isSuperReceiver(Expr *recExpr); + bool isSuperReceiver(Expr *recExpr); QualType getSuperStructType(); QualType getConstantStringStructType(); bool BufferContainsPPDirectives(const char *startBuf, const char *endBuf); @@ -323,6 +325,7 @@ namespace { void SynthMsgSendSuperStretFunctionDecl(); void SynthGetClassFunctionDecl(); void SynthGetMetaClassFunctionDecl(); + void SynthGetSuperClassFunctionDecl(); void SynthSelGetUidFunctionDecl(); void SynthSuperContructorFunctionDecl(); @@ -370,6 +373,7 @@ namespace { void RewriteByRefVar(VarDecl *VD); std::string SynthesizeByrefCopyDestroyHelper(VarDecl *VD, int flag); Stmt *RewriteBlockDeclRefExpr(Expr *VD); + Stmt *RewriteLocalVariableExternalStorage(DeclRefExpr *DRE); void RewriteBlockPointerFunctionArgs(FunctionDecl *FD); std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i, @@ -510,6 +514,7 @@ void RewriteObjC::Initialize(ASTContext &context) { MsgSendFpretFunctionDecl = 0; GetClassFunctionDecl = 0; GetMetaClassFunctionDecl = 0; + GetSuperClassFunctionDecl = 0; SelGetUidFunctionDecl = 0; CFStringFunctionDecl = 0; ConstantStringClassReference = 0; @@ -572,6 +577,8 @@ void RewriteObjC::Initialize(ASTContext &context) { Preamble += "(struct objc_object *, struct objc_selector *, ...);\n"; Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_getClass"; Preamble += "(const char *);\n"; + Preamble += "__OBJC_RW_DLLIMPORT struct objc_class *class_getSuperclass"; + Preamble += "(struct objc_class *);\n"; Preamble += "__OBJC_RW_DLLIMPORT struct objc_object *objc_getMetaClass"; Preamble += "(const char *);\n"; Preamble += "__OBJC_RW_DLLIMPORT void objc_exception_throw(struct objc_object *);\n"; @@ -699,9 +706,9 @@ void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) { void RewriteObjC::RewriteInclude() { SourceLocation LocStart = SM->getLocForStartOfFile(MainFileID); - std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); - const char *MainBufStart = MainBuf.first; - const char *MainBufEnd = MainBuf.second; + llvm::StringRef MainBuf = SM->getBufferData(MainFileID); + const char *MainBufStart = MainBuf.begin(); + const char *MainBufEnd = MainBuf.end(); size_t ImportLen = strlen("import"); // Loop over the whole file, looking for includes. @@ -724,9 +731,9 @@ void RewriteObjC::RewriteInclude() { } void RewriteObjC::RewriteTabs() { - std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); - const char *MainBufStart = MainBuf.first; - const char *MainBufEnd = MainBuf.second; + llvm::StringRef MainBuf = SM->getBufferData(MainFileID); + const char *MainBufStart = MainBuf.begin(); + const char *MainBufEnd = MainBuf.end(); // Loop over the whole file, looking for tabs. for (const char *BufPtr = MainBufStart; BufPtr != MainBufEnd; ++BufPtr) { @@ -966,8 +973,6 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { } void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { - std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID); - SourceLocation LocStart = PDecl->getLocStart(); // FIXME: handle protocol headers that are declared across multiple lines. @@ -2491,6 +2496,23 @@ void RewriteObjC::SynthGetClassFunctionDecl() { FunctionDecl::Extern, false); } +// SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls); +void RewriteObjC::SynthGetSuperClassFunctionDecl() { + IdentifierInfo *getSuperClassIdent = + &Context->Idents.get("class_getSuperclass"); + llvm::SmallVector<QualType, 16> ArgTys; + ArgTys.push_back(Context->getObjCClassType()); + QualType getClassType = Context->getFunctionType(Context->getObjCClassType(), + &ArgTys[0], ArgTys.size(), + false /*isVariadic*/, 0, + false, false, 0, 0, false, + CC_Default); + GetSuperClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl, + SourceLocation(), + getSuperClassIdent, getClassType, 0, + FunctionDecl::Extern, false); +} + // SynthGetMetaClassFunctionDecl - id objc_getClass(const char *name); void RewriteObjC::SynthGetMetaClassFunctionDecl() { IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getMetaClass"); @@ -2551,18 +2573,10 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { return cast; } -ObjCInterfaceDecl *RewriteObjC::isSuperReceiver(Expr *recExpr) { +bool RewriteObjC::isSuperReceiver(Expr *recExpr) { // check if we are sending a message to 'super' - if (!CurMethodDef || !CurMethodDef->isInstanceMethod()) return 0; - - if (ObjCSuperExpr *Super = dyn_cast<ObjCSuperExpr>(recExpr)) { - const ObjCObjectPointerType *OPT = - Super->getType()->getAs<ObjCObjectPointerType>(); - assert(OPT); - const ObjCInterfaceType *IT = OPT->getInterfaceType(); - return IT->getDecl(); - } - return 0; + if (!CurMethodDef || !CurMethodDef->isInstanceMethod()) return false; + return isa<ObjCSuperExpr>(recExpr); } // struct objc_super { struct objc_object *receiver; struct objc_class *super; }; @@ -2640,6 +2654,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SynthMsgSendFpretFunctionDecl(); if (!GetClassFunctionDecl) SynthGetClassFunctionDecl(); + if (!GetSuperClassFunctionDecl) + SynthGetSuperClassFunctionDecl(); if (!GetMetaClassFunctionDecl) SynthGetMetaClassFunctionDecl(); @@ -2669,8 +2685,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, MsgSendStretFlavor = MsgSendSuperStretFunctionDecl; assert(MsgSendFlavor && "MsgSendFlavor is NULL!"); - ObjCInterfaceDecl *SuperDecl = - CurMethodDef->getClassInterface()->getSuperClass(); + ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface(); llvm::SmallVector<Expr*, 4> InitExprs; @@ -2683,19 +2698,31 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SourceLocation())) ); // set the 'receiver'. + // (id)class_getSuperclass((Class)objc_getClass("CurrentClass")) llvm::SmallVector<Expr*, 8> ClsExprs; QualType argType = Context->getPointerType(Context->CharTy); ClsExprs.push_back(StringLiteral::Create(*Context, - SuperDecl->getIdentifier()->getNameStart(), - SuperDecl->getIdentifier()->getLength(), + ClassDecl->getIdentifier()->getNameStart(), + ClassDecl->getIdentifier()->getLength(), false, argType, SourceLocation())); CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl, &ClsExprs[0], ClsExprs.size(), StartLoc, EndLoc); + // (Class)objc_getClass("CurrentClass") + CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context, + Context->getObjCClassType(), + CastExpr::CK_Unknown, Cls); + ClsExprs.clear(); + ClsExprs.push_back(ArgExpr); + Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl, + &ClsExprs[0], ClsExprs.size(), + StartLoc, EndLoc); + + // (id)class_getSuperclass((Class)objc_getClass("CurrentClass")) // To turn off a warning, type-cast to 'id' - InitExprs.push_back( // set 'super class', using objc_getClass(). + InitExprs.push_back( // set 'super class', using class_getSuperclass(). NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), CastExpr::CK_Unknown, Cls)); @@ -2755,12 +2782,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, } else { // instance message. Expr *recExpr = Exp->getReceiver(); - if (ObjCInterfaceDecl *SuperDecl = isSuperReceiver(recExpr)) { + if (isSuperReceiver(recExpr)) { MsgSendFlavor = MsgSendSuperFunctionDecl; if (MsgSendStretFlavor) MsgSendStretFlavor = MsgSendSuperStretFunctionDecl; assert(MsgSendFlavor && "MsgSendFlavor is NULL!"); - + ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface(); llvm::SmallVector<Expr*, 4> InitExprs; InitExprs.push_back( @@ -2770,20 +2797,32 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Context->getObjCIdType(), SourceLocation())) ); // set the 'receiver'. - + + // (id)class_getSuperclass((Class)objc_getClass("CurrentClass")) llvm::SmallVector<Expr*, 8> ClsExprs; QualType argType = Context->getPointerType(Context->CharTy); ClsExprs.push_back(StringLiteral::Create(*Context, - SuperDecl->getIdentifier()->getNameStart(), - SuperDecl->getIdentifier()->getLength(), + ClassDecl->getIdentifier()->getNameStart(), + ClassDecl->getIdentifier()->getLength(), false, argType, SourceLocation())); CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl, &ClsExprs[0], ClsExprs.size(), StartLoc, EndLoc); + // (Class)objc_getClass("CurrentClass") + CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context, + Context->getObjCClassType(), + CastExpr::CK_Unknown, Cls); + ClsExprs.clear(); + ClsExprs.push_back(ArgExpr); + Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl, + &ClsExprs[0], ClsExprs.size(), + StartLoc, EndLoc); + + // (id)class_getSuperclass((Class)objc_getClass("CurrentClass")) // To turn off a warning, type-cast to 'id' InitExprs.push_back( - // set 'super class', using objc_getClass(). + // set 'super class', using class_getSuperclass(). NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), CastExpr::CK_Unknown, Cls)); // struct objc_super @@ -3986,6 +4025,12 @@ void RewriteObjC::RewriteByRefString(std::string &ResultStr, "_" + utostr(BlockByRefDeclNo[VD]) ; } +static bool HasLocalVariableExternalStorage(ValueDecl *VD) { + if (VarDecl *Var = dyn_cast<VarDecl>(VD)) + return (Var->isFunctionOrMethodVarDecl() && !Var->hasLocalStorage()); + return false; +} + std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i, const char *funcName, std::string Tag) { @@ -4060,7 +4105,10 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i, } else { std::string Name = (*I)->getNameAsString(); - (*I)->getType().getAsStringInternal(Name, Context->PrintingPolicy); + QualType QT = (*I)->getType(); + if (HasLocalVariableExternalStorage(*I)) + QT = Context->getPointerType(QT); + QT.getAsStringInternal(Name, Context->PrintingPolicy); S += Name + " = __cself->" + (*I)->getNameAsString() + "; // bound by copy\n"; } @@ -4149,8 +4197,11 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag, S += "struct __block_impl *"; Constructor += ", void *" + ArgName; } else { - (*I)->getType().getAsStringInternal(FieldName, Context->PrintingPolicy); - (*I)->getType().getAsStringInternal(ArgName, Context->PrintingPolicy); + QualType QT = (*I)->getType(); + if (HasLocalVariableExternalStorage(*I)) + QT = Context->getPointerType(QT); + QT.getAsStringInternal(FieldName, Context->PrintingPolicy); + QT.getAsStringInternal(ArgName, Context->PrintingPolicy); Constructor += ", " + ArgName; } S += FieldName + ";\n"; @@ -4380,10 +4431,19 @@ void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) { GetBlockDeclRefExprs(*CI); } // Handle specific things. - if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) + if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) { // FIXME: Handle enums. if (!isa<FunctionDecl>(CDRE->getDecl())) BlockDeclRefs.push_back(CDRE); + } + else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) + if (HasLocalVariableExternalStorage(DRE->getDecl())) { + BlockDeclRefExpr *BDRE = + new (Context)BlockDeclRefExpr(DRE->getDecl(), DRE->getType(), + DRE->getLocation(), false); + BlockDeclRefs.push_back(BDRE); + } + return; } @@ -4406,10 +4466,16 @@ void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S, } // Handle specific things. - if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) + if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(S)) { if (!isa<FunctionDecl>(CDRE->getDecl()) && !InnerContexts.count(CDRE->getDecl()->getDeclContext())) InnerBlockDeclRefs.push_back(CDRE); + } + else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) { + if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) + if (Var->isFunctionOrMethodVarDecl()) + ImportedLocalExternalDecls.insert(Var); + } return; } @@ -4572,6 +4638,23 @@ Stmt *RewriteObjC::RewriteBlockDeclRefExpr(Expr *DeclRefExp) { return PE; } +// Rewrites the imported local variable V with external storage +// (static, extern, etc.) as *V +// +Stmt *RewriteObjC::RewriteLocalVariableExternalStorage(DeclRefExpr *DRE) { + ValueDecl *VD = DRE->getDecl(); + if (VarDecl *Var = dyn_cast<VarDecl>(VD)) + if (!ImportedLocalExternalDecls.count(Var)) + return DRE; + Expr *Exp = new (Context) UnaryOperator(DRE, UnaryOperator::Deref, + DRE->getType(), DRE->getLocation()); + // Need parens to enforce precedence. + ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), + Exp); + ReplaceStmt(DRE, PE); + return PE; +} + void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) { SourceLocation LocStart = CE->getLParenLoc(); SourceLocation LocEnd = CE->getRParenLoc(); @@ -5091,6 +5174,13 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, } else { FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString()); Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation()); + if (HasLocalVariableExternalStorage(*I)) { + QualType QT = (*I)->getType(); + QT = Context->getPointerType(QT); + Exp = new (Context) UnaryOperator(Exp, UnaryOperator::AddrOf, QT, + SourceLocation()); + } + } InitExprs.push_back(Exp); } @@ -5205,11 +5295,12 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { llvm::SmallVector<BlockDeclRefExpr *, 8> InnerBlockDeclRefs; llvm::SmallPtrSet<const DeclContext *, 8> InnerContexts; InnerContexts.insert(BE->getBlockDecl()); + ImportedLocalExternalDecls.clear(); GetInnerBlockDeclRefExprs(BE->getBody(), InnerBlockDeclRefs, InnerContexts); // Rewrite the block body in place. RewriteFunctionBodyOrGlobalInitializer(BE->getBody()); - + ImportedLocalExternalDecls.clear(); // Now we snarf the rewritten text and stash it away for later use. std::string Str = Rewrite.getRewrittenText(BE->getSourceRange()); RewrittenBlockExprs[BE] = Str; @@ -5392,6 +5483,8 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { ValueDecl *VD = DRE->getDecl(); if (VD->hasAttr<BlocksAttr>()) return RewriteBlockDeclRefExpr(DRE); + if (HasLocalVariableExternalStorage(VD)) + return RewriteLocalVariableExternalStorage(DRE); } if (CallExpr *CE = dyn_cast<CallExpr>(S)) { diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index d2aa548..24d51e2 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -119,19 +119,19 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, } assert(StartColNo <= EndColNo && "Invalid range!"); - + // Pick the first non-whitespace column. while (StartColNo < SourceLine.size() && (SourceLine[StartColNo] == ' ' || SourceLine[StartColNo] == '\t')) ++StartColNo; - + // Pick the last non-whitespace column. if (EndColNo > SourceLine.size()) EndColNo = SourceLine.size(); while (EndColNo-1 && (SourceLine[EndColNo-1] == ' ' || SourceLine[EndColNo-1] == '\t')) --EndColNo; - + // If the start/end passed each other, then we are trying to highlight a range // that just exists in whitespace, which must be some sort of other bug. assert(StartColNo <= EndColNo && "Trying to highlight whitespace??"); @@ -300,10 +300,10 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, if (E.isMacroID()) E = SM.getImmediateSpellingLoc(E); Ranges[i] = SourceRange(S, E); } - + // Get the pretty name, according to #line directives etc. PresumedLoc PLoc = SM.getPresumedLoc(Loc); - + // If this diagnostic is not in the main file, print out the "included from" // lines. if (LastWarningLoc != PLoc.getIncludeLoc()) { @@ -330,8 +330,10 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, unsigned FileOffset = LocInfo.second; // Get information about the buffer it points into. - std::pair<const char*, const char*> BufferInfo = SM.getBufferData(FID); - const char *BufStart = BufferInfo.first; + bool Invalid = false; + const char *BufStart = SM.getBufferData(FID, &Invalid).data(); + if (Invalid) + return; unsigned ColNo = SM.getColumnNumber(FID, FileOffset); unsigned CaretEndColNo @@ -563,7 +565,7 @@ static unsigned findEndOfWord(unsigned Start, // We have the start of a balanced punctuation sequence (quotes, // parentheses, etc.). Determine the full sequence is. - llvm::SmallVector<char, 16> PunctuationEndStack; + llvm::SmallString<16> PunctuationEndStack; PunctuationEndStack.push_back(EndPunct); while (End < Length && !PunctuationEndStack.empty()) { if (Str[End] == PunctuationEndStack.back()) @@ -704,7 +706,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, if (DiagOpts->ShowLocation) { if (DiagOpts->ShowColors) OS.changeColor(savedColor, true); - + // Emit a Visual Studio compatible line number syntax. if (LangOpts && LangOpts->Microsoft) { OS << PLoc.getFilename() << '(' << LineNo << ')'; |