aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
AgeCommit message (Collapse)Author
2009-06-23Fix our check for "random whitespace between a \ and newline" to workChris Lattner
with dos style newlines. I have a trivial test for this: // RUN: clang-cc %s -verify #define test(x, y) \ x ## y but I don't know how to get svn to not change newlines and testrunner doesn't work with dos style newlines either, so "not worth it". :) rdar://6994000 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73945 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18Fix a crash that can occur when a #pragma handler eats to the end of theChris Lattner
line, and when the pragma is at the end of a file. In this case, the last token consumed could pop the lexer, invalidating CurPPLexer. Thanks to Peter Thoman for pointing it out. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73689 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16my refactoring of builtins changed target-specific builtins to only beChris Lattner
registered when PCH wasn't being used. We should always install (in BuiltinInfo) information about target-specific builtins, but we shouldn't register any builtin identifier infos. This fixes the build of apps that use PCH and target specific builtins together. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73492 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15PR4395: Don't detect token concatenation in C mode for Eli Friedman
C++-specific tokens. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73408 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15Fix #pragma GCC system_header by making it insert a virtual linemarker intoChris Lattner
the file at the point of the pragma. This allows clang to know that all sourcelocations after the pragma are in a system header. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73376 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-15use the new Path::isAbsolute function, fixing a fixme. Patch by Gregory ↵Chris Lattner
Curfman! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73370 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-13implement and document a new __has_feature and __has_builtin magic Chris Lattner
builtin preprocessor macro. This appears to work with two caveats: 1) builtins are registered in -E mode, and 2) target-specific builtins are unconditionally registered even if they aren't supported by the target (e.g. SSE4 builtin when only SSE1 is enabled). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73289 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-10PR4353: Add support for \E as a character escape.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73153 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05Move CharIsSigned from TargetInfo to LangOptions.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72928 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01PR4283: Don't truncate multibyte character constants in the Eli Friedman
preprocessor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72686 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-28fix the "pasting formed 'a]', an invalid preprocessing token"Chris Lattner
diagnostic to include the full instantiation location for the invalid paste. For: #define foo(a, b) a ## b #define bar(x) foo(x, ]) bar(a) bar(zdy) Instead of: t.c:3:22: error: pasting formed 'a]', an invalid preprocessing token #define foo(a, b) a ## b ^ t.c:3:22: error: pasting formed 'zdy]', an invalid preprocessing token we now produce: t.c:7:1: error: pasting formed 'a]', an invalid preprocessing token bar(a) ^ t.c:4:16: note: instantiated from: #define bar(x) foo(x, ]) ^ t.c:3:22: note: instantiated from: #define foo(a, b) a ## b ^ t.c:8:1: error: pasting formed 'zdy]', an invalid preprocessing token bar(zdy) ^ t.c:4:16: note: instantiated from: #define bar(x) foo(x, ]) ^ t.c:3:22: note: instantiated from: #define foo(a, b) a ## b ^ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72519 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27Don't vary token concatenation based on the language options; this Eli Friedman
behavior is more likely to be confusing than useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27Make the bad paste diagnostic print the entire pasted token.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72497 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-25Fix a couple of bugs:Chris Lattner
1. When we accept "#garbage" in asm-with-cpp mode, change the token kind of the # to unknown so that the preprocessor won't try to process it as a real #. This fixes a crash on the attached example 2. Fix macro definition extents processing to handle #foo at the end of a macro to say the definition ends with the foo, not the #. This is a follow-on fix to r72283, and rdar://6916026 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72388 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-25improve comment, no functionality change.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-24Make sure an invalid concatentaion doesn't insert whitespace before Eli Friedman
the RHS. Fixes assembler-with-cpp issue reported on cfe-dev. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72370 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22In assembler-with-cpp mode, don't error on '#' (stringize) operator applied toDaniel Dunbar
non-argument names, pass the tokens through. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22The TokenLexer may encounter annotations if the parser enters them using ↵Argyrios Kyrtzidis
Preprocessor::EnterTokenStream. So check for annotation before using the Token's IdentifierInfo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72278 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21Use v.data() instead of &v[0] when SmallVector v might be empty.Jay Foad
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16PR3942: Don't warn on unsigned overflow in preprocessor expressions.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71960 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13Fix rdar://6880630 - # in _Pragma does not start a preprocessor directive.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13When we expect two arguments but have zero, make sure to addChris Lattner
two empty arguments. Also, add an assert so that this bug manifests as an assertion failure, not a valgrind problem. This fixes rdar://6880648 - [cpp] crash in ArgNeedsPreexpansion git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71616 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12accept "#pragma clang foo" where we accept "#pragma GCC foo".Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71572 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03Fix for PR4132: make sure to insert whitespace consistently before a Eli Friedman
pasted token. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28Implement -Wfour-char-constants, which is an extension, not an extwarn,Chris Lattner
and apparently not part of -Wall git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70329 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28implement -WmulticharChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70315 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28Emit keyword extension warning in all modes, not just C99 mode.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28Get rid of some useless uses of NoExtensions. The philosophy here is Eli Friedman
that if we're going to print an extension warning anyway, there's no point to changing behavior based on NoExtensions: it will only make error recovery worse. Note that this doesn't cause any behavior change because NoExtensions isn't used by the current front-end. I'm still considering what to do about the remaining use of NoExtensions in IdentifierTable.cpp. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70273 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Lazily load the controlling macros for all of the headers known in theDouglas Gregor
PCH file. In the Cocoa-prefixed "Hello, World" benchmark, this takes us from reading 503 identifiers down to 37 and from 470 macros down to 4. It also results in an 8% performance improvement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70094 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Silence gcc warnings.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70086 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24Add PCH support for #import.Steve Naroff
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24fix rdar://6816766 - Crash with function-like macro test at end of directive.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69964 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24simplification and speedupChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69963 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21apply Eli's patch to fix PR4008, with a testcase. Thanks Eli!Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21improve MacroInfo to track the source range of the macro definition,Chris Lattner
patch by Alexei Svitkine! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21add a preprocessor callback function for #undef, patch byChris Lattner
Alexei Svitkine! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21Use an APInt of target int size to detect overflow while parsing multichars.Sanjiv Gupta
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-20fix the second half of PR4006 and rdar://6807000 by treatingChris Lattner
() 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-20Move the on-disk hash table code into its own header. No functionality change.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69580 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19implement "#pragma GCC diagnostic". Besides being a nice feature, thisChris Lattner
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-19Warn about uses of #pragma STDC FENV_ACCESS ON, since we don't Chris Lattner
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-19diagnose invalid syntax of STDC pragmas.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69554 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19reject invalid stuff in the STDC namespace.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69551 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19stub out STDC #pragmas.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19basic support for -Wunknown-pragmas, more coming.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19move token paste poisoning diagnostics to after the instantiation locChris Lattner
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-19Fix PR3918: Invalid use of __VA_ARGS__ not diagnosed,Chris Lattner
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-19Fix PR4006, incorrect handling of __VA_ARGS__ when it was the first tokenChris Lattner
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-18Fix PR3917: the location of a #line directive is the location of the first _.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69485 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18Change Preprocessor::AdvanceToTokenCharacter to stop atChris Lattner
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