aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ASTUnit.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-02-20Recommit virtual file systemBen Langmuir1-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
2014-02-20Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka1-3/+3
assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
2014-02-19Use llvm::DeleteContainerSeconds when possibleReid Kleckner1-4/+1
llvm-svn: 201739
2014-02-19Initial implementation of virtual file systemBen Langmuir1-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
2014-02-12Fix memory leak introduced by r201010.Daniel Jasper1-0/+1
llvm-svn: 201220
2014-02-10ASTUnit: simplify remapping files by using the exact same logic in PreprocessorDmitri Gribenko1-16/+4
llvm-svn: 201082
2014-02-08ASTUnit: remove dead code in remapping filesDmitri Gribenko1-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
2014-02-07ASTUnit: ArrayRef'ize RemappedFilesDmitri Gribenko1-11/+8
llvm-svn: 200975
2014-02-03Fix a -Wformat warning in ASTUnit.cppReid Kleckner1-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
2014-01-10Use the simpler version of llvm::sys::fs::remove when possible.Rafael Espindola1-2/+1
llvm-svn: 198957
2013-12-20Remove obsolete preamble FIXMEAlp Toker1-2/+0
The MD5 is checked since r197755 which is as good as comparing buffer contents in this context. llvm-svn: 197842
2013-12-20Correctly compute the size in bytes of PreambleFileHash.MD5Dmitri Gribenko1-2/+2
llvm-svn: 197762
2013-12-20ASTUnit::getMainBufferWithPrecompiledPreamble: use MD5 hash of the remappedDmitri Gribenko1-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
2013-12-19Simplify codeDmitri Gribenko1-1/+1
llvm-svn: 197748
2013-11-22Make ASTUnit structure stable with NDEBUGAlp Toker1-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
2013-10-24Use the same SourceManager for ModuleMaps and compilations.Manuel Klimek1-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
2013-10-15[libclang] For an unscoped enum include the enumerators in the top-level ↵Argyrios Kyrtzidis1-0/+12
code-completion hash since they enter the top-level namespace. rdar://14703327 llvm-svn: 192720
2013-09-13Remove unnecessary inclusion of Sema.hDavid Blaikie1-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
2013-08-24This wasn't headers, just missing namespaces.Benjamin Kramer1-4/+4
/me bows head in shame. llvm-svn: 189172
2013-08-24Replace compLocDecl with less_first.Benjamin Kramer1-14/+8
llvm-svn: 189170
2013-08-07[PCH] Fix a PCH serialization crash, with invalid code related to forward ↵Argyrios Kyrtzidis1-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
2013-07-29Update for llvm api change.Rafael Espindola1-5/+5
llvm-svn: 187379
2013-07-29Convert a use of stat with sys::fs::status.Rafael Espindola1-9/+10
llvm-svn: 187364
2013-07-18Fix crash in libclang if code completion is used with unknown flags.Manuel Klimek1-1/+1
Use CaptureDroppedDiagnostics to make sure that there is a diagnostic client installed when warning flags are parsed. llvm-svn: 186582
2013-07-05Use llvm::sys::fs::createUniqueFile.Rafael Espindola1-2/+1
Include a test that clang now produces output files with permissions matching the umask. llvm-svn: 185727
2013-07-05Use llvm::sys::fs::createTemporaryFile.Rafael Espindola1-1/+1
llvm-svn: 185717
2013-06-26Don't use PathV1.h in ASTUnit.cpp.Rafael Espindola1-5/+3
llvm-svn: 184912
2013-06-26Remove the last use of PathWithStatus.Rafael Espindola1-4/+4
llvm-svn: 184909
2013-06-26Use llvm::sys::fs::unique_file.Rafael Espindola1-26/+7
llvm-svn: 184908
2013-06-26Remove some uses of llvm::sys::Path.Rafael Espindola1-6/+6
llvm-svn: 184907
2013-06-24[libclang/codecompletion] Make sure the top-level decl hash takes into ↵Argyrios Kyrtzidis1-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
2013-06-20Use the new name of getUniqueID.Rafael Espindola1-5/+5
llvm-svn: 184432
2013-06-18Use llvm::sys::fs::GetUniqueID.Rafael Espindola1-15/+22
llvm-svn: 184218
2013-06-11Include PathV1.h in files that use it.Rafael Espindola1-0/+1
This is preparation for replacing Path.h with PathV2.h. llvm-svn: 183781
2013-06-11Modify a comment to reflect changes of r183717.Argyrios Kyrtzidis1-2/+2
llvm-svn: 183751
2013-06-11ASTUnit: Invert the dependency of PrecompilePreambleAction on ↵Benjamin Kramer1-40/+43
PrecompilePreambleConsumer. Actions outlive consumers. PR16295. Found by AddressSanitizer. llvm-svn: 183741
2013-06-11[libclang] Allow building a precompiled preamble with compiler errorsArgyrios Kyrtzidis1-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
2013-05-24[modules] If we hit a failure while loading a PCH/module, abort parsing ↵Argyrios Kyrtzidis1-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
2013-05-10[libclang] When parsing with CXTranslationUnit_ForSerialization, make sure ↵Argyrios Kyrtzidis1-0/+10
to install the ASTWriter that we create as an ASTMutationListener. Fixes rdar://13833268 llvm-svn: 181575
2013-05-08[PCH] Remove the ASTReaderListener::ReadHeaderFileInfo callback.Argyrios Kyrtzidis1-11/+3
This made sense in pre-module era, before merging of HeaderFileInfos was introduced. Final part of rdar://13840148. llvm-svn: 181490
2013-05-05Use remove_if to erase parts of a vector. Avoids O(n^2) worst cases.Benjamin Kramer1-8/+9
llvm-svn: 181150
2013-05-03Remove DiagnosticConsumer::clone(), a bad idea that is now unused.Douglas Gregor1-11/+1
llvm-svn: 181070
2013-05-03When building a module, forward diagnostics to the outer diagnostic consumer.Douglas Gregor1-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
2013-03-19<rdar://problem/13363214> Eliminate race condition between module rebuild ↵Douglas Gregor1-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
2013-03-05[libclang] When logging a CXTranslationUnit that came from an AST file, ↵Argyrios Kyrtzidis1-0/+9
print out the filename. llvm-svn: 176511
2013-02-24[preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis1-1/+2
available the full information about the macro (e.g if it was imported and where). llvm-svn: 175978
2013-02-22Comment parsing: add CommentOptions to allow specifying custom comment block ↵Dmitri Gribenko1-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
2013-01-23Use 'const Decl *' throughout code completion in SemaDmitri Gribenko1-2/+2
llvm-svn: 173277
2013-01-21[ASTUnit] Unlike LoadFromCommandLine, LoadFromCompilerInvocation causes a ↵Argyrios Kyrtzidis1-0/+2
crash if Precompilepreamble is set to true because there is no FileManager at that point. Patch by Hurcan Solter! llvm-svn: 173071
2013-01-20Nuke SetUpBuildDumpLog.Sean Silva1-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