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

191 Коммитов

Автор SHA1 Сообщение Дата
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
Chris Lattner 2db78dd977 start moving fp macros over
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57134 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 20:40:30 +00:00
Chris Lattner 0e5d4ef315 move a bunch more integer sizing out of target-specific code into
target indep code.  

Note that this changes functionality on PIC16: it defines __INT_MAX__
correctly for it, and it changes sizeof(long) to 16-bits (to match
the size of pointer).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57132 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 20:06:37 +00:00
Chris Lattner 9b53316457 eliminate __USER_LABEL_PREFIX__ from the Targets.cpp file, start moving
integer size #defines over to the Preprocessor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57130 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:44:25 +00:00
Chris Lattner 2b43ad9588 gcc no longer defines __block to nothing when blocks aren't enabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57129 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:32:52 +00:00
Chris Lattner 62213d9082 rearrange preprocessor macro definitions into language-specific
then target specific.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57128 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:32:22 +00:00
Chris Lattner 3fdf467893 Implement PR2773, support for __USER_LABEL_PREFIX__
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57127 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 19:22:37 +00:00
Daniel Dunbar 4095080aff Add Preprocessor::RemovePragmaHandler.
- No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57065 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 19:17:46 +00:00
Chris Lattner c29bbde0a1 Document assumptions that NumericLiteralParser makes with an assertion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56876 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-30 20:45:40 +00:00
Chris Lattner 048dd943fc define __PASCAL_STRINGS__ whenever -fpascal-strings is enabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56824 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-30 00:48:48 +00:00
Chris Lattner 71af229645 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is a darwin-specific #define
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56822 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-30 00:46:39 +00:00
Chris Lattner 4411f46050 Fix the root cause of PR2750 instead of the side effect.
NumericLiteral parser is not careful about overrun because
it should never be possible.  It implicitly expects that its
input matched the regex for pp-constant.  Because of this, it
knows it can't be pointing to a prefix of something that
looks like a number.  This is all fine, except that __LINE__
does not prevent implicit concatenation from happening.  Fix
__LINE__ to not do this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56818 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 23:12:31 +00:00
Nico Weber 48002c8957 whitespace and comment changes, to fix grammar and 80 col violations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56776 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 00:25:48 +00:00
Chris Lattner 0b9e736308 clean up a bunch of fixme's I added, by moving
DirectoryLookup::DirType into SourceManager.h


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56692 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 21:18:42 +00:00
Chris Lattner 721818304a Fix the rest of rdar://6243860 hopefully. This requires changing FileIDInfo
to whether the fileid is a 'extern c system header' in addition to whether it
is a system header, most of this is spreading plumbing around.  Once we have that,
PPLexerChange bases its "file enter/exit" notifications to PPCallbacks to
base the system header state on FileIDInfo instead of HeaderSearch.  Finally,
in Preprocessor::HandleIncludeDirective, mirror logic in GCC: the system headerness
of a file being entered can be set due to the #includer or the #includee.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56688 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 20:12:23 +00:00
Daniel Dunbar 38a67c9dfb Update clang to pretend to be gcc-4.2.
- This really needs to be automated and configurable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56635 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 01:13:13 +00:00
Steve Naroff dca6d6e8b0 Fix <rdar://problem/6240065> clang: __BLOCKS__ should be defined.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56503 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-23 21:28:24 +00:00
Argyrios Kyrtzidis 02e7e7442c Line endings: CRLF -> LF
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55829 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 08:53:53 +00:00
Steve Naroff b4eaf9cf5f - Implement __block.
- Replace FIXME in Preprocessor::HandleIdentifier() with a check that avoids diagnosing extension tokens that originate from macro definitions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55639 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 18:50:17 +00:00
Steve Naroff c9a4eea592 Pull code from last commit. will put back soon.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55637 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 18:04:36 +00:00
Steve Naroff 042f955a20 Implement block pseudo-storage class modifiers (__block, __byref).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55635 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 15:20:19 +00:00
Eli Friedman 6f7adbdcd0 Fix for PR2750; don't check for an 'e' in the trash after the token.
Note that this isn't really a complete fix; I think there are other 
potential overrun situations.  I don't really know what the best 
systematic fix is, though.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55622 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 05:29:22 +00:00
Argyrios Kyrtzidis ed5c38682c Rename Preprocessor::DisableBacktrack -> Preprocessor::CommitBacktrackedTokens.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55281 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-24 12:29:43 +00:00
Argyrios Kyrtzidis 2174a4ff83 Add a safety check.
Make sure there's no "dangling" backtrack position when Preprocessor is destroyed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55236 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 12:12:06 +00:00
Argyrios Kyrtzidis bff73f7f2d Change line endings: CRLF -> LF
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55235 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-23 12:05:53 +00:00
Argyrios Kyrtzidis a9e274c01e Allow nested backtracks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55204 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-22 21:27:50 +00:00
Chris Lattner 9aa77f137b various updates to match r54873 on mainline.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-17 07:19:51 +00:00
Daniel Dunbar 662e8b5647 Change Parser & Sema to use interned "super" for comparions.
- Added as private members for each because it is not clear where to
   put the common definition. Perhaps the IdentifierInfos all of these
   "pseudo-keywords" should be collected into one place (this would
   KnownFunctionIDs and Objective-C property IDs, for example).

Remove Token::isNamedIdentifier.
 - There isn't a good reason to use strcmp when we have interned
   strings, and there isn't a good reason to encourage clients to do
   so.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54794 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-14 22:04:54 +00:00
Daniel Dunbar fba5cb12ad Move some ObjC preprocessor definitions into
InitializePredefinedMacros().
 - Also now properly wired to -fobjc-gc, -fnext-runtime.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54661 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-12 00:21:46 +00:00
Chris Lattner de9d55a0db remove obsolete comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54652 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 22:03:07 +00:00
Daniel Dunbar acc5f3e423 More #include cleaning
- Kill unnecessary #includes in .cpp files. This is an automatic
   sweep so some things removed are actually used, but happen to be
   included by a previous header. I tried to get rid of the obvious
   examples and this was the easiest way to trim the #includes in one
   fell swoop.
 - We now return to regularly scheduled development.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 06:23:49 +00:00
Nico Weber 7bfaaaecb3 * Remove isInSystemHeader() from DiagClient, move it to SourceManager
* Move FormatError() from TextDiagnostic up to DiagClient, remove now  
  empty class TextDiagnostic
* Make DiagClient optional for Diagnostic

This fixes the following problems:

* -html-diags (and probably others) does now output the same set of  
  warnings as console clang does
* nothing crashes if one forgets to call setHeaderSearch() on  
  TextDiagnostic
* some code duplication is removed




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54620 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 19:59:06 +00:00
Argyrios Kyrtzidis 03db1b31dd Allow the preprocessor to cache the lexed tokens, so that we can do efficient lookahead and backtracking.
1) New public methods added:
  -EnableBacktrackAtThisPos
  -DisableBacktrack
  -Backtrack
  -isBacktrackEnabled

2) LookAhead() implementation is replaced with a more efficient one.
3) LookNext() is removed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 13:15:22 +00:00
Chris Lattner 6ea623823f In c89 mode accept hex fp constants as an extension:
t2.c:1:17: warning: hexadecimal floating constants are a C99 feature
long double d = 0x0.0000003ffffffff00000p-16357L;
                ^

instead of emitting a weird error message that doesn't make sense:

t2.c:1:41: error: hexadecimal floating constants require an exponent
long double d = 0x0.0000003ffffffff00000p-16357L;
                                        ^

rdar://6096838


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54035 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-25 18:18:34 +00:00
Ted Kremenek 109949a5f5 Patch by
"When dumping the tokens (-dumptokens output type), the column numbers are not
correctly shown. This patch fixes that issue."



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53796 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-19 19:10:04 +00:00
Argyrios Kyrtzidis 63cf923e41 Convert CRLF -> LF line endings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53519 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-12 20:28:04 +00:00
Argyrios Kyrtzidis 9e0ed0bd5a Add Preprocessor::LookNext method, which implements an efficient way to 'take a peek' at the next token without consuming it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53375 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 22:46:46 +00:00
Nuno Lopes 551d5e9811 move the linux predefined macro definition to the TargetInfo, where it really belongs
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53149 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-05 19:32:25 +00:00
Nuno Lopes e8825aa06c predefine the macro linux when compiled on a linux system. this fixes the build of libtidy
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53145 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-05 17:58:44 +00:00
Chris Lattner b081a350b5 Fix PR2252: don't warn on negating an unsigned value ever, and don't emit
'integer constant is so large that it is unsigned' warning for hex literals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53070 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 03:47:30 +00:00
Chris Lattner 413d355e38 Fix a bug reported by Kelly Wilson, where we incorrectly
rejected FP immediates like 08.123


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52890 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-30 06:44:49 +00:00
Chris Lattner 368328c88b refactor some code out into a new method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52889 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-30 06:39:54 +00:00
Chris Lattner d86522a2c7 clang uses the llvm backend, so define __llvm__ like llvm-gcc.
Additionally, define __clang__ so clients can predicate based on
clang features.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52788 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 17:26:01 +00:00
Nuno Lopes 0049db6ce1 fix PR2357 (#ifs didnt invalidate the multiple-inclusion optimization state)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51843 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 18:31:24 +00:00
Steve Naroff 73b17cd017 Fix rewriter bug <rdar://problem/5929344> clang ObjC rewriter: "extern int __CFConstantStringClassReference[];" should be extern "C".
Have clang predefine OBJC_NEW_PROPERTIES (which is what gcc does).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51163 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-15 21:12:10 +00:00
Steve Naroff 0c7e8058de DO NOT pre-defined __OBJC2__. The __OBJC2__ macro should only be defined when targeting the new, Apple 2.0 *runtime ABI*. It is not intended to be used to #ifdef ObjC 2.0 langauge features. This is unfortunate (given it's name). In a perfect world, this defined would be named __OBJC2_RUNTIME_ABI__. Oh well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50913 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 20:52:28 +00:00
Chris Lattner 63bc035870 The awesome GNU "comma elision extension" works with both the standard
__VA_ARGS__ syntax as well as with the amazingly awesome GNU "named 
variadic macro" extension.  Allow it with the GNU syntax as well.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50843 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-08 05:10:33 +00:00
Chris Lattner 44cbbb05f5 Fix typo, improve comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50666 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 20:09:27 +00:00
Chris Lattner 98ed49f370 Fix a few more bugs in preprocessor expressions w.r.t. ?:. Now I
think it is really right. :)  This fixes PR2284.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50665 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 20:07:41 +00:00
Chris Lattner 8ed3044a33 Neil pointed out that clang doesn't generate ranges from diagnostics
related to pp-expressions.  Doing so is pretty simple and this
patch implements it, yielding nice diagnostics like:

t.c:2:7: error: division by zero in preprocessor expression
#if 1 / (0 + 0)
    ~ ^ ~~~~~~~
t.c:5:14: error: expected ')' in preprocessor expression
#if (412 + 42
     ~~~~~~~~^
t.c:5:5: error: to match this '('
#if (412 + 42
    ^
t.c:10:10: warning: left side of operator converted from negative value to unsigned: -42 to 18446744073709551574
#if (-42 + 0U) / -2
     ~~~ ^ ~~
t.c:10:16: warning: right side of operator converted from negative value to unsigned: -2 to 18446744073709551614
#if (-42 + 0U) / -2
    ~~~~~~~~~~ ^ ~~
5 diagnostics generated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50638 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 06:45:50 +00:00
Chris Lattner 9e66ba6d1c fix a bug handling right associative operators that Neil noticed, hopefully
the final part of PR2279


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50635 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 04:10:51 +00:00
Chris Lattner 019ef7e102 ||/&& do not do UAC's either. This silences a bogus warning on #if -1 || 4U.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 23:46:17 +00:00
Chris Lattner 463ec60993 Neil points out that commas don't do UACs either.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50631 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 23:38:48 +00:00
Chris Lattner 9189156429 Fix the rest of PR2279:
a) correct rejection of ',' in pp expressions.
b) the precedence of ',' was wrong w.r.t. ?:.

Thanks again to Neil for finding these and providing testcases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50625 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 18:36:18 +00:00
Chris Lattner d5214b22cc Fix PR2279 part C: shifts don't perform the UACs, thanks to Neil
for pointing this out.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50624 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 18:25:32 +00:00
Chris Lattner 3b6911527a fix a nasty bug that Neil identifier in pp-expr parsing (this is PR2279 part D).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50617 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 07:15:21 +00:00
Chris Lattner 70f66ab053 for exponent-related errors, emit the diagnostic on the 'e' or 'p'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49997 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-20 18:47:55 +00:00
Chris Lattner 0b7f69d789 when emitting diagnostics about some character in a numeric
literal, indicate what character the error is about or where
it would be.  For example:

pr2241.c:1:17: error: exponent has no digits
float f[] = { 1e  , 1ee0 };
                ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49996 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-20 18:41:46 +00:00
Chris Lattner aa39197431 simplify ownership of the predefines buffer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49973 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-19 23:09:31 +00:00
Ted Kremenek 339b9c2775 class Preprocessor: Now owns the "predefines" char*; it deletes [] it in its dstor.
clang.cpp: InitializePreprocessor now makes a copy of the contents of PredefinesBuffer and
  passes it to the preprocessor object.
  
clang.cpp: DriverPreprocessorFactory now calls "InitializePreprocessor" instead of this being done in main().

html::HighlightMacros() now takes a PreprocessorFactory, allowing it to conjure up a new
Preprocessor to highlight macros.

class HTMLDiagnostics now takes a PreprocessorFactory* that it can use for html::HighlightMacros().
Updated clients of HTMLDiagnostics to use this new interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49875 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 22:31:54 +00:00
Ted Kremenek ec6c574478 Added "PreprocessorFactory", an interface for lazily creating Preprocessor objects on-demand.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49868 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 21:23:07 +00:00
Nate Begeman 5253c7ff26 Fix typo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-14 02:26:39 +00:00
Chris Lattner d98d975ccd Fix PR2220, making diagnostics for unexpected tokens in pp expressions
more nice.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49619 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-13 20:38:43 +00:00
Chris Lattner b25e5d79d9 don't diagnose empty source files, thanks Neil!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49575 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-12 05:54:25 +00:00
Chris Lattner 8fa3078cfe don't read off the front of the buffer. Thanks to Sam for pointing this out.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49535 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-11 16:20:41 +00:00
Steve Naroff 0c29b22f43 Support MS-specific integer suffixes (i8, i16, i32, i64, i128).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49229 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-04 21:02:54 +00:00
Chris Lattner 35de512b9c Update to match simplified llvm MemoryBuffer interfaces for files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49042 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-01 18:04:30 +00:00
Chris Lattner ea301e15a6 Avoid overflowing buffer, patch by Algeris Kirtzidis!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48741 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-24 21:14:55 +00:00
Sam Bishop 9a4939f7ed Plug a memory leak in the "this macro expands into a single trivially-
expanded token" case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48637 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-21 07:13:02 +00:00
Chris Lattner f90a248578 move #include to the file that needs it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48485 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-18 05:59:11 +00:00
Chris Lattner bda0b626e7 Make a major restructuring of the clang tree: introduce a top-level
lib dir and move all the libraries into it.  This follows the main
llvm tree, and allows the libraries to be built in parallel.  The
top level now enforces that all the libs are built before Driver,
but we don't care what order the libs are built in.  This speeds
up parallel builds, particularly incremental ones.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-15 23:59:48 +00:00