summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* The __weak and __strong defines are common to all darwin targetsChris Lattner2009-04-071-8/+2
| | | | | | | | | | | and are even set in C mode. As such, move them to Targets.cpp. __OBJC_GC__ is also darwin specific, but seems reasonable to always define it when in objc-gc mode. This fixes rdar://6761450 llvm-svn: 68494
* Define __OPTIMIZE__ and __OPTIMIZE_SIZE__ if the -O[12] and -Os flags are ↵Anders Carlsson2009-04-061-0/+5
| | | | | | passed to the compiler. llvm-svn: 68450
* Put back __OBJC2__ definition.Fariborz Jahanian2009-03-261-4/+0
| | | | llvm-svn: 67802
* - Minor change to dump of ivar layout map.Fariborz Jahanian2009-03-261-0/+4
| | | | | | | | - Temporarily undef'ed __OBJC2__ in nonfragile objc abi mode as it was forcing ivar synthesis in a certain project which clang does not yet support. llvm-svn: 67766
* change the __VERSION__ string to be more sensible. It would be useful to ↵Chris Lattner2009-03-241-2/+1
| | | | | | include the clang version # too. llvm-svn: 67619
* rename the <predefines> buffer to <built-in> to solve PR3849.Chris Lattner2009-03-201-4/+11
| | | | | | | | | | | | | | Add a #include directive around the command line buffer so that diagnostics generated from -include directives get diagnostics like: In file included from <built-in>:98: In file included from <command line>:3: ./t.h:2:1: warning: type specifier missing, defaults to 'int' b; ^ llvm-svn: 67396
* pass LangOptions into TargetInfo::getTargetDefines, so that targetsChris Lattner2009-03-201-1/+1
| | | | | | can have language-specific defines. llvm-svn: 67375
* (Hopefully) instantiate dependent array types correctly.Anders Carlsson2009-03-151-0/+3
| | | | llvm-svn: 67032
* make Preprocessor::Diags be a pointer instead of a reference.Chris Lattner2009-03-131-1/+1
| | | | llvm-svn: 66955
* fix PR3768, Clang does -D__STDC_HOSTED__=1, even if -ffreestanding is passed.Chris Lattner2009-03-091-1/+5
| | | | llvm-svn: 66474
* Fix warnings in build on clang-x86_64-freebsd buildbot.Mike Stump2009-03-071-1/+1
| | | | llvm-svn: 66344
* improve compatibility with GCC 4.4, patch by Michel Salim (PR3697)Chris Lattner2009-03-021-0/+1
| | | | llvm-svn: 65884
* Clean up and document code modification hints.Douglas Gregor2009-02-271-1/+19
| | | | llvm-svn: 65641
* switch the macroinfo argument lists from being allocated off the heapChris Lattner2009-02-201-1/+1
| | | | | | | | | to being allocated from the same bumpptr that the MacroInfo objects themselves are. This speeds up -Eonly cocoa.h pth by ~4%, fsyntax-only is barely measurable. llvm-svn: 65195
* detemplatify setArgumentList and some other cleanups.Chris Lattner2009-02-201-1/+0
| | | | llvm-svn: 65187
* require the MAcroInfo objects are explcitly destroyed.Chris Lattner2009-02-201-0/+1
| | | | llvm-svn: 65179
* update comment.Chris Lattner2009-02-181-5/+1
| | | | llvm-svn: 64939
* Fix some issues handling sub-token locations that come from macro expansions.Chris Lattner2009-02-181-1/+1
| | | | | | | | | | | | | | | We now emit: t.m:6:15: warning: field width should have type 'int', but argument has type 'unsigned int' printf(STR, (unsigned) 1, 1); ^ ~~~~~~~~~~~~ t.m:3:18: note: instantiated from: #define STR "abc%*ddef" ^ which has the correct location in the string literal in the note line. llvm-svn: 64936
* define __OBJC2__ for objc's nonfragile abi.Fariborz Jahanian2009-02-161-0/+2
| | | | llvm-svn: 64642
* Add support for deprecated members of RecordDecls (e.g. struct fields).Chris Lattner2009-02-161-2/+0
| | | | llvm-svn: 64634
* track "just a little more" location information for macro instantiations.Chris Lattner2009-02-151-1/+2
| | | | | | | | | | | | Now instead of just tracking the expansion history, also track the full range of the macro that got replaced. For object-like macros, this doesn't change anything. For _Pragma and function-like macros, this means we track the locations of the ')'. This is required for PR3579 because apparently GCC uses the line of the ')' of a function-like macro as the location to expand __LINE__ to. llvm-svn: 64601
* Give TargetInfo a new IntPtrType to hold the intptr_t type forChris Lattner2009-02-131-0/+1
| | | | | | | | | | a target. Make Preprocessor.cpp define a new __INTPTR_TYPE__ macro based on this. On linux/32, set intptr_t to int, instead of long. This fixes PR3563. llvm-svn: 64495
* Fix rdar://6562329, a static analyzer crash Ted noticed on Chris Lattner2009-02-131-1/+4
| | | | | | | | | | | | | | wine sources. This was happening because HighlightMacros was calling EnterMainFile multiple times on the same preprocessor object and getting an assert due to the new #line stuff (the file in question was bison output with #line directives). The fix for this is to not reenter the file. Instead, relex the tokens in raw mode, swizzle them a bit and repreprocess the token stream. An added bonus of this is that rewrite macros will now hilight the macro definition as well as its uses. Woo. llvm-svn: 64480
* PTH: Cache stat information for files in the PTH file. Hook up FileManagerTed Kremenek2009-02-121-0/+6
| | | | | | | | | | | | | to use this stat information in the PTH file using a 'StatSysCallCache' object. Performance impact (Cocoa.h, PTH): - number of stat calls reduces from 1230 to 425 - fsyntax-only: time improves by 4.2% We can reduce the number of stat calls to almost zero by caching negative stat calls and directory stat calls in the PTH file as well. llvm-svn: 64353
* Export __INT8_TYPE__ / __INT16_TYPE__ / __INT32_TYPE__ / __INT64_TYPE__Chris Lattner2009-02-061-8/+29
| | | | | | | in a gcc 4.5 compatible way so that stdint.h can follow the compiler's notion of types. llvm-svn: 63976
* -funsigned-char sets __CHAR_UNSIGNED__Chris Lattner2009-02-061-0/+3
| | | | llvm-svn: 63942
* Add an implementation of -dM that follows GCC closely enough to permitChris Lattner2009-02-061-1/+1
| | | | | | | diffing the output of: clang -dM -o - -E -x c foo.c | sort llvm-svn: 63926
* get __WCHAR_TYPE__ from the targetinfo hookChris Lattner2009-02-061-4/+4
| | | | llvm-svn: 63920
* simplify and refactor a bunch of type definition code in PreprocessorChris Lattner2009-02-061-60/+13
| | | | | | predefines buffer initialization. llvm-svn: 63919
* remove some ad-hocery and use DefineTypeSize for more things.Chris Lattner2009-02-061-27/+7
| | | | | | Now you too can have a 47 bit long long! llvm-svn: 63918
* refactor some code into a DefineTypeSize function.Chris Lattner2009-02-061-6/+21
| | | | llvm-svn: 63917
* correct and generalize computation of __INTMAX_MAX__.Chris Lattner2009-02-051-4/+16
| | | | llvm-svn: 63848
* fix some differences between apple gcc and clang on darwin/x86-32.Chris Lattner2009-02-051-2/+8
| | | | llvm-svn: 63846
* move library-specific diagnostic headers into library private dirs. ReduceChris Lattner2009-01-291-1/+1
| | | | | | redundant #includes. Patch by Anders Johnsen! llvm-svn: 63271
* Split the single monolithic DiagnosticKinds.def file into oneChris Lattner2009-01-271-1/+1
| | | | | | | | | .def file for each library. This means that adding a diagnostic to sema doesn't require all the other libraries to be rebuilt. Patch by Anders Johnsen! llvm-svn: 63111
* Introduce a new PresumedLoc class to represent the concept of a locationChris Lattner2009-01-271-11/+1
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 63098
* PTH: Use Token::setLiteralData() to directly store a pointer to cached ↵Ted Kremenek2009-01-271-27/+2
| | | | | | | | | | spelling data in the PTH file. This removes a ton of code for looking up spellings using sourcelocations in the PTH file. This simplifies both PTH-generation and reading. Performance impact for -fsyntax-only on Cocoa.h (with Cocoa.h in the PTH file): - PTH generation time improves by 5% - PTH reading improves by 0.3%. llvm-svn: 63072
* This change refactors some of the low-level lexer interfaces a bit.Chris Lattner2009-01-261-6/+22
| | | | | | | | | | | | | 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. llvm-svn: 63028
* This is a follow-up to r62675:Chris Lattner2009-01-231-4/+0
| | | | | | | | | | Refactor how the preprocessor changes a token from being an tok::identifier to a keyword (e.g. tok::kw_for). Instead of doing this in HandleIdentifier, hoist this common case out into the caller, so that every keyword doesn't have to go through HandleIdentifier. This drops time in HandleIdentifier from 1.25ms to .62ms, and speeds up clang -Eonly with PTH by about 1%. llvm-svn: 62855
* Add a bit to IdentifierInfo that acts as a simple predicate whichChris Lattner2009-01-211-0/+5
| | | | | | | | | tells us whether Preprocessor::HandleIdentifier needs to be called. Because this method is only rarely needed, this saves a call and a bunch of random checks. This drops the time in HandleIdentifier from 3.52ms to .98ms on cocoa.h on my machine. llvm-svn: 62675
* Run destructors of MacroInfo objects to free memory they allocate. This ↵Ted Kremenek2009-01-191-1/+3
| | | | | | addresses <rdar://problem/6506035>. llvm-svn: 62498
* in Preprocessor::AdvanceToTokenCharacter, don't actually botherChris Lattner2009-01-171-9/+7
| | | | | | creating a whole lexer when we just want one static method. llvm-svn: 62420
* suck the call to "getSpellingLoc" that all clients do intoChris Lattner2009-01-171-4/+2
| | | | | | the implementation of PTHManager::getSpelling. llvm-svn: 62408
* this massive patch introduces a simple new abstraction: it makesChris Lattner2009-01-171-13/+8
| | | | | | | | | | | | | | | "FileID" a concept that is now enforced by the compiler's type checker instead of yet-another-random-unsigned floating around. This is an important distinction from the "FileID" currently tracked by SourceLocation. *That* FileID may refer to the start of a file or to a chunk within it. The new FileID *only* refers to the file (and its #include stack and eventually #line data), it cannot refer to a chunk. FileID is a completely opaque datatype to all clients, only SourceManager is allowed to poke and prod it. llvm-svn: 62407
* more SourceLocation lexicon change: instead of referring to theChris Lattner2009-01-161-2/+2
| | | | | | "logical" location, refer to the "instantiation" location. llvm-svn: 62316
* remove obsolete comment which happened to go over 80 cols.Chris Lattner2009-01-161-8/+1
| | | | llvm-svn: 62313
* remove an unneeded const_cast.Chris Lattner2009-01-161-7/+5
| | | | llvm-svn: 62311
* Change some terminology in SourceLocation: instead of referring to Chris Lattner2009-01-161-15/+15
| | | | | | | the "physical" location of tokens, refer to the "spelling" location. This is more concrete and useful, tokens aren't really physical objects! llvm-svn: 62309
* IdentifierInfo:Ted Kremenek2009-01-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - IdentifierInfo can now (optionally) have its string data not be co-located with itself. This is for use with PTH. This aspect is a little gross, as getName() and getLength() now make assumptions about a possible alternate representation of IdentifierInfo. Perhaps we should make IdentifierInfo have virtual methods? IdentifierTable: - Added class "IdentifierInfoLookup" that can be used by IdentifierTable to perform "string -> IdentifierInfo" lookups using an auxilliary data structure. This is used by PTH. - Perform tests show that IdentifierTable::get() does not slow down because of the extra check for the IdentiferInfoLookup object (the regular StringMap lookup does enough work to mitigate the impact of an extra null pointer check). - The upshot is that now that some IdentifierInfo objects might be owned by the IdentiferInfoLookup object. This should be reviewed. PTH: - Modified PTHManager::GetIdentifierInfo to *not* insert entries in IdentifierTable's string map, and instead create IdentifierInfo objects on the fly when mapping from persistent IDs to IdentifierInfos. This saves a ton of work with string copies, hashing, and StringMap lookup and resizing. This change was motivated because when processing source files in the PTH cache we don't need to do any string -> IdentifierInfo lookups. - PTHManager now subclasses IdentifierInfoLookup, allowing clients of IdentifierTable to transparently use IdentifierInfo objects managed by the PTH file. PTHManager resolves "string -> IdentifierInfo" queries by doing a binary search over a sorted table of identifier strings in the PTH file (the exact algorithm we use can be changed as needed). These changes lead to the following performance changes when using PTH on Cocoa.h: - fsyntax-only: 10% performance improvement - Eonly: 30% performance improvement llvm-svn: 62273
* PTH:Ted Kremenek2009-01-131-2/+2
| | | | | | | | | | | | | | | | | - Use canonical FileID when using getSpelling() caching. This addresses some cache misses we were seeing with -fsyntax-only on Cocoa.h - Added Preprocessor::getPhysicalCharacterAt() utility method for clients to grab the first character at a specified sourcelocation. This uses the PTH spelling cache. - Modified Sema::ActOnNumericConstant() to use Preprocessor::getPhysicalCharacterAt() instead of SourceManager::getCharacterData() (to get PTH hits). These changes cause -fsyntax-only to not page in any sources from Cocoa.h. We see a speedup of 27%. llvm-svn: 62193
OpenPOWER on IntegriCloud