summaryrefslogtreecommitdiffstats
path: root/clang/tools/index-test/index-test.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-25 22:15:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-25 22:15:12 +0000
commit02f3e84c5b91565f3b9c9c4793117276e38d6e4b (patch)
tree97352a714e339bd8d46d1358df458ea222d0b202 /clang/tools/index-test/index-test.cpp
parentad3f2fcf43eb7dc680728aca5b5c6d257928d04e (diff)
downloadbcm5719-llvm-02f3e84c5b91565f3b9c9c4793117276e38d6e4b.tar.gz
bcm5719-llvm-02f3e84c5b91565f3b9c9c4793117276e38d6e4b.zip
Check that index-test uses an up-to-date AST file.
llvm-svn: 74214
Diffstat (limited to 'clang/tools/index-test/index-test.cpp')
-rw-r--r--clang/tools/index-test/index-test.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/tools/index-test/index-test.cpp b/clang/tools/index-test/index-test.cpp
index 63d37b2baaf..5606e757669 100644
--- a/clang/tools/index-test/index-test.cpp
+++ b/clang/tools/index-test/index-test.cpp
@@ -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;
OpenPOWER on IntegriCloud