Commit Graph

64 Commits

Author SHA1 Message Date
Chris Lattner b03dc76499 clean up a bunch of fixme's I added, by moving
DirectoryLookup::DirType into SourceManager.h

llvm-svn: 56692
2008-09-26 21:18:42 +00:00
Chris Lattner 71efd8159e fit in 80 cols.
llvm-svn: 56687
2008-09-26 20:05:14 +00:00
Daniel Dunbar e778131386 Make clang preprocessed output a bit more like gcc output.
llvm-svn: 56636
2008-09-26 01:13:35 +00:00
Daniel Dunbar 98e0e535bd Workaround gcc bug causing crash on our preprocessed outputs.
- 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.

llvm-svn: 55825
2008-09-05 03:22:57 +00:00
Chris Lattner cdceb08ca2 Use raw_ostream to output an unsigned.
llvm-svn: 54973
2008-08-19 04:23:15 +00:00
Chris Lattner 286e5e6c61 printing with an unspecified dest means to print to stdout.
llvm-svn: 54872
2008-08-17 07:09:08 +00:00
Chris Lattner b52817bff0 don't delete a variable on the stack
llvm-svn: 54871
2008-08-17 07:07:01 +00:00
Chris Lattner 7459c86a29 simplify this code a bit more.
llvm-svn: 54864
2008-08-17 03:54:39 +00:00
Chris Lattner 068529a243 remove global variables for output stream.
llvm-svn: 54861
2008-08-17 03:12:02 +00:00
Chris Lattner b5a92f8648 Switch to shared raw_ostream code instead of having it be clang specific.
This also helps the eventual distcc project.

llvm-svn: 54858
2008-08-17 01:47:12 +00:00
Chris Lattner 47fb9efa5d Fix rdar://5843510 don't assert and die when an invalid output
file is specified, print a happy little error message.

llvm-svn: 49518
2008-04-11 06:14:11 +00:00
Chris Lattner 2163265b53 Fix rdar://5846705: "clang -E foo.c -o foo.i" should remove foo.i on error.
llvm-svn: 49368
2008-04-08 04:16:20 +00:00
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