On Tue, Jul 31, 2012 at 9:59 PM, Richard Smith <[email protected]> wrote: > On Tue, Jul 31, 2012 at 6:56 AM, Manuel Klimek <[email protected]> wrote: >> >> Author: klimek >> Date: Tue Jul 31 08:56:54 2012 >> New Revision: 161047 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=161047&view=rev >> Log: >> Fixes a segfault in Tooling when using pch's: >> Clear the FileManager's stat cache in between running >> translation units, as the stat cache loaded from a pch >> is only valid for one compiler invocation. >> >> >> Added: >> cfe/trunk/test/Tooling/Inputs/ >> cfe/trunk/test/Tooling/Inputs/lit.local.cfg >> cfe/trunk/test/Tooling/Inputs/pch-fail.h >> cfe/trunk/test/Tooling/Inputs/pch.cpp >> cfe/trunk/test/Tooling/Inputs/pch.h >> cfe/trunk/test/Tooling/pch.cpp >> Modified: >> cfe/trunk/include/clang/Basic/FileManager.h >> cfe/trunk/lib/Basic/FileManager.cpp >> cfe/trunk/lib/Tooling/Tooling.cpp >> >> Modified: cfe/trunk/include/clang/Basic/FileManager.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=161047&r1=161046&r2=161047&view=diff >> >> ============================================================================== >> --- cfe/trunk/include/clang/Basic/FileManager.h (original) >> +++ cfe/trunk/include/clang/Basic/FileManager.h Tue Jul 31 08:56:54 2012 >> @@ -186,6 +186,9 @@ >> /// \brief Removes the specified FileSystemStatCache object from the >> manager. >> void removeStatCache(FileSystemStatCache *statCache); >> >> + /// \brief Removes all FileSystemStatCache objects from the manager. >> + void clearStatCaches(); >> + >> /// \brief Lookup, cache, and verify the specified directory (real or >> /// virtual). >> /// >> >> Modified: cfe/trunk/lib/Basic/FileManager.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=161047&r1=161046&r2=161047&view=diff >> >> ============================================================================== >> --- cfe/trunk/lib/Basic/FileManager.cpp (original) >> +++ cfe/trunk/lib/Basic/FileManager.cpp Tue Jul 31 08:56:54 2012 >> @@ -223,6 +223,10 @@ >> PrevCache->setNextStatCache(statCache->getNextStatCache()); >> } >> >> +void FileManager::clearStatCaches() { >> + StatCache.reset(0); >> +} >> + >> /// \brief Retrieve the directory that the given file name resides in. >> /// Filename can point to either a real file or a virtual file. >> static const DirectoryEntry *getDirectoryFromFile(FileManager &FileMgr, >> >> Modified: cfe/trunk/lib/Tooling/Tooling.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=161047&r1=161046&r2=161047&view=diff >> >> ============================================================================== >> --- cfe/trunk/lib/Tooling/Tooling.cpp (original) >> +++ cfe/trunk/lib/Tooling/Tooling.cpp Tue Jul 31 08:56:54 2012 >> @@ -212,6 +212,7 @@ >> const bool Success = Compiler.ExecuteAction(*ScopedToolAction); >> >> Compiler.resetAndLeakFileManager(); >> + Files->clearStatCaches(); >> return Success; >> } >> >> >> Added: cfe/trunk/test/Tooling/Inputs/lit.local.cfg >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/Inputs/lit.local.cfg?rev=161047&view=auto >> >> ============================================================================== >> --- cfe/trunk/test/Tooling/Inputs/lit.local.cfg (added) >> +++ cfe/trunk/test/Tooling/Inputs/lit.local.cfg Tue Jul 31 08:56:54 2012 >> @@ -0,0 +1 @@ >> +config.suffixes = [] >> >> Added: cfe/trunk/test/Tooling/Inputs/pch-fail.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/Inputs/pch-fail.h?rev=161047&view=auto >> >> ============================================================================== >> (empty) >> >> Added: cfe/trunk/test/Tooling/Inputs/pch.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/Inputs/pch.cpp?rev=161047&view=auto >> >> ============================================================================== >> (empty) >> >> Added: cfe/trunk/test/Tooling/Inputs/pch.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/Inputs/pch.h?rev=161047&view=auto >> >> ============================================================================== >> (empty) >> >> Added: cfe/trunk/test/Tooling/pch.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/pch.cpp?rev=161047&view=auto >> >> ============================================================================== >> --- cfe/trunk/test/Tooling/pch.cpp (added) >> +++ cfe/trunk/test/Tooling/pch.cpp Tue Jul 31 08:56:54 2012 >> @@ -0,0 +1,21 @@ >> +// This is a regression test for handling of stat caches within the >> tooling >> +// infrastructure. This test reproduces the problem under valgrind: >> + >> +// First, create a pch that we can later load. Loading the pch will >> insert >> +// a stat cache into the FileManager: >> +// RUN: %clang -x c++-header %S/Inputs/pch.h -o %t1 >> + >> +// Use the generated pch and enforce a subsequent stat miss by by using > > > Typo: "by by" :)
r161106. Thx _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
