summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Comment parsing: add CommentOptions to allow specifying custom comment block ↵Dmitri Gribenko2013-02-221-0/+5
| | | | | | | | | | | | | | | | commands Add an ability to specify custom documentation block comment commands via a new class CommentOptions. The intention is that this class will hold future customizations for comment parsing, including defining documentation comments with specific numbers of parameters, etc. CommentOptions instance is a member of LangOptions. CommentOptions is controlled by a new command-line parameter -fcomment-block-commands=Foo,Bar,Baz. llvm-svn: 175892
* Use 'const Decl *' throughout code completion in SemaDmitri Gribenko2013-01-231-2/+2
| | | | llvm-svn: 173277
* [ASTUnit] Unlike LoadFromCommandLine, LoadFromCompilerInvocation causes a ↵Argyrios Kyrtzidis2013-01-211-0/+2
| | | | | | | | | | crash if Precompilepreamble is set to true because there is no FileManager at that point. Patch by Hurcan Solter! llvm-svn: 173071
* Nuke SetUpBuildDumpLog.Sean Silva2013-01-201-5/+2
| | | | | | | Also, it was the only reason that `argc` and `argv` were being passed into createDiagnostics, so remove those parameters and clean up callers. llvm-svn: 172945
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* [libclang] In ASTUnit::getMainFileName() Invocation may be null because the ↵Argyrios Kyrtzidis2013-01-111-1/+15
| | | | | | | | ASTUnit came from loading a PCH/module. llvm-svn: 172259
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-1/+1
| | | | llvm-svn: 171367
* [libclang] Don't try to translate diagnostics from the precompiled preamble ↵Argyrios Kyrtzidis2012-12-221-11/+0
| | | | | | | | | | | to the code-completion results, the SourceManager state may be slightly different when code-completing. And we don't even care for diagnostics when code-completing, anyway. llvm-svn: 170979
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-14/+14
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Since CreateTargetInfo is taking ownership of the target options, passDouglas Gregor2012-11-161-6/+6
| | | | | | it as a pointer. llvm-svn: 168136
* [libclang] When caching code-completion results, pass the ↵Argyrios Kyrtzidis2012-11-161-4/+5
| | | | | | | | | | | | | | CachedCompletionAllocator to the CodeCompletionTUInfo that is going to be used to get the results. Previously we would use ASTUnit's CodeCompletionTUInfo which has its own allocator that will go away when we reparse. That could result in a use-after-free bug when getting the parent context name from a CodeCompletionString. Addresses rdar://12568377. llvm-svn: 168133
* [modules] Setup the import location of a module file and use itArgyrios Kyrtzidis2012-11-151-1/+1
| | | | | | as the include location of the main file of an imported module. llvm-svn: 168061
* Use empty parens for empty function parameter list instead of '(void)'.Dmitri Gribenko2012-11-151-2/+2
| | | | llvm-svn: 168041
* Turn FrontendInputFile into an immutable class and have it also acceptArgyrios Kyrtzidis2012-11-091-20/+20
| | | | | | a memory buffer instead of only a filename. llvm-svn: 167627
OpenPOWER on IntegriCloud