diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-25 22:15:12 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-25 22:15:12 +0000 |
commit | 119b7feb01d3f135670bb867305468a1728c474f (patch) | |
tree | 7de6e2c0fcae6920d08505ff40eff12e6c48a02a /tools/index-test/index-test.cpp | |
parent | e53060fa78ad7e98352049f72787bdb7543e2a48 (diff) |
Check that index-test uses an up-to-date AST file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74214 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/index-test/index-test.cpp')
-rw-r--r-- | tools/index-test/index-test.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp index 63d37b2baa..5606e75766 100644 --- a/tools/index-test/index-test.cpp +++ b/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; |