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

191 Коммитов

Автор SHA1 Сообщение Дата
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
Ted Kremenek 0c6a77bc1f - Remove PTHManager.cpp. Move all of its functions to PTHLexer.cpp since some of the internal methods are used by PTHLexer (their implementations are intertwined.) This enables some important inlining opportunities at -O3.
- Don't construct an std::vector<Token> prior to feeding PTH tokens to the Preprocessor.  Stream them off the PTH file directly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60447 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 00:38:03 +00:00
Ted Kremenek 6137dc99ef Preprocessor:
- Added method "setPTHManager" that will be called by the driver to install
  a PTHManager for the Preprocessor.
- Fixed some comments.
- Added EnterSourceFileWithPTH to mirror EnterSourceFileWithLexer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60437 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 19:46:31 +00:00
Ted Kremenek be1ee79d20 Added PTHManager, a utility class that will be used by Preprocessor to lazily create PTHLexer objects for pre-tokenized files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60436 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 19:45:05 +00:00
Douglas Gregor bec1c9d6f3 Objective-C keywords are not always identifiers. Some are also C++ keywords
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60373 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 21:46:47 +00:00
Daniel Dunbar c1571453de Add LangOptions marker for assembler-with-cpp mode and use to define
__ASSEMBLER__ properly. Patch from Roman Divacky (with minor
formatting changes). Thanks!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 18:55:22 +00:00
Ted Kremenek 82a500b141 PTHLexer now owns the Token vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60136 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27 00:38:24 +00:00
Daniel Dunbar ddd3e8b90a Comment fix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59997 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 00:20:22 +00:00
Chris Lattner 28eb7e992b make the 'to match this' diagnostic a note.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59921 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-23 23:17:07 +00:00
Chris Lattner 08631c5fa0 Convert IdentifierInfo's to be printed the same as DeclarationNames
with implicit quotes around them.  This has a bunch of follow-on 
effects and requires tweaking to a whole lot of code.  This causes
a regression in two tests (xfailed) by causing it to emit things like:

  Line 10: duplicate interface declaration for category 'MyClass1' ('Category1')

instead of:

  Line 10: duplicate interface declaration for category 'MyClass1(Category1)'

I will fix this in a follow-up commit.

As part of this, I had to start switching stuff to use ->getDeclName() instead
of Decl::getName() for consistency.  This is good, but I was planning to do this
as an independent patch.  There will be several follow-on patches
to clean up some of the mess, but this patch is already too big.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59917 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-23 21:45:46 +00:00
Chris Lattner 4984212fce Fix a weird inconsistency with hex floats. Previously the lexer
would not eat the "-1" in "0x0p-1", but LiteralSupport would accept
it when extensions are on.  This caused strangeness and failures 
when hexfloats were properly treated as an extension (not error)
in LiteralSupport.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59865 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 07:39:03 +00:00
Chris Lattner ac92d82911 remove the NumericLiteralParser::Diag helper method, inlining it into
its call sites.  This makes it more explicit when the hasError flag is
getting set and removes a confusing difference in behavior between
PP.Diag and Diag in this code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59863 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 07:23:31 +00:00
Chris Lattner adc4eeb080 Move the Preprocessor::Diag methods inline. This has the interesting
(and carefully calculated) effect of allowing the compiler to reason
about the aliasing properties of DiagnosticBuilder object better,
allowing the whole thing to be promoted to registers instead of
resulting in a ton of stack traffic.

While I'm not very concerned about the performance of the Diag() method
invocations, I *am* more concerned about their code size and impact on the
non-diagnostic code.  This patch shrinks the clang executable (in 
release-asserts mode with gcc-4.2) from 14523980 to 14519816 bytes.  This
isn't much, but it shrinks the lexer from 38192 to 37776, PPDirectives.o
from 31116 to 28868 bytes, etc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59862 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 07:03:46 +00:00
Chris Lattner 9efe970928 inline a method into its only two call sites.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59860 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 06:42:31 +00:00
Chris Lattner 30c6476e8e actually, this version isn't really needed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59859 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 06:22:39 +00:00
Chris Lattner 306fda76b0 remove a sneaky version of Diag hiding in PreprocessorLexer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59858 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 06:20:42 +00:00
Chris Lattner 74d15dfd18 Change the Lexer::Diag method to not magically silence warnings,
force the caller to check instead.  This eliminates the need (and the
risk!) of weird null DiagnosticBuilder's floating around.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59856 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 02:02:22 +00:00
Chris Lattner 3cbfe2c415 Split the DiagnosticInfo class into two disjoint classes:
one for building up the diagnostic that is in flight (DiagnosticBuilder)
and one for pulling structured information out of the diagnostic when
formatting and presenting it.

There is no functionality change with this patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59849 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22 00:59:29 +00:00
Ted Kremenek d2bdeed072 In PTHLexer::DiscardToEndOfLine() use Lex() instead of AdvanceToken(). This handles transitions in the preprocessor state.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59845 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 23:28:56 +00:00