summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Preprocessor: don't keep comments under -traditional-cpp.Jordan Rose2013-03-051-1/+10
| | | | | | | | | | | This patch is designed for minimal intrusion into normal preprocessing and compilation; under -E -traditional-cpp, the lexer will still generate tok::comment nodes since it is preserving all whitespace, but the output printer will then throw it away. <rdar://problem/13338680> llvm-svn: 176534
* [preprocessor] Use MacroDirective in the preprocessor callbacks to make ↵Argyrios Kyrtzidis2013-02-241-4/+5
| | | | | | | | available the full information about the macro (e.g if it was imported and where). llvm-svn: 175978
* Preprocessor: preserve whitespace in -traditional-cpp mode.Jordan Rose2013-02-211-2/+2
| | | | | | | | | Note that unlike GNU cpp we currently do not preserve whitespace in macros (even in -traditional-cpp mode). <rdar://problem/12897179> llvm-svn: 175778
* [preprocessor] Split the MacroInfo class into two separate concepts, ↵Argyrios Kyrtzidis2013-02-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | MacroInfo class for the data specific to a macro definition (e.g. what the tokens are), and MacroDirective class which encapsulates the changes to the "macro namespace" (e.g. the location where the macro name became active, the location where it was undefined, etc.) (A MacroDirective always points to a MacroInfo object.) Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but splitting the concepts allows us to better model the effect of modules to the macro namespace (also as a bonus it allows better modeling of push_macro/pop_macro #pragmas). Modules can have their own macro history, separate from the local (current translation unit) macro history; MacroDirectives will be used to model the macro history (changes to macro namespace). For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created to indicate that "FOO" became active at the import location. Module "A" itself will contain another MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives will point to the same MacroInfo object. Introducing the separation of macro concepts is the first part towards better modeling of module macros. llvm-svn: 175585
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-081-3/+3
| | | | | | | Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
* Fix the indentation of the first line of preprocessor outputHal Finkel2013-01-281-1/+5
| | | | | | | | | | The -E output from clang did not produce the correct indentation on the first line. This is because MoveToLine returned false, and when this happens, the regular process for producing initial indentation is skipped. Thanks to Eli for suggesting a way to simplify this to a one-line change. llvm-svn: 173657
* Constify argument of Preprocessor::getMacroInfoHistory and propagate toDmitri Gribenko2013-01-141-1/+1
| | | | | | callers, removing unneeded const_cast llvm-svn: 172372
* Make sure clang puts tokens from different files on separate lines in "-E ↵Eli Friedman2013-01-091-1/+4
| | | | | | | | -P" mode. <rdar://problem/12774044> llvm-svn: 171944
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | 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
* CPP Output: Do not emit an enter file marker for the main file.Daniel Dunbar2012-11-161-0/+11
| | | | | | | | - This diverges from gcc, and confuses tools (like dtrace) which track # line markers as a way to determine which content is in the context of the main file. llvm-svn: 168128
* Keep history of macro definitions and #undefsAlexander Kornienko2012-08-291-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add missing cctype includes.Joerg Sonnenberger2012-08-101-0/+1
| | | | llvm-svn: 161660
* [-E] Emit a rewritten _Pragma on its own line.Jordan Rose2012-06-151-29/+36
| | | | | | | | | | | 1. Teach Lexer that pragma lexers are like macro expansions at EOF. 2. Treat pragmas like #define/#undef when printing. 3. If we just printed a directive, add a newline before any more tokens. (4. Miscellaneous cleanup in PrintPreprocessedOutput.cpp) PR10594 and <rdar://problem/11562490> (two separate related problems) llvm-svn: 158571
* 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
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-071-3/+3
| | | | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Remove Diagnostic.h include from Preprocessor.h.Benjamin Kramer2012-02-041-3/+3
| | | | | | | - 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
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-1/+0
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
* remove unneeded config.h includesDylan Noblesmith2011-12-221-1/+0
| | | | llvm-svn: 147195
* For the FileChanged Preprocessor callback, when exiting a file, pass its FileID.Argyrios Kyrtzidis2011-10-111-2/+4
| | | | llvm-svn: 141681
* 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
* Rename getInstantiationColumnNumber to getExpansionColumnNumber in bothChandler Carruth2011-07-251-1/+1
| | | | | | SourceManager and FullSourceLoc. llvm-svn: 135965
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-17/+17
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Update the remaining comments in Frontend to 'expansion'.Chandler Carruth2011-07-141-2/+2
| | | | llvm-svn: 135150
* Copy diagnostic pragmas to the preprocessed output, from Richard Osborne!Douglas Gregor2011-06-221-0/+44
| | | | llvm-svn: 133633
* Rename tok::eom to tok::eod.Peter Collingbourne2011-02-281-1/+1
| | | | | | | | 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
* Frontend: Factor out header include dumping (-H) into its own preprocessorDaniel Dunbar2011-02-021-36/+4
| | | | | | | | callbacks class. - Aside from being generally cleaner, this also allows -H to work correctly in modes other than standard preprocessing (e.g., -c, -MM, etc.) llvm-svn: 124723
* Several PPCallbacks take an SourceLocation + IdentifierInfo, ratherCraig Silverstein2010-11-191-10/+7
| | | | | | | | | | | than a Token that holds the same information all in one easy-to-use package. There's no technical reason to prefer the former -- the information comes from a Token originally -- and it's clumsier to use, so I've changed the code to use tokens everywhere. Approved by clattner llvm-svn: 119845
* Make sure to always check the result ofDouglas Gregor2010-11-121-6/+20
| | | | | | | SourceManager::getPresumedLoc(), so that we don't try to make use of an invalid presumed location. Doing so can cause crashes. llvm-svn: 118885
* make sure #pragma clang is treated the same way as #pragma gcc in -E mode,Chris Lattner2010-11-101-2/+3
| | | | | | unknown pragmas should just be passed through to the .i file. llvm-svn: 118659
* Handle '#line' in '-E' that has an empty file name. Fixes ↵Ted Kremenek2010-09-171-2/+2
| | | | | | <rdar://problem/8439412>. llvm-svn: 114142
* Make sure we're producing a newline in the preprocessed output beforeDouglas Gregor2010-09-101-2/+1
| | | | | | emitting a #pragma, whenever one is needed. Fixes <rdar://problem/8417307>. llvm-svn: 113648
* When we parse a pragma, keep track of how that pragma was originallyDouglas Gregor2010-09-091-4/+20
| | | | | | | | 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
* Frontend/-H: Add comment on why I used a temporary string here.Daniel Dunbar2010-09-081-0/+1
| | | | llvm-svn: 113379
* Frontend: Add basic -H support.Daniel Dunbar2010-08-241-7/+39
| | | | | | | - I didn't implement the GCC "multiple include guard" detection parts, because it doesn't seem useful or obvious. llvm-svn: 111983
* Push location through the MacroUndefined PPCallback and use it to print ↵Benjamin Kramer2010-08-071-0/+13
| | | | | | #undefs in -dD mode. (PR7818) llvm-svn: 110523
* Modify the pragma handlers to accept and use StringRefs instead of ↵Argyrios Kyrtzidis2010-07-131-3/+3
| | | | | | | | | | | IdentifierInfos. When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded). We can avoid this if we just use StringRefs for the pragmas. As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified. llvm-svn: 108237
* Implement support for #pragma message, patch by Michael Spencer!Chris Lattner2010-06-261-1/+25
| | | | llvm-svn: 106950
* fix the various buildbot failures by ensuring that tokens are really ↵Chris Lattner2010-06-151-4/+3
| | | | | | completely initialized. llvm-svn: 106043
* fix an uninitialized variable, patch by Michael Spencer!Chris Lattner2010-06-151-0/+2
| | | | llvm-svn: 106025
* fix PR7360: -P mode turns off line markers, but not blank space.Chris Lattner2010-06-121-15/+10
| | | | | | | Apparently some programs which abuse the preprocessor depend on this. llvm-svn: 105889
* Preprocessor: Ignore unknown pragmas in -E -dM and -Eonly modes.Daniel Dunbar2010-06-111-0/+3
| | | | llvm-svn: 105830
* push some source location information down through the compiler,Chris Lattner2010-04-201-4/+2
| | | | | | | | into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
* Remove this hard-coded buffer size. In some basic experiments preprocessingDan Gohman2010-04-161-2/+0
| | | | | | | | | | | large files, this doesn't seem significantly better than just letting raw_ostream pick a buffer size. This code predates raw-ostream's automatic buffer sizing; in fact, it was introduced as part of the code which would eventually become raw_ostream. llvm-svn: 101473
* Improve line marker directive locations, patch by Jordy RoseChris Lattner2010-04-141-1/+1
| | | | llvm-svn: 101226
* make the token paste avoidance logic turn "..." into ".. ." instead of ". . ."Chris Lattner2010-04-141-3/+6
| | | | | | when avoiding paste. Patch by David Peixotto! llvm-svn: 101218
* cache the PP's SourceManager.Chris Lattner2010-04-131-5/+6
| | | | llvm-svn: 101099
* make the preprocessor listen to linemarker directives in -E mode,Chris Lattner2010-04-131-10/+14
| | | | | | PR6101. This is based on a patch and testcase by Jordy Rose! llvm-svn: 101097
* Entering the main source file in the preprocessor can fail if theDouglas Gregor2010-03-171-2/+4
| | | | | | source file has been changed. Handle that failure more gracefully. llvm-svn: 98727
* Use SmallString instead of SmallVectorKovarththanan Rajaratnam2010-03-131-1/+1
| | | | llvm-svn: 98436
OpenPOWER on IntegriCloud