summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a nasty corner case that Neil noticed in PR1900, where we would Chris Lattner2008-01-071-0/+4
| | | | | | | | | | | | incorrectly apply the multiple include optimization to files with guards like: #if !defined(x) MACRO where MACRO could expand to different things in different contexts. Thanks Neil! llvm-svn: 45716
* Fix typoNate Begeman2008-01-071-1/+1
| | | | llvm-svn: 45682
* Don't attribute in file headers anymore. See llvmdev for theChris Lattner2007-12-291-2/+2
| | | | | | discussion of this change. llvm-svn: 45410
* Interned MainFileID within SourceManager. Since SourceManager is referenced byTed Kremenek2007-12-191-1/+4
| | | | | | | | | 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
* TargetInfo no longer includes a reference to SourceManager.Ted Kremenek2007-12-121-8/+10
| | | | | | | | | | | | | | | Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation. Added many utility methods to FullSourceLoc to provide shorthand for: FullLoc.getManager().someMethod(FullLoc.getLocation()); instead we have: FullLoc.someMethod(); Modified TextDiagnostics (and related classes) to use this short-hand. llvm-svn: 44957
* Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. NowTed Kremenek2007-12-111-2/+2
| | | | | | | | | | | | | | | | | | SourceManager is passed by reference, allowing the SourceManager to be associated with a specific translation unit, and not the entire execution of the driver. Modified all users of Diagnostics to comply with this new interface. Integrated SourceManager as a member variable of TargetInfo. TargetInfo will eventually be associated with a single translation unit (just like SourceManager). Made the SourceManager reference in ASTContext private. Provided accessor getSourceManager() for clients to use instead. Modified clients to comply with new interface. llvm-svn: 44878
* Add dumping support for locations, make -dumptokens print out the locationChris Lattner2007-12-091-1/+20
| | | | | | info of each token. llvm-svn: 44741
* Fix PR1820, an incredibly subtle macro expansion bug that Neil discovered.Chris Lattner2007-11-231-0/+10
| | | | | | Neil, please review this fix. llvm-svn: 44285
* fix a bug Steve noticed, where a #import of the main file itself would fail.Chris Lattner2007-11-151-1/+6
| | | | llvm-svn: 44178
* Since we are all working on Leopard, change the built-in MacOS X version ↵Steve Naroff2007-11-101-1/+1
| | | | | | number (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) to target Leopard. This is only a short term solution, until the clang driver implements the "-mmacosx-version-min" flag (which will compute this value based on the target). llvm-svn: 43981
* Implement a more sensible strategy for ObjC built-in types (addressing a ↵Steve Naroff2007-10-311-27/+1
| | | | | | | | | | | | long standing FIXME in Sema::GetObjcIdType()). This removes several gross hacks to work around the previous "lazy" behavior. Two notes: - MinimalActions still needs to be taught about the built-in types (This breaks one of the -noop test cases). I started this, then added a FIXME. - I didn't convert Sema::GetObjcProtoType() yet. llvm-svn: 43567
* Checking in some code that is still under construction.Steve Naroff2007-10-311-1/+0
| | | | | | I need to (finally) change the way Class/id/SEL/IMP are built-in...the current approach of doing it in the preprocessor is "broken". The other problem is Sema::GetObjcIdType/GetObjcSelType/GetObjcClassType, the hooks that initialize ASTContext lazily. These built-in types need to be done up front... llvm-svn: 43557
* Add some plumbing to help cope with rewriting "id<p>", "Class<p>*".Steve Naroff2007-10-311-1/+1
| | | | llvm-svn: 43543
* Stop pre-defining objc_msgSend/objc_getClass in the preprocessor. Instead, I ↵Steve Naroff2007-10-301-15/+1
| | | | | | generate these declaration on the fly when rewriting a message expression. llvm-svn: 43529
* Avoid using macro expansions, which causes these to come out in -E mode.Chris Lattner2007-10-301-6/+6
| | | | llvm-svn: 43505
* Incorporate some feedback from Chris...Steve Naroff2007-10-241-1/+1
| | | | llvm-svn: 43285
* - Add rewrite rule for @class.Steve Naroff2007-10-231-0/+17
| | | | | | | - Add setter/getter to ObjcClassDecl. - Predefined key runtime functions. llvm-svn: 43257
* Predefine all the ObjC goodies from <objc/objc.h>. Removed all the ObjC ↵Steve Naroff2007-10-171-3/+21
| | | | | | goodies from the respective test files. Moving forward, it will be very nice to assume these builtin! llvm-svn: 43077
* resolve a fixme, by moving __builtin_va_list to a more logicalChris Lattner2007-10-101-0/+6
| | | | | | place and making it correctly parameterized on the target. llvm-svn: 42830
* Add a dummy for the id typedef. Steve, plz fill this in. :)Chris Lattner2007-10-091-0/+7
| | | | llvm-svn: 42819
* Make a significant change to invert the control flow handlingChris Lattner2007-10-091-7/+131
| | | | | | | | | | | | | | | | | | | | | | 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
* Switch lexer/pp over to new Token::is/isNot apiChris Lattner2007-10-091-32/+32
| | | | llvm-svn: 42799
* improve layering:Chris Lattner2007-10-071-21/+43
| | | | | | | | | Now instead of IdentifierInfo knowing anything about MacroInfo, only the preprocessor knows. This makes MacroInfo truly private to the Lex library (and its direct clients) instead of being accessed in the Basic library. llvm-svn: 42727
* change calls to getMacroInfo into hasMacroDefinition() where possible.Chris Lattner2007-10-071-3/+3
| | | | llvm-svn: 42726
* If we see an invalid #ifdef directive, enter a conditional compilation regionChris Lattner2007-09-241-1/+6
| | | | | | so that we don't emit an error on the #endif. Suggestion by Neil. llvm-svn: 42258
* Add #include required on win32.Chris Lattner2007-09-031-0/+1
| | | | llvm-svn: 41686
* Fix a scoping bug that apple gcc doesn't catch for some reason.Chris Lattner2007-07-231-1/+2
| | | | llvm-svn: 40450
* implement a missing feature in the #include handler, whereChris Lattner2007-07-231-9/+81
| | | | | | | | it did not handle <xyz> headers coming from macro expansions. This requires special treatment, as the include name is lexed as multiple tokens, which require reassembly before processing. llvm-svn: 40418
* refactor the interface to Preprocessor::GetIncludeFilenameSpelling,Chris Lattner2007-07-231-9/+9
| | | | | | no functionality changes. llvm-svn: 40414
* fix a bug getting the spelling of an identifier tokenChris Lattner2007-07-221-1/+7
| | | | | | | that required cleaning. If the token required cleaning, don't include the cleaned tokens in the returned length. llvm-svn: 40410
* At one point there were going to be lexer and parser tokens.Chris Lattner2007-07-201-54/+54
| | | | | | | 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
* simplify the lexer ctor to take a SLoc instead of a sloc and a redundant ↵Chris Lattner2007-07-201-5/+2
| | | | | | buffer*. llvm-svn: 40104
* Reimplement SourceLocation. Instead of having a Chris Lattner2007-07-201-28/+35
| | | | | | | | | | | | | | | | | 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
* Fix a stringizing bug that Neil noticed. We should preprocess this:Chris Lattner2007-07-191-2/+4
| | | | | | | | | | #define t(x) #x t(a c) to "a c", not "ac". llvm-svn: 40060
* Correctly respect C99 5.1.1.2p4 when searching for the first '(' ofChris Lattner2007-07-191-3/+13
| | | | | | a function-like macro invocation. Patch contributed by Neil Booth. llvm-svn: 40026
* Add a new Preprocessor::AdvanceToTokenCharacter method which, given a slocChris Lattner2007-07-161-0/+37
| | | | | | | specifying the start of a token and a logical (phase 3) character number, returns a sloc representing the input character corresponding to it. llvm-svn: 39905
* Cache macro expander objects to avoid thrashing malloc in heavy expansion ↵Chris Lattner2007-07-151-6/+33
| | | | | | | | | situations. This doesn't significantly improve carbon.h, but it does speed up INPUTS/macro_pounder_obj.c by 48% llvm-svn: 39864
* switch function-like macros from using a vector for their arguments to anChris Lattner2007-07-141-4/+13
| | | | | | | explicitly new'd array. The array never mutates once created, so a vector is overkill. llvm-svn: 39862
* expose an iterator interface to getReplacementTokens instead of the ↵Chris Lattner2007-07-141-1/+2
| | | | | | datastructure itself. llvm-svn: 39860
* split function-like and object-like macro body parsing to make theChris Lattner2007-07-141-24/+36
| | | | | | code more obvious. llvm-svn: 39859
* remove use of alloca.Chris Lattner2007-07-131-2/+3
| | | | llvm-svn: 39815
* Solaris needs an included header for allocaGabor Greif2007-07-131-0/+1
| | | | llvm-svn: 39797
* Finally bite the bullet and make the major change: split the clang namespaceChris Lattner2007-06-151-4/+3
| | | | | | | | | | | | | 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
* Implement support for formal arguments. We can now compile this:Chris Lattner2007-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | int test(int X, short Y, float Z) { return (int)(X*Y+Z); } to: define i32 @test(i32 %X, i16 %Y, float %Z) { entry: %promote = sext i16 %Y to i32 ; <i32> [#uses=1] %mul = mul i32 %promote, %X ; <i32> [#uses=1] %promote3 = sitofp i32 %mul to float ; <float> [#uses=1] %add = add float %promote3, %Z ; <float> [#uses=1] %conv = fptosi float %add to i32 ; <i32> [#uses=1] ret i32 %conv } with: $ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis llvm-svn: 39652
* Bug #:Steve Naroff2007-06-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Implement semantic analysis for vector_size attribute! We now produce the following diagnostics... [administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang vector.c vector.c:2:29: error: attribute requires precisely 1 argument typedef int __attribute__(( vector_size )) tVecp; ^ vector.c:7:32: error: attribute requires precisely 1 argument extern int foo __attribute__(( vector_size )); ^ vector.c:8:34: error: attribute requires precisely 1 argument extern float bar __attribute__(( vector_size(16,18) )); ^ vector.c:11:34: error: vector_size requires integer constant (attribute ignored) extern char foo2 __attribute__(( vector_size(16.2) )); ^ ~~~~ vector.c:21:47: error: invalid vector type 'struct s' struct s { int a; } structVar __attribute__(( vector_size(16) )); llvm-svn: 39643
* Add support for inserting up to 10 strings in a diagnostic, with %0, %1, %2,Chris Lattner2007-05-161-1/+5
| | | | | | etc. llvm-svn: 39447
* Remove the clang::SourceBuffer class, switch to the llvm::MemoryBuffer class.Chris Lattner2007-04-291-1/+1
| | | | llvm-svn: 39426
* Include the filename being looked up in an error message. This gives us stuffChris Lattner2007-04-101-2/+4
| | | | | | | | | | | | | | | | | like this: t3.c:5:10: error: 'vers2.h' file not found #include xstr(INCFILE(2).h) ^ instead of: t3.c:5:10: error: file not found #include xstr(INCFILE(2).h) ^ which is useful if the #include name is generated through macro expansion. llvm-svn: 39398
* switch to using iterators instead of stringmap visitors.Chris Lattner2007-02-111-16/+8
| | | | llvm-svn: 39336
* CStringMap -> StringMap.Chris Lattner2007-02-081-1/+1
| | | | llvm-svn: 39334
OpenPOWER on IntegriCloud