]> granicus.if.org Git - clang/commitdiff
Pass Preprocessor through DiagnosticClient::BeginSourceFile.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 14 Nov 2009 02:48:04 +0000 (02:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 14 Nov 2009 02:48:04 +0000 (02:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88744 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h
include/clang/Frontend/ChainedDiagnosticClient.h
include/clang/Frontend/TextDiagnosticPrinter.h
tools/clang-cc/clang-cc.cpp

index ba086ebf7a39817a0e14708bc1b86ba6407e41fb..3a70e134b82b303fc948b35be632174f474d3d23 100644 (file)
@@ -32,6 +32,7 @@ namespace clang {
   class IdentifierInfo;
   class LangOptions;
   class PartialDiagnostic;
+  class Preprocessor;
   class SourceRange;
 
   // Import the diagnostic enums themselves.
@@ -791,7 +792,8 @@ public:
   /// \arg LO - The language options for the source file being processed.
   /// \arg PP - The preprocessor object being used for the source; this optional
   /// and may not be present, for example when processing AST source files.
-  virtual void BeginSourceFile(const LangOptions &LangOpts) {}
+  virtual void BeginSourceFile(const LangOptions &LangOpts,
+                               const Preprocessor *PP = 0) {}
 
   /// EndSourceFile - Callback to inform the diagnostic client that processing
   /// of a source file has ended. The diagnostic client should assume that any
index 9dc3898f4ef6fbbee9a3f5f8e0479f2256b469ba..d65eb4ad9eb611254dedc4c27f1ca4ce6d5b5087 100644 (file)
@@ -30,9 +30,10 @@ public:
     Secondary.reset(_Secondary);
   }
 
-  virtual void BeginSourceFile(const LangOptions &LO) {
-    Primary->BeginSourceFile(LO);
-    Secondary->BeginSourceFile(LO);
+  virtual void BeginSourceFile(const LangOptions &LO,
+                               const Preprocessor *PP) {
+    Primary->BeginSourceFile(LO, PP);
+    Secondary->BeginSourceFile(LO, PP);
   }
 
   virtual void EndSourceFile() {
index 29a9c305b1142a5ce8f370aea982955920f1f3a9..d727e4800727ee51e8a9857c6b37a1ee8f5827fb 100644 (file)
@@ -42,7 +42,7 @@ public:
                         bool OwnsOutputStream = false);
   virtual ~TextDiagnosticPrinter();
 
-  void BeginSourceFile(const LangOptions &LO) {
+  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) {
     LangOpts = &LO;
   }
 
index 16af1cb203dea04a4a712bf1319c610ae939a307..6ae474289a64ad7feb231d86bb52730c0ba49552 100644 (file)
@@ -579,7 +579,7 @@ static void ProcessASTInputFile(CompilerInstance &CI, const std::string &InFile,
   AST->getSourceManager().createMainFileIDForMemBuffer(SB);
 
   // Stream the input AST to the consumer.
-  CI.getDiagnostics().getClient()->BeginSourceFile(PP.getLangOptions());
+  CI.getDiagnostics().getClient()->BeginSourceFile(PP.getLangOptions(), &PP);
   ParseAST(PP, Consumer.get(), AST->getASTContext(),
            CI.getFrontendOpts().ShowStats);
   CI.getDiagnostics().getClient()->EndSourceFile();
@@ -767,7 +767,8 @@ int main(int argc, char **argv) {
     Clang.createPreprocessor();
 
     // Process the source file.
-    Clang.getDiagnostics().getClient()->BeginSourceFile(Clang.getLangOpts());
+    Clang.getDiagnostics().getClient()->BeginSourceFile(Clang.getLangOpts(),
+                                                      &Clang.getPreprocessor());
     ProcessInputFile(Clang, InFile, ProgAction);
     Clang.getDiagnostics().getClient()->EndSourceFile();
   }