// FIXME: This is temporary; eventually, CIndex will always do this.
bool OnlyLocalDecls;
+ /// The name of the original source file used to generate this ASTUnit.
+ std::string OriginalSourceFile;
+
// Critical optimization when using clang_getCursor().
ASTLocation LastLoc;
} // anonymous namespace
const std::string &ASTUnit::getOriginalSourceFileName() {
- return dyn_cast<PCHReader>(Ctx->getExternalSource())->getOriginalSourceFile();
+ return OriginalSourceFile;
}
const std::string &ASTUnit::getPCHFileName() {
+ assert(Ctx->getExternalSource() && "Not an ASTUnit from a PCH file!");
return dyn_cast<PCHReader>(Ctx->getExternalSource())->getFileName();
}
return NULL;
}
+ AST->OriginalSourceFile = Reader->getOriginalSourceFile();
+
// PCH loaded successfully. Now create the preprocessor.
// Get information about the target being compiled for.
// FIXME: Use the provided diagnostic client.
AST.reset(new ASTUnit());
+ AST->OriginalSourceFile = Clang.getFrontendOpts().Inputs[0].second;
+
// Create a file manager object to provide access to and cache the filesystem.
Clang.setFileManager(&AST->getFileManager());