summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Pragma.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Comments: no need to escape any characters in \code ... \endcode.Dmitri Gribenko2012-11-301-6/+6
| | | | llvm-svn: 169030
* Support for #pragma region/endregion for MSVC compatibility. Patch thanks ↵Aaron Ballman2012-11-301-0/+25
| | | | | | to pravic! llvm-svn: 169028
* Made the "expected string literal" diagnostic more expressiveAndy Gibbs2012-11-171-2/+5
| | | | llvm-svn: 168267
* Refactored duplicate string literal lexing code within Preprocessor, into aAndy Gibbs2012-11-171-88/+11
| | | | | | | | | | | | | common LexStringLiteral function. In doing so, some consistency problems have been ironed out (e.g. where the first token in the string literal was lexed with macro expansion, but subsequent ones were not) and also an erroneous diagnostic has been corrected. LexStringLiteral is complemented by a FinishLexStringLiteral function which can be used in the situation where the first token of the string literal has already been lexed. llvm-svn: 168266
* Removed an extra blank line.Mahesha S2012-10-241-1/+0
| | | | llvm-svn: 166571
* Rework the (de-)serialization of macros, as stored inDouglas Gregor2012-10-091-1/+1
| | | | | | | | | | | | | | | | 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
* StringRef'ize Preprocessor::CreateString().Dmitri Gribenko2012-09-241-2/+2
| | | | llvm-svn: 164555
* Fixed a problem with #pragma push_macro/pop_macro implementation.Alexander Kornienko2012-08-291-2/+7
| | | | | | | | | | | | | | | | | | | | Summary: The problem was with the following sequence: #pragma push_macro("long") #undef long #pragma pop_macro("long") in case when "long" didn't represent a macro. Fixed crash and removed code duplication for #undef/pop_macro case. Added regression tests. Reviewers: doug.gregor, klimek Reviewed By: doug.gregor CC: cfe-commits, chapuni Differential Revision: http://llvm-reviews.chandlerc.com/D31 llvm-svn: 162845
* Keep history of macro definitions and #undefsAlexander Kornienko2012-08-291-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros> I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux. Stats before this patch: *** Preprocessor Stats: 73222 directives found: 19171 #define. 4345 #undef. #include/#include_next/#import: 5233 source files entered. 27 max include stack depth 19210 #if/#ifndef/#ifdef. 2384 #else/#elif. 6891 #endif. 408 #pragma. 14466 #if/#ifndef#ifdef regions skipped 80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path. 127145 token paste (##) operations performed, 11008 on the fast path. Preprocessor Memory: 5874615B total BumpPtr: 4399104 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 Stats with this patch: ... Preprocessor Memory: 7541687B total BumpPtr: 6066176 Macro Expanded Tokens: 417768 Predefines Buffer: 8135 Macros: 1048576 #pragma push_macro Info: 0 Poison Reasons: 1024 Comment Handlers: 8 In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation. As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time. Reviewers: doug.gregor, klimek, rsmith, djasper Reviewed By: doug.gregor CC: cfe-commits, chandlerc Differential Revision: http://llvm-reviews.chandlerc.com/D28 llvm-svn: 162810
* Use LLVM_BUILTIN_TRAP instead of lame volatile int traps.David Blaikie2012-08-211-1/+1
| | | | | | (from a todo mentioned in r159469 & originally suggested by Chandler Carruth) llvm-svn: 162302
* Use -frewrite-includes for crash reports.David Blaikie2012-06-291-0/+4
| | | | | | | | | | | In future changes we should: * use __builtin_trap rather than derefing 'random' volatile pointers. * avoid dumping temporary files into /tmp when running tests, instead preferring a location that is properly cleaned up by lit. Review by Chandler Carruth. llvm-svn: 159469
* Documentation cleanup:James Dennett2012-06-171-29/+42
| | | | | | | * Escaped #pragma (as \#pragma) in Doxygen comments; * Added \code...\endcode annotations around code examples in doc comments. llvm-svn: 158615
* Disable _Pragma during HTML macro rewriting to keep from crashing.Jordan Rose2012-06-081-0/+3
| | | | | | | | | | | | | | | | | | | 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
* Correct handling of _Pragma macro inside a macro argument.Argyrios Kyrtzidis2012-04-031-5/+60
| | | | | | | | | | | | | | | | 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
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-061-0/+23
| | | | | | | | | | grammar requires a string-literal and not a user-defined-string-literal. The two constructs are still represented by the same TokenKind, in order to prevent a combinatorial explosion of different kinds of token. A flag on Token tracks whether a ud-suffix is present, in order to prevent clients from needing to look at the token's spelling. llvm-svn: 152098
* Remove unused variable.Benjamin Kramer2012-03-031-1/+0
| | | | llvm-svn: 151989
* Adding support for #pragma include_alias in MS compatibility mode. This ↵Aaron Ballman2012-03-021-0/+116
| | | | | | implements PR 10705. llvm-svn: 151949
* Revert r151800, which was committed without review and has correctness issues.Richard Smith2012-03-011-105/+0
| | | | llvm-svn: 151804
* Implements support for #pragma include_alias in ms compatibility mode. ↵Aaron Ballman2012-03-011-0/+105
| | | | | | Fixes PR10705. llvm-svn: 151800
* 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
* Fix a memory leak of PragmaNamespaces, rdar://10611796.Argyrios Kyrtzidis2012-01-061-1/+3
| | | | llvm-svn: 147635
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 explicit attributes to mark functions as having had theirJohn McCall2011-09-301-0/+55
| | | | | | | | | | | CoreFoundation object-transfer properties audited, and add a #pragma to cause them to be automatically applied to functions in a particular span of code. This has to be implemented largely in the preprocessor because of the requirement that the region be entirely contained in a single file; that's hard to impose from the parser without registering for a ton of callbacks. llvm-svn: 140846
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-1/+1
| | | | llvm-svn: 140367
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-1/+1
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* Add an experimental flag -fauto-module-import that automatically turnsDouglas Gregor2011-09-151-1/+2
| | | | | | | #include or #import direcctives of framework headers into module imports of the corresponding framework module. llvm-svn: 139860
* Change err_pp_file_not_found back to an Error; when it's a Warning, we ↵Eli Friedman2011-08-301-1/+2
| | | | | | | | suppress it in system headers. And it is not a good idea to suppress it in system headers. (This was originally changed in r134996 to implement -MG.) Fixes <rdar://10041960>. And also brings down the number of warnings without a flag by one :) llvm-svn: 138842
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-3/+3
| | | | llvm-svn: 136210
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-12/+12
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Implement -MG. Fixes PR9613Peter Collingbourne2011-07-121-1/+1
| | | | llvm-svn: 134996
* Copy diagnostic pragmas to the preprocessed output, from Richard Osborne!Douglas Gregor2011-06-221-4/+13
| | | | llvm-svn: 133633
* Make more use of llvm::StringRef in various APIs. In particular, don'tJay Foad2011-06-211-7/+4
| | | | | | use the deprecated forms of llvm::StringMap::GetOrCreateValue(). llvm-svn: 133515
* Disable MSVC warning about runtime stack overflow for DebugOverflowStack.Francois Pichet2011-05-251-0/+8
| | | | llvm-svn: 132059
* A StringRef-ication of the DiagnosticIDs API and internals.Argyrios Kyrtzidis2011-05-251-3/+2
| | | | | | | | | Patch by Matthieu Monrocq with tweaks by me to avoid StringRefs in the static diagnostic data structures, which resulted in a huge global-var-init function. Depends on llvm commit r132046. llvm-svn: 132047
* Invoke the FileChanged callback before pushing the linemarker for a systemChris Lattner2011-05-221-5/+5
| | | | | | | | | | | | | | | | | | | | | | header. Getting it in the wrong order generated incorrect line markers in -E mode. In the testcase from PR9861 we used to generate: # 1 "test.c" 2 # 1 "./foobar.h" 1 # 0 "./foobar.h" # 0 "./foobar.h" 3 # 2 "test.c" 2 now we properly produce: # 1 "test.c" 2 # 1 "./foobar.h" 1 # 1 "./foobar.h" 3 # 2 "test.c" 2 This fixes PR9861. llvm-svn: 131871
* To be able to replay compilations we need to accurately remodel howManuel Klimek2011-04-261-1/+1
| | | | | | | | | includes get resolved, especially when they are found relatively to another include file. We also try to get it working for framework includes, but that part of the code is untested, as I don't have a code base that uses it. llvm-svn: 130246
* Add a 'RawPath' parameter to the PPCallbacks interface. This allowsChandler Carruth2011-03-161-1/+1
| | | | | | | | | | | | | | | clients to observe the exact path through which an #included file was located. This is very useful when trying to record and replay inclusion operations without it beind influenced by the aggressive caching done inside the FileManager to avoid redundant system calls and filesystem operations. The work to compute and return this is only done in the presence of callbacks, so it should have no effect on normal compilation. Patch by Manuel Klimek. llvm-svn: 127742
* Rename tok::eom to tok::eod.Peter Collingbourne2011-02-281-12/+12
| | | | | | | | The previous name was inaccurate as this token in fact appears at the end of every preprocessing directive, not just macro definitions. No functionality change, except for a diagnostic tweak. llvm-svn: 126631
* Reimplement __pragma support using a TokenLexerPeter Collingbourne2011-02-221-36/+29
| | | | llvm-svn: 126221
* Make TokenLexer capable of storing preprocessor directive tokensPeter Collingbourne2011-02-221-1/+2
| | | | llvm-svn: 126220
* Move support for "#pragma STDC FP_CONTRACT" to Parser; add Sema actionsPeter Collingbourne2011-02-141-15/+0
| | | | llvm-svn: 125474
* Make LexOnOffSwitch a Preprocessor member functionPeter Collingbourne2011-02-141-35/+35
| | | | llvm-svn: 125473
* Introduced raw_identifier token kind.Abramo Bagnara2010-12-221-2/+2
| | | | llvm-svn: 122394
* Fix diagnostic pragmas.Argyrios Kyrtzidis2010-12-151-4/+9
| | | | | | | | | | | | Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state. Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect a lot of places, like C++ inline methods, template instantiations, the lexer, etc. Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location. Fixes rdar://8365684. llvm-svn: 121873
* Make sure to always check the result ofDouglas Gregor2010-11-121-0/+3
| | | | | | | SourceManager::getPresumedLoc(), so that we don't try to make use of an invalid presumed location. Doing so can cause crashes. llvm-svn: 118885
* Fix typo in comment.Ted Kremenek2010-10-191-1/+1
| | | | llvm-svn: 116825
* Fix coding standard mistake from my last commit.Michael J. Spencer2010-09-271-1/+1
| | | | | | That, and keep aKor happy :P. llvm-svn: 114816
* Lexer: Implement GCC's version of pragma message.Michael J. Spencer2010-09-271-15/+26
| | | | llvm-svn: 114814
* When we parse a pragma, keep track of how that pragma was originallyDouglas Gregor2010-09-091-24/+44
| | | | | | | | spelled (#pragma, _Pragma, __pragma). In -E mode, use that information to add appropriate newlines when translating _Pragma and __pragma into #pragma, like GCC does. Fixes <rdar://problem/8412013>. llvm-svn: 113553
OpenPOWER on IntegriCloud