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

120 Коммитов

Автор SHA1 Сообщение Дата
Oscar Fuentes 148f061354 CMake: Added some source files.
Patch contributed by Jay Foad!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59656 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 18:46:39 +00:00
Argyrios Kyrtzidis fad03b2b38 Remove Preprocessor::CacheTokens boolean data member. The same functionality can be provided by using Preprocessor::isBacktrackEnabled().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59631 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 14:23:14 +00:00
Chris Lattner 6cf3ed7be7 don't turn identifierinfo's into strings in diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59602 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 07:33:58 +00:00
Ted Kremenek 2df37b8eae Revert 59574 (caused tests to fail).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59579 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 01:54:47 +00:00
Ted Kremenek 0a36264440 - Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.
- Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry
  (simplifies some uses).
- Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile.

Performance testing of -Eonly on Cocoa.h shows no performance regression because
of this patch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59574 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 00:46:18 +00:00
Ted Kremenek 4b71e3e439 Initialize CurPPLexer in Preprocessor's constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59573 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 00:44:06 +00:00
Chris Lattner 204b2fed90 Remove the last of the old-style Preprocessor::Diag methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59554 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 21:48:13 +00:00
Chris Lattner 56b05c8829 remove one more Preprocessor::Diag method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59512 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 08:02:48 +00:00
Chris Lattner 3692b09faa Convert the lexer and start converting the PP over to using canonical Diag methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59511 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 07:59:24 +00:00
Chris Lattner 0a14eee528 This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed.  In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
ton of random stuff.  This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how 
Diagnostic::Report works.  Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and 
ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator.  When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information.  This is a somewhat tricky dance, but it means that the 
accumulated DiagnosticInfo is allowed to keep pointers to other expression 
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema.  For example, instead of calling:

  Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
       SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

  Diag(BuiltinLoc, diag::err_overload_no_match)
      << typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just 
strings) in a type-safe way.  Go operator overloading?!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 07:04:44 +00:00
Chris Lattner 2383b7f6ae Change the diagnostics interface to take an array of pointers to
strings instead of array of strings.  This reduces string copying
in some not-very-important cases, but paves the way for future 
improvements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 04:56:44 +00:00
Ted Kremenek 4b391087f9 - Add Lexer::isPragma() accessor for clients of Lexer that aren't friends.
- Add static method to test if the current lexer is a non-macro/non-pragma
  lexer.
- Refactor some code in PPLexerChange to use this static method.
- No performance change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59486 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 01:33:13 +00:00
Ted Kremenek 68a91d5736 Replace more uses of 'CurLexer->' with 'CurPPLexer->'. No performance change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59482 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 01:12:54 +00:00
Ted Kremenek f6452c5421 Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null.
Performance tests on Cocoa.h (using the regular Lexer) shows no performance
difference.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59479 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 01:04:47 +00:00
Ted Kremenek ac6b06df32 Added conditional guard 'if (CurLexer)' when using SetCommentRetentionState().
This is because the PTHLexer will not support this method. Performance testing
on preprocessing Cocoa.h shows that this results in a negligible performance
difference (less than 1%).

I tried making Lexer::SetCommentRetentionState() an out-of-line function (a
precursor to making it a virtual function in PreprocessorLexer) and noticed a 1%
decrease in speed (it is called in a hot part of the Preprocessor).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59477 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 00:43:07 +00:00
Ted Kremenek 60e45d4c41 Change a bunch of uses of 'CurLexer->' to 'CurPPLexer->', which should be the
alias for the current PreprocessorLexer. No functionality change. Performance
testing shows this results in no performance degradation when preprocessing
Cocoa.h.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59474 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 00:34:22 +00:00
Ted Kremenek 9c1b750c59 - Add 'CurPPLexer' to Preprocessor to keep track of the current
PreprocessorLexer, which will either be a 'Lexer' or 'PTHLexer'.
- Added stub field 'CurPTHLexer' to keep track of the current PTHLexer.
- Modified IncludeStackInfo to track both the current PTHLexer and
  current PreprocessorLexer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59472 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 00:12:49 +00:00
Chris Lattner 51881c56b0 Trivial tidying
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59424 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 20:22:05 +00:00
Ted Kremenek caaa7df2c7 Using llvm::OwningPtr<> for CurLexer and CurTokenLexer. This makes both the ownership semantics of these objects explicit within the Preprocessor and also tightens up the code (explicit deletes not needed).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59249 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 17:11:24 +00:00
Ted Kremenek ed04c4cdca Use PushIncludeMacroStack/PopMacroStack instead of manually pushing/popping from IncludeMacroStack. This is both cleaner and makes the include stack transparently extensible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59248 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 16:51:03 +00:00
Ted Kremenek d6a2e7d71e Move some diagnostic handling to PreprocessorLexer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59191 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 23:13:54 +00:00
Ted Kremenek 2c71d0f00e Add virtual dtor to PreprocessorLexer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59188 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 22:48:57 +00:00
Ted Kremenek 6db72c092d Remove Lexer::LexIncludeFilename.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59186 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 22:44:15 +00:00
Ted Kremenek ab91b7086c Move LexIncludeFilename from Lexer to PreprocessorLexer.
PreprocessorLexer now has a virtual method "IndirectLex" which allows it to call the lex method of its subclasses.  This is not for performance intensive operations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59185 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 22:43:05 +00:00
Ted Kremenek 174da89d2d Use PushIncludeMacroStack() instead of manually manipulating the include stack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59181 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 22:21:57 +00:00
Ted Kremenek 274b20863a Add skeleton for PTH lexer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59169 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 21:37:15 +00:00
Argyrios Kyrtzidis 3604e3895e Introduce annotation tokens, a special kind of token, created and used only by the parser to replace a group of tokens with a single token encoding semantic information.
Will be fully utilized later for C++ nested-name-specifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58911 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-08 16:17:04 +00:00
Sanjiv Gupta 73608a89a6 Fixed build warning. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58503 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 10:24:31 +00:00
Sanjiv Gupta 31fc07df7f Made the mechanism of defining preprocessor defs for maxint, ptrdiff_t, wchar
etc more generic. For some targets, long may not be equal to pointer size. For
example: PIC16 has int as i16, ptr as i16 but long as i32.

Also fixed a few build warnings in assert() functions in CFRefCount.cpp,
CGDecl.cpp, SemaDeclCXX.cpp and ParseDeclCXX.cpp.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58501 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 09:52:39 +00:00
Ted Kremenek 8173dba222 Initialize Suffix and Prefix to 0, even with a bad entry. Removes an uninitialized value warning from gcc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28 00:18:42 +00:00
Chris Lattner 9d72851fec Rename Characteristic_t to CharacteristicKind
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27 01:19:25 +00:00
Oscar Fuentes d2f4e5ea6e CMake: Builds and installs clang binary and libs (no docs yet). It
must be under the `tools' subdirectory of the LLVM *source* tree.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-26 00:56:18 +00:00
Daniel Dunbar a179be34c1 Speed up NumericLiteralParser::GetIntegerValue.
- Implement fast path when value easily fits in a uint64.
 - ~6x faster, translates to 1-2% on Cocoa.h


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-16 07:32:01 +00:00
Daniel Dunbar d70cb64570 Simplify overflow-on-add check in NumericLiteralParser::GetIntegerValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-16 06:39:30 +00:00
Chris Lattner 9e6293d4df Change FormTokenWithChars to take the token kind to form, since all clients
were setting a kind and then forming it.  This is just a minor API cleanup, 
no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57404 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 04:51:35 +00:00
Chris Lattner 31f0ecae4b When in keep whitespace mode, make sure to return block comments that are
unterminated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 04:19:49 +00:00
Chris Lattner 2d3818959d Change SkipBlockComment and SkipBCPLComment to return true when in
keep comment mode, instead of returning false.  This matches SkipWhitespace.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 04:15:42 +00:00
Chris Lattner d88dc48e33 Add a new mode to the lexer which enables it to return all characters,
even whitespace, as tokens from the file.  This is enabled with
L->SetKeepWhitespaceMode(true) on a raw lexer.  In this mode, you too
can use clang as a really complex version of 'cat' with code like this:

  Lexer RawLex(SourceLocation::getFileLoc(SM.getMainFileID(), 0),
               PP.getLangOptions(), File.first, File.second);
  
  RawLex.SetKeepWhitespaceMode(true);
  
  Token RawTok;
  RawLex.LexFromRawLexer(RawTok);
  while (RawTok.isNot(tok::eof)) {
    std::cout << PP.getSpelling(RawTok);
    RawLex.LexFromRawLexer(RawTok);
  }

This will emit exactly the input file, with no canonicalization or other
translation.  Realistic clients actually do something with the tokens of
course :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57401 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 04:05:48 +00:00
Chris Lattner aea3ad0737 Stop the preprocessor from poking the lexer's private parts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57399 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 03:31:33 +00:00
Chris Lattner f744d133e8 Fix a couple more places that poke KeepCommentMode unnecesarily.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 03:27:19 +00:00
Chris Lattner fa95a019da add a new inKeepCommentMode() accessor to abstract the KeepCommentMode
ivar.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57397 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 03:22:02 +00:00
Chris Lattner a2c7ad9c73 fix misleading comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57396 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 01:34:51 +00:00
Chris Lattner 0af574270d Simplify raw mode lexing by treating an unterminate /**/ comment the
same we we do an unterminated string or character literal.  This makes
it so we can guarantee that the lexer never calls into the 
preprocessor (which would be suicide for a raw lexer).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57395 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 01:31:51 +00:00
Chris Lattner 8527b71b19 add a comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57394 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 01:23:27 +00:00
Chris Lattner 590f0cc643 Change how raw lexers are handled: instead of creating them and then
using LexRawToken, create one and use LexFromRawLexer.  This avoids
twiddling the RawLexer flag around and simplifies some code (even 
speeding raw lexing up a tiny bit).

This change also improves the token paster to use a Lexer on the stack
instead of new/deleting it. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 01:15:46 +00:00
Chris Lattner 33d34a6f7a silence some release-assert warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57391 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 00:28:42 +00:00
Chris Lattner 7a4f004a77 improve a comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57389 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-12 00:23:07 +00:00
Chris Lattner eb52b44caf __CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57164 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 07:43:09 +00:00
Chris Lattner 12f0926029 move __FLT_EVAL_METHOD__, __FLT_RADIX__, and __DECIMAL_DIG__ into
target indep code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57139 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 21:49:27 +00:00
Chris Lattner e9863cab04 suck the rest of the FP macros out of the targets into the PP
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57137 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 21:40:58 +00:00