aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ASTUnit.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko1-1/+1
brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
2013-01-11[libclang] In ASTUnit::getMainFileName() Invocation may be null because the ↵Argyrios Kyrtzidis1-1/+15
ASTUnit came from loading a PCH/module. llvm-svn: 172259
2013-01-02s/CPlusPlus0x/CPlusPlus11/gRichard Smith1-1/+1
llvm-svn: 171367
2012-12-22[libclang] Don't try to translate diagnostics from the precompiled preamble ↵Argyrios Kyrtzidis1-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
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-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
2012-11-16Since CreateTargetInfo is taking ownership of the target options, passDouglas Gregor1-6/+6
it as a pointer. llvm-svn: 168136
2012-11-16[libclang] When caching code-completion results, pass the ↵Argyrios Kyrtzidis1-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
2012-11-15[modules] Setup the import location of a module file and use itArgyrios Kyrtzidis1-1/+1
as the include location of the main file of an imported module. llvm-svn: 168061
2012-11-15Use empty parens for empty function parameter list instead of '(void)'.Dmitri Gribenko1-2/+2
llvm-svn: 168041
2012-11-09Turn FrontendInputFile into an immutable class and have it also acceptArgyrios Kyrtzidis1-20/+20
a memory buffer instead of only a filename. llvm-svn: 167627
2012-11-02When code-completing don't disable the preprocessing record if modules are ↵Argyrios Kyrtzidis1-2/+3
enabled. llvm-svn: 167325
2012-10-31[PCH] Remove the stat cache from the PCH file.Argyrios Kyrtzidis1-4/+1
The stat cache became essentially useless ever since we started validating all file entries in the PCH. But the motivating reason for removing it now is that it also affected correctness in this situation: -You have a header without include guards (using "#pragma once" or #import) -When creating the PCH: -The same header is referenced in an #include with different filename cases. -In the PCH, of course, we record only one file entry for the header file -But we cache in the PCH file the stat info for both filename cases -Then the source files are updated and the header file is updated in a way that its size and modification time are the same but its inode changes -When using the PCH: -We validate the headers, we check that header file and we create a file entry with its current inode -There's another #include with a filename with different case than the previously created file entry -In order to get its stat info we go through the cached stat info of the PCH and we receive the old inode -because of the different inodes, we think they are different files so we go ahead and include its contents. Removing the stat cache will potentially break clients that are attempting to use the stat cache as a way of avoiding having the actual input files available. If that use case is important, patches are welcome to bring it back in a way that will actually work correctly (i.e., emit a PCH that is self-contained, coping with literal strings, line/column computations, etc.). This fixes rdar://5502805 llvm-svn: 167172
2012-10-31Decouple code-completion for the SkipFunctionBodies frontend option andArgyrios Kyrtzidis1-2/+0
add a test to make sure code-completion skips bodies. llvm-svn: 167141
2012-10-29Move getOriginalSourceFileName inline. Patch by Laszlo Nagy.Rafael Espindola1-4/+0
llvm-svn: 166981
2012-10-25ASTUnit doesn't actually care about the predefines; don't record them.Douglas Gregor1-18/+2
llvm-svn: 166650
2012-10-24Teach the preprocessor to hold onto the preprocessor options.Douglas Gregor1-1/+3
llvm-svn: 166599
2012-10-24Move HeaderSearchOptions into the Lex library, make it intrusivelyDouglas Gregor1-1/+4
reference-counted, and hold a reference to it in HeaderSearch. llvm-svn: 166583
2012-10-23Make DiagnosticOptions intrusively reference-counted, and make sureDouglas Gregor1-4/+4
the various stakeholders bump up the reference count. In particular, the diagnostics engine now keeps the DiagnosticOptions object alive. llvm-svn: 166508
2012-10-23If the precompiled header named by "-include" is actually a directory,Douglas Gregor1-9/+2
check each of the files within that directory to determine if any of them is an AST file that matches the language and target options. If so, the first matching AST file is loaded. This fixes a longstanding discrepency with GCC's precompiled header implementation. llvm-svn: 166469
2012-10-22Allow clients of the AST reader to specify what kinds of AST loadDouglas Gregor1-4/+8
failures they know how to tolerate, e.g., out-of-date input files or configuration/version mismatches. Suppress the corresponding diagnostics if the client can handle it. No clients actually use this functionality, yet. llvm-svn: 166449
2012-10-22Distinguish the various kinds of AST file loading failures:Douglas Gregor1-1/+4
file corruption, compiler version mismatch, target/language configuration mismatch, out-of-date AST file. No functionality change yet. llvm-svn: 166446
2012-10-16Serialize TargetOptions into an AST file, and make sure that we keepDouglas Gregor1-22/+10
target options around so they can be accessed at any point (rather than keeping them transient). llvm-svn: 166072
2012-10-15Teach TargetInfo to hold on to the TargetOptions with which it wasDouglas Gregor1-4/+6
created. llvm-svn: 165943
2012-10-11[libclang] Improve AST serialization done by ASTUnit::Save().Argyrios Kyrtzidis1-28/+64
The ASTUnit needs to initialize an ASTWriter at the beginning of parsing to fully handle serialization of a translation unit that imports modules. Do this by introducing an option to enable it, which corresponds to CXTranslationUnit_ForSerialization on the C API side. llvm-svn: 165717
2012-10-10When indexing a module file, for the ppIncludedFile callback giveArgyrios Kyrtzidis1-5/+11
an invalid location if the location points to the synthetic buffer for the module input. llvm-svn: 165592
2012-10-03[libclang] When indexing, invoke the importedASTFile for PCH files as well.Argyrios Kyrtzidis1-0/+36
llvm-svn: 165161
2012-10-03Some renames to use the 'visitor' nomenclature, no functionality change.Argyrios Kyrtzidis1-1/+1
llvm-svn: 165083
2012-10-02[libclang] When indexing an AST file, only deserialize the file levelArgyrios Kyrtzidis1-0/+24
declarations of the current primary module. llvm-svn: 165046
2012-10-02[libclang] When indexing an AST file, only deserialize the preprocessing recordArgyrios Kyrtzidis1-0/+15
entities of the current primary module. llvm-svn: 165023
2012-09-27[libclang] Always report a CXCursor_MacroDefinition for code-completionArgyrios Kyrtzidis1-3/+1
results for a macro name, not CXCursor_NotImplemented. llvm-svn: 164740
2012-09-26Have ASTUnit::Save() return a bool to indicate save error.Argyrios Kyrtzidis1-5/+5
Removes a dependency of ASTUnit to clang-c/Index.h. llvm-svn: 164704
2012-09-15Allow disabling PCH validation when loading an AST file by checkingArgyrios Kyrtzidis1-1/+4
an environment variable for debugging purposes. llvm-svn: 163958
2012-09-14[libclang] When loading an AST file, make sure to apply the language optionsArgyrios Kyrtzidis1-0/+15
to the target info. Related to rdar://12069503. llvm-svn: 163931
2012-08-14Fix undefined behavior in code completion, caught byRichard Smith1-66/+66
-fcatch-undefined-behavior. Don't try to fit 34 different flags into 32 bits. Also, don't use 32-bit signed left shifts for this. llvm-svn: 161830
2012-07-11Introduce a flag in SourceManager to treat non-system source filesArgyrios Kyrtzidis1-8/+20
as "volatile", meaning there's a high enough chance that they may change while we are trying to use them. This flag is only enabled by libclang. Currently "volatile" source files will be stat'ed immediately before opening them, because the file size stat info may not be accurate since when we got it (e.g. from the PCH). This avoids crashes when trying to reference mmap'ed memory from a file whose size is not what we expect. Note that there's still a window for a racing issue to occur but the window for it should be way smaller than before. We can consider later on to avoid mmap completely on such files. rdar://11612916 llvm-svn: 160074
2012-07-03[libclang] Protect against a race condition where a threadArgyrios Kyrtzidis1-1/+2
may be destroying an ASTUnit while cleanupOnDiskMapAtExit is getting called. rdar://11781241 llvm-svn: 159664
2012-07-02Add a new libclang completion API to get brief documentation comment that isDmitri Gribenko1-17/+31
attached to a declaration in the completion string. Since extracting comments isn't free, a new code completion option is introduced. A new code completion option that enables including brief comments into CodeCompletionString should be a, err, code completion option. But because ASTUnit caches global declarations during parsing before even completion consumer is created, the option is duplicated as a translation unit option (in both libclang and ASTUnit, like the option to cache code completion results). llvm-svn: 159539
2012-06-08[libclang] Don't crash when saving a PCH from a prefix headerArgyrios Kyrtzidis1-2/+9
that does not exist. rdar://11607033 llvm-svn: 158193
2012-05-21[driver] When creating the compiler invocation out of command-lineArgyrios Kyrtzidis1-6/+0
arguments, force use of clang frontend for the driver. Fixes rdar://11356765. llvm-svn: 157205
2012-04-14ASTUnit: Don't clone the new DiagnosticConsumer, causing it to get leaked.Benjamin Kramer1-2/+4
llvm-svn: 154739
2012-04-12Added a flag to the parser to skip method bodies.Erik Verbruggen1-0/+5
llvm-svn: 154584
2012-04-11[libclang] If displayDiagnostics is set (when calling clang_createIndex), ↵Argyrios Kyrtzidis1-24/+44
make sure to output the errors that occurred even if we did not get an AST (e.g. because the PCH failed to load). Also honor displayDiagnostics in clang_indexSourceFile(). rdar://11203489 llvm-svn: 154472
2012-04-10[code-complete] Introduce CodeCompletionTUInfo which will be used for cachingArgyrios Kyrtzidis1-9/+17
code-completion related strings specific to a translation unit (ASTContext and related data) CodeCompletionAllocator does such limited caching, by caching the name assigned to a DeclContext*, but that is not the appropriate place since that object has a lifetime that can extend beyond that of an ASTContext. Introduce CodeCompletionTUInfo which will be always tied to a translation unit to do this kind of caching and move the caching of CodeCompletionAllocator into this object, and propagate it to all the places where it will be needed. The plan is to extend the caching where appropriate, using CodeCompletionTUInfo, to avoid re-calculating code-completion strings. Part of rdar://10796159. llvm-svn: 154408
2012-03-13[libclang] When there's a file error when saving the PCH, make sure toArgyrios Kyrtzidis1-1/+3
clear the error from raw_fd_ostream, otherwise we will crash. rdar://10976410 llvm-svn: 152605
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie1-5/+5
(Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
2012-03-07[PCH] Mark a PCH file with a flag to indicate if the serialized AST hadArgyrios Kyrtzidis1-11/+14
compiler errors or not. -Control whether ASTReader should reject such a PCH by a boolean flag at ASTReader's creation time. By default, such a PCH file will be rejected with an error when trying to load it. [libclang] Allow clang_saveTranslationUnit to create a PCH file even if compiler errors occurred. -Have libclang API calls accept a PCH that had compiler errors. The general idea is that we want libclang to stay functional even if a PCH had a compiler error. rdar://10976363. llvm-svn: 152192
2012-02-29Serialization: Switch over to using the native SmallVector based BitstreamWriterDaniel Dunbar1-1/+1
ctor. llvm-svn: 151752
2012-02-25Don't record nested macro expansions in the preprocessing record,Argyrios Kyrtzidis1-9/+2
it can only bring pain when dealing with preprocessor abuse (see: boost). rdar://10898986 llvm-svn: 151427
2012-02-20Basic: import IntrusiveRefCntPtr<> into clang namespaceDylan Noblesmith1-12/+12
The class name is long enough without the llvm:: added. Also bring in RefCountedBase and RefCountedBaseVPTR. llvm-svn: 150958
2012-02-05Basic: import SmallString<> into clang namespaceDylan Noblesmith1-1/+1
(I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799