aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/ASTUnit.cpp
AgeCommit message (Collapse)Author
2012-09-27[libclang] Always report a CXCursor_MacroDefinition for code-completionArgyrios Kyrtzidis
results for a macro name, not CXCursor_NotImplemented. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164740 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-26Have ASTUnit::Save() return a bool to indicate save error.Argyrios Kyrtzidis
Removes a dependency of ASTUnit to clang-c/Index.h. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164704 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-15Allow disabling PCH validation when loading an AST file by checkingArgyrios Kyrtzidis
an environment variable for debugging purposes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163958 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14[libclang] When loading an AST file, make sure to apply the language optionsArgyrios Kyrtzidis
to the target info. Related to rdar://12069503. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163931 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-14Fix undefined behavior in code completion, caught byRichard Smith
-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161830 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-11Introduce a flag in SourceManager to treat non-system source filesArgyrios Kyrtzidis
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160074 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-03[libclang] Protect against a race condition where a threadArgyrios Kyrtzidis
may be destroying an ASTUnit while cleanupOnDiskMapAtExit is getting called. rdar://11781241 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159664 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02Add a new libclang completion API to get brief documentation comment that isDmitri Gribenko
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159539 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08[libclang] Don't crash when saving a PCH from a prefix headerArgyrios Kyrtzidis
that does not exist. rdar://11607033 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158193 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-21[driver] When creating the compiler invocation out of command-lineArgyrios Kyrtzidis
arguments, force use of clang frontend for the driver. Fixes rdar://11356765. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157205 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-14ASTUnit: Don't clone the new DiagnosticConsumer, causing it to get leaked.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154739 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-12Added a flag to the parser to skip method bodies.Erik Verbruggen
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154584 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11[libclang] If displayDiagnostics is set (when calling clang_createIndex), ↵Argyrios Kyrtzidis
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154472 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-10[code-complete] Introduce CodeCompletionTUInfo which will be used for cachingArgyrios Kyrtzidis
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154408 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-13[libclang] When there's a file error when saving the PCH, make sure toArgyrios Kyrtzidis
clear the error from raw_fd_ostream, otherwise we will crash. rdar://10976410 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152605 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie
(Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07[PCH] Mark a PCH file with a flag to indicate if the serialized AST hadArgyrios Kyrtzidis
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152192 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29Serialization: Switch over to using the native SmallVector based BitstreamWriterDaniel Dunbar
ctor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151752 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-25Don't record nested macro expansions in the preprocessing record,Argyrios Kyrtzidis
it can only bring pain when dealing with preprocessor abuse (see: boost). rdar://10898986 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151427 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-20Basic: import IntrusiveRefCntPtr<> into clang namespaceDylan Noblesmith
The class name is long enough without the llvm:: added. Also bring in RefCountedBase and RefCountedBaseVPTR. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150958 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-05Basic: import SmallString<> into clang namespaceDylan Noblesmith
(I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-05Basic: import OwningPtr<> into clang namespaceDylan Noblesmith
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149798 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01[libclang] Make sure we don't ever leave a StoredDiagnostic associated withArgyrios Kyrtzidis
a SourceManager that has already been deleted, rdar://10768346. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149532 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-30Thread a TargetInfo through to the module map; we'll need it forDouglas Gregor
target-specific module requirements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149224 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-29Ensure that we clean up after a failed module build and cope with theDouglas Gregor
results in libclang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149200 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20Extract the (InputKind, std::string) pair used to describe inputs toDouglas Gregor
the front end into its own class, FrontendInputFile, to make it easier to introduce new per-input data. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148546 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-17[libclang] Make sure Preprocessor is set in ASTUnit during indexing.Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148319 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-01Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor
ObjCProtocolDecl modules forward declarations properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147415 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-31Implement support for module requirements, which indicate the languageDouglas Gregor
features needed for a particular module to be available. This allows mixed-language modules, where certain headers only work under some language variants (e.g., in C++, std.tuple might only be available in C++11 mode). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147387 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-27Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDeclDouglas Gregor
covers both declarations (@class) and definitions (@interface) of an Objective-C class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147299 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-25Remove unused variables.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147260 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-30Promote ModuleMap::Module to a namespace-scope class in the BasicDouglas Gregor
library, since modules cut across all of the libraries. Rename serialization::Module to serialization::ModuleFile to side-step the annoying naming conflict. Prune a bunch of ModuleMap.h includes that are no longer needed (most files only needed the Module type). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145538 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-30When writing a module file, pass the module through to the ASTDouglas Gregor
writer. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145479 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29Initialize NumWarningsInPreamble in ASTUnit's constructor, for safety.Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145412 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-28[libclang] Indexing API: If the client requested to get a CXTranslationUnit ↵Argyrios Kyrtzidis
after indexing, honor all the TU options. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145229 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-28[libclang] Indexing API: Capture diagnostics during indexing.Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145228 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-23[libclang] Fix operations (token annotation, getting cursor, etc.) with a ↵Argyrios Kyrtzidis
file region inside an objc container that "contains" other file-level declarations. When getting the array of file-level declarations that overlap with a file region, we failed to report that the region overlaps with an objc container, if the container had other file-level declarations declared lexically inside it. Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST and handling them appropriately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145109 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-18Change ASTConsumer::HandleTopLevelDecl to return true for the parser to continueArgyrios Kyrtzidis
parsing or false to abort parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144943 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-17Make 'LangOptions' in CompilerInvocation a heap-allocated, reference counted ↵Ted Kremenek
object. I discovered that llvm::RefCountedBase<T> has a bug where the reference count is copied in the copy constructor, which means that there were cases when the CompilerInvocation objects created by ASTUnit were actually leaked. When I fixed that bug locally, it showed that a whole bunch of code assumed that the LangOptions object that was part of CompilerInvocation was still alive. By making it heap-allocated and reference counted, we can keep it around after the CompilerInvocation object goes away. As part of this change, change CompilerInvocation:getLangOptions() to return a pointer, acting as another clue that this object may outlive the CompilerInvocation object. This commit doesn't fix the CompilerInvocation leak itself. That will come when I commit the fix to llvm::RefCountedBase<T> to mainline LLVM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144930 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-17Simplify crash cleanup logic in ASTUnit::LoadFromCommandLine() by zeroing ↵Ted Kremenek
out two IntrusiveRefCnt pointers after we have assigned their respective values into fields of ASTUnit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144929 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-16[libclang] Fix crash on invalid code. Fixes rdar://10451854Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144766 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-11I predict that HeaderSearch will need the ability to generateDouglas Gregor
diagnostics in the future. Make it so. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144347 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-07ASTConsumer::handleTopLevelDecl will end up getting called forDouglas Gregor
function template instantiations. Fixes <rdar://problem/10398005> / PR11312. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143984 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-03After resetting the diagnostic state, set the number of warning occurring in ↵Argyrios Kyrtzidis
the preamble. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143647 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-03[libclang] Fix crash when a #pragma diagnostic is included in the preamble.Argyrios Kyrtzidis
A PCH file keeps track of #pragma diagnostics state; when loading the preamble, they conflicted with the #pragma diagnostic state already present in the DiagnosticsEngine object due to parsing the preamble. Fix this by clearing the state of the DiagnosticsEngine object. Fixes rdar://10363572 && http://llvm.org/PR11254. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143644 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-03[libclang] Add infrastructure to be able to only deserialize decls in a file ↵Argyrios Kyrtzidis
region and use it for clang_getCursor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143605 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-01Put a reference of the ASTReader in the ASTUnit.Argyrios Kyrtzidis
This is intended for direct access of the ASTReader for uses that make little sense to try to shoehorn in the ExternalASTSource interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143465 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-31Revert r143342. Caching of code-completion results was intentionally placed ↵Argyrios Kyrtzidis
in "reparse" because we don't want to take this performance hit when doing code completion Log of r143342: Move caching of code-completion results from ASTUnit::Reparse to ASTUnit::CodeComplete, so that it will happen when we are doing code-completion, not reparsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143367 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-31Move caching of code-completion results from ASTUnit::Reparse to ↵Argyrios Kyrtzidis
ASTUnit::CodeComplete, so that it will happen when we are doing code-completion, not reparsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143342 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-31Have the ASTUnit associate the local declarations that get parsed with the fileArgyrios Kyrtzidis
that contains them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143338 91177308-0d34-0410-b5e6-96231b3b80d8