[cfe-commits] r105581 - in /cfe/trunk: include/clang/Frontend/FrontendAction.h lib/Frontend/ASTMerge.cpp lib/Frontend/FrontendAction.cpp

Daniel Dunbar daniel at zuster.org
Mon Jun 7 16:25:50 PDT 2010


Author: ddunbar
Date: Mon Jun  7 18:25:49 2010
New Revision: 105581

URL: http://llvm.org/viewvc/llvm-project?rev=105581&view=rev
Log:
FrontendAction: Track active file kind.

Modified:
    cfe/trunk/include/clang/Frontend/FrontendAction.h
    cfe/trunk/lib/Frontend/ASTMerge.cpp
    cfe/trunk/lib/Frontend/FrontendAction.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=105581&r1=105580&r2=105581&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Mon Jun  7 18:25:49 2010
@@ -15,10 +15,10 @@
 #include <string>
 
 namespace clang {
-class ASTUnit;
 class ASTConsumer;
-class CompilerInstance;
 class ASTMergeAction;
+class ASTUnit;
+class CompilerInstance;
 
 enum InputKind {
   IK_None,
@@ -40,6 +40,7 @@
 /// the frontend.
 class FrontendAction {
   std::string CurrentFile;
+  InputKind CurrentFileKind;
   llvm::OwningPtr<ASTUnit> CurrentASTUnit;
   CompilerInstance *Instance;
   friend class ASTMergeAction;
@@ -117,6 +118,11 @@
     return CurrentFile;
   }
 
+  InputKind getCurrentFileKind() const {
+    assert(!CurrentFile.empty() && "No current file!");
+    return CurrentFileKind;
+  }
+
   ASTUnit &getCurrentASTUnit() const {
     assert(!CurrentASTUnit && "No current AST unit!");
     return *CurrentASTUnit;
@@ -126,7 +132,7 @@
     return CurrentASTUnit.take();
   }
 
-  void setCurrentFile(llvm::StringRef Value, ASTUnit *AST = 0);
+  void setCurrentFile(llvm::StringRef Value, InputKind Kind, ASTUnit *AST = 0);
 
   /// @}
   /// @name Supported Modes

Modified: cfe/trunk/lib/Frontend/ASTMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTMerge.cpp?rev=105581&r1=105580&r2=105581&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTMerge.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTMerge.cpp Mon Jun  7 18:25:49 2010
@@ -26,7 +26,8 @@
   // FIXME: This is a hack. We need a better way to communicate the
   // AST file, compiler instance, and file name than member variables
   // of FrontendAction.
-  AdaptedAction->setCurrentFile(getCurrentFile(), takeCurrentASTUnit());
+  AdaptedAction->setCurrentFile(getCurrentFile(), getCurrentFileKind(),
+                                takeCurrentASTUnit());
   AdaptedAction->setCompilerInstance(&CI);
   return AdaptedAction->BeginSourceFileAction(CI, Filename);
 }

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=105581&r1=105580&r2=105581&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon Jun  7 18:25:49 2010
@@ -25,8 +25,10 @@
 
 FrontendAction::~FrontendAction() {}
 
-void FrontendAction::setCurrentFile(llvm::StringRef Value, ASTUnit *AST) {
+void FrontendAction::setCurrentFile(llvm::StringRef Value, InputKind Kind,
+                                    ASTUnit *AST) {
   CurrentFile = Value;
+  CurrentFileKind = Kind;
   CurrentASTUnit.reset(AST);
 }
 
@@ -35,7 +37,7 @@
                                      InputKind InputKind) {
   assert(!Instance && "Already processing a source file!");
   assert(!Filename.empty() && "Unexpected empty filename!");
-  setCurrentFile(Filename);
+  setCurrentFile(Filename, InputKind);
   setCompilerInstance(&CI);
 
   // AST files follow a very different path, since they share objects via the
@@ -52,7 +54,7 @@
     if (!AST)
       goto failure;
 
-    setCurrentFile(Filename, AST);
+    setCurrentFile(Filename, InputKind, AST);
 
     // Set the shared objects, these are reset when we finish processing the
     // file, otherwise the CompilerInstance will happily destroy them.
@@ -127,7 +129,7 @@
   }
 
   CI.getDiagnosticClient().EndSourceFile();
-  setCurrentFile("");
+  setCurrentFile("", IK_None);
   setCompilerInstance(0);
   return false;
 }
@@ -206,7 +208,7 @@
   }
 
   setCompilerInstance(0);
-  setCurrentFile("");
+  setCurrentFile("", IK_None);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list