summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* More PCH -> AST renaming.Sebastian Redl2010-08-181-9/+9
| | | | llvm-svn: 111472
* Rename various classes from PCH to AST.Sebastian Redl2010-08-181-2/+2
| | | | llvm-svn: 111471
* Rename PCHReader to ASTReader.Sebastian Redl2010-08-181-10/+10
| | | | llvm-svn: 111467
* Rename PCHWriter.h to ASTWriter.hSebastian Redl2010-08-181-1/+1
| | | | llvm-svn: 111466
* Rename PCHWriter to ASTWriterSebastian Redl2010-08-181-2/+2
| | | | llvm-svn: 111463
* When creating an ASTUnit by parsing source code, set DisableFree toDouglas Gregor2010-08-181-1/+1
| | | | | | | | false (not true), so that the CompilerInstance will actually free data structures when it's done. This fixes a major leak with libclang's in-process code completion. llvm-svn: 111457
* Simplify the ownership model for DiagnosticClients, which was reallyDouglas Gregor2010-08-181-18/+16
| | | | | | | convoluted and a bit leaky. Now, the Diagnostic object owns its DiagnosticClient. llvm-svn: 111437
* Reintroduce the serialization library, with fixed dependencies.Sebastian Redl2010-08-171-2/+2
| | | | llvm-svn: 111279
* Revert Sebastian's build-breaking patch.Douglas Gregor2010-08-171-2/+2
| | | | llvm-svn: 111265
* Create a new Serialization module that contains all the PCH code, and will ↵Sebastian Redl2010-08-171-2/+2
| | | | | | contain all the module code in the future. Update the Makefiles, CMake projects and the Xcode project. I hope I did everything right for Xcode. No functionality change. llvm-svn: 111258
* When the # of top-level declarations changes after reparsing aDouglas Gregor2010-08-171-1/+15
| | | | | | | | translation unit, refresh code-completion results because they've probably changed. However, enforce a cooldown period between refreshes, to avoid thrashing. llvm-svn: 111218
* Move include to the proper place. No functionality changeDouglas Gregor2010-08-161-0/+1
| | | | llvm-svn: 111204
* Implement support for cached code completions forDouglas Gregor2010-08-161-21/+51
| | | | | | | | | | nested-name-specifiers. Also includes fixes to the generation of nested-name-specifier result in the non-cached case; we were producing lame results for namespaces and namespace aliases, which (1) didn't always have nested-name-specifiers when we want them, and (2) did not have the necessary "::" as part of the completion. llvm-svn: 111203
* Formatting fixes. No functionality changeDouglas Gregor2010-08-161-5/+5
| | | | llvm-svn: 111186
* Implement name hiding of cached global code-completion results.Douglas Gregor2010-08-161-3/+81
| | | | llvm-svn: 111184
* Move some code out-of-line which has long since grown too large to beDouglas Gregor2010-08-161-61/+69
| | | | | | inlined. No functionality change. llvm-svn: 111176
* When caching code completions for global declarations, keep track ofDouglas Gregor2010-08-161-8/+38
| | | | | | | | | | | | | | | | the usage type of each declaration result, then compare those types to the preferred type of the completion. This provides parity in the priority calculation between the code-completion results produced directly from Sema and those cached by ASTUnit. For the standard Cocoa.h (+ others) example, there's a penalty of 3-4 hundredeths of a second when caching the global results (for ~31,000 results), because we need an ASTContext-agnostic representation of types for the comparison, and therefore we use... strings. Eventually, we'd like to implement a more efficient ASTContext-agnostic encoding of types. llvm-svn: 111165
* Dereferencing NULL pointers is such poor form.Douglas Gregor2010-08-161-4/+8
| | | | llvm-svn: 111150
* When caching global completion results, keep track of the simplifiedDouglas Gregor2010-08-161-1/+23
| | | | | | | | | | | type class, so that we can adjust priorities appropriately when the preferred type for the context and the actual type of the completion are similar. This gets us one step closer to parity of the cached completion results with the non-cached completion results. llvm-svn: 111139
* Open AST/PCH files in binary mode.Benjamin Kramer2010-08-151-2/+2
| | | | llvm-svn: 111106
* Extend the code-completion caching infrastructure to include globalDouglas Gregor2010-08-151-6/+90
| | | | | | | | | | | | | | | | | | declarations (in addition to macros). Each kind of declaration maps to a certain set of completion contexts, and the ASTUnit completion logic introduces the completion strings for those declarations if the actual code-completion occurs in one of the contexts where it matters. There are a few new code-completion-context kinds. Without these, certain completions (e.g., after "using namespace") would need to suppress all global completions, which would be unfortunate. Note that we don't get the priorities right for global completions, because we don't have enough type information. We'll need a way to compare types in an ASTContext-agnostic way before this can be implemented. llvm-svn: 111093
* Implement caching of code-completion results for macro definitionsDouglas Gregor2010-08-131-8/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | when the CXTranslationUnit_CacheCompletionResults option is given to clang_parseTranslationUnit(). Essentially, we compute code-completion results for macro definitions after we have parsed the file, then store an ASTContext-agnostic version of those results (completion string, cursor kind, priority, and active contexts) in the ASTUnit. When performing code completion in that ASTUnit, we splice the macro definition results into the results provided by the actual code-completion (which has had macros turned off) before libclang gets those results. We use completion context information to only splice in those results that make sense for that context. With a completion involving all of the macros from Cocoa.h and a few other system libraries (totally ~8500 macro definitions) living in a precompiled header, we get about a 9% performance improvement from code completion, since we no longer have to deserialize all of the macro definitions from the precompiled header. Note that macro definitions are merely the canary; the cache is designed to also support other top-level declarations, which should be a bigger performance win. That optimization will be next. Note also that there is no mechanism for determining when to throw away the cache and recompute its contents. llvm-svn: 111051
* Implement clang_saveTranslationUnit(), which saves a translation unitDouglas Gregor2010-08-131-0/+23
| | | | | | into a PCH/AST file. llvm-svn: 111006
* Teach ASTUnit to hold on to the Sema object and ASTConsumer that areDouglas Gregor2010-08-131-3/+14
| | | | | | | | used when parsing (or re-parsing) a file. Also, when loading a precompiled header into ASTUnit, create a Sema object that holds onto semantic-analysis information. llvm-svn: 111003
* Reintroduce the ASTConsumer/ASTUnit fix from r110610, it has nothing to do ↵Sebastian Redl2010-08-111-0/+3
| | | | | | with the breakage. llvm-svn: 110840
* Fix a thinko in the creation of temporary files for the precompiled preambleDouglas Gregor2010-08-111-1/+2
| | | | llvm-svn: 110804
* Speculatively revert r110610 " Make ObjCInterfaceDecl redeclarable,Douglas Gregor2010-08-111-3/+0
| | | | | | | | and create separate decl nodes for forward declarations and the definition," which appears to be causing significant Objective-C breakage. llvm-svn: 110803
* - Make ObjCInterfaceDecl redeclarable, and create separate decl nodes for ↵Sebastian Redl2010-08-091-0/+3
| | | | | | | | | | forward declarations and the definition. - Eagerly create ObjCInterfaceTypes for declarations. - The two above changes lead to a 0.5% increase in memory use and no speed regression when parsing Cocoa.h. On the other hand, now chained PCH works when there's a forward declaration in one PCH and the interface definition in another. - Add HandleInterestingDecl to ASTConsumer. PCHReader passes the "interesting" decls it finds to this function instead of HandleTopLevelDecl. The default implementation forwards to HandleTopLevelDecl, but ASTUnit's handler for example ignores them. This fixes a potential crash when lazy loading of PCH data would cause ASTUnit's "top level" declaration collection to change while being iterated. llvm-svn: 110610
* Use precompiled preambles for in-process code completion.Douglas Gregor2010-08-091-12/+91
| | | | llvm-svn: 110596
* Add an environment variable that makes libclang use chaining for PCH.Sebastian Redl2010-08-061-1/+3
| | | | llvm-svn: 110414
* Give clang_codeCompleteAt() an "options" parameter, and add a newDouglas Gregor2010-08-051-3/+11
| | | | | | | | | flags enumeration + default-generating function that allows code-completion to be customized via the libclang API. Plus, turn on spell-checking when performing code completion. llvm-svn: 110319
* When performing in-process code completion, don't free the remappedDouglas Gregor2010-08-041-0/+1
| | | | | | | file buffers until the code completion results are destroyed; diagnostics may end up referring into the source. llvm-svn: 110216
* Add code-completion support directly to ASTUnit, which performs codeDouglas Gregor2010-08-041-16/+102
| | | | | | | | | | | | | | completion within the translation unit using the same command-line arguments for parsing the translation unit. Eventually, we'll reuse the precompiled preamble to improve code-completion performance, and this also gives us a place to cache results. Expose this function via the new libclang function clang_codeCompleteAt(), which performs the code completion within a CXTranslationUnit. The completion occurs in-process (clang_codeCompletion() runs code completion out-of-process). llvm-svn: 110210
* When we try (but fail) to build a precompiled preamble, wait for aDouglas Gregor2010-08-041-8/+31
| | | | | | | | | short "cooling off" period (defaulting to 5 reparses) before trying to build a precompiled preamble again. Previously, if we failed to build the precompiled preamble at any time, we just gave up the whole charade any never tried again. llvm-svn: 110187
* When using a precompiled preamble, keep track of the top-levelDouglas Gregor2010-08-031-7/+47
| | | | | | | | | | declarations that we saw when creating the precompiled preamble, and provide those declarations in addition to the declarations parsed in the main source file when traversing top-level declarations. This makes the use of precompiled preambles a pure optimization, rather than changing the semantics of the parsed translation unit. llvm-svn: 110131
* Reshuffle the PCH generator action and consumer, so that we can re-useDouglas Gregor2010-08-031-3/+52
| | | | | | it while generating precompiled preambles. No functionality change. llvm-svn: 110108
* When using a precompiled preamble, save the diagnostics produced whenDouglas Gregor2010-08-021-15/+41
| | | | | | | | creating the preamble and "replay" them when reusing the preamble. Also, fix a thinko in the copying of the preamble when building the precompiled preamble. llvm-svn: 110061
* Implement dependency analysis for the precompiled preamble. If any ofDouglas Gregor2010-07-311-14/+91
| | | | | | | the files in the precompiled preamble have changed since it was build, force the preamble to be rebuilt. llvm-svn: 109937
* Add some timers to ASTUnit that are only enabled when the LIBCLANG_TIMING ↵Douglas Gregor2010-07-301-15/+55
| | | | | | environment variable is set. llvm-svn: 109890
* Turn off precompiled preamble support for C++Douglas Gregor2010-07-281-1/+2
| | | | llvm-svn: 109680
* Fix use-after-free with precompiled preamblesDouglas Gregor2010-07-271-3/+9
| | | | llvm-svn: 109505
* Implement -fno-validate-pch at the -cc1 level, which suppresses mostDouglas Gregor2010-07-271-2/+7
| | | | | | | | | | | | | | | of the usual consistency checks used to determine when a precompiled header is incompatible with the translation unit it's being loaded into. Enable this option when loading a precompiled preamble, because the preamble loader will be performing all of this checking itself. Enable the preamble-based test now that it's working. This option is also useful for debugging Clang's PCH (<rdar://problem/7532213>). llvm-svn: 109475
* Introduce basic support for loading a precompiled preamble whileDouglas Gregor2010-07-261-16/+56
| | | | | | | | | | | | | | | | | | | | | | | reparsing an ASTUnit. When saving a preamble, create a buffer larger than the actual file we're working with but fill everything from the end of the preamble to the end of the file with spaces (so the lexer will quickly skip them). When we load the file, create a buffer of the same size, filling it with the file and then spaces. Then, instruct the lexer to start lexing after the preamble, therefore continuing the parse from the spot where the preamble left off. It's now possible to perform a simple preamble build + parse (+ reparse) with ASTUnit. However, one has to disable a bunch of checking in the PCH reader to do so. That part isn't committed; it will likely be handled with some other kind of flag (e.g., -fno-validate-pch). As part of this, fix some issues with null termination of the memory buffers created for the preamble; we were trying to explicitly NULL-terminate them, even though they were also getting implicitly NULL terminated, leading to excess warnings about NULL characters in source files. llvm-svn: 109445
* Make ASTContext always use the BumpPtrAllocator.Douglas Gregor2010-07-251-1/+0
| | | | llvm-svn: 109375
* Put a newline at the end of the padded buffers used for theDouglas Gregor2010-07-241-4/+6
| | | | | | | precompiled preamble. This will suppress the -pedantic "no newline at end of file" warning. llvm-svn: 109301
* Once we've built (or reused) a precompiled preamble, create theDouglas Gregor2010-07-241-31/+45
| | | | | | | | appropriately-padded main file buffer (that has spaces in the extra "reserved" space) and thread that buffer through to the parsing function. This still does nothing. llvm-svn: 109299
* Once we've built a precompiled preamble, keep track of the details ofDouglas Gregor2010-07-231-42/+164
| | | | | | | | | | | | that preamble (the preamble text, preamble file, reserved main file size). Check these details when we try to rebuild the precompiled preamble, and when nothing has changed, re-use the precompiled preamble. This code is still very much a WIP, and can't even properly be tested because we have no way to use the precompiled preamble yet. "Trust me" llvm-svn: 109294
* Fix build on Ubuntu 10.04.Zhongxing Xu2010-07-231-0/+1
| | | | llvm-svn: 109208
* Basic plumbing for generating a precompiled preamble for anDouglas Gregor2010-07-231-4/+197
| | | | | | | ASTUnit/CXTranslationUnit. We can't actually use this preamble yet, however. llvm-svn: 109202
* Introduce a new libclang API, clang_reparseTranslationUnit(), whichDouglas Gregor2010-07-191-50/+102
| | | | | | | | reparses an already-parsed translation unit. At the moment it's just a convenience function, but we hope to use it for performance optimizations. llvm-svn: 108756
OpenPOWER on IntegriCloud