aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-01-28Fix the indentation of the first line of preprocessor outputHal Finkel1-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
2013-01-14Constify argument of Preprocessor::getMacroInfoHistory and propagate toDmitri Gribenko1-1/+1
callers, removing unneeded const_cast llvm-svn: 172372
2013-01-09Make sure clang puts tokens from different files on separate lines in "-E ↵Eli Friedman1-1/+4
-P" mode. <rdar://problem/12774044> llvm-svn: 171944
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-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
2012-11-16CPP Output: Do not emit an enter file marker for the main file.Daniel Dunbar1-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
2012-08-29Keep history of macro definitions and #undefsAlexander Kornienko1-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
2012-08-10Add missing cctype includes.Joerg Sonnenberger1-0/+1
llvm-svn: 161660
2012-06-15[-E] Emit a rewritten _Pragma on its own line.Jordan Rose1-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
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie1-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
2012-02-07Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer1-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
2012-02-05Basic: import SmallString<> into clang namespaceDylan Noblesmith1-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
2012-02-04Remove Diagnostic.h include from Preprocessor.h.Benjamin Kramer1-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
2012-01-17Remove unnecessary default cases in switches over enums.David Blaikie1-1/+0
This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
2011-12-22remove unneeded config.h includesDylan Noblesmith1-1/+0
llvm-svn: 147195
2011-10-11For the FileChanged Preprocessor callback, when exiting a file, pass its FileID.Argyrios Kyrtzidis1-2/+4
llvm-svn: 141681
2011-09-17Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet1-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
2011-07-25Rename getInstantiationColumnNumber to getExpansionColumnNumber in bothChandler Carruth1-1/+1
SourceManager and FullSourceLoc. llvm-svn: 135965
2011-07-23remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner1-17/+17
LLVM.h imports them into the clang namespace. llvm-svn: 135852
2011-07-14Update the remaining comments in Frontend to 'expansion'.Chandler Carruth1-2/+2
llvm-svn: 135150
2011-06-22Copy diagnostic pragmas to the preprocessed output, from Richard Osborne!Douglas Gregor1-0/+44
llvm-svn: 133633
2011-02-28Rename tok::eom to tok::eod.Peter Collingbourne1-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
2011-02-02Frontend: Factor out header include dumping (-H) into its own preprocessorDaniel Dunbar1-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
2010-11-19Several PPCallbacks take an SourceLocation + IdentifierInfo, ratherCraig Silverstein1-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
2010-11-12Make sure to always check the result ofDouglas Gregor1-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
2010-11-10make sure #pragma clang is treated the same way as #pragma gcc in -E mode,Chris Lattner1-2/+3
unknown pragmas should just be passed through to the .i file. llvm-svn: 118659
2010-09-17Handle '#line' in '-E' that has an empty file name. Fixes ↵Ted Kremenek1-2/+2
<rdar://problem/8439412>. llvm-svn: 114142
2010-09-10Make sure we're producing a newline in the preprocessed output beforeDouglas Gregor1-2/+1
emitting a #pragma, whenever one is needed. Fixes <rdar://problem/8417307>. llvm-svn: 113648
2010-09-09When we parse a pragma, keep track of how that pragma was originallyDouglas Gregor1-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
2010-09-08Frontend/-H: Add comment on why I used a temporary string here.Daniel Dunbar1-0/+1
llvm-svn: 113379
2010-08-24Frontend: Add basic -H support.Daniel Dunbar1-7/+39
- I didn't implement the GCC "multiple include guard" detection parts, because it doesn't seem useful or obvious. llvm-svn: 111983
2010-08-07Push location through the MacroUndefined PPCallback and use it to print ↵Benjamin Kramer1-0/+13
#undefs in -dD mode. (PR7818) llvm-svn: 110523
2010-07-13Modify the pragma handlers to accept and use StringRefs instead of ↵Argyrios Kyrtzidis1-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
2010-06-26Implement support for #pragma message, patch by Michael Spencer!Chris Lattner1-1/+25
llvm-svn: 106950
2010-06-15fix the various buildbot failures by ensuring that tokens are really ↵Chris Lattner1-4/+3
completely initialized. llvm-svn: 106043
2010-06-15fix an uninitialized variable, patch by Michael Spencer!Chris Lattner1-0/+2
llvm-svn: 106025
2010-06-12fix PR7360: -P mode turns off line markers, but not blank space.Chris Lattner1-15/+10
Apparently some programs which abuse the preprocessor depend on this. llvm-svn: 105889
2010-06-11Preprocessor: Ignore unknown pragmas in -E -dM and -Eonly modes.Daniel Dunbar1-0/+3
llvm-svn: 105830
2010-04-20push some source location information down through the compiler,Chris Lattner1-4/+2
into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
2010-04-16Remove this hard-coded buffer size. In some basic experiments preprocessingDan Gohman1-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
2010-04-14Improve line marker directive locations, patch by Jordy RoseChris Lattner1-1/+1
llvm-svn: 101226
2010-04-14make the token paste avoidance logic turn "..." into ".. ." instead of ". . ."Chris Lattner1-3/+6
when avoiding paste. Patch by David Peixotto! llvm-svn: 101218
2010-04-13cache the PP's SourceManager.Chris Lattner1-5/+6
llvm-svn: 101099
2010-04-13make the preprocessor listen to linemarker directives in -E mode,Chris Lattner1-10/+14
PR6101. This is based on a patch and testcase by Jordy Rose! llvm-svn: 101097
2010-03-17Entering the main source file in the preprocessor can fail if theDouglas Gregor1-2/+4
source file has been changed. Handle that failure more gracefully. llvm-svn: 98727
2010-03-13Use SmallString instead of SmallVectorKovarththanan Rajaratnam1-1/+1
llvm-svn: 98436
2010-03-07Rename to addPPCallbacks since we're effectively adding a callback and maybe ↵Kovarththanan Rajaratnam1-4/+4
chaining it to an existing one llvm-svn: 97913
2010-02-27Revert 97324. Chris says this cleanup could hurt -E performance.Benjamin Kramer1-8/+24
llvm-svn: 97331
2010-02-27Simplify code.Benjamin Kramer1-24/+8
llvm-svn: 97324
2010-02-27Add an overload of Preprocessor::getSpelling which takes a SmallVector andBenjamin Kramer1-6/+1
returns a StringRef. Use it to simplify some repetitive code. llvm-svn: 97322
2010-01-19Avoid an instantiation of std::sort.Benjamin Kramer1-14/+10
llvm-svn: 93882