diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-06-07 23:25:49 +0000 | 
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-06-07 23:25:49 +0000 | 
| commit | fcb2e6ddea39b8f235fa00fc0b245ce01d76956b (patch) | |
| tree | ba04fb28a098711c83a1736a6d410eb60e1ef647 | |
| parent | fa6214c9523a7af4ba9eb7806f20397795846b52 (diff) | |
| download | bcm5719-llvm-fcb2e6ddea39b8f235fa00fc0b245ce01d76956b.tar.gz bcm5719-llvm-fcb2e6ddea39b8f235fa00fc0b245ce01d76956b.zip  | |
FrontendAction: Track active file kind.
llvm-svn: 105581
| -rw-r--r-- | clang/include/clang/Frontend/FrontendAction.h | 12 | ||||
| -rw-r--r-- | clang/lib/Frontend/ASTMerge.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 12 | 
3 files changed, 18 insertions, 9 deletions
diff --git a/clang/include/clang/Frontend/FrontendAction.h b/clang/include/clang/Frontend/FrontendAction.h index 9945be79b7e..3992c92874a 100644 --- a/clang/include/clang/Frontend/FrontendAction.h +++ b/clang/include/clang/Frontend/FrontendAction.h @@ -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 @@ enum InputKind {  /// the frontend.  class FrontendAction {    std::string CurrentFile; +  InputKind CurrentFileKind;    llvm::OwningPtr<ASTUnit> CurrentASTUnit;    CompilerInstance *Instance;    friend class ASTMergeAction; @@ -117,6 +118,11 @@ public:      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 @@ public:      return CurrentASTUnit.take();    } -  void setCurrentFile(llvm::StringRef Value, ASTUnit *AST = 0); +  void setCurrentFile(llvm::StringRef Value, InputKind Kind, ASTUnit *AST = 0);    /// @}    /// @name Supported Modes diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp index 8118631d5c4..e916e200659 100644 --- a/clang/lib/Frontend/ASTMerge.cpp +++ b/clang/lib/Frontend/ASTMerge.cpp @@ -26,7 +26,8 @@ bool ASTMergeAction::BeginSourceFileAction(CompilerInstance &CI,    // 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);  } diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 92137a6dc59..56676e1ef93 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -25,8 +25,10 @@ FrontendAction::FrontendAction() : Instance(0) {}  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 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,                                       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 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,      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 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,    }    CI.getDiagnosticClient().EndSourceFile(); -  setCurrentFile(""); +  setCurrentFile("", IK_None);    setCompilerInstance(0);    return false;  } @@ -206,7 +208,7 @@ void FrontendAction::EndSourceFile() {    }    setCompilerInstance(0); -  setCurrentFile(""); +  setCurrentFile("", IK_None);  }  //===----------------------------------------------------------------------===//  | 

