summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Teach the preprocessor to hold onto the preprocessor options.Douglas Gregor2012-10-241-2/+5
| | | | llvm-svn: 166599
* Rework the (de-)serialization of macros, as stored inDouglas Gregor2012-10-091-2/+4
| | | | | | | | | | | | | | | | MacroInfo*. Instead of simply dumping an offset into the current file, give each macro definition a proper ID with all of the standard modules-remapping facilities. Additionally, when a macro is modified in a subsequent AST file (e.g., #undef'ing a macro loaded from another module or from a precompiled header), provide a macro update record rather than rewriting the entire macro definition. This gives us greater consistency with the way we handle declarations, and ties together macro definitions much more cleanly. Note that we're still not actually deserializing macro history (we never were), but it's far easy to do properly now. llvm-svn: 165560
* Move the 'find macro by spelling' infrastructure to the Preprocessor class andDmitri Gribenko2012-09-291-0/+33
| | | | | | | use it to suggest appropriate macro for __attribute__((deprecated)) in -Wdocumentation-deprecated-sync. llvm-svn: 164892
* For PPCallbacks::InclusionDirective() add a parameter for the module, wheneverArgyrios Kyrtzidis2012-09-291-4/+8
| | | | | | | an inclusion directive was automatically turned into a module import, and PPCallbacks::moduleImport() for an explicit module import. llvm-svn: 164874
* StringRef'ize Preprocessor::CreateString().Dmitri Gribenko2012-09-241-4/+4
| | | | llvm-svn: 164555
* Added some preprocessor memory usage stats to -cc1 -print-statsAlexander Kornienko2012-08-131-0/+14
| | | | llvm-svn: 161752
* Patch for handling C99 veriadic macros when using precompiled headers,Douglas Gregor2012-06-291-0/+10
| | | | | | from Filipe Cabecinhas! llvm-svn: 159446
* Structured comment parsing, first step.Dmitri Gribenko2012-06-201-2/+2
| | | | | | | | | * Retain comments in the AST * Serialize/deserialize comments * Find comments attached to a certain Decl * Expose raw comment text and SourceRange via libclang llvm-svn: 158771
* Revert predefined decl tracking.Meador Inge2012-06-191-1/+1
| | | | | | | | | | r158085 added some logic to track predefined declarations. The main reason we had predefined declarations in the input was because the __builtin_va_list declarations were injected into the preprocessor input. As of r158592 we explicitly build the __builtin_va_list declarations. Therefore the predefined decl tracking is no longer needed. llvm-svn: 158732
* Disable _Pragma during HTML macro rewriting to keep from crashing.Jordan Rose2012-06-081-1/+2
| | | | | | | | | | | | | | | | | | | The preprocessor's handling of diagnostic push/pops is stateful, so encountering pragmas during a re-parse causes problems. HTMLRewrite already filters out normal # directives including #pragma, so it's clear it's not expected to be interpreting pragmas in this mode. This fix adds a flag to Preprocessor to explicitly disable pragmas. The "right" fix might be to separate pragma lexing from pragma parsing so that we can throw away pragmas like we do preprocessor directives, but right now it's important to get the fix in. Note that this has nothing to do with the "hack" of re-using the input preprocessor in HTMLRewrite. Even if we someday copy the preprocessor instead of re-using it, the copy would (and should) include the diagnostic level tables and have the same problems. llvm-svn: 158214
* Add a -rewrite-includes option, which is similar to -rewrite-macros, but ↵David Blaikie2012-06-061-0/+1
| | | | | | | | | only expands #include directives. Patch contributed by Lubos Lunak (l.lunax@suse.cz). Review by Matt Beaumont-Gay (matthewbg@google.com). llvm-svn: 158093
* Add pedantic warning -Wempty-translation-unit (C11 6.9p1).Jordan Rose2012-06-061-1/+1
| | | | | | | | | | | | | | | | | | | In standard C since C89, a 'translation-unit' is syntactically defined to have at least one "external-declaration", which is either a decl or a function definition. In Clang the latter gives us a declaration as well. The tricky bit about this warning is that our predefines can contain external declarations (__builtin_va_list and the 128-bit integer types). Therefore our AST parser now makes sure we have at least one declaration that doesn't come from the predefines buffer. Also, remove bogus warning about empty source files. This doesn't catch source files that only contain comments, and never fired anyway because of our predefines. PR12665 and <rdar://problem/9165548> llvm-svn: 158085
* Initialize the non-target-dependent fields of the Preprocessor in its ↵Argyrios Kyrtzidis2012-06-021-48/+47
| | | | | | | | | | | constructor so we can destroy it even if it was constructed with "DelayInitialization = true", and we didn't end up calling Preprocessor::Initialize. Fixes crashes in rdar://11558355 llvm-svn: 157892
* Correct handling of _Pragma macro inside a macro argument.Argyrios Kyrtzidis2012-04-031-0/+1
| | | | | | | | | | | | | | | | If we are pre-expanding a macro argument don't actually "activate" the pragma at that point, activate the pragma whenever we encounter it again in the token stream. This ensures that we will activate it in the correct location or that we will ignore it if it never enters the token stream, e.g: \#define EMPTY(x) \#define INACTIVE(x) EMPTY(x) INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\"")) This also fixes the crash in rdar://11168596. llvm-svn: 153959
* From Vassil Vassilev:Axel Naumann2012-03-161-4/+5
| | | | | | | | | | | | | | Enable incremental parsing by the Preprocessor, where more code can be provided after an EOF. It mainly prevents the tearing down of the topmost lexer. To be used like this: PP.enableIncrementalProcessing(); while (getMoreSource()) { while (Parser.ParseTopLevelDecl(ADecl)) {...} } PP.enableIncrementalProcessing(false); llvm-svn: 152914
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-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
* [preprocessor] Enhance PreprocessingRecord to keep track of locations of ↵Argyrios Kyrtzidis2012-03-051-2/+3
| | | | | | | | | conditional directives. Introduce PreprocessingRecord::rangeIntersectsConditionalDirective() which returns true if a given range intersects with a conditional directive block. llvm-svn: 152018
* Change @import to @__experimental_modules_import. We are not ready to ↵Ted Kremenek2012-03-011-6/+6
| | | | | | | | commit to a particular syntax for modules, and don't have time to push it forward in the near future. llvm-svn: 151841
* Don't record nested macro expansions in the preprocessing record,Argyrios Kyrtzidis2012-02-251-4/+2
| | | | | | | | it can only bring pain when dealing with preprocessor abuse (see: boost). rdar://10898986 llvm-svn: 151427
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-071-15/+0
| | | | | | | | | | | | | | | | | | operator overloads out of line. This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. llvm-svn: 150006
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-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
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-1/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Remove Diagnostic.h include from Preprocessor.h.Benjamin Kramer2012-02-041-0/+15
| | | | | | | - Move the offending methods out of line and fix transitive includers. - This required changing an enum in the PPCallback API into an unsigned. llvm-svn: 149782
* Thread a TargetInfo through to the module map; we'll need it forDouglas Gregor2012-01-301-1/+3
| | | | | | target-specific module requirements. llvm-svn: 149224
* Rework HeaderSearch's interface for getting a module from a name andDouglas Gregor2012-01-291-1/+1
| | | | | | | | | for getting the name of the module file, unifying the code for searching for a module with a given name (into lookupModule()) and separating out the mapping to a module file (into getModuleFileName()). No functionality change. llvm-svn: 149197
* When loading an AST file, set SourceManager::MainFileID to the main file of ↵Argyrios Kyrtzidis2012-01-051-12/+16
| | | | | | | | the AST file, as suggested by Tom Honermann. llvm-svn: 147612
* Don't treat 'import' as a contextual keyword when we're in a caching lexer, ↵Douglas Gregor2012-01-041-9/+18
| | | | | | or when modules are disabled. llvm-svn: 147524
* Eliminate the uglified keyword __import_module__ for importingDouglas Gregor2012-01-031-12/+6
| | | | | | | | | | | | | modules. This leaves us without an explicit syntax for importing modules in C/C++, because such a syntax needs to be discussed first. In Objective-C/Objective-C++, the @import syntax is used to import modules. Note that, under -fmodules, C/C++ programs can import modules via the #include mechanism when a module map is in place for that header. This allows us to work with modules in C/C++ without committing to a syntax. llvm-svn: 147467
* Introduce a non-uglified syntax for module imports in Objective-C:Douglas Gregor2012-01-031-5/+11
| | | | | | @import identifier [. identifier]* ; llvm-svn: 147452
* Add a "Modules" language option, which subsumes the previousDouglas Gregor2012-01-031-1/+0
| | | | | | "AutoModuleImport" preprocessor option and is tied to -fmodules. llvm-svn: 147448
* Added -Wdisabled-macro-expansion warning.Abramo Bagnara2012-01-011-2/+5
| | | | llvm-svn: 147418
* When we treat an #include or #import as a module import, create anDouglas Gregor2011-12-021-1/+2
| | | | | | | implicit ImportDecl in the translation unit to record the presence of the import. llvm-svn: 145727
* Implementing parsing and resolution of module export declarationsDouglas Gregor2011-12-021-1/+6
| | | | | | | | within module maps, which will (eventually) be used to re-export a module from another module. There are still some pieces missing, however. llvm-svn: 145665
* Introduce the notion of name visibility into modules. For a givenDouglas Gregor2011-12-011-1/+2
| | | | | | | | | | | | | | (sub)module, all of the names may be hidden, just the macro names may be exposed (for example, after the preprocessor has seen the import of the module but the parser has not), or all of the names may be exposed. Importing a module makes its names, and the names in any of its non-explicit submodules, visible to name lookup (transitively). This commit only introduces the notion of name visible and marks modules and submodules as visible when they are imported. The actual name-hiding logic in the AST reader will follow (along with test cases). llvm-svn: 145586
* Teach the preprocessor how to handle module import declarations thatDouglas Gregor2011-11-301-9/+23
| | | | | | | involve submodules (e.g., importing std.vector), rather than always importing the top-level module. llvm-svn: 145478
* Switch the module-loading interfaces and parser from a simpleDouglas Gregor2011-11-301-3/+5
| | | | | | | top-level module name to a module path (e.g., std.vector). We're still missing a number of pieces for this actually to do something. llvm-svn: 145462
* Remove an assertion that is not valid if we cancel parsing.Argyrios Kyrtzidis2011-11-231-3/+0
| | | | llvm-svn: 145108
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AST file more lazy, so that we don't eagerly load that information for all known identifiers each time a new AST file is loaded. The eager reloading made some sense in the context of precompiled headers, since very few identifiers were defined before PCH load time. With modules, however, a huge amount of code can get parsed before we see an @import, so laziness becomes important here. The approach taken to make this information lazy is fairly simple: when we load a new AST file, we mark all of the existing identifiers as being out-of-date. Whenever we want to access information that may come from an AST (e.g., whether the identifier has a macro definition, or what top-level declarations have that name), we check the out-of-date bit and, if it's set, ask the AST reader to update the IdentifierInfo from the AST files. The update is a merge, and we now take care to merge declarations before/after imports with declarations from multiple imports. The results of this optimization are fairly dramatic. On a small application that brings in 14 non-trivial modules, this takes modules from being > 3x slower than a "perfect" PCH file down to 30% slower for a full rebuild. A partial rebuild (where the PCH file or modules can be re-used) is down to 7% slower. Making the PCH file just a little imperfect (e.g., adding two smallish modules used by a bunch of .m files that aren't in the PCH file) tips the scales in favor of the modules approach, with 24% faster partial rebuilds. This is just a first step; the lazy scheme could possibly be improved by adding versioning, so we don't search into modules we already searched. Moreover, we'll need similar lazy schemes for all of the other lookup data structures, such as DeclContexts. llvm-svn: 143100
* Add a -Wc++0x-compat warning for C++11 keywords used as identifiers when inRichard Smith2011-10-111-0/+11
| | | | | | C++98 mode. Only the first occurrence of each keyword will produce a warning. llvm-svn: 141700
* Fixed exapnsion range for # and ##.Abramo Bagnara2011-10-031-3/+5
| | | | llvm-svn: 141012
* Properly initialize Preprocessor::CurLexerKind to avoid use of uninitialized ↵Zhongxing Xu2011-09-261-2/+2
| | | | | | variable. llvm-svn: 140514
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-1/+1
| | | | llvm-svn: 140478
* Introduce PreprocessingRecord::getPreprocessedEntitiesInRange()Argyrios Kyrtzidis2011-09-191-1/+2
| | | | | | | | | | which will do a binary search and return a pair of iterators for preprocessed entities in the given source range. Source ranges of preprocessed entities are stored twice currently in the PCH/Module file but this will be fixed in a subsequent commit. llvm-svn: 140058
* Add an experimental flag -fauto-module-import that automatically turnsDouglas Gregor2011-09-151-0/+1
| | | | | | | #include or #import direcctives of framework headers into module imports of the corresponding framework module. llvm-svn: 139860
* Optimize the preprocessor's handling of the __import_module__Douglas Gregor2011-09-071-15/+30
| | | | | | | | | | | | keyword. We now handle this keyword in HandleIdentifier, making a note for ourselves when we've seen the __import_module__ keyword so that the next lexed token can trigger a module import (if needed). This greatly simplifies Preprocessor::Lex(), and completely erases the 5.5% -Eonly slowdown Argiris noted when I originally implemented __import_module__. Big thanks to Argiris for noting that horrible regression! llvm-svn: 139265
* Use const_cast to avoid warnings.Benjamin Kramer2011-09-041-1/+1
| | | | llvm-svn: 139104
* Support code-completion for C++ inline methods and ObjC buffering methods.Argyrios Kyrtzidis2011-09-041-26/+25
| | | | | | | | | | | | | | Previously we would cut off the source file buffer at the code-completion point; this impeded code-completion inside C++ inline methods and, recently, with buffering ObjC methods. Have the code-completion inserted into the source buffer so that it can be buffered along with a method body. When we actually hit the code-completion point the cut-off lexing or parsing. Fixes rdar://10056932&8319466 llvm-svn: 139086
* Allow the preprocessor to be constructed without performing target-Douglas Gregor2011-09-011-53/+69
| | | | | | | | and language-specific initialization. Use this to allow ASTUnit to create a preprocessor object *before* loading the AST file. No actual functionality change. llvm-svn: 138983
* Teach ASTContext and Preprocessor to hold on to references to the sameDouglas Gregor2011-09-011-1/+1
| | | | | | | | | LangOptions, rather than making distinct copies of LangOptions. Granted, LangOptions doesn't actually get modified, but this will eventually make it easier to construct ASTContext and Preprocessor before we know all of the LangOptions. llvm-svn: 138959
* Make sure to initialize field. Hopefully this will fix some test failures ↵Eli Friedman2011-08-311-0/+1
| | | | | | on Windows. llvm-svn: 138880
OpenPOWER on IntegriCloud