#include <string>
namespace clang {
-class ASTUnit;
class ASTConsumer;
-class CompilerInstance;
class ASTMergeAction;
+class ASTUnit;
+class CompilerInstance;
enum InputKind {
IK_None,
/// the frontend.
class FrontendAction {
std::string CurrentFile;
+ InputKind CurrentFileKind;
llvm::OwningPtr<ASTUnit> CurrentASTUnit;
CompilerInstance *Instance;
friend class ASTMergeAction;
return CurrentFile;
}
+ InputKind getCurrentFileKind() const {
+ assert(!CurrentFile.empty() && "No current file!");
+ return CurrentFileKind;
+ }
+
ASTUnit &getCurrentASTUnit() const {
assert(!CurrentASTUnit && "No current AST unit!");
return *CurrentASTUnit;
return CurrentASTUnit.take();
}
- void setCurrentFile(llvm::StringRef Value, ASTUnit *AST = 0);
+ void setCurrentFile(llvm::StringRef Value, InputKind Kind, ASTUnit *AST = 0);
/// @}
/// @name Supported Modes
// 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);
}
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);
}
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
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.
}
CI.getDiagnosticClient().EndSourceFile();
- setCurrentFile("");
+ setCurrentFile("", IK_None);
setCompilerInstance(0);
return false;
}
}
setCompilerInstance(0);
- setCurrentFile("");
+ setCurrentFile("", IK_None);
}
//===----------------------------------------------------------------------===//