diff options
Diffstat (limited to 'Driver')
-rw-r--r-- | Driver/ASTConsumers.cpp | 6 | ||||
-rw-r--r-- | Driver/RewriteTest.cpp | 7 | ||||
-rw-r--r-- | Driver/Targets.cpp | 5 | ||||
-rw-r--r-- | Driver/TextDiagnosticBuffer.cpp | 1 | ||||
-rw-r--r-- | Driver/TextDiagnosticBuffer.h | 6 | ||||
-rw-r--r-- | Driver/TextDiagnosticPrinter.cpp | 12 | ||||
-rw-r--r-- | Driver/TextDiagnosticPrinter.h | 13 | ||||
-rw-r--r-- | Driver/TextDiagnostics.cpp | 3 | ||||
-rw-r--r-- | Driver/TextDiagnostics.h | 12 | ||||
-rw-r--r-- | Driver/TranslationUnit.cpp | 6 | ||||
-rw-r--r-- | Driver/clang.cpp | 10 | ||||
-rw-r--r-- | Driver/clang.h | 4 |
12 files changed, 51 insertions, 34 deletions
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp index 5cd3f77562..85140bc060 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -356,7 +356,7 @@ namespace { ASTDumper() : DeclPrinter() {} void Initialize(ASTContext &Context, unsigned MainFileID) { - SM = &Context.SourceMgr; + SM = &Context.getSourceManager(); } virtual void HandleTopLevelDecl(Decl *D) { @@ -400,7 +400,7 @@ namespace { SourceManager *SM; public: void Initialize(ASTContext &Context, unsigned MainFileID) { - SM = &Context.SourceMgr; + SM = &Context.getSourceManager(); } virtual void HandleTopLevelDecl(Decl *D) { @@ -482,7 +482,7 @@ namespace { SourceManager *SM; public: virtual void Initialize(ASTContext &Context, unsigned MainFileID) { - SM = &Context.SourceMgr; + SM = &Context.getSourceManager(); } virtual void VisitCFG(CFG& C) { diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 77adafecba..cc10ab0d38 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -64,7 +64,7 @@ namespace { public: void Initialize(ASTContext &context, unsigned mainFileID) { Context = &context; - SM = &Context->SourceMgr; + SM = &Context->getSourceManager(); MsgSendFunctionDecl = 0; MsgSendSuperFunctionDecl = 0; MsgSendStretFunctionDecl = 0; @@ -87,7 +87,7 @@ namespace { MainFileEnd = MainBuf->getBufferEnd(); - Rewrite.setSourceMgr(Context->SourceMgr); + Rewrite.setSourceMgr(Context->getSourceManager()); // declaring objc_selector outside the parameter list removes a silly // scope related warning... const char *s = "struct objc_selector; struct objc_class;\n" @@ -917,7 +917,8 @@ Stmt *RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) { unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error, "rewriter could not replace sub-expression due to macros"); SourceRange Range = Exp->getSourceRange(); - Diags.Report(Exp->getAtLoc(), DiagID, 0, 0, &Range, 1); + Diags.Report(Exp->getAtLoc(), DiagID, Context->getSourceManager(), + 0, 0, &Range, 1); delete Replacement; return Exp; } diff --git a/Driver/Targets.cpp b/Driver/Targets.cpp index 23f8307caa..6e810efd3c 100644 --- a/Driver/Targets.cpp +++ b/Driver/Targets.cpp @@ -702,7 +702,8 @@ static TargetInfoImpl *CreateTarget(const std::string& T) { /// CreateTargetInfo - Return the set of target info objects as specified by /// the -arch command line option. -TargetInfo *clang::CreateTargetInfo(const std::vector<std::string>& triples, +TargetInfo *clang::CreateTargetInfo(SourceManager& SrcMgr, + const std::vector<std::string>& triples, Diagnostic *Diags) { assert (!triples.empty() && "No target triple."); @@ -713,7 +714,7 @@ TargetInfo *clang::CreateTargetInfo(const std::vector<std::string>& triples, if (!PrimaryTarget) return NULL; - TargetInfo *TI = new TargetInfo(PrimaryTarget, Diags); + TargetInfo *TI = new TargetInfo(SrcMgr, PrimaryTarget, Diags); // Add all secondary targets. for (unsigned i = 1, e = triples.size(); i != e; ++i) { diff --git a/Driver/TextDiagnosticBuffer.cpp b/Driver/TextDiagnosticBuffer.cpp index d0e2f900c5..c77801b767 100644 --- a/Driver/TextDiagnosticBuffer.cpp +++ b/Driver/TextDiagnosticBuffer.cpp @@ -21,6 +21,7 @@ void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level Level, SourceLocation Pos, diag::kind ID, + SourceManager& SrcMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *, diff --git a/Driver/TextDiagnosticBuffer.h b/Driver/TextDiagnosticBuffer.h index d155874458..5da37c3e27 100644 --- a/Driver/TextDiagnosticBuffer.h +++ b/Driver/TextDiagnosticBuffer.h @@ -30,7 +30,7 @@ public: private: DiagList Errors, Warnings; public: - TextDiagnosticBuffer(SourceManager &SM) : TextDiagnostics(SM) {} + TextDiagnosticBuffer() {} const_iterator err_begin() const { return Errors.begin(); } const_iterator err_end() const { return Errors.end(); } @@ -40,7 +40,9 @@ public: virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel, SourceLocation Pos, - diag::kind ID, const std::string *Strs, + diag::kind ID, + SourceManager& SrcMgr, + const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, unsigned NumRanges); diff --git a/Driver/TextDiagnosticPrinter.cpp b/Driver/TextDiagnosticPrinter.cpp index 463a3d7e8e..d2eaacaace 100644 --- a/Driver/TextDiagnosticPrinter.cpp +++ b/Driver/TextDiagnosticPrinter.cpp @@ -31,13 +31,13 @@ NoCaretDiagnostics("fno-caret-diagnostics", " diagnostics")); void TextDiagnosticPrinter:: -PrintIncludeStack(SourceLocation Pos) { +PrintIncludeStack(SourceLocation Pos, SourceManager& SourceMgr) { if (Pos.isInvalid()) return; Pos = SourceMgr.getLogicalLoc(Pos); // Print out the other include frames first. - PrintIncludeStack(SourceMgr.getIncludeLoc(Pos)); + PrintIncludeStack(SourceMgr.getIncludeLoc(Pos),SourceMgr); unsigned LineNo = SourceMgr.getLineNumber(Pos); std::cerr << "In file included from " << SourceMgr.getSourceName(Pos) @@ -46,7 +46,8 @@ PrintIncludeStack(SourceLocation Pos) { /// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s) /// any characters in LineNo that intersect the SourceRange. -void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, +void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, + SourceManager& SourceMgr, unsigned LineNo, std::string &CaratLine, const std::string &SourceLine) { @@ -101,6 +102,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level Level, SourceLocation Pos, diag::kind ID, + SourceManager& SourceMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, @@ -116,7 +118,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, // "included from" lines. if (LastWarningLoc != SourceMgr.getIncludeLoc(LPos)) { LastWarningLoc = SourceMgr.getIncludeLoc(LPos); - PrintIncludeStack(LastWarningLoc); + PrintIncludeStack(LastWarningLoc,SourceMgr); } // Compute the column number. Rewind from the current position to the start @@ -162,7 +164,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, // Highlight all of the characters covered by Ranges with ~ characters. for (unsigned i = 0; i != NumRanges; ++i) - HighlightRange(Ranges[i], LineNo, CaratLine, SourceLine); + HighlightRange(Ranges[i], SourceMgr, LineNo, CaratLine, SourceLine); // Next, insert the carat itself. if (ColNo-1 < CaratLine.size()) diff --git a/Driver/TextDiagnosticPrinter.h b/Driver/TextDiagnosticPrinter.h index beb9d808e9..c87c20e4f0 100644 --- a/Driver/TextDiagnosticPrinter.h +++ b/Driver/TextDiagnosticPrinter.h @@ -24,17 +24,20 @@ class SourceManager; class TextDiagnosticPrinter : public TextDiagnostics { SourceLocation LastWarningLoc; public: - TextDiagnosticPrinter(SourceManager &sourceMgr) - : TextDiagnostics(sourceMgr) {} + TextDiagnosticPrinter() {} - void PrintIncludeStack(SourceLocation Pos); - void HighlightRange(const SourceRange &R, unsigned LineNo, + void PrintIncludeStack(SourceLocation Pos, SourceManager& SrcMgr); + void HighlightRange(const SourceRange &R, + SourceManager& SrcMgr, + unsigned LineNo, std::string &CaratLine, const std::string &SourceLine); virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel, SourceLocation Pos, - diag::kind ID, const std::string *Strs, + diag::kind ID, + SourceManager& SrcMgr, + const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, unsigned NumRanges); diff --git a/Driver/TextDiagnostics.cpp b/Driver/TextDiagnostics.cpp index 5b14cdda82..46e535de90 100644 --- a/Driver/TextDiagnostics.cpp +++ b/Driver/TextDiagnostics.cpp @@ -40,7 +40,8 @@ std::string TextDiagnostics::FormatDiagnostic(Diagnostic &Diags, } bool TextDiagnostics::IgnoreDiagnostic(Diagnostic::Level Level, - SourceLocation Pos) { + SourceLocation Pos, + SourceManager& SourceMgr) { if (Pos.isValid()) { // If this is a warning or note, and if it a system header, suppress the // diagnostic. diff --git a/Driver/TextDiagnostics.h b/Driver/TextDiagnostics.h index 27d9d3a8e4..ad5e4cb89b 100644 --- a/Driver/TextDiagnostics.h +++ b/Driver/TextDiagnostics.h @@ -24,23 +24,25 @@ class Preprocessor; class TextDiagnostics : public DiagnosticClient { HeaderSearch *TheHeaderSearch; protected: - SourceManager &SourceMgr; - std::string FormatDiagnostic(Diagnostic &Diags, Diagnostic::Level Level, diag::kind ID, const std::string *Strs, unsigned NumStrs); public: - TextDiagnostics(SourceManager &sourceMgr) : SourceMgr(sourceMgr) {} + TextDiagnostics() {} virtual ~TextDiagnostics(); void setHeaderSearch(HeaderSearch &HS) { TheHeaderSearch = &HS; } virtual bool IgnoreDiagnostic(Diagnostic::Level Level, - SourceLocation Pos); + SourceLocation Pos, + SourceManager& SrcMgr); + virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel, SourceLocation Pos, - diag::kind ID, const std::string *Strs, + diag::kind ID, + SourceManager& SrcMgr, + const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, unsigned NumRanges) = 0; diff --git a/Driver/TranslationUnit.cpp b/Driver/TranslationUnit.cpp index 627657aa92..6f35a32371 100644 --- a/Driver/TranslationUnit.cpp +++ b/Driver/TranslationUnit.cpp @@ -102,7 +102,7 @@ void TranslationUnit::Emit(llvm::Serializer& Sezr) const { Sezr.EnterBlock(); // Emit the SourceManager. - Sezr.Emit(Context->SourceMgr); + Sezr.Emit(Context->getSourceManager()); // Emit the LangOptions. Sezr.Emit(LangOpts); @@ -184,7 +184,7 @@ TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr, assert (FoundBlock); // Read the SourceManager. - SourceManager::CreateAndRegister(Dezr,FMgr); + SourceManager& SrcMgr = *SourceManager::CreateAndRegister(Dezr,FMgr); // Read the LangOptions. TU->LangOpts.Read(Dezr); @@ -196,7 +196,7 @@ TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr, std::vector<std::string> triples; triples.push_back(triple); delete [] triple; - Dezr.RegisterPtr(PtrID,CreateTargetInfo(triples,NULL)); + Dezr.RegisterPtr(PtrID,CreateTargetInfo(SrcMgr,triples,NULL)); } // For Selectors, we must read the identifier table first because the diff --git a/Driver/clang.cpp b/Driver/clang.cpp index eb469d87ec..c009e06860 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -989,10 +989,10 @@ int main(int argc, char **argv) { std::auto_ptr<TextDiagnostics> DiagClient; if (!VerifyDiagnostics) { // Print diagnostics to stderr by default. - DiagClient.reset(new TextDiagnosticPrinter(SourceMgr)); + DiagClient.reset(new TextDiagnosticPrinter()); } else { // When checking diagnostics, just buffer them up. - DiagClient.reset(new TextDiagnosticBuffer(SourceMgr)); + DiagClient.reset(new TextDiagnosticBuffer()); if (InputFilenames.size() != 1) { fprintf(stderr, @@ -1013,7 +1013,7 @@ int main(int argc, char **argv) { { // Create triples, and create the TargetInfo. std::vector<std::string> triples; CreateTargetTriples(triples); - Target = CreateTargetInfo(triples,&Diags); + Target = CreateTargetInfo(SourceMgr,triples,&Diags); if (Target == 0) { fprintf(stderr, "Sorry, I don't know what target this is: %s\n", @@ -1026,7 +1026,9 @@ int main(int argc, char **argv) { // -I- is a deprecated GCC feature, scan for it and reject it. for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) { if (I_dirs[i] == "-") { - Diags.Report(SourceLocation(), diag::err_pp_I_dash_not_supported); + Diags.Report(SourceLocation(), diag::err_pp_I_dash_not_supported, + SourceMgr); + I_dirs.erase(I_dirs.begin()+i); --i; } diff --git a/Driver/clang.h b/Driver/clang.h index 098c51b39f..c4bbb84658 100644 --- a/Driver/clang.h +++ b/Driver/clang.h @@ -25,6 +25,7 @@ class TargetInfo; class Diagnostic; class ASTConsumer; class IdentifierTable; +class SourceManager; /// DoPrintPreprocessedInput - Implement -E mode. void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP, @@ -36,7 +37,8 @@ MinimalAction *CreatePrintParserActionsAction(IdentifierTable &); /// CreateTargetInfo - Return the set of target info objects as specified by /// the -arch command line option. -TargetInfo *CreateTargetInfo(const std::vector<std::string>& triples, +TargetInfo *CreateTargetInfo(SourceManager& SrcMgr, + const std::vector<std::string>& triples, Diagnostic *Diags); /// EmitLLVMFromASTs - Implement -emit-llvm, which generates llvm IR from C. |