Граф коммитов

409 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 2197c96354 Fix some issues handling sub-token locations that come from macro expansions.
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 18:52:52 +00:00
Fariborz Jahanian 2639e4f884 define __OBJC2__ for objc's nonfragile abi.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 18:28:48 +00:00
Chris Lattner cfdff38e8e Add support for deprecated members of RecordDecls (e.g. struct fields).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64634 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 17:07:21 +00:00
Chris Lattner 6678133b8c add a new SourceManager::getInstantiationRange helper method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64606 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 21:26:50 +00:00
Chris Lattner 081927bbab fix PR3579: __LINE__ expands to the presumed location of the
*end* of a macro instantiation, not the start of it.  This is
really all about bug-for-bug compatibility with GCC, but not
doing this breaks the FreeBSD kernel.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64604 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 21:06:39 +00:00
Chris Lattner e7fb48466a track "just a little more" location information for macro instantiations.
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 20:52:18 +00:00
Chris Lattner 67116083e7 add an assertion from Alexei Svitkine!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64503 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 23:06:48 +00:00
Chris Lattner 6ad474f82f Give TargetInfo a new IntPtrType to hold the intptr_t type for
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64495 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 22:28:55 +00:00
Ted Kremenek ad6ce5cb0e PTH: Cache directory and negative 'stat' calls. This gives us a 1% performance improvement on Cocoa.h (fsyntax-only+PTH).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64490 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 22:07:44 +00:00
Chris Lattner 05db4278ec Fix rdar://6562329, a static analyzer crash Ted noticed on
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 19:33:24 +00:00
Ted Kremenek a4b44dd9d3 Add some boilerplate to the PTH file to prepare for the caching of stats for directories (and negative stats too).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64477 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 19:13:46 +00:00
Mike Stump 47837874d9 Fix cmake builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64455 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 15:42:50 +00:00
Eli Friedman 03a2807021 Fix gcc warning: gcc correctly notes that const-qualifying the return
type doesn't do anything.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64424 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 01:02:29 +00:00
Chris Lattner d7038e18ef factor token concatenation avoidance logic out of
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-13 00:46:04 +00:00
Daniel Dunbar 82320e9460 Fix assertion when input is an empty string.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64397 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 19:31:53 +00:00
Ted Kremenek 5f747d187b Re-enable PTH stat caching. All tests pass now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64356 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 03:45:39 +00:00
Ted Kremenek d69ab87dd9 Fix bad reading of bytes in ReadUnalignedLE64() (copy-paste error).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 03:39:55 +00:00
Ted Kremenek c8b44f5997 Temporarily disable PTH stat caching as it appears to be failing on some machines.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64354 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 03:36:54 +00:00
Ted Kremenek 337edcdbec PTH: Cache stat information for files in the PTH file. Hook up FileManager
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64353 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 03:26:59 +00:00
Ted Kremenek a4bd8eb4d6 PTH: Have meta data be at the beginning of the PTH file, not the end.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64338 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-11 23:34:32 +00:00
Ted Kremenek 7e3a004c6e PTH: Replace string identifier to persistent ID lookup with a hashtable. This is
actually *slightly* slower than the binary search. Since this is algorithmically
better, further performance tuning should be able to make this faster.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64326 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-11 21:29:16 +00:00
Ted Kremenek f1de4649e9 PTH: Don't emit the PTH offset of the IdentifierInfo string data as that data is
referenced by other tables.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64304 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-11 16:06:55 +00:00
Ted Kremenek d8c02929fe PTH: Replace ad hoc 'file name' -> 'PTH data' lookup table in the PTH file with an on-disk chained hash table. This data structure is implemented using templates, and will be used to replace similar data structures. This change leads to no visibile performance impact on Cocoa.h, but now we only pay a price for the table on order with the number of files accessed and not the number in the PTH file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64245 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-10 22:16:22 +00:00
Chris Lattner 03c972767e Export __INT8_TYPE__ / __INT16_TYPE__ / __INT32_TYPE__ / __INT64_TYPE__
in a gcc 4.5 compatible way so that stdint.h can follow the compiler's 
notion of types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63976 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 22:59:26 +00:00
Chris Lattner f668a714b1 -funsigned-char sets __CHAR_UNSIGNED__
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63942 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 18:20:57 +00:00
Chris Lattner f73903a1de Add an implementation of -dM that follows GCC closely enough to permit
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-06 06:45:26 +00:00
Chris Lattner 09b5c1d08a add interface for walking macro table.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63925 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 06:26:42 +00:00
Chris Lattner 3c3b155ea8 get __WCHAR_TYPE__ from the targetinfo hook
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63920 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 05:06:07 +00:00
Chris Lattner 2b5abf515f simplify and refactor a bunch of type definition code in Preprocessor
predefines buffer initialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63919 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 05:04:11 +00:00
Chris Lattner 86d85b8e5e remove some ad-hocery and use DefineTypeSize for more things.
Now you too can have a 47 bit long long!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63918 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 04:55:18 +00:00
Chris Lattner 996feccdec refactor some code into a DefineTypeSize function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63917 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 04:50:25 +00:00
Chris Lattner 659dc14559 correct and generalize computation of __INTMAX_MAX__.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63848 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 07:27:41 +00:00
Chris Lattner d427ad4cce fix some differences between apple gcc and clang on darwin/x86-32.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 07:19:24 +00:00
Chris Lattner be5c64d7a7 Fix PR3464 by searching for headers from the predefines
buffer as if the #include happened from the main file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04 19:45:07 +00:00
Chris Lattner 137b6a6149 Implement handling of file entry/exit notifications from GNU
line markers, including maintenance of the virtual include stack.

For something like this:

# 42 "bar.c" 1
# 142 "bar2.c" 1

#warning zappa
# 92 "bar.c" 2
#warning gonzo
# 102 "foo.c" 2
#warning bonkta


we now produce these three warnings:

#1:
In file included from foo.c:3:
In file included from bar.c:42:
bar2.c:143:2: warning: #warning zappa
#warning zappa
 ^

#2:
In file included from foo.c:3:
bar.c:92:2: warning: #warning gonzo
#warning gonzo
 ^

#3:
foo.c:102:2: warning: #warning bonkta
#warning bonkta
 ^




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63722 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04 06:25:26 +00:00
Chris Lattner 9d79ebac47 propagate linemarker flags down into the the line table, currently
ignoring include stack push/pop info though.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63719 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04 05:21:58 +00:00
Chris Lattner 4c4ea17d7f stub out basic #line handling calls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63667 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-03 21:52:55 +00:00
Chris Lattner 500d3297d2 move library-specific diagnostic headers into library private dirs. Reduce
redundant #includes.  Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63271 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29 05:15:15 +00:00
Ted Kremenek 26555b18aa Add more PTH diagnostics for invalid PTH files, etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63232 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 21:02:43 +00:00
Ted Kremenek 8a6aec620d Enhance PTHManager::Create() to take an optional Diagnostic* argument that can be used to report issues such as a missing PTH file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 20:49:33 +00:00
Chris Lattner 20c6b3b85e Split the single monolithic DiagnosticKinds.def file into one
.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!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63111 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 18:30:58 +00:00
Chris Lattner b9c3f966b1 Introduce a new PresumedLoc class to represent the concept of a location
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-27 07:57:44 +00:00
Chris Lattner 202fd2c4fb Fix a bug that I noticed by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63094 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 05:34:03 +00:00
Ted Kremenek 277faca30c PTH: Use Token::setLiteralData() to directly store a pointer to cached 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%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 00:01:05 +00:00
Chris Lattner 363fdc2965 Fix a bug I introduced in my changes, which caused MeasureTokenLength
to crash when given an instantiation location.  Thanks to Fariborz for
the testcase.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63057 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 22:24:27 +00:00
Ted Kremenek 4adc71ae2c Silence warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63054 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 22:16:12 +00:00
Ted Kremenek 67d15050bb Add version number checking to PTH files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 21:50:21 +00:00
Ted Kremenek e1b6498c41 Embed the offset of the PTH table inside the prologue of the PTH file. This will help improve gradual versioning of PTH files instead of relying that the PTH table is at a fixed offset.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63045 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 21:43:14 +00:00
Chris Lattner e7689886d6 remove my hacks that aggressively threw away multiple
instantiation history in an effort to speed up c99-intconst-1.c.
Now that multiple nested instantiations are allowed, we just
make them and don't pay the cost of lookups.  With the other
changes that went in before this, reverting this is actually
a speedup for c99-intconst-1.c, speeding it up from 1.96s to 1.80s,
and preserves much better loc info.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63036 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 20:24:53 +00:00
Chris Lattner 071831dcc7 allow _Pragmas formed from #defines to keep their full instantiation
history



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63035 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 20:15:46 +00:00
Chris Lattner 47246be8ac This change refactors some of the low-level lexer interfaces a bit.
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-26 19:29:26 +00:00
Chris Lattner 5b9a504720 start plumbing together the line table information. So far we just
unique the Filenames in #line directives, assigning them UIDs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63010 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 07:57:50 +00:00
Chris Lattner 478a18ec47 add parsing and constraint enforcement for GNU line marker directives.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63003 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 06:19:46 +00:00
Chris Lattner 099dd05b57 a few minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 05:30:54 +00:00
Chris Lattner 359cc44754 parse and enforce required constraints on #line directives. Right now
we just discard them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62999 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 05:29:08 +00:00
Chris Lattner 7c35122df2 eagerly resolve the spelling locations of macro argument preexpansions.
This reduces fsyntax-only time on c99-intconst-1.c from 2.43s down to 
2.01s (20%), reducing the number of fileid lookups from 2529040 linear 
and 64771121 binary to 5625902 linear and 4151182 binary.

This knocks getFileID down to only 4.6% of compile time on this testcase.
At this point, malloc/free is over 35% of compile time, primarily allocating
MacroArgs objects and their argument preexpansion vectors.

I don't feel like malloc avoiding right now, so I'm just going to call
this good.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 04:33:10 +00:00
Chris Lattner 9bd0d59026 Eagerly resolve the spelling location of the tokens in a definition
of a macro.  Since these tokens may themselves be from macro 
expansions, we need to resolve down to the spelling loc when the
macro ends up being instantiated.  Instead of resolving this for
each token expanded from the macro definition, just do it once when
the macro is defined.  This speeds up clang on c99-intconst-1.c from
2.66s to 2.43s (9.5%), reducing the FileID lookups from 407244 linear and
114175649 binary to 2529040 linear and 64771121 binary.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62993 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 04:06:48 +00:00
Chris Lattner b99bdadf9a Only resolve a macro's instantiation loc once per macro, instead of once
per token lexed from it.  This speeds up clang on c99-intconst-1.c from
the GCC testsuite from 3.64s to 2.66s (36%).  This reduces the number of
binary search FileID lookups from 251570522 to 114175649 on this testcase.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62992 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 03:46:22 +00:00
Chris Lattner de7aeefc55 Check in the long promised SourceLocation rewrite. This lays the
ground work for implementing #line, and fixes the "out of macro ID's" 
problem.

There is nothing particularly tricky about the code, other than the
very performance sensitive SourceManager::getFileID() method.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62978 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 00:43:02 +00:00
Chris Lattner 863c486fcb This is a follow-up to r62675:
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%.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62855 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 18:35:48 +00:00
Chris Lattner fbc33388c1 Update comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62819 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23 00:13:28 +00:00
Chris Lattner 6f78c3b8b9 remove my gross #ifdef's, using portable abstractions now that the 32-bit
load is always aligned.

I verified that the bswap doesn't occur in the assembly code on x86.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62815 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-22 23:50:07 +00:00
Chris Lattner 5ff4317536 remove Read8/Read24, which are dead. Rename Read16/Read32 to be more
descriptive.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62775 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-22 19:48:26 +00:00
Ted Kremenek b248d53f25 Fix <rdar://problem/6512717> by correctly reading the right offset in the token data in PTHLexer::getSourceLocation().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62725 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 22:41:38 +00:00
Chris Lattner d0a69696ac merge two checks for identifiers in the pth loop into one.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62677 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:50:06 +00:00
Chris Lattner d1186fa381 a trivial micro optimization to save a load.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62676 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:45:14 +00:00
Chris Lattner 6a170eb3ea Add a bit to IdentifierInfo that acts as a simple predicate which
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62675 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:43:11 +00:00
Ted Kremenek cdd8f2153e Don't crash on empty PTH files. This fixes <rdar://problem/6512714>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62673 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:34:28 +00:00
Chris Lattner 6353bebfc2 really we only need on Read24!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62672 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:28:57 +00:00
Chris Lattner aff6ef8e7b revert my previous patch, it assumed endianness.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62671 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:21:56 +00:00
Chris Lattner 2f6572bafa minor cleanups: now that tokens are 4-byte aligned in a PTH
file, just load them directly as ints.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62668 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21 07:06:08 +00:00
Ted Kremenek ea9c26b3db Fix: <rdar://problem/6510344> [pth] PTH slows down regular lexer considerably (when it has substantial work)
Changes to IdentifierTable:
- High-level summary: StringMap never owns IdentifierInfos.  It just
references them.
- The string map now has StringMapEntry<IdentifierInfo*> instead of
  StringMapEntry<IdentifierInfo>.  The IdentifierInfo object is
  allocated using the same bump pointer allocator as used by the
  StringMap.

Changes to IdentifierInfo:
- Added an extra pointer to point to the
  StringMapEntry<IdentifierInfo*> in the string map.  This pointer
  will be null if the IdentifierInfo* is *only* used by the PTHLexer
  (that is it isn't in the StringMap).

Algorithmic changes:
- Non-PTH case:
   IdentifierInfo::get() will always consult the StringMap first to
   see if we have an IdentifierInfo object.  If that StringMapEntry
   references a null pointer, we allocate a new one from the BumpPtrAllocator
   and update the reference in the StringMapEntry.
- PTH case:
   We do the same lookup as with the non-PTH case, but if we don't get
   a hit in the StringMap we do a secondary lookup in the PTHManager for
   the IdentifierInfo.  If we don't find an IdentifierInfo we create a
   new one as in the non-PTH case.  If we do find and IdentifierInfo
   in the PTHManager, we update the StringMapEntry to refer to it so
   that the IdentifierInfo will be found on the next StringMap lookup.
   This way we only do a binary search in the PTH file at most once
   for a given IdentifierInfo.  This greatly speeds things up for source
   files containing a non-trivial amount of code.

Performance impact:
   While these changes do add some extra indirection in
   IdentifierTable to access an IdentifierInfo*, I saw speedups even
   in the non-PTH case as well.

   Non-PTH: For -fsyntax-only on Cocoa.h, we see a 6% speedup.
   PTH (with Cocoa.h in token cache): 11% speedup.

   I also did an experiment where we did -fsyntax-only on a source file
   including a large header and Cocoa.h, but the token cache did not
   contain the larger header.  For this file, we were seeing a performance
   *regression* when using PTH of 3% over non-PTH.  Now we are seeing
   a performance improvement of 9%!

Tests:
   The serialization tests are now failing.  I looked at this extensively,
   and I my belief is that this change is unmasking a bug rather than
   introducing a new one.  I have disabled the serialization tests for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62636 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-20 23:28:34 +00:00
Ted Kremenek 7b78b7c6d9 PTH: Emitted tokens now consist of 12 bytes that are loaded used 3 32-bit loads. This reduces user time but increases system time because of the slightly larger PTH file. Although there is no performance win on Cocoa.h and -Eonly, overall this seems like a good step.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62542 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 23:13:15 +00:00
Chris Lattner 8c61b53fdb do not use SourceManager::getFileCharacteristic(FileID), it is not
safe because a #line can change the file characteristic on a per-loc
basis.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62502 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 08:01:53 +00:00
Chris Lattner 693faa6e69 do not use SourceManager::getFileCharacteristic(FileID), it is not
safe because a #line can change the file characteristic on a per-loc
basis.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 07:59:15 +00:00
Chris Lattner a11d617933 Rename SourceManager::getCanonicalFileID -> getFileID. There is
no longer such thing as a non-canonical FileID.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 07:46:45 +00:00
Ted Kremenek 9ee7d456b4 Run destructors of MacroInfo objects to free memory they allocate. This addresses <rdar://problem/6506035>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 07:45:44 +00:00
Chris Lattner 9ebac5e0da Make some enums in SourceLocation private, remove a useless assertion from ScratchBuffer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62492 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 06:57:37 +00:00
Chris Lattner bcc2a67e51 Make SourceLocation::getFileLoc private to reduce the API exposure of
SourceLocation.  This requires making some cleanups to token pasting
and _Pragma expansion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62490 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-19 06:46:35 +00:00
Chris Lattner 4d2d04e9fb fix rdar://6505352 - Bogus warning with -WUndef, a case
Anders noticed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62472 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 21:18:58 +00:00
Chris Lattner 77ecb3a28f rearrange GetIdentifierInfo so that the fast path can be partially inlined into PTHLexer::Lex. This speeds up the user time of PTH -Eonly by another 2ms (4.4%)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62454 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 02:57:21 +00:00
Chris Lattner 898a0bb197 rename some variables, only set a tokens identifierinfo if non-null.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62450 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 02:34:01 +00:00
Chris Lattner f15674c680 On i386 and x86-64, just do unaligned loads
instead of assembling from bytes.  This speeds up -Eonly PTH reading 
of cocoa.h by about 2ms, which is 4.2%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62447 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 02:19:16 +00:00
Chris Lattner 1b5285e1ba switch PTHLexer to use Read32 and friends instead of lots of inlined
copies.  I verified that this causes no performance change in PTH.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62445 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 02:10:31 +00:00
Chris Lattner da9d61c96c switch PTH lexer from using "const char*"s to "const unsigned char*"s
internally.  This is just a cleanup that reduces the need to cast to
unsigned char before assembling a larger integer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62442 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-18 01:57:14 +00:00
Chris Lattner 3b4d5e955e Rename SourceLocation::getFileID to getChunkID, because it returns
the chunk ID not the file ID.  This exposes problems in 
TextDiagnosticPrinter where it should have been using the canonical
file ID but wasn't.  Fix these along the way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62427 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 08:45:21 +00:00
Chris Lattner 8350394c65 simplify some lookups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62426 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 08:30:10 +00:00
Chris Lattner 42e00d19b0 Change the Lexer ctor used to lex _Pragma directives into a static factory
method.  This lets us clean up the interface and make it more obvious that
this method is *really really* _Pragma specific.

Note that _Pragma handling uglifies the Lexer in the critical path.  It would
be very interesting to consider making _Pragma remapping be a new special
lexer class of its own.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62425 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 08:27:52 +00:00
Chris Lattner f056d92e18 simplify PTHManager::CreateLexer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62424 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 08:06:50 +00:00
Chris Lattner 88d3ac1341 Change the Lexer ctor used in the non _Pragma case to take a FileID instead
of a SourceLocation.  This should speed it up and definitely simplifies it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 08:03:42 +00:00
Chris Lattner 28c90ad7ef in Preprocessor::AdvanceToTokenCharacter, don't actually bother
creating a whole lexer when we just want one static method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 07:57:25 +00:00
Chris Lattner 0770dabb1a More simplifications to the lexer ctors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62419 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 07:56:59 +00:00
Chris Lattner de96c0f29c make the verbose raw-lexer ctor fully explicit instead of having
embedded magic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62417 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 07:42:27 +00:00
Chris Lattner 025c3a6640 add a simplified lexer ctor that sets up the lexer to raw-lex an
entire file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62414 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 07:35:14 +00:00
Chris Lattner 22d91ca8d7 refactor some common initialization code out of the two lexer ctors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62411 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 06:55:17 +00:00
Chris Lattner 6b7b840361 suck the call to "getSpellingLoc" that all clients do into
the implementation of PTHManager::getSpelling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62408 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 06:29:33 +00:00
Chris Lattner 2b2453a7d8 this massive patch introduces a simple new abstraction: it makes
"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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62407 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 06:22:33 +00:00
Chris Lattner c6fe32a91c Instead of iterating over FileID's, have PTH generation iterate over the
content cache directly.  Content cache has a 1-1 mapping with fileentries,
whereas multiple FileIDs can be the same FileEntry.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62401 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-17 03:48:08 +00:00
Chris Lattner 8402c73dd8 Fix PR2477 - clang misparses "//*" in C89 mode
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62368 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 22:39:25 +00:00
Chris Lattner 41c3ae108a As a performance optimization, don't bother calling MacroInfo::isIdenticalTo
if warnings in system headers are disabled.  isIdenticalTo can end up 
calling the expensive getSpelling method, and other bad stuff and is 
completely unneeded if the warning will be discarded anyway. rdar://6502956


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62347 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 19:50:11 +00:00
Chris Lattner 172e336b12 only notify callbacks if they exist.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62334 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 19:01:46 +00:00
Chris Lattner a9d9145741 Improve #pragma comment support by building the string argument and
notifying PPCallbacks about it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62333 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 18:59:23 +00:00
Chris Lattner bbee00b645 minor cleanups to StringLiteralParser: no need to pass target info
into its ctor.  Also, make it handle validity checking of pascal
strings instead of making clients do it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62332 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 18:51:42 +00:00
Chris Lattner 636c5ef657 Implement basic support for parsing #pragma comment, a microsoft extension
documented here:
http://msdn.microsoft.com/en-us/library/7f0aews7(VS.80).aspx

This is according to my understanding reading the docs, I don't know if it
really agrees fully with what VC++ allows.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 08:21:25 +00:00
Chris Lattner f7cf85b330 more SourceLocation lexicon change: instead of referring to the
"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-16 07:36:28 +00:00
Chris Lattner fff745ee45 remove obsolete comment which happened to go over 80 cols.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62313 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 07:04:11 +00:00
Chris Lattner 9938d0731d remove an unneeded const_cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62311 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 07:02:14 +00:00
Chris Lattner df7c17a8d0 Change some terminology in SourceLocation: instead of referring to
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-16 07:00:02 +00:00
Ted Kremenek e1deaac733 PTH: Fix termination condition in binary search.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62277 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 19:28:38 +00:00
Ted Kremenek 72b1b15ee8 IdentifierInfo:
- 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62273 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 18:47:46 +00:00
Ted Kremenek 293b4af04c PTH: Embed a persistentID side-table in the PTH file that is sorted in the
lexical order of the corresponding identifier strings. This will be used for a
forthcoming optimization. This slows down PTH generation time by 7%. We can
revert this change if the optimization proves to not be valuable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 01:26:25 +00:00
Ted Kremenek 28396608ec PTH:
- 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%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 23:19:12 +00:00
Ted Kremenek 7bd88aa620 Fix corner cases in PTH getSpelling() binary search.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62187 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 22:16:45 +00:00
Ted Kremenek f02f6f0ee3 PTH: Fix remaining cases where the spelling cache in the PTH file was being missed when it shouldn't. This shaves another 7% off PTH time for -Eonly on Cocoa.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62186 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 22:05:50 +00:00
Ted Kremenek 5f074266cc Enhance PTH 'getSpelling' caching:
- Refactor caching logic into a helper class PTHSpellingSearch
- Allow "random accesses" in the spelling cache, thus catching the remaining
  cases where 'getSpelling' wasn't hitting the PTH cache
  
For -Eonly, PTH, Cocoa.h:
- This reduces wall time by 3% (user time unchanged, sys time reduced)
- This reduces the amount of paged source by 1112K.
  The remaining 1112K still being paged in is from somewhere else
  (investigating).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62009 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 22:05:30 +00:00
Ted Kremenek defb7094c8 Invert assertion condition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61961 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 00:36:11 +00:00
Ted Kremenek 32a8ad526f PTH: Hook up getSpelling() caching in PTHLexer. This results in a nice
performance gain. Here's what we see for -Eonly on Cocoa.h (using PTH):

- wall time decreases by 21% (26% speedup overall)
- system time decreases by 35%
- user time decreases by 6%

These reductions are due to not paging source files just to get spellings for
literals. The solution in place doesn't appear to be 100% yet, as we still see
some of the pages for source files getting mapped in. Using -print-stats, we see
that SourceManager maps in 7179K less bytes of source text (reduction of 75%).
Will investigate why the remaining 25% are getting paged in.

With these changes, here's how PTH compares to non-PTH on Cocoa.h:
  -Eonly: PTH takes 64% of the time as non-PTH (54% speedup)
  -fsyntax-only: PTH takes 89% of the time as non-PTH (11% speedup)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 04:30:32 +00:00
Ted Kremenek b70e3dafb9 PTH:
- Added stub PTHLexer::getSpelling() that will be used for fetching cached
  spellings from the PTH file.  This doesn't do anything yet.
- Added a hook in Preprocessor::getSpelling() to call PTHLexer::getSpelling()
  when using a PTHLexer.
- Updated PTHLexer to read the offsets of spelling tables in the PTH file.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61911 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 02:47:16 +00:00
Chris Lattner c19e8a2b92 Optimize stringification a bit to avoid std::string thrashing and
avoid the version of Preprocessor::getSpelling that returns an 
std::string.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61769 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 23:04:18 +00:00
Chris Lattner e1dccaefe2 simplify Preprocessor::getSpelling now that identifiers carry around
their length.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61734 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05 19:44:41 +00:00
Steve Naroff 86bc6cf05a Add parser support for __forceinline, __w64, __ptr64.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61431 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-25 14:41:26 +00:00
Steve Naroff 239f07384f Add parser support for __cdecl, __stdcall, and __fastcall.
Change preprocessor implementation of _cdecl to reference __cdecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61430 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-25 14:16:32 +00:00
Steve Naroff f59e17ecf0 Add explicit "fuzzy" parse support for Microsoft declspec.
Remove previous __declspec macro that would effectively erase the construct prior to parsing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61422 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-24 20:59:21 +00:00
Ted Kremenek 6aa6ac4b39 Remove old PTH token-generation test harness.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61382 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 19:25:33 +00:00
Ted Kremenek 59d08cb672 PTH: Remove some methods and simplify some conditions in PTHLexer::Lex(). No big functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61381 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 19:24:24 +00:00
Ted Kremenek 18d9afb815 PTH: Use 3 bytes instead of 4 bytes to encode the persistent ID for a token.
- This reduces the PTH size for Cocoa.h by 7%.
- The increases PTH -Eonly speed for Cocoa.h by 0.8%.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61377 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 18:41:34 +00:00
Ted Kremenek 6b1c9708c8 Cosmetics: rename a variable and tighten spacing. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61375 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 18:27:26 +00:00
Ted Kremenek 8f174e173c PTH:
- Encode the token length with 2 bytes instead of 4.
- This reduces the size of the .pth file for Cocoa.h by 12%.
- This speeds up PTH time (-Eonly) on Cocoa.h by 1.6%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61364 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 02:52:12 +00:00
Ted Kremenek 866bdf7454 PTH:
- In PTHLexer::Lex read all of the token data from PTH file before
  constructing the token.  The idea is to enhance locality.
- Do not use Read8/Read32 in PTHLexer::Lex.  Inline these operations manually.
- Change PTHManager::ReadIdentifierInfo() to PTHManager::GetIdentifierInfo().
  They are functionally the same except that PTHLexer::Lex() reads the
  persistent id.

These changes result in a 3.3% speedup for PTH on Cocoa.h (-Eonly).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61363 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 02:30:15 +00:00
Ted Kremenek e5680f3cd6 PTH:
- Embed 'eom' tokens in PTH file.
- Use embedded 'eom' tokens to not lazily generate them in the PTHLexer.
  This means that PTHLexer can always advance to the next token after
  reading a token (instead of buffering tokens using a copy).
- Moved logic of 'ReadToken' into Lex.  GetToken & ReadToken no longer exist.
- These changes result in a 3.3% speedup (-Eonly) on Cocoa.h.
- The code is a little gross.  Many cleanups are possible and should be done.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61360 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-23 01:30:52 +00:00
Steve Naroff 7e0fbb2561 Don't define __STDC__ when compiling with -fms-extensions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61223 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 22:37:25 +00:00
Ted Kremenek 80d2f30593 Use '&' to test StartOfLine flag.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61205 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 18:15:29 +00:00
Ted Kremenek 74c3e6e5e9 Rewrite PTHLexer::DiscardToEndOfLine() to not use GetToken and instead only read the bytes needed to determine if a token is not at the start of the line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61172 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 23:52:11 +00:00
Ted Kremenek 30a12ec2a7 Change PTHLexer::getSourceLocation() to not call GetToken() and instead just read the file offset in the token data buffer directly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61170 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 23:36:32 +00:00
Chris Lattner b60d7999d6 add a dropped word back
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61152 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 21:38:44 +00:00
Ted Kremenek 1c13c4f87e Shadow CurPtr with a local variable in ReadToken.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61145 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 18:38:19 +00:00
Ted Kremenek 0ea76727ae Preprocessor: Allocate MacroInfo objects using a BumpPtrAllocator instead using new/delete. This speeds up -Eonly on Cocoa.h using the regular lexer by 1.8% and the PTHLexer by 3%.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 19:56:42 +00:00
Chris Lattner 9485d2382c eliminate the isCXXNamedOperator function and some string compares and
use identifierinfo instead.  Patch by Chris Goller!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60992 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 20:12:40 +00:00
Ted Kremenek 41a2660377 PTH: Added minor 'sibling jumping' optimization for iterating over the side table used for fast preprocessor block skipping. This has a minor performance improvement when preprocessing Cocoa.h, but can have some wins in pathologic cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60966 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 22:05:38 +00:00
Ted Kremenek 268ee7016a Added PTH optimization to not process entire blocks of tokens that appear in skipped preprocessor blocks. This improves PTH speed by 6%. The code for this optimization itself is not very optimized, and will get cleaned up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60956 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 18:34:08 +00:00
Chris Lattner bc3e984221 rdar://6060752 - don't warn about trigraphs in bcpl-style comments
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60942 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 07:34:39 +00:00
Chris Lattner 47a2b40b7a fix thought-o
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60937 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-12 07:14:34 +00:00
Ted Kremenek fb645b6547 PTH:
- Added a side-table per each token-cached file with the preprocessor conditional stack.  This tracks what #if's are matched with what #endifs and where their respective tokens are in the PTH file.  This will allow for quick skipping of excluded conditional branches in the Preprocessor.
- Performance testing shows the addition of this information (without actually utilizing it) leads to no performance regressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60911 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11 23:36:38 +00:00
Ted Kremenek cd223444d1 PTHLexer: Keep track of the location of the last '#' token and provide the means to jump ahead in the token stream.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60905 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11 22:41:47 +00:00
Ted Kremenek 7415326dcb Remove unused ivar CurTokenIdx.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60896 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11 20:39:48 +00:00
Ted Kremenek bc0f6bc039 PreprocessorLexer (and subclasses):
- Added virtual method 'getSourceLocation()' (no arguments) that gets the location of the next "observable" location (e.g., next character, next token).
PPLexerChange.cpp:
- Implemented FIXME by using PreprocessorLexer::getSourceLocation() to get the location in the file we are returning to after lexing a #included file.  This appears to be slightly faster than having the branch (i.e., 'if(CurLexer)').  It's also not a really hot part of the Preprocessor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60860 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 23:20:59 +00:00
Ted Kremenek cf58e6249c Declare PerIDCache as IdentifierInfo** instead of void*. This is just cleaner. No performance change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60843 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 19:40:23 +00:00
Ted Kremenek 0e50b6e7c1 Remove unneeded assertion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60559 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 22:47:11 +00:00
Ted Kremenek 271b7af521 Use 'free' to release PerIDCache since it was allocated using calloc().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60556 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 22:09:37 +00:00
Ted Kremenek 6183e4815a PTH:
Use an array instead of a DenseMap to cache persistent IDs -> IdentifierInfo*.  This leads to a 4% speedup at -fsyntax-only using PTH.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60452 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 01:16:39 +00:00