summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [C++11] Use std::atomic instead of LLVM's.Benjamin Kramer2014-03-021-10/+6
| | | | | | No intended functionality change. llvm-svn: 202652
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-2/+2
| | | | llvm-svn: 202639
* [ASTUnit] Don't let the preamble diagnostics out-live the CompilerInstance ↵Argyrios Kyrtzidis2014-02-281-51/+93
| | | | | | | | | | that created them, this is inherently unsafe. Instead get the diagnostic info into a SourceManager-independent form. llvm-svn: 202471
* [ASTUnit] Fix use-after-free bug in ↵Argyrios Kyrtzidis2014-02-271-22/+8
| | | | | | | | | | | | | | | ASTUnit::getMainBufferWithPrecompiledPreamble(). With r197755 we started reading the contents of buffer file entries, but the buffers may point to ASTReader blobs that have been disposed. Fix this by having the CompilerInstance object keep a reference to the ASTReader as well as having the ASTContext keep reference to the ExternalASTSource. This was very difficult to construct a test case for. rdar://16149782 llvm-svn: 202346
* Recommit virtual file systemBen Langmuir2014-02-201-3/+3
| | | | | | | | | | | Previously reverted in r201755 due to causing an assertion failure. I've removed the offending assertion, and taught the CompilerInstance to create a default virtual file system inside createFileManager. In the future, we should be able to reach into the CompilerInvocation to customize this behaviour without breaking clients that don't care. llvm-svn: 201818
* Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka2014-02-201-3/+3
| | | | | | | | | | assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
* Use llvm::DeleteContainerSeconds when possibleReid Kleckner2014-02-191-4/+1
| | | | llvm-svn: 201739
* Initial implementation of virtual file systemBen Langmuir2014-02-191-3/+3
| | | | | | | | | | | | This adds the minimum virtual file system support to start migrating FileManager onto the VFS. Originally discussed here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html Differential Revision: http://llvm-reviews.chandlerc.com/D2745 llvm-svn: 201618
* Fix memory leak introduced by r201010.Daniel Jasper2014-02-121-0/+1
| | | | llvm-svn: 201220
* ASTUnit: simplify remapping files by using the exact same logic in PreprocessorDmitri Gribenko2014-02-101-16/+4
| | | | llvm-svn: 201082
* ASTUnit: remove dead code in remapping filesDmitri Gribenko2014-02-081-73/+22
| | | | | | | ASTUnit contains code to remap files to other files on disk. This code is not used. We only remap files to MemoryBuffers. llvm-svn: 201010
* ASTUnit: ArrayRef'ize RemappedFilesDmitri Gribenko2014-02-071-11/+8
| | | | llvm-svn: 200975
* Fix a -Wformat warning in ASTUnit.cppReid Kleckner2014-02-031-2/+2
| | | | | | | | | | llvm::sys::cas_flag is 'long' instead of 'uint32_t' on win32, because that's what InterlockedIncrement is defined to accept. I still don't know if we should be calling fprintf from ASTUnit.cpp behind a getenv check. llvm-svn: 200718
* Use the simpler version of llvm::sys::fs::remove when possible.Rafael Espindola2014-01-101-2/+1
| | | | llvm-svn: 198957
* Remove obsolete preamble FIXMEAlp Toker2013-12-201-2/+0
| | | | | | | The MD5 is checked since r197755 which is as good as comparing buffer contents in this context. llvm-svn: 197842
* Correctly compute the size in bytes of PreambleFileHash.MD5Dmitri Gribenko2013-12-201-2/+2
| | | | llvm-svn: 197762
* ASTUnit::getMainBufferWithPrecompiledPreamble: use MD5 hash of the remappedDmitri Gribenko2013-12-201-12/+51
| | | | | | | | | | | files to tell if they were changed since the last time we have computed the preamble We used to check only the buffer size, so if the new remapped buffer has the same size as the previous one, we would think that the buffer did not change, and we did not rebuild the preambule, which sometimes caused us to crash. llvm-svn: 197755
* Simplify codeDmitri Gribenko2013-12-191-1/+1
| | | | llvm-svn: 197748
* Make ASTUnit structure stable with NDEBUGAlp Toker2013-11-221-1/+1
| | | | | | | | | ASTUnit instances are allocated infrequently so it's fine to keep this field around in all build configurations. Assigns null to silence -Wunused-private-field in Release. llvm-svn: 195419
* Use the same SourceManager for ModuleMaps and compilations.Manuel Klimek2013-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows using virtual file mappings on the original SourceManager to map in virtual module.map files. Without this patch, the ModuleMap search will find a module.map file (as the FileEntry exists in the FileManager), but will be unable to get the content from the SourceManager (as ModuleMap previously created its own SourceManager). Two problems needed to be fixed which this patch exposed: 1. Storing the inferred module map When writing out a module, the ASTWriter stores the names of the files in the main source manager; when loading the AST again, the ASTReader errs out if such a file is found missing, unless it is overridden. Previously CompilerInstance's compileModule method would store the inferred module map to a temporary file; the problem with this approach is that now that the module map is handled by the main source manager, the ASTWriter stores the name of the temporary module map as source to the compilation; later, when the module is loaded, the temporary file has already been deleted, which leads to a compilation error. This patch changes the inferred module map to instead inject a virtual file into the source manager. This both saves some disk IO, and works with how the ASTWriter/ASTReader handle overridden source files. 2. Changing test input in test/Modules/Inputs/* Now that the module map file is handled by the main source manager, the VerifyDiagnosticConsumer will not ignore diagnostics created while parsing the module map file. The module test test/Modules/renamed.m uses -I test/Modules/Inputs and triggers recursive loading of all module maps in test/Modules/Inputs, some of which had conflicting names, thus leading errors while parsing the module maps. Those diagnostics already occur on trunk, but before this patch they would not break the test, as they were ignored by the VerifyDiagnosticConsumer. This patch thus changes the module maps that have been recently introduced which broke the invariant of compatible modules maps in test/Modules/Inputs. llvm-svn: 193314
* [libclang] For an unscoped enum include the enumerators in the top-level ↵Argyrios Kyrtzidis2013-10-151-0/+12
| | | | | | | | code-completion hash since they enter the top-level namespace. rdar://14703327 llvm-svn: 192720
* Remove unnecessary inclusion of Sema.hDavid Blaikie2013-09-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let me tell you a tale... Within some twisted maze of debug info I've ended up implementing an insane man's Include What You Use device. When the debugger emits debug info it really shouldn't, I find out why & then realize the code could be improved too. In this instance CIndexDiagnostics.cpp had a lot more debug info with Clang than GCC. Upon inspection a major culprit was all the debug info describing clang::Sema. This was emitted because clang::Sema is befriended by DiagnosticEngine which was rightly required, but GCC doesn't emit debug info for friends so it never emitted anything for Clang. Clang does emit debug info for friends (will be fixed/changed to reduce debug info size). But why didn't Clang just emit a declaration of Sema if this entire TU didn't require a definition? 1) Diagnostic.h did the right thing, only using a declaration of Sema and not including Sema.h at all. 2) Some other dependency of CIndexDiagnostics.cpp didn't do the right thing. ASTUnit.h, only needing a declaration, still included Sema.h (hence this commit which removes that include and adds the necessary includes to the cpp files that were relying on this) 3) -flimit-debug-info didn't save us because of EnterExpressionEvaluationContext, defined inline in Sema.h which fires the "requiresCompleteType" check/flag (since it uses nested types from Sema and calls Sema member functions) and thus, if debug info is ever emitted for the type, the whole type is emitted and not just a declaration. Improving -flimit-debug-info to account for this would be... hard. Modifying the code so that's not 'required to be complete' might be possible, but probably only by moving EnterExpressionEvaluationContext either into Sema, or out of Sema.h. That might be a bit too much of a contortion to be bothered with. Also, this is only one of the cases where emitting debug info for friends caused us to emit a lot more debug info (this change reduces Clang's DWO size by 0.93%, dropping friends entirely reduces debug info by 3.2%) - I haven't hunted down the other cases, but I assume they might be similar (Sema or something like it). IWYU or a similar tool might help us reduce build times a bit, but analyzing debug info to find these differences isn't worthwhile. I'll take the 3.2% win, provide this small improvement to the code itself, and move on. llvm-svn: 190715
* This wasn't headers, just missing namespaces.Benjamin Kramer2013-08-241-4/+4
| | | | | | /me bows head in shame. llvm-svn: 189172
* Replace compLocDecl with less_first.Benjamin Kramer2013-08-241-14/+8
| | | | llvm-svn: 189170
* [PCH] Fix a PCH serialization crash, with invalid code related to forward ↵Argyrios Kyrtzidis2013-08-071-3/+7
| | | | | | | | | | | | | | | | enum references. The problem was that an enum without closing semicolon could be associated as a forward enum in an erroneous declaration, leading to the identifier being associated with the enum decl but without a declaration actually referencing it. This resulted in not having it serialized before serializing the identifier that is associated with. Also prevent the ASTUnit from querying the serialized DeclID for an invalid top-level decl; it may not have been serialized. rdar://14539667 llvm-svn: 187914
* Update for llvm api change.Rafael Espindola2013-07-291-5/+5
| | | | llvm-svn: 187379
* Convert a use of stat with sys::fs::status.Rafael Espindola2013-07-291-9/+10
| | | | llvm-svn: 187364
* Fix crash in libclang if code completion is used with unknown flags.Manuel Klimek2013-07-181-1/+1
| | | | | | | Use CaptureDroppedDiagnostics to make sure that there is a diagnostic client installed when warning flags are parsed. llvm-svn: 186582
* Use llvm::sys::fs::createUniqueFile.Rafael Espindola2013-07-051-2/+1
| | | | | | | Include a test that clang now produces output files with permissions matching the umask. llvm-svn: 185727
* Use llvm::sys::fs::createTemporaryFile.Rafael Espindola2013-07-051-1/+1
| | | | llvm-svn: 185717
* Don't use PathV1.h in ASTUnit.cpp.Rafael Espindola2013-06-261-5/+3
| | | | llvm-svn: 184912
* Remove the last use of PathWithStatus.Rafael Espindola2013-06-261-4/+4
| | | | llvm-svn: 184909
* Use llvm::sys::fs::unique_file.Rafael Espindola2013-06-261-26/+7
| | | | llvm-svn: 184908
* Remove some uses of llvm::sys::Path.Rafael Espindola2013-06-261-6/+6
| | | | llvm-svn: 184907
* [libclang/codecompletion] Make sure the top-level decl hash takes into ↵Argyrios Kyrtzidis2013-06-241-1/+9
| | | | | | | | | | | account ImportDecls. The top-level hash is used to determine if we need to update the global code-completion results. ImportDecls did not affect the hash so a newly introduced ImportDecl would not trigger an update of the global results. rdar://14202797 llvm-svn: 184782
* Use the new name of getUniqueID.Rafael Espindola2013-06-201-5/+5
| | | | llvm-svn: 184432
* Use llvm::sys::fs::GetUniqueID.Rafael Espindola2013-06-181-15/+22
| | | | llvm-svn: 184218
* Include PathV1.h in files that use it.Rafael Espindola2013-06-111-0/+1
| | | | | | This is preparation for replacing Path.h with PathV2.h. llvm-svn: 183781
* Modify a comment to reflect changes of r183717.Argyrios Kyrtzidis2013-06-111-2/+2
| | | | llvm-svn: 183751
* ASTUnit: Invert the dependency of PrecompilePreambleAction on ↵Benjamin Kramer2013-06-111-40/+43
| | | | | | | | PrecompilePreambleConsumer. Actions outlive consumers. PR16295. Found by AddressSanitizer. llvm-svn: 183741
* [libclang] Allow building a precompiled preamble with compiler errorsArgyrios Kyrtzidis2013-06-111-7/+15
| | | | | | | | | | | A while ago we allowed libclang to build a PCH that had compiler errors; this was to retain the performance afforded by a PCH even if the user's code is in an intermediate state. Extend this for the precompiled preamble as well. rdar://14109828 llvm-svn: 183717
* [modules] If we hit a failure while loading a PCH/module, abort parsing ↵Argyrios Kyrtzidis2013-05-241-1/+6
| | | | | | | | | | instead of trying to continue in an invalid state. Also don't let libclang create a PCH with such an error. Fixes rdar://13953768 llvm-svn: 182629
* [libclang] When parsing with CXTranslationUnit_ForSerialization, make sure ↵Argyrios Kyrtzidis2013-05-101-0/+10
| | | | | | | | to install the ASTWriter that we create as an ASTMutationListener. Fixes rdar://13833268 llvm-svn: 181575
* [PCH] Remove the ASTReaderListener::ReadHeaderFileInfo callback.Argyrios Kyrtzidis2013-05-081-11/+3
| | | | | | | | This made sense in pre-module era, before merging of HeaderFileInfos was introduced. Final part of rdar://13840148. llvm-svn: 181490
* Use remove_if to erase parts of a vector. Avoids O(n^2) worst cases.Benjamin Kramer2013-05-051-8/+9
| | | | llvm-svn: 181150
* Remove DiagnosticConsumer::clone(), a bad idea that is now unused.Douglas Gregor2013-05-031-11/+1
| | | | llvm-svn: 181070
* When building a module, forward diagnostics to the outer diagnostic consumer.Douglas Gregor2013-05-031-4/+24
| | | | | | | | | | | | | | | Previously, we would clone the current diagnostic consumer to produce a new diagnostic consumer to use when building a module. The problem here is that we end up losing diagnostics for important diagnostic consumers, such as serialized diagnostics (where we'd end up with two diagnostic consumers writing the same output file). With forwarding, the diagnostics from all of the different modules being built get forwarded to the one serialized-diagnostic consumer and are emitted in a sane way. Fixes <rdar://problem/13663996>. llvm-svn: 181067
* <rdar://problem/13363214> Eliminate race condition between module rebuild ↵Douglas Gregor2013-03-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | and the global module index. The global module index was querying the file manager for each of the module files it knows about at load time, to prune out any out-of-date information. The file manager would then cache the results of the stat() falls used to find that module file. Later, the same translation unit could end up trying to import one of the module files that had previously been ignored by the module cache, but after some other Clang instance rebuilt the module file to bring it up-to-date. The stale stat() results in the file manager would trigger a second rebuild of the already-up-to-date module, causing failures down the line. The global module index now lazily resolves its module file references to actual AST reader module files only after the module file has been loaded, eliminating the stat-caching race. Moreover, the AST reader can communicate to its caller that a module file is missing (rather than simply being out-of-date), allowing us to simplify the module-loading logic and allowing the compiler to recover if a dependent module file ends up getting deleted. llvm-svn: 177367
* [libclang] When logging a CXTranslationUnit that came from an AST file, ↵Argyrios Kyrtzidis2013-03-051-0/+9
| | | | | | print out the filename. llvm-svn: 176511
* [preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis2013-02-241-1/+2
| | | | | | | | available the full information about the macro (e.g if it was imported and where). llvm-svn: 175978
OpenPOWER on IntegriCloud