Commit Graph

511 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 832de9fcf1 [preprocessing record] Have the MacroDefinitions map point to the MacroDefinition object instead
its index in the preprocessed entities vector.

This is because the order of the entities in the vector can change in some (uncommon) cases.

llvm-svn: 175907
2013-02-22 18:35:59 +00:00
Jordan Rose 176057b578 Preproceessor: fix #if skipping under -traditional-cpp.
When parsing directives within skipped #if blocks, we don't want to retain
any whitespace. Previously we were just skipping comments, but it's not
possible to skip comments and retain other whitespace. This change matches
the usual behavior for parsing directives (i.e. the behavior outside of
skipped #if blocks).

<rdar://problem/13267695>

llvm-svn: 175840
2013-02-22 00:32:00 +00:00
Jordan Rose cb8a1aca35 Preprocessor: preserve whitespace in -traditional-cpp mode.
Note that unlike GNU cpp we currently do not preserve whitespace in macros
(even in -traditional-cpp mode).

<rdar://problem/12897179>

llvm-svn: 175778
2013-02-21 18:53:19 +00:00
Dmitri Gribenko 4b8a84fdca FileCheck'ize tests
llvm-svn: 174815
2013-02-09 16:41:47 +00:00
Dmitri Gribenko f37d0cd780 FileCheck'ize a test
llvm-svn: 174814
2013-02-09 16:25:38 +00:00
Jordan Rose 58c61e006f Properly validate UCNs for C99 and C++03 (both more restrictive than C(++)11).
Add warnings under -Wc++11-compat, -Wc++98-compat, and -Wc99-compat when a
particular UCN is incompatible with a different standard, and -Wunicode when
a UCN refers to a surrogate character in C++03.

llvm-svn: 174788
2013-02-09 01:10:25 +00:00
Jordan Rose a08ed5965c Simplify logic for avoiding concatenation after numeric constants.
I threw in a couple of test cases for UD-suffixes -- already working, but
it wasn't immediately obvious to me.

llvm-svn: 174767
2013-02-08 22:30:31 +00:00
Bill Schmidt 38378a06dd Add some missing PPC cpus
llvm-svn: 174215
2013-02-01 20:23:10 +00:00
Hal Finkel df1e4bfcb2 Add PPC A2Q core and BG/Q preprocessor definitions
The a2q core is the variant of the a2 core used on the BG/Q supercomputers.

llvm-svn: 174151
2013-02-01 05:53:33 +00:00
Tim Northover 9bb857a4f1 Add support for AArch64 target.
In cooperation with the LLVM patch, this should implement all scalar front-end
parts of the C and C++ ABIs for AArch64.

This patch excludes the NEON support also reviewed due to an outbreak of
batshit insanity in our legal department. That will be committed soon bringing
the changes to precisely what has been approved.

Further reviews would be gratefully received.

llvm-svn: 174055
2013-01-31 12:13:10 +00:00
Douglas Gregor 1a347f76c2 Reinstate r173952, this time limiting it to exactly the form
#define X X

for which there is no point warning, ever.

llvm-svn: 173991
2013-01-30 23:10:17 +00:00
Argyrios Kyrtzidis a94bd438f8 Revert "[preprocessor] Don't warn about "disabled expansion of recursive macro""
This reverts commit r173952

llvm-svn: 173970
2013-01-30 20:42:17 +00:00
Argyrios Kyrtzidis 8c8684bbe1 [preprocessor] Don't warn about "disabled expansion of recursive macro"
for "#define X X".

This is a pattern that, for example, stdbool.h uses.
rdar://12435773

llvm-svn: 173952
2013-01-30 18:55:52 +00:00
Argyrios Kyrtzidis 005206a813 [Preprocessor] When checking if we can concatenate two tokens, check
if they were already concatenated in source using the spelling locations
even if they came from a macro expansion.

This fixes an issue where a GUID passed as macro argument ends up
malformed after preprocessing because we added spaces inside it.

rdar://13016645

llvm-svn: 173826
2013-01-29 20:28:24 +00:00
Dmitri Gribenko 35630ec93a FileCheck'ize tests
llvm-svn: 173720
2013-01-28 21:43:46 +00:00
Dmitri Gribenko 6f2082b28c FileCheck'ize a test
llvm-svn: 173717
2013-01-28 21:04:29 +00:00
Dmitri Gribenko 1223762783 Migrate a test to -verify
llvm-svn: 173716
2013-01-28 20:55:54 +00:00
Dmitri Gribenko b5bf9b64d2 FileCheck'ize and merge tests
llvm-svn: 173697
2013-01-28 17:31:40 +00:00
Hal Finkel 2109f23000 Fix the indentation of the first line of preprocessor output
The -E output from clang did not produce the correct indentation on the first line.
This is because MoveToLine returned false, and when this happens,
the regular process for producing initial indentation is skipped.

Thanks to Eli for suggesting a way to simplify this to a one-line change.

llvm-svn: 173657
2013-01-28 04:37:37 +00:00
Dmitri Gribenko 5a7ae8dc18 Migrate tests to -verify
llvm-svn: 173582
2013-01-26 17:11:39 +00:00
NAKAMURA Takumi f10ef4d40c clang/test/Preprocessor/iwithprefix.c: Tweak default includes not to use /usr/include.
You may see such a message on non-posix system;
  ignoring nonexistent directory "/usr/local/include"
  ignoring nonexistent directory "/usr/include"

llvm-svn: 173525
2013-01-25 23:17:20 +00:00
Dmitri Gribenko f079de0a08 FileCheck'ize tests
llvm-svn: 173484
2013-01-25 20:34:08 +00:00
Dmitri Gribenko d9c7ceebde Migrate tests to -verify and merge them
llvm-svn: 173482
2013-01-25 20:33:53 +00:00
Daniel Dunbar b7eaa6b8ac [tests] Force a triple to ensure /usr/include is one of the entries.
llvm-svn: 173469
2013-01-25 18:50:18 +00:00
Daniel Dunbar bd5dfe4511 [tests] Add a test for -iwithprefix.
- This just scratches the surface, We have pretty horrible test coverage in
   this area it seems like, but this at least covers the change in r173410.

llvm-svn: 173464
2013-01-25 18:08:53 +00:00
Jordan Rose d4960d3eb1 Test fix-it ranges for Unicode characters.
Also, remove stray -fdiagnostics-parseable-fixits from ucn-pp-identifier.

llvm-svn: 173373
2013-01-24 21:19:51 +00:00
Jordan Rose 62db5066e9 Add a fixit for \U1234 -> \u1234.
llvm-svn: 173371
2013-01-24 20:50:52 +00:00
Jordan Rose 7f43dddae0 Handle universal character names and Unicode characters outside of literals.
This is a missing piece for C99 conformance.

This patch handles UCNs by adding a '\\' case to LexTokenInternal and
LexIdentifier -- if we see a backslash, we tentatively try to read in a UCN.
If the UCN is not syntactically well-formed, we fall back to the old
treatment: a backslash followed by an identifier beginning with 'u' (or 'U').

Because the spelling of an identifier with UCNs still has the UCN in it, we
need to convert that to UTF-8 in Preprocessor::LookUpIdentifierInfo.

Of course, valid code that does *not* use UCNs will see only a very minimal
performance hit (checks after each identifier for non-ASCII characters,
checks when converting raw_identifiers to identifiers that they do not
contain UCNs, and checks when getting the spelling of an identifier that it
does not contain a UCN).

This patch also adds basic support for actual UTF-8 in the source. This is
treated almost exactly the same as UCNs except that we consider stray
Unicode characters to be mistakes and offer a fixit to remove them.

llvm-svn: 173369
2013-01-24 20:50:46 +00:00
Bill Wendling 8879c43a53 Don't check lines beginning with '#', since they could contain a path with the unexpected word in them.
llvm-svn: 173307
2013-01-23 23:07:21 +00:00
Joey Gouly 1d58cdbf4e Add some semantic checks for OpenCL. Variadic macros, VLAs and bitfields are not supported.
llvm-svn: 172732
2013-01-17 17:35:00 +00:00
Matt Beaumont-Gay 978cca9f49 Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.

This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.

There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.

llvm-svn: 172696
2013-01-17 02:06:08 +00:00
Aaron Ballman 6ce0000dd5 No longer crashing with an assert when __has_include or __has_include_next is used outside of a preprocessor directive. This fixes PR14837.
llvm-svn: 172639
2013-01-16 19:32:21 +00:00
Argyrios Kyrtzidis eb994f4064 [PreprocessingRecord] A macro expansion can be reported out-of-order in cases when
there are macro expansions inside macro arguments where the arguments are
not expanded in the same order as listed; don't assert that all macro expansions
are in source order.

rdar://12397063

llvm-svn: 172018
2013-01-09 23:22:20 +00:00
Eli Friedman c52435b4a2 Make sure clang puts tokens from different files on separate lines in "-E -P" mode. <rdar://problem/12774044>
llvm-svn: 171944
2013-01-09 03:16:42 +00:00
Eli Friedman ec94b61745 Make __has_include a bit more resilient in the presence of macros. <rdar://problem/12748859>.
llvm-svn: 171939
2013-01-09 02:20:00 +00:00
Richard Smith 89645bc888 s/CXX0X/CXX11/g, except for __GNU_EXPERIMENTAL_CXX0X__, and update a few nearby 'C++0x' comments.
llvm-svn: 171372
2013-01-02 12:01:23 +00:00
Argyrios Kyrtzidis 5e14925a35 [preprocessor] When "merging" macro argument tokens into one SLocEntry chunk,
make sure they came from the same kind of FileIDs.

Thanks to Abramo Bagnara for providing the test case.

llvm-svn: 170616
2012-12-19 23:55:44 +00:00
Argyrios Kyrtzidis 164fdb607b [preprocessor] For errors at a function macro invocation, also include
a note about where the macro is defined.

llvm-svn: 170228
2012-12-14 18:53:47 +00:00
Richard Smith 181879c293 Don't warn about disabled macro expansion if we see the name of a function-like macro which isn't immediately followed by '('. FreeBSD's stdio.h #defines foo(x) to (foo)(x), apparently.
llvm-svn: 169960
2012-12-12 02:46:14 +00:00
NAKAMURA Takumi 5c9f577c7f Disable clang/test/Preprocessor/macro-multiline.c for now, while investigating lit.ShUtil.parser.
llvm-svn: 169458
2012-12-06 01:09:31 +00:00
Andy Gibbs d41d094244 Prevent premature macro expansion in __has_builtin, __has_feature,
__has_attribute, __has_extension, making them behave more akin to
conventional macros.

llvm-svn: 168268
2012-11-17 19:18:27 +00:00
Andy Gibbs a8df57a962 Made the "expected string literal" diagnostic more expressive
llvm-svn: 168267
2012-11-17 19:16:52 +00:00
Andy Gibbs 58905d251b Refactored duplicate string literal lexing code within Preprocessor, into a
common LexStringLiteral function.  In doing so, some consistency problems have
been ironed out (e.g. where the first token in the string literal was lexed
with macro expansion, but subsequent ones were not) and also an erroneous
diagnostic has been corrected.

LexStringLiteral is complemented by a FinishLexStringLiteral function which
can be used in the situation where the first token of the string literal has
already been lexed.

llvm-svn: 168266
2012-11-17 19:15:38 +00:00
Andy Gibbs f591982bb2 Fix handling of invalid uses of the __has_warning builtin macro
llvm-svn: 168265
2012-11-17 19:14:53 +00:00
Eli Friedman 3e94f57a0f Add missing features for misc x86 CPUs to CPU feature translation. Patch by Jung-uk Kim.
llvm-svn: 168239
2012-11-17 01:43:10 +00:00
Daniel Dunbar 5d38875d81 CPP Output: Do not emit an enter file marker for the main file.
- This diverges from gcc, and confuses tools (like dtrace) which track # line
   markers as a way to determine which content is in the context of the main
   file.

llvm-svn: 168128
2012-11-16 01:51:11 +00:00
Eli Friedman 14d3c79b45 Suppress elided variadic macro argument extension diagnostic for macros using
the related comma pasting extension.

In certain cases, we used to get two diagnostics for what is essentially one
extension.  This change suppresses the first diagnostic in certain cases
where we know we're going to print the second diagnostic.  The
diagnostic is redundant, and it can't be suppressed in the definition
of the macro because it points at the use of the macro, so we want to
avoid printing it if possible.

The implementation works by detecting constructs which look like comma
pasting at the time of the definition of the macro; this information
is then used when the macro is used.  (We can't actually detect
whether we're using the comma pasting extension until the macro is
actually used, but we can detecting constructs which will be comma
pasting if the varargs argument is elided.)

<rdar://problem/12292192>

llvm-svn: 167907
2012-11-14 02:18:46 +00:00
Michael Liao 625a875f05 Add clang support of RTM from TSX
- New options '-mrtm'/'-mno-rtm' are added to enable/disable RTM feature
- Builtin macro '__RTM__' is defined if RTM feature is enabled
- RTM intrinsic header is added and introduces 3 new intrinsics, namely
  '_xbegin', '_xend', and '_xabort'.
- 3 new builtins are added to keep compatible with gcc, namely
  '__builtin_ia32_xbegin', '__builtin_ia32_xend', and '__builtin_ia32_xabort'.
- Test cases for pre-defined macro and new intrinsic codegen are added.

llvm-svn: 167665
2012-11-10 05:17:46 +00:00
Eli Friedman c6d2fdbbb1 Make __LDBL_MAX__ etc. have the correct type on targets where long double/double/etc. have the same format. PR14285.
Based on patch by Jeroen Dobbelaere.

llvm-svn: 167649
2012-11-10 00:20:38 +00:00
Andy Gibbs 571df35397 Improved support for removing the comma preceding __VA_ARGS__ where __VA_ARGS__
is empty in a variadic macro expansion.  This fixes a divergence in support for
the ", ## __VA_ARGS__" GCC extension which differed in behaviour when in strict
C99 mode (note: there is no change in behaviour has been made in the gnu99 mode
that clang uses by default).  In addition, there is improved support for the
Microsoft alternative extension ", __VA_ARGS__".

llvm-svn: 167613
2012-11-09 13:24:30 +00:00