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

409 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 2451b528fe improve MacroInfo to track the source range of the macro definition,
patch by Alexei Svitkine!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 04:46:33 +00:00
Chris Lattner 41c17473e3 add a preprocessor callback function for #undef, patch by
Alexei Svitkine!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 03:42:09 +00:00
Sanjiv Gupta 4bc11af9be Use an APInt of target int size to detect overflow while parsing multichars.
So 'abc' on i16 platforms will warn but not on i32 platforms.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69653 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 02:21:29 +00:00
Chris Lattner 97e2de171d fix the second half of PR4006 and rdar://6807000 by treating
() as being either zero arguments or one empty argument depending
on situation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69627 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-20 21:08:10 +00:00
Douglas Gregor 9378ba44b3 Move the on-disk hash table code into its own header. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69580 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-20 07:08:21 +00:00
Chris Lattner edaf877d24 implement "#pragma GCC diagnostic". Besides being a nice feature, this
will let us test for multiple different warning modes in the same
file in regression tests.

This implements rdar://2362963, a 10-year old feature request :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69560 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 23:16:58 +00:00
Chris Lattner 4d8aac3778 Warn about uses of #pragma STDC FENV_ACCESS ON, since we don't
support it.  I don't know what evaluation method we use for complex
arithmetic, so I don't know whether/if we should warn about use of
CX_LIMITED_RANGE.

This concludes my planned hacking on STDC pragmas, flame away :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69556 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:55:32 +00:00
Chris Lattner 6c5cf4a2e2 diagnose invalid syntax of STDC pragmas.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69554 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:50:08 +00:00
Chris Lattner f545be5552 reject invalid stuff in the STDC namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69551 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:25:37 +00:00
Chris Lattner 062f232465 stub out STDC #pragmas.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:20:35 +00:00
Chris Lattner af7cdf45da basic support for -Wunknown-pragmas, more coming.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:10:26 +00:00
Chris Lattner 332ee08e2f move token paste poisoning diagnostics to after the instantiation loc
for a token is set, this makes the diagnostic "expanded from stack" work
for this diagnostic.  Add a testcase for PR3918.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69544 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 20:29:42 +00:00
Chris Lattner 88e43a519e Fix PR3918: Invalid use of __VA_ARGS__ not diagnosed,
by rejecting invalid poisoned tokens in the token
pasting path.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69536 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 20:06:32 +00:00
Chris Lattner 8fde5978a6 Fix PR4006, incorrect handling of __VA_ARGS__ when it was the first token
in a function-like macro body.  This has the added bonus of moving some
function-like macro specific code out of the object-like macro codepath.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69530 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 18:26:34 +00:00
Chris Lattner dff070fb0f Fix PR3917: the location of a #line directive is the location of the first _.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69485 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 22:29:33 +00:00
Chris Lattner 88e2524b8f Change Preprocessor::AdvanceToTokenCharacter to stop at
the first real character of a token.  For example, advancing
to byte 3 of foo\
bar

should stop at the b, not the \.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69484 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 22:28:58 +00:00
Chris Lattner 033749571f add a new Lexer::SkipEscapedNewLines method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69483 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 22:27:02 +00:00
Chris Lattner 24f0e48c0a factor escape newline measuring out into its own helper function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69482 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 22:05:41 +00:00
Chris Lattner 0edfab68d4 remove unneeded scopes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69481 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 21:57:20 +00:00
Chris Lattner 390c8cea4a fix typo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69479 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 21:55:02 +00:00
Chris Lattner dc8c90da15 more fun with line markers: the digit string is required to be interpreted
as decimal, even if it starts with 0.  Also, since things like 0x1 are
completely illegal, don't even bother using numericliteralparser for them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69454 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 18:35:15 +00:00
Chris Lattner 5c497a80c6 fix PR3927 by being more careful about the pp test for identifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69423 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 06:44:18 +00:00
Chris Lattner bc81682756 second half of PR3940: #line requires simple digit sequence.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 06:38:24 +00:00
Chris Lattner 6272bcfe5d enforce requirements imposed by C90 6.8 TC1, fixing PR3919.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 02:23:25 +00:00
Chris Lattner 8fe00e783e Fix PR3938 by taking into account C99 6.10p4.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69413 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 01:34:22 +00:00
Chris Lattner 0a4f1b9550 Substantially restructure function-like macro argument parsing.
Highlights: PP::isNextPPTokenLParen() no longer eats the ( 
when present.  We now simplify slightly the logic parsing
macro arguments.  We now handle PR3937 and other related cases
correctly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69411 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 01:13:56 +00:00
Chris Lattner 9cb51ce03c Fix two problems from PR3916, and one problem I noticed while hacking
on the code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69404 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 23:56:52 +00:00
Chris Lattner 58e91d5751 implement PR3940: #line numbers not fully checked
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69403 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 23:37:49 +00:00
Chris Lattner ab82f41b21 #line is allowed to have macros that expand to nothing after them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69401 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 23:30:53 +00:00
Chris Lattner 2c78b873f4 Change Lexer::MeasureTokenLength to take a LangOptions reference.
This allows it to accurately measure tokens, so that we get:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~~^

instead of the woefully inferior:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~ ^

Most of this is just plumbing to push the reference around.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 23:22:57 +00:00
Chris Lattner f87b3dfdf9 temporarily revert r69046
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69054 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 18:05:08 +00:00
Sanjiv Gupta 0fab49f7da Literal value calculation isn't likely to overflow on targets having int as 32 or less. Fixing the assert as it otherwise triggers for PIC16 which as i16 as int.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69046 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 16:46:37 +00:00
Chris Lattner 959875a66d Offer a fixit hint for our warning about tokens at the end of a directive:
t.c:3:8: warning: extra tokens at end of #endif directive
#endif foo
       ^
       //

Don't do this in strict-C89 mode because bcpl comments aren't 
valid there, and it is too much trouble to analyze whether
C block comments are safe.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69024 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 05:15:20 +00:00
Chris Lattner 35410d5cbb Fix the #import / #include_next "extra tokens at end of #foo directive"
Warning to properly report that it is an import/include_next instead of
claiming it is a #include.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69023 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 05:07:49 +00:00
Daniel Dunbar 8533bd5a32 Fix assertion failure in PTH when tokens followed a closing #endif.
- Ted, please check.

 - Missing test case because PTH won't reliably cache the tokens in a
   test case. *cough*


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68966 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-13 17:57:49 +00:00
Chris Lattner c1f9d828c7 implement the microsoft/gnu "__COUNTER__" macro: rdar://4329310
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68933 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-13 01:29:17 +00:00
Chris Lattner f4a72b0774 add a ppcallback hook for macro definitions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68883 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 01:39:54 +00:00
Douglas Gregor e1d918e9fe Compare the predefines buffer in the PCH file with the predefines
buffer generated for the current translation unit. If they are
different, complain and then ignore the PCH file. This effectively
checks for all compilation options that somehow would affect
preprocessor state (-D, -U, -include, the dreaded -imacros, etc.).

When we do accept the PCH file, throw away the contents of the
predefines buffer rather than parsing them, since all of the results
of that parsing are already stored in the PCH file. This eliminates
the ugliness with the redefinition of __builtin_va_list, among other
things.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68838 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 23:10:45 +00:00
Chris Lattner 531cc83556 do a dance with predefines, and finally enable reading of macros from
PCH.  This works now, except for limitations not being able to do things
with identifiers.  The basic example in the testcase works though.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68832 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 22:13:17 +00:00
Chris Lattner 6bf0f4ce59 move a bunch of code for initializing the predefines buffer out of Preprocessor.cpp
into clang-cc.cpp.  This makes it so clang-cc constructs the *entire* predefines 
buffer, not just half of it.  A bonus of this is that we get to kill a copy
of DefineBuiltinMacro.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68830 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 21:58:23 +00:00
Chris Lattner 555589dd01 simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 21:17:07 +00:00
Douglas Gregor 14f79002e5 PCH serialization/deserialization of the source manager. With this
improvement, source locations read from the PCH file will properly
resolve to the source files that were used to build the PCH file
itself.

Once we have the preprocessor state stored in the PCH file, source
locations that refer to macro instantiations that occur in the PCH
file should have the appropriate instantiation information.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 03:52:48 +00:00
Chris Lattner fd10511b3e finish the implementation of -imacros. The driver still needs to be hooked up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 20:53:24 +00:00
Chris Lattner de076650fa reject the #__include_macros directive unless it comes from the
predefines buffer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68627 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 18:46:40 +00:00
Chris Lattner b8e240ed8b Add initial support for -imacros. Right now it has the same semantics as
-include, but that will be fixed soon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68625 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 18:24:34 +00:00
Daniel Dunbar 3bbc75302f More fixes to builtin preprocessor defines.
- Add -static-define option driver can use when __STATIC__ should be
   defined (instead of __DYNAMIC__).

 - Don't set __OPTIMIZE_SIZE__ on Os, __OPTIMIZE_SIZE__ is tied to Oz.

 - Set __NO_INLINE__ following GCC 4.2.

 - Set __GNU_GNU_INLINE__ or __GNU_STDC_INLINE__ following GCC 4.2.

 - Set __EXCEPTIONS for Objective-C NonFragile ABI.

 - Set __STRICT_ANSI__ for standard conforming modes.

 - I added a clang style test case in utils for this, but its not
   particularly portable and I don't think it belongs in the test
   suite.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68621 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 18:03:55 +00:00
Daniel Dunbar 9fd0b1f845 Set __PIC__ (more) correctly.
- Add -pic-level clang-cc option to specify the value for the define,
   updated driver to pass this.

 - Added __pic__

 - Added OBJC_ZEROCOST_EXCEPTIONS define while I was here (to match gcc).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 03:03:23 +00:00
Chris Lattner 3a5cbd37c9 The __weak and __strong defines are common to all darwin targets
and are even set in C mode.  As such, move them to Targets.cpp.

__OBJC_GC__ is also darwin specific, but seems reasonable to always
define it when in objc-gc mode.

This fixes rdar://6761450


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68494 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 04:48:21 +00:00
Anders Carlsson 4ca076fffd Define __OPTIMIZE__ and __OPTIMIZE_SIZE__ if the -O[12] and -Os flags are passed to the compiler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68450 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-06 17:37:10 +00:00
Chris Lattner ead616c5d8 fix rdar://6757323, where an escaped newline in a // comment
was causing the char after the newline to get eaten.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-05 00:26:41 +00:00