aboutsummaryrefslogtreecommitdiff
path: root/Driver/PrintPreprocessedOutput.cpp
AgeCommit message (Collapse)Author
2009-03-24Move <root>/Driver into <root>/tools/clang-cc.Daniel Dunbar
Again, I tried to update cmake but it is untested. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67605 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20fix test/Preprocessor/macro_paste_mscomment.c.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13factor token concatenation avoidance logic out of Chris Lattner
PrintPreprocessedOutput into its own file. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64418 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-10make -dM emit macros in a deterministic (sorted) order instead of Chris Lattner
random hash table order, I don't like non-determinstic output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-10use efficient form of getSpelling, this speeds up -dM by 16%.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64244 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06Add an implementation of -dM that follows GCC closely enough to permitChris Lattner
diffing the output of: clang -dM -o - -E -x c foo.c | sort git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63926 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06factor some code out into a helper function.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63922 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04lower the interface to getLineNumber like we did forChris Lattner
getColumnNumber. This fixes a FIXME in SourceManager::getPresumedLoc because we now just decompose the sloc once. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63701 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-30avoid emitting a bogus line marker for the top level #includeChris Lattner
location. We now -E a file containing "foo" into: # 1 "t.c" # 1 "t.c" 1 # 1 "<predefines>" 1 # 1 "t.c" 2 foo instead of: # 1 "t.c" # 1 "t.c" 1 # 0 "t.c" # 1 "<predefines>" 1 # 1 "t.c" 2 foo git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27Introduce a new PresumedLoc class to represent the concept of a locationChris Lattner
as reported to the user and as manipulated by #line. This is what __FILE__, __INCLUDE_LEVEL__, diagnostics and other things should follow (but not dependency generation!). This patch also includes several cleanups along the way: - SourceLocation now has a dump method, and several other places that did similar things now use it. - I cleaned up some code in AnalysisConsumer, but it should probably be simplified further now that NamedDecl is better. - TextDiagnosticPrinter is now simplified and cleaned up a bit. This patch is a prerequisite for #line, but does not actually provide any #line functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26minor speedups/cleanups for -E mode.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63029 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26This change refactors some of the low-level lexer interfaces a bit.Chris Lattner
Token now has a class of kinds for "literals", which include numeric constants, strings, etc. These tokens can optionally have a pointer to the start of the token in the lexer buffer. This makes it faster to get spelling and do other gymnastics, because we don't have to go through source locations. This change is performance neutral, but will make other changes more feasible down the road. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16Make sure to escape " when it occurs in a string in pragma commentChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62367 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16Make -E mode propagate #pragma comment's into the output.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62339 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16more SourceLocation lexicon change: instead of referring to theChris Lattner
"logical" location, refer to the "instantiation" location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16Change some terminology in SourceLocation: instead of referring to Chris Lattner
the "physical" location of tokens, refer to the "spelling" location. This is more concrete and useful, tokens aren't really physical objects! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62309 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11make paste avoidance avoid pasting digraphs and :: only when digraphs or c++ ↵Chris Lattner
is enabled respectively. Inspired by a patch by Dan Villiom Podlaski Christiansen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62044 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13[LLVM up] Update for raw_fd_ostream change. This fixes a FIXME thatDaniel Dunbar
the Backend output should be done in binary mode. - I'd appreciate it if someone who has a Windows build could verify this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59221 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27Rename Characteristic_t to CharacteristicKindChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26clean up a bunch of fixme's I added, by moving Chris Lattner
DirectoryLookup::DirType into SourceManager.h git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56692 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26fit in 80 cols.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56687 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26Make clang preprocessed output a bit more like gcc output.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56636 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05Workaround gcc bug causing crash on our preprocessed outputs.Daniel Dunbar
- gcc is not happy if we start a preprocessed file with #line 1 "XXX" 1 - Workaround by making sure file starts with a simple #line change. Also, factored WriteLineInfo out. Also, fixed bug where FileType was not being correctly updated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55825 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-19Use raw_ostream to output an unsigned.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54973 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17printing with an unspecified dest means to print to stdout.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54872 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17don't delete a variable on the stackChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54871 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17simplify this code a bit more.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54864 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17remove global variables for output stream.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54861 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17Switch to shared raw_ostream code instead of having it be clang specific.Chris Lattner
This also helps the eventual distcc project. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54858 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-11Fix rdar://5843510 don't assert and die when an invalid outputChris Lattner
file is specified, print a happy little error message. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49518 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-08Fix rdar://5846705: "clang -E foo.c -o foo.i" should remove foo.i on error.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49368 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-27Make -o work with -E, patch contributed by Shantonu Sen!Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46426 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15avoid pasting L + "foo" into L"foo".Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46000 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-15avoid token pasting between identifiers and wide strings: Chris Lattner
abc+L"foo" -> abc L"foo", not abcL"foo" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45999 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29Don't attribute in file headers anymore. See llvmdev for theChris Lattner
discussion of this change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45410 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-19Interned MainFileID within SourceManager. Since SourceManager is referenced byTed Kremenek
both Preprocessor and ASTContext, we no longer need to explicitly pass MainFileID around in function calls that also pass either Preprocessor or ASTContext. This resulted in some nice cleanups in the ASTConsumers and the driver. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45228 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-15simplify the interfaces to ProcessInputFile and InitializePreprocessorChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45060 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-09The flags on tokens indicate whether they are the start of a *physical* line, Chris Lattner
not the start of a logical line. Be careful about this distinction, which affects when newlines are printed and when paste-avoidance happens, etc. This fixes PR1848, thanks to Neil for noticing this! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-09Fix a pretty big but subtle bug counting the number of newlines to emit.Chris Lattner
This would cause us to emit different code (in -E mode) for these two files: --- #define t(x) x t(a 3) --- #define t(x) x t(a 3) --- In one case, -E would print "a\n3", in the other it printed "a3". Now it prints "a3" for both. This is part of PR1848. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44742 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-10fix a bunch of regressions I introduced :(Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42846 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-10clang -E should not print tokens from the predefines buffer.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42838 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09Make a significant change to invert the control flow handlingChris Lattner
predefined macros. Previously, these were handled by the driver, now they are handled by the preprocessor. Some fallout of this: 1. Instead of preprocessing two buffers (the predefines, then the main source file) we now start preprocessing the main source file and inject the predefines as a "psuedo #include" from the main source file. 2. #1 allows us to nuke the Lexer::IsMainFile flag and simplify Preprocessor::isInPrimaryFile. 3. The driver doesn't have to know about standard #defines, the preprocessor knows, which is nice for people wanting to define their own drivers. 4. This allows us to put normal tokens in the predefine buffer, for example a definition for __builtin_va_list that is target-specific, and a typedef for id in objc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42818 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09convert driver over to use Token::is/isNot APIs. fwew, all done.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42800 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-03Add #ifdefs to make the source portable to windows. Patch contributedChris Lattner
by Hartmut Kaiser! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41684 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-24avoid std::string yet again.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40462 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-24Use a smallstring instead of an std::string in FileChanged to avoid some ↵Chris Lattner
malloc traffic. This speeds up -E on xalancbmk by 2.4% git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40461 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-23Fix two paste-avoidance bugs I introduced last night. PatchChris Lattner
by Neil Booth. This fixes Preprocessor/output_paste_avoid.c git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40454 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-23avoid creating std::strings in MoveToLineChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40424 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-23In OutputString, avoid calling memcpy for really tiny strings. Chris Lattner
This speeds up -E on 447.dealII by 5.8% git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40423 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-23Avoid calling getSpelling at all for identifiers, which areChris Lattner
trivial to handle and very very common. This speeds up -E on 447.dealII by 2.5% git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40422 91177308-0d34-0410-b5e6-96231b3b80d8