Commit Graph

52 Commits

Author SHA1 Message Date
Chris Lattner 02bf44436f Make -o work with -E, patch contributed by Shantonu Sen!
llvm-svn: 46426
2008-01-27 23:55:11 +00:00
Chris Lattner 15346fae70 avoid pasting L + "foo" into L"foo".
llvm-svn: 46000
2008-01-15 05:22:14 +00:00
Chris Lattner 877ca77420 avoid token pasting between identifiers and wide strings:
abc+L"foo" -> abc L"foo", not abcL"foo"

llvm-svn: 45999
2008-01-15 05:14:19 +00:00
Chris Lattner 5b12ab8c93 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.

llvm-svn: 45410
2007-12-29 19:59:25 +00:00
Ted Kremenek 230bd918b2 Interned MainFileID within SourceManager. Since SourceManager is referenced by
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.

llvm-svn: 45228
2007-12-19 22:51:13 +00:00
Chris Lattner 60a288ab19 simplify the interfaces to ProcessInputFile and InitializePreprocessor
llvm-svn: 45060
2007-12-15 20:48:40 +00:00
Chris Lattner 3ed83c1c0f The flags on tokens indicate whether they are the start of a *physical* line,
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!

llvm-svn: 44743
2007-12-09 21:11:08 +00:00
Chris Lattner 84f450789a Fix a pretty big but subtle bug counting the number of newlines to emit.
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.

llvm-svn: 44742
2007-12-09 20:45:43 +00:00
Chris Lattner 7b4ab65c7d fix a bunch of regressions I introduced :(
llvm-svn: 42846
2007-10-10 23:31:03 +00:00
Chris Lattner 3ff2e69713 clang -E should not print tokens from the predefines buffer.
llvm-svn: 42838
2007-10-10 20:45:16 +00:00
Chris Lattner 1f1b0dbc28 Make a significant change to invert the control flow handling
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.

llvm-svn: 42818
2007-10-09 22:10:18 +00:00
Chris Lattner 3c69f12cbc convert driver over to use Token::is/isNot APIs. fwew, all done.
llvm-svn: 42800
2007-10-09 18:03:42 +00:00
Chris Lattner cd1e8d2c9d Add #ifdefs to make the source portable to windows. Patch contributed
by Hartmut Kaiser!

llvm-svn: 41684
2007-09-03 18:24:56 +00:00
Chris Lattner 1af0e0116a avoid std::string yet again.
llvm-svn: 40462
2007-07-24 06:59:01 +00:00
Chris Lattner 4c4a245475 Use a smallstring instead of an std::string in FileChanged to avoid some malloc traffic.
This speeds up -E on xalancbmk by 2.4%

llvm-svn: 40461
2007-07-24 06:57:14 +00:00
Chris Lattner d63c8a5963 Fix two paste-avoidance bugs I introduced last night. Patch
by Neil Booth.  This fixes Preprocessor/output_paste_avoid.c

llvm-svn: 40454
2007-07-23 23:21:34 +00:00
Chris Lattner 5cdfebbf10 avoid creating std::strings in MoveToLine
llvm-svn: 40424
2007-07-23 06:31:11 +00:00
Chris Lattner 93c4ea75ec In OutputString, avoid calling memcpy for really tiny strings.
This speeds up -E on 447.dealII by 5.8%

llvm-svn: 40423
2007-07-23 06:23:07 +00:00
Chris Lattner 0af9823e4d Avoid calling getSpelling at all for identifiers, which are
trivial to handle and very very common.  This speeds up -E on 
447.dealII by 2.5%

llvm-svn: 40422
2007-07-23 06:14:36 +00:00
Chris Lattner 4418ce1091 change the concatenation avoidance algorithm to be partially table-driven
and avoid computing the spelling of tokens when not needed.  This speeds
up -E on 447.dealII by 2.2%

llvm-svn: 40421
2007-07-23 06:09:34 +00:00
Chris Lattner e4c566c604 If a token doesn't need cleaning, we can get its first character
without having to get the whole token.  This speeds up -E on 
447.dealII by 1.8%

llvm-svn: 40420
2007-07-23 05:18:42 +00:00
Chris Lattner 5f075827bf A minor tweak to -E output, speeding up -E 1.5% on 447.dealII
llvm-svn: 40419
2007-07-23 05:14:05 +00:00
Chris Lattner 7dd7a1d310 no need to avoid pasting >* It can't form ->*, because we know the previous
token was not -> and if the token before it was -, the - and > would avoid pasting.

llvm-svn: 40409
2007-07-22 22:33:25 +00:00
Chris Lattner 9c691703ce remove redundant test
llvm-svn: 40386
2007-07-22 06:40:36 +00:00
Chris Lattner 9b7962495f avoid a small bit of string traffic by not storing the ""'s around a string in CurFilename
llvm-svn: 40385
2007-07-22 06:38:50 +00:00
Chris Lattner 146762e7a4 At one point there were going to be lexer and parser tokens.
Since that point is now long gone, we should rename LexerToken to
Token, as it is the only kind of token we have.

llvm-svn: 40105
2007-07-20 16:59:19 +00:00
Chris Lattner dc5c055fd1 Reimplement SourceLocation. Instead of having a
fileid/offset pair, it now contains a bit discriminating between
mapped locations and file locations.  This separates the tables for
macros and files in SourceManager, and allows better separation of
concepts in the rest of the compiler.  This allows us to have *many*
macro instantiations before running out of 'addressing space'.

This is also more efficient, because testing whether something is a
macro expansion is now a bit test instead of a table lookup (which
also used to require having a srcmgr around, now it doesn't).

This is fully functional, but there are several refinements and
optimizations left.

llvm-svn: 40103
2007-07-20 16:37:10 +00:00
Chris Lattner 23b7eb677d Finally bite the bullet and make the major change: split the clang namespace
out of the llvm namespace.  This makes the clang namespace be a sibling of
llvm instead of being a child.

The good thing about this is that it makes many things unambiguous.  The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier.  IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.

llvm-svn: 39659
2007-06-15 23:05:46 +00:00
Chris Lattner 2ea9dd7fc0 ProcessInputFile no longer mutates LangInfo.
llvm-svn: 39210
2006-11-21 06:18:11 +00:00
Chris Lattner b352e3edb5 Change KeepComments/KeepMacroComments modes to be facets of the preprocessor
state, not aspects of the language standard being parsed.

llvm-svn: 39209
2006-11-21 06:17:10 +00:00
Chris Lattner 96327eaa52 first step refactoring driver so that it can process multiple input files
at once.

llvm-svn: 39207
2006-11-21 05:52:55 +00:00
Chris Lattner 87f267ef4e eliminate global variables now that PPCallbacks can have state
llvm-svn: 39205
2006-11-21 05:02:33 +00:00
Chris Lattner b8d6d5a81d Formalize preprocessor callbacks together into a PPCallbacks structure, instead
of having a loose collection of function pointers.  This also allows clients to
maintain state, and reduces the size of the Preprocessor.h interface.

llvm-svn: 39203
2006-11-21 04:09:30 +00:00
Chris Lattner 9916c5ca7e Remove GNU C++ min/max operator extension support, they have been removed
from gcc mainline.

llvm-svn: 39067
2006-10-27 05:24:37 +00:00
Chris Lattner 9f547a4fdd Fix regression in my last commit
llvm-svn: 39013
2006-10-18 06:06:41 +00:00
Chris Lattner 8fd6ee1f2f silence warning
llvm-svn: 39009
2006-10-18 04:02:50 +00:00
Chris Lattner 4beb0381ed Trigraphs are not enabled in -fpreprocessed mode.
llvm-svn: 38796
2006-07-29 17:50:10 +00:00
Chris Lattner cd028fc1f6 Fix -E mode to enter the main file *after* -E mode configures the preprocessor.
llvm-svn: 38784
2006-07-29 06:35:08 +00:00
Chris Lattner 457fc15bc5 Implement comment saving mode: the -C and -CC options.
llvm-svn: 38783
2006-07-29 06:30:25 +00:00
Chris Lattner 331ad778b0 Implement paste avoidance, implementing Preprocessor/output_paste_avoid.c
llvm-svn: 38767
2006-07-28 06:56:01 +00:00
Chris Lattner ecc39e9325 Change Lexer::Stringify to not add ""'s around the string.
llvm-svn: 38708
2006-07-15 05:23:31 +00:00
Chris Lattner 67c3848e4e Cleanup some obsolete comments.
llvm-svn: 38673
2006-07-04 23:24:26 +00:00
Chris Lattner ef9eae1c44 Change the Preprocessor::getSpelling interface to let it be zero-copy in
the common case.

llvm-svn: 38671
2006-07-04 22:33:12 +00:00
Chris Lattner f46be6cb02 Switch to using unix "write" when available, instead of stdio. This speeds up
-E -P mode by 10% (i.e. takes away almost all i/o time).

llvm-svn: 38669
2006-07-04 22:19:33 +00:00
Chris Lattner 728b4dc26a improve comments
llvm-svn: 38668
2006-07-04 21:28:37 +00:00
Chris Lattner ff3f5f4b77 fix compile error
llvm-svn: 38667
2006-07-04 21:25:59 +00:00
Chris Lattner 03cbe1fc02 Minor code cleanup
llvm-svn: 38666
2006-07-04 21:24:33 +00:00
Chris Lattner 3338ba87d5 Make -P mode faster and closer to GCC output by not emitting newlines at all.
This allows the SourceManager to not compute line number information for each buffer.

llvm-svn: 38665
2006-07-04 21:19:39 +00:00
Chris Lattner 73b6a2f62d Match GCC behavior better in -P mode.
llvm-svn: 38663
2006-07-04 19:40:52 +00:00
Chris Lattner deb3701c23 Switch from using iostreams to using stdio for -E mode output. This speeds
up clang -E iostream by 30%.

llvm-svn: 38660
2006-07-04 19:24:06 +00:00