Check that index-test uses an up-to-date AST file.

llvm-svn: 74214
This commit is contained in:
Argyrios Kyrtzidis 2009-06-25 22:15:12 +00:00
parent ad3f2fcf43
commit 02f3e84c5b
1 changed files with 12 additions and 0 deletions

View File

@ -88,6 +88,18 @@ int main(int argc, char **argv) {
if (!PointAtLocation.empty()) {
const std::string &Filename = PointAtLocation[0].FileName;
const FileEntry *File = FileMgr.getFile(Filename);
// Safety check. Using an out-of-date AST file will only lead to crashes
// or incorrect results.
// FIXME: Check all the source files that make up the AST file.
const FileEntry *ASTFile = FileMgr.getFile(InFile);
if (File->getModificationTime() > ASTFile->getModificationTime()) {
llvm::errs() << "[" << InFile << "] Error: " <<
"Pointing at a source file which was modified after creating "
"the AST file\n";
return 1;
}
if (File == 0) {
llvm::errs() << "File '" << Filename << "' does not exist\n";
return 1;