Commit Graph

683 Commits

Author SHA1 Message Date
Simon Atanasyan 22127cee34 [Mips] Support -mnan=2008 option. Define "__mips_nan2008" macros and pass
this option to the assembler.

llvm-svn: 191282
2013-09-24 09:09:16 +00:00
Ben Langmuir 58078d0103 Add C intrinsics for Intel SHA Extensions
Intrinsics added shaintrin.h, which is included from x86intrin.h if __SHA__ is
enabled. SHA implies SSE2, which is needed for the __m128i type.

Also add the -msha/-mno-sha option.

llvm-svn: 190999
2013-09-19 13:22:04 +00:00
Eli Friedman 0834a4b901 Make Preprocessor::Lex non-recursive.
Before this patch, Lex() would recurse whenever the current lexer changed (e.g.
upon entry into a macro). This patch turns the recursion into a loop: the
various lex routines now don't return a token when the current lexer changes,
and at the top level Preprocessor::Lex() now loops until it finds a token.
Normally, the recursion wouldn't end up being very deep, but the recursion depth
can explode in edge cases like a bunch of consecutive macros which expand to
nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this
patch).

<rdar://problem/14569770>

llvm-svn: 190980
2013-09-19 00:41:32 +00:00
Craig Topper 5f79e2661d Disabling sse2 should disable aes and pclmul support.
llvm-svn: 190977
2013-09-19 00:01:05 +00:00
Joey Gouly 1e8637b259 [ARMv8] Add builtins for CRC instructions.
Patch by Bradley Smith!

llvm-svn: 190931
2013-09-18 10:07:09 +00:00
Hal Finkel c4d7c82c7f Add the intrinsic __builtin_convertvector
LLVM supports applying conversion instructions to vectors of the same number of
elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to
cause such instructions to be generated when using builtin vector types.

C-style casting on vectors is already defined in terms of bitcasts, and so
cannot be used for these conversions as well (without leading to a very
confusing set of semantics). As a result, this adds a __builtin_convertvector
intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is
intended to aid the creation of vector intrinsic headers that create generic IR
instead of target-dependent intrinsics (in other words, this is a generic
_mm_cvtepi32_ps). As noted in the documentation, the action of
__builtin_convertvector is defined in terms of the action of a C-style cast on
each vector element.

llvm-svn: 190915
2013-09-18 03:29:45 +00:00
Craig Topper 31db3a2efc Make F16C feature imply AVX. Matches GCC behavior.
llvm-svn: 190776
2013-09-16 04:54:13 +00:00
Reid Kleckner 881dff3683 Lex and ignore Microsoft's #pragma warning(...)
Summary:
This fixes PR17145 and avoids unknown pragma warnings.

This change does not attempt to map MSVC warning numbers to clang
warning flags.  Perhaps in the future we will implement a mapping for
some common subset of Microsoft warnings, but for now we don't.

Reviewers: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1652

llvm-svn: 190726
2013-09-13 22:00:30 +00:00
Craig Topper c0070a4320 Fix a bug where -msse followed by -mno-sse would leave MMX enabled.
llvm-svn: 190496
2013-09-11 06:48:53 +00:00
Craig Topper 7481d8aa17 Separate popcnt and sse4.2 feature control somewhat to match gcc behavior.
Enabling sse4.2 will implicitly enable popcnt unless popcnt is explicitly disabled.
Disabling sse4.2 will not disable popcnt if popcnt is explicitly enabled.

llvm-svn: 190387
2013-09-10 06:55:47 +00:00
Sylvestre Ledru 4e06e6e8c3 Follow up on commit r190159. Also test the KFreeBSD i686 platform defines + minor cosmetics
llvm-svn: 190162
2013-09-06 15:36:36 +00:00
Sylvestre Ledru fd7cd35592 Add a test for the KFreeBSD define (#define __FreeBSD_kernel__ 1). This was introduced in commit r190048
llvm-svn: 190159
2013-09-06 14:53:07 +00:00
Rafael Espindola ff7cea8c1a Don't pass -O0 to clang_cc1, it is the default.
llvm-svn: 189910
2013-09-04 04:12:25 +00:00
Benjamin Kramer ffecc84583 Add support for -march=slm, aka Intel Atom Silvermont.
llvm-svn: 189670
2013-08-30 14:05:34 +00:00
Eli Friedman 80e45b8cd4 Properly escape filenames in line directives.
Fixes PR17018.  Only partial test coverage because I don't want
to try to write a test which generates a file whose name contains a newline.

llvm-svn: 189557
2013-08-29 01:42:42 +00:00
Eli Friedman cefc7eafc6 Fix "//" comments with -traditional-cpp in C++.
Apparently, gcc's -traditional-cpp behaves slightly differently in C++ mode;
specifically, it discards "//" comments.  Match gcc's behavior.

<rdar://problem/14808126>

llvm-svn: 189515
2013-08-28 20:53:32 +00:00
Eli Friedman 2afb63c001 Handle -D arguments ending in a backslash.
We translate these into #define directives; to preserve gcc-compatible
semantics (where the expanded macro includes the backslash), we add
an extra "\\\n" to the end of the synthesized "#define".

<rdar://problem/14810220>

llvm-svn: 189511
2013-08-28 20:35:38 +00:00
Craig Topper 258a86802a Add test cases for avx512 feature flags. Fix typo in avx512pf options.
llvm-svn: 188984
2013-08-22 04:32:55 +00:00
Eli Friedman 5ba37d5282 Split isFromMainFile into two functions.
Basically, isInMainFile considers line markers, and isWrittenInMainFile
doesn't.  Distinguishing between the two is useful when dealing with
files which are preprocessed files or rewritten with -frewrite-includes
(so we don't, for example, print useless warnings).

llvm-svn: 188968
2013-08-22 00:27:10 +00:00
Rafael Espindola 0221d8636e Don't disable SSE4A when disabling AVX.
Thanks for Craig Topper for noticing it.

llvm-svn: 188902
2013-08-21 13:28:02 +00:00
Craig Topper 679b53ac67 Add avx512cd, avx512er, avx512pf feature flags and enable them on KNL CPU.
llvm-svn: 188867
2013-08-21 05:29:10 +00:00
Rafael Espindola db0fcfbfae Centralize the logic for handling -m* options and fix pr16943.
This moves the logic for handling -mfoo -mno-foo from the driver to -cc1. It
also changes -cc1 to apply the options in order, fixing pr16943.

The handling of -mno-mmx -msse is now an explicit special case.

llvm-svn: 188817
2013-08-20 18:57:55 +00:00
Craig Topper af0ca63cec Rename __AVX512__ to __AVX512F__
llvm-svn: 188764
2013-08-20 07:52:37 +00:00
Craig Topper 449314e1ec Add AVX-512 feature flag and knl cpu to clang.
llvm-svn: 188758
2013-08-20 07:09:39 +00:00
Craig Topper 33b4cde2f2 Revert r188756 because some other changes snuck in with it.
llvm-svn: 188757
2013-08-20 07:07:29 +00:00
Craig Topper ffb7180e96 Add AVX-512 feature flag and knl cpu to clang.
llvm-svn: 188756
2013-08-20 07:05:05 +00:00
Robert Lytton 0e07649ae5 Add XCore target
llvm-svn: 188258
2013-08-13 09:43:10 +00:00
Jack Carter 44ff1e5673 [Mips] MSA frontend option support
This patch adds -mmsa and -mno-msa to the options supported by 
clang to enable and disable support for MSA.

When MSA is enabled, a predefined macro '__mips_msa' is defined to 1.

Patch by Daniel Sanders

llvm-svn: 188184
2013-08-12 17:20:29 +00:00
Tim Northover 2fe823a6c3 AArch64: initial NEON support
Patch by Ana Pazos

- Completed implementation of instruction formats:
AdvSIMD three same
AdvSIMD modified immediate
AdvSIMD scalar pairwise

- Completed implementation of instruction classes
(some of the instructions in these classes
belong to yet unfinished instruction formats):
Vector Arithmetic
Vector Immediate
Vector Pairwise Arithmetic

- Initial implementation of instruction formats:
AdvSIMD scalar two-reg misc
AdvSIMD scalar three same

- Intial implementation of instruction class:
Scalar Arithmetic

- Initial clang changes to support arm v8 intrinsics.
Note: no clang changes for scalar intrinsics function name mangling yet.

- Comprehensive test cases for added instructions
To verify auto codegen, encoding, decoding, diagnosis, intrinsics.

llvm-svn: 187568
2013-08-01 09:23:19 +00:00
Bill Schmidt 778d387684 [PowerPC] Support powerpc64le as a syntax-checking target.
This patch provides basic support for powerpc64le as an LLVM target.
However, use of this target will not actually generate little-endian
code.  Instead, use of the target will cause the correct little-endian
built-in defines to be generated, so that code that tests for
__LITTLE_ENDIAN__, for example, will be correctly parsed for
syntax-only testing.  Code generation will otherwise be the same as
powerpc64 (big-endian), for now.

The patch leaves open the possibility of creating a little-endian
PowerPC64 back end, but there is no immediate intent to create such a
thing.

The new test case variant ensures that correct built-in defines for
little-endian code are generated.

llvm-svn: 187180
2013-07-26 01:36:11 +00:00
Rafael Espindola 644eb0a8da Add not to a command that is expected to fail.
llvm-svn: 187065
2013-07-24 18:45:44 +00:00
Richard Trieu 7aa7218545 Changed "an macro" to "a macro" in diagnostic note.
llvm-svn: 186988
2013-07-23 21:06:45 +00:00
Richard Trieu 79b45389c3 Add new diagnostic messages when too many arguments are presented to a
function-like macro.  Clang will attempt to correct the arguments by detecting
braced initializer lists:

1) If possible, suggest parentheses around arguments
containing braced lists which will give the proper number of arguments.
2) If a braced list is detected at the start of a macro argument, it cannot be
corrected by parentheses.  Instead, just point out the location of these
braced lists.

llvm-svn: 186971
2013-07-23 18:01:49 +00:00
Richard Smith 701a3523ba Don't give # and ## special treatment when in -traditional-cpp mode. Patch by
Austin Seipp!

llvm-svn: 185896
2013-07-09 01:00:29 +00:00
Richard Smith baf2912b40 Generalize hack allowing 'const' in __has_attribute (etc) to allow any token
with identifier info. This covers most identifier-like entities (other than
the ISO646 keywords).

llvm-svn: 185895
2013-07-09 00:57:56 +00:00
Rafael Espindola 925213b0fa Add 'not' to commands that are expected to fail.
This is at least good documentation, but also opens the possibility of
using pipefail.

llvm-svn: 185652
2013-07-04 16:16:58 +00:00
Rafael Espindola 80a99478bd Convert test to FileCheck.
llvm-svn: 185645
2013-07-04 15:08:20 +00:00
Roman Divacky 13b586f298 Dont define __LONG_DOUBLE_128__ unless LongDoubleWidth is really 128bits width.
It's not the case on ie. FreeBSD.

llvm-svn: 185572
2013-07-03 19:45:54 +00:00
Anton Korobeynikov ef4129084a Fix MSP430 builtin types.
Patch by Job Noorman!

llvm-svn: 185362
2013-07-01 19:42:40 +00:00
Reid Kleckner 596b85cc23 Match MSVC's handling of commas during macro argument expansion
This allows clang to parse the type_traits header in Visual Studio 2012,
which is included widely in practice.

This is a rework of r163022 by João Matos.  The original patch broke
preprocessing of gtest headers, which this patch addresses.

Patch by Will Wilson!

llvm-svn: 184968
2013-06-26 17:16:08 +00:00
Chandler Carruth 6aa92ad762 Fix a couple of PPC predefined macros that I spotted while driving by
this code. These aren't technically standard predefines for the platform
but apparantly lots of folks use them as they show up within LLVM's own
codebase. ;] This may even fix some self host issues w/ the JIT!!!

llvm-svn: 184830
2013-06-25 11:13:47 +00:00
Rafael Espindola 49ddb8675b Accept both / and \\ to fix the windows bots.
llvm-svn: 184790
2013-06-24 22:07:15 +00:00
Eli Friedman cdf8b88285 Make sure the assembler-with-cpp hack for "#" works with multiple "#"s in
succession. Fixes PR16363.

llvm-svn: 184240
2013-06-18 21:33:38 +00:00
Aaron Ballman 5d041beb4e Adding support for MSVC #pragma detect_mismatch functionality by emitting a FAILIFMISMATCH linker command into the object file.
llvm-svn: 183178
2013-06-04 02:07:14 +00:00
Argyrios Kyrtzidis 977026c5f5 [Preprocessor] Prevent expansion of y in x ## y when x is empty
When x is empty, x ## is suppressed, and when y gets expanded, the fact that it follows ## is not
available in the macro expansion result. The macro definition can be checked instead, the ## will
be available there regardless of what x expands to.

Fixes http://llvm.org/PR12767

Patch by Harald van Dijk!

llvm-svn: 182699
2013-05-25 01:35:18 +00:00
Jakob Stoklund Olesen 826df14d72 OpenBSD/sparc64 uses long long for int64_t and intmax_t.
Other operating systems, including FreeBSD and NetBSD, use long.

llvm-svn: 182215
2013-05-19 17:53:37 +00:00
David Fang 072d47b67f fix PR 15726: ptrdiff_t should be int on PowerPC Darwin
llvm-svn: 182029
2013-05-16 17:51:48 +00:00
Jakob Stoklund Olesen 248520bdea Use correct types for SPARC v9.
It's an LP64 platform.

llvm-svn: 181867
2013-05-15 03:22:33 +00:00
Richard Smith 0a715429b9 C++1y: Update __cplusplus to temporary value 201305L to allow detection of provisional C++1y support.
Add __has_feature and __has_extension checks for C++1y features (based on the provisional names from
the C++ features study group), and update documentation to match.

llvm-svn: 181342
2013-05-07 19:32:56 +00:00
Ulrich Weigand 47445073f8 Add SystemZ support
This patch then adds all the usual platform-specific pieces for SystemZ:
driver support, basic target info, register names and constraints,
ABI info and vararg support.  It also adds new tests to verify pre-defined
macros and inline asm, and updates a test for the minimum alignment change.

This version of the patch incorporates feedback from reviews by
Eric Christopher and John McCall.  Thanks to all reviewers!

Patch by Richard Sandiford.

llvm-svn: 181211
2013-05-06 16:26:41 +00:00
Benjamin Kramer 914d7e06b6 Add support for -march=btver2.
llvm-svn: 181006
2013-05-03 10:47:15 +00:00
Hans Wennborg 4c02be3b83 Make sure we define wchar_t related macros correctly in -fms-extensions mode.
This adds a test to make sure we define _WCHAR_T_DEFINED and
_NATIVE_WCHAR_T_DEFINED correctly in the preprocessor, and updates
stddef.h to set it when typedeffing wchar_t.

llvm-svn: 180918
2013-05-02 13:12:32 +00:00
Argyrios Kyrtzidis f97290bb53 [test] add missing header for the test.
llvm-svn: 180719
2013-04-29 17:31:48 +00:00
Argyrios Kyrtzidis c3b4b79beb When emitting a preprocessed file with implicit module imports, make sure line directives are emitted in the next line.
rdar://13722737

llvm-svn: 180718
2013-04-29 17:26:22 +00:00
Jordan Rose 111c4a6b69 Fix off-by-one error in #pragma clang system_header.
The system_header pragma (from GCC) is implemented using line notes in the
source manager. However, a line note's line number specifies the number
not for the current line, but for the next line. This was making all
line numbers appear off by one after the pragma.

Reported by Andy Gibbs, uncovered during r179677.

llvm-svn: 179709
2013-04-17 19:09:18 +00:00
Tareq A. Siraj 0de0dd4923 Parser support for #pragma clang __debug captured
This patch implements parsing ‘#pragma clang __debug’ as a first step for
implementing captured statements. Captured statements are a mechanism for
doing outlining in the AST.
see http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.

Currently returns StmtEmpty

Author: Andy Zhang <andy.zhang@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D369

llvm-svn: 179614
2013-04-16 18:41:26 +00:00
Simon Atanasyan 607776140b [Mips] Support -mmicromips / -mno-micromips command line options.
llvm-svn: 179489
2013-04-14 14:07:51 +00:00
Simon Atanasyan 1607191e66 [Mips] Follow-up to r179481. Consider "single-float" as a separate
independent of float ABI feature in the MipsTargetInfoBase class.

llvm-svn: 179486
2013-04-14 14:07:30 +00:00
Reid Kleckner 9643a313ac Fix failing dependencies-and-pp.c test
The bots seem to do more line wrapping because they have longer absolute
paths.

llvm-svn: 179284
2013-04-11 13:43:19 +00:00
Reid Kleckner 37e8fe13e0 FileCheck-ify more grep tests with quoted double quotes
This required some tedious reordering to match clang's order.
Presumably these ObjC tests were generated based on llvm-gcc's output
ordering.

llvm-svn: 179282
2013-04-11 13:24:56 +00:00
Reid Kleckner e494399203 FileCheck-ify some clang grep tests that use double quotes
The escaping interaction between Python and grep doesn't work on my
system.  This change fixes the tests for me.

llvm-svn: 179214
2013-04-10 21:10:39 +00:00
Argyrios Kyrtzidis a6444b1ce1 [frontend] When preprocessing, turn implicit module imports into @imports.
part of rdar://13610250

llvm-svn: 179144
2013-04-10 01:53:46 +00:00
Michael Ilseman 82a2a3d8f5 Repeat some #line directive tests for the GNU line marker directive.
llvm-svn: 179142
2013-04-10 01:41:19 +00:00
Michael Ilseman e910cc8e07 Improve the diagnostics of the number-reading preprocessor directives.
The GNU line marker directive was sharing code with the #line directive, but some of the warnings/errors were reporting as #line directive diagnostics in both cases.

Previously:
#line 11foo1   ==> "#line directive requires a simple digit sequence"
# 11foo1       ==> "#line directive requires a simple digit sequence"

Now, we get:
#line 11foo1   ==> "#line directive requires a simple digit sequence"
# 11foo1       ==> "GNU line marker directive requires a simple digit sequence"

llvm-svn: 179139
2013-04-10 01:04:18 +00:00
Tim Northover b85654d3cd AArch64: bring predefines in line with most recent ACLE document
The prefixes and names used are now identical to 32-bit ARM, which is also
expected to remain unchanged.

If we made this change after a release, we'd probably have to support both
variants for a while, but I think since AArch64 exists only on trunk now, it's
acceptable to simply swap them now.

llvm-svn: 178870
2013-04-05 14:08:55 +00:00
Michael J. Spencer a0d5eb3a27 Add support for __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4,8} on x86.
This fixes std::thread with libstdc++.

llvm-svn: 178816
2013-04-04 23:53:43 +00:00
Argyrios Kyrtzidis 0c2f30b9d3 [preprocessor] Allow comparing two macro definitions syntactically instead of only lexically.
Syntactically means the function macro parameter names do not need to use the same
identifiers in order for the definitions to be considered identical.

Syntactic equivalence is a microsoft extension for macro redefinitions and we'll also
use this kind of comparison to check for ambiguous macros coming from modules.

rdar://13562254

llvm-svn: 178671
2013-04-03 17:39:30 +00:00
Evgeniy Stepanov c3c725aae3 Define __SIZE_MAX__ preprocessor macro.
llvm-svn: 178226
2013-03-28 08:36:54 +00:00
David Blaikie 1dc4a3dfd6 PR15539: Record "evaluating if/elif condition" flag in the right place
The previous implementation missed the case where the elif condition was
evaluated from the context of an #ifdef that was false causing PR15539.

llvm-svn: 177345
2013-03-18 23:22:28 +00:00
Jordan Rose 67b66231a8 Preprocessor: don't keep comments under -traditional-cpp.
This patch is designed for minimal intrusion into normal preprocessing
and compilation; under -E -traditional-cpp, the lexer will still
generate tok::comment nodes since it is preserving all whitespace, but
the output printer will then throw it away.

<rdar://problem/13338680>

llvm-svn: 176534
2013-03-05 23:54:55 +00:00
Jordan Rose 864b810739 Preprocessor: don't consider // to be a line comment in -E -std=c89 mode.
It's beneficial when compiling to treat // as the start of a line
comment even in -std=c89 mode, since it's not valid C code (with a few
rare exceptions) and is usually intended as such. We emit a pedantic
warning and then continue on as if line comments were enabled.
This has been our behavior for quite some time.

However, people use the preprocessor for things besides C source files.
In today's prompting example, the input contains (unquoted) URLs, which
contain // but should still be preserved.

This change instructs the lexer to treat // as a plain token if Clang is
in C90 mode and generating preprocessed output rather than actually compiling.

<rdar://problem/13338743>

llvm-svn: 176526
2013-03-05 22:51:04 +00:00
Argyrios Kyrtzidis f77453cf22 Add a test to make sure __has_include works from inside a macro.
llvm-svn: 176152
2013-02-27 01:34:48 +00:00
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
Mahesha S 19a429e7e6 Reverted back the changes made in 166868 and in 166869
llvm-svn: 166871
2012-10-27 10:44:42 +00:00
Mahesha S 5d61097dd9 Feature:
OpenMP support.

Sub-Feature:
  Support for "#pragma omp ..." registration with
  Preprocessor.

Files Changed/Added:
  * include/clang/Basic/DiagnosticGroups.td (C)
  * include/clang/Basic/DiagnosticParseKinds.td (C)
  * include/clang/Basic/TokenKinds.def (C)
  * include/clang/Parse/Parser.h (C)
  * lib/Parse/Parser.cpp (C)

Test Cases Changed/Added:
  * test/Preprocessor/pragma_omp.c (A)
  * test/Preprocessor/pragma_omp_ignored_warning.c (A)

llvm-svn: 166869
2012-10-27 09:05:45 +00:00
David Tweed d8bb236e18 Correct test inovocations to use %clang_cc1 rather than direct invocation (so that it can have additional options set when trying to debug issues causing regressions).
llvm-svn: 166681
2012-10-25 13:56:30 +00:00
Richard Trieu da031982b8 Fix for PR13334. This prevents crashes that result from badly formed
expressions involving __has_include

llvm-svn: 166438
2012-10-22 20:28:48 +00:00
Andy Gibbs c6e68daac0 Prior to adding the new "expected-no-diagnostics" directive to VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive.
llvm-svn: 166280
2012-10-19 12:44:48 +00:00
Michael Gottesman 101290bcef [clang-tests] Changed relative paths to absolute paths in run command for annotate-macro-args.m, get-cursor-macro-args.m, import_self.c.
This fixes make check-all failures when make -C is used to run the tests.

llvm-svn: 164978
2012-10-01 23:39:44 +00:00
Benjamin Kramer 2715fce524 Allow -MF to be used in combination with -E -M or -E -MM.
Fixes PR13851. Patch by Dimitry Andric!

llvm-svn: 164717
2012-09-26 19:01:49 +00:00
Nico Weber dd9602fe93 Revert r163022, it caused PR13924.
Add a test for PR13924. Do not revert the test added in r163022,
it surprisingly still passes even after reverting the code changes.

llvm-svn: 164672
2012-09-26 08:19:01 +00:00
Eli Friedman 847f3ca350 The keywords "true" and "false" shouldn't warn under -Wundef.
llvm-svn: 164279
2012-09-20 02:38:38 +00:00
Anton Korobeynikov e6f74094b5 Add some ARM EABI preprocessor builtins tests
llvm-svn: 163467
2012-09-08 08:45:10 +00:00
Joao Matos c0d4c1bcde Normalize line endings of r163022.
llvm-svn: 163023
2012-08-31 21:34:27 +00:00
Joao Matos e85e3b64f8 Emulate MSVC's preprocessor macro argument separator behavior by not considering commas from nested macro expansions as argument separators. Fixes parsing of VS 2012 headers.
llvm-svn: 163022
2012-08-31 21:10:54 +00:00
Richard Smith 5edd5830e1 Make preprocessor act in a GCC-compatible fashion when a macro is redefined
within its own argument list. The original definition is used for the immediate
expansion, but the new definition is used for any subsequent occurences within
the argument list or after the expansion.

llvm-svn: 162906
2012-08-30 13:38:46 +00:00
Simon Atanasyan c6a0be00ab Define __mips64 / __mips64__ macros for MIPS 64-bit targets.
The patch suggested by Brad Smith.

llvm-svn: 162858
2012-08-29 20:50:11 +00:00
Alexander Kornienko c0b4928df8 Fixed a problem with #pragma push_macro/pop_macro implementation.
Summary:
The problem was with the following sequence:
  #pragma push_macro("long")
  #undef long
  #pragma pop_macro("long")
in case when "long" didn't represent a macro.
Fixed crash and removed code duplication for #undef/pop_macro case. Added regression tests.

Reviewers: doug.gregor, klimek

Reviewed By: doug.gregor

CC: cfe-commits, chapuni

Differential Revision: http://llvm-reviews.chandlerc.com/D31

llvm-svn: 162845
2012-08-29 16:56:24 +00:00
Simon Atanasyan 5a0642fdc1 Define _MIPS_ARCH and _MIPS_ARCH_<cpu name> macros for MIPS targets.
The patch suggested by Logan Chien.

llvm-svn: 162840
2012-08-29 15:17:29 +00:00
Fariborz Jahanian 7513fa346c c: small refactoring of checking for __attribute__(const))
per Richard's comment.

llvm-svn: 161786
2012-08-13 21:15:02 +00:00
Dylan Noblesmith 8d48c8c675 Frontend: define _LP64 in a target-independent way
Instead of adding it to each individual subclass in
Targets.cpp, simply check the appropriate target
values.

Where before it was only on x86_64 and ppc64, it's now
also defined on mips64 and nvptx64.

Also add a bunch of negative tests to ensure it is *not*
defined on any other architectures while we're here.

llvm-svn: 161685
2012-08-10 19:12:37 +00:00
Dylan Noblesmith 4c004f3e13 Preprocessor: fix __OPTIMIZE_SIZE__ and -Oz
Add some tests for __OPTIMIZE_SIZE__ and  __NO_INLINE__,
removing the superfluous copies in the target-specific
tests, since it's target-independent.

This uncovered a bug in the handling of -Oz: it would
attempt to store the value 2 in the 1-bit bitfield OptimizeSize,
leaving a value of 0 and never defining __OPTIMIZE_SIZE__.

llvm-svn: 161495
2012-08-08 16:09:15 +00:00
Dylan Noblesmith 673728fe57 Preprocessor: add __BYTE_ORDER__ predefined macro
The __BYTE_ORDER__ predefined macro was added in GCC 4.6:
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html

It's used like the following:

 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 ...
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 ...
 #else
 #error insane architecture like the pdp-11
 #endif

There's a similar macro, __FLOAT_WORD_ORDER__, but it looks like it
mainly exist to accommodate fairly obscure architectures and ARM's
old FPA instructions, so it doesn't seem nearly as useful.

The tests are updated to check for the correct(at least, based on
clang's current output) value of the macro on each target. So now the
suite will catch bugs like the one fixed in r157626.

llvm-svn: 160879
2012-07-27 18:34:31 +00:00
Dylan Noblesmith eaea2a884b test/Preprocessor: add NVPTX predefine tests
llvm-svn: 160866
2012-07-27 16:37:53 +00:00
Bob Wilson 6a039161d7 Define __FINITE_MATH_ONLY__ based on -ffast-math and -ffinite-math-only.
This macro was being unconditionally set to zero, preceded by a FIXME comment.
This fixes <rdar://problem/11845441>.  Patch by Michael Gottesman!

llvm-svn: 160491
2012-07-19 03:52:53 +00:00
Jordan Rose 1fa2acaed4 Start testing some commented-out cases of badly-formed __has_include.
Filed PR13334 for the cases that cause the compiler to crash, and
PR13335 for the cases where we should be recovering more gracefully.

llvm-svn: 160070
2012-07-11 20:12:19 +00:00
Jordan Rose b13eb8dca5 Allow -verify directives to be filtered by preprocessing.
This is accomplished by making VerifyDiagnosticsConsumer a CommentHandler,
which then only reads the -verify directives that are actually in live
blocks of code. It also makes it simpler to handle -verify directives that
appear in header files, though we still have to manually reparse some files
depending on how they are generated.

This requires some test changes. In particular, all PCH tests now have their
-verify directives outside the "header" portion of the file, using the @line
syntax added in r159978. Other tests have been modified mostly to make it
clear what is being tested, and to prevent polluting the expected output with
the directives themselves.

Patch by Andy Gibbs! (with slight modifications)

The new Frontend/verify-* tests exercise the functionality of this commit,
as well as r159978, r159979, and r160053 (Andy's other -verify enhancements).

llvm-svn: 160068
2012-07-11 19:58:23 +00:00
Benjamin Kramer 1e250395fa Wire up -mrdrnd for X86.
For some reason GCC decided to call the feature rdrnd instead of rdrand,
which requires translating it for LLVM.

llvm-svn: 159897
2012-07-07 09:39:18 +00:00
Simon Atanasyan 9780e4a2bb MIPS: Define __mips_dsp_rev / __mips_dspr2 / __mips_dsp macros
if -mdsp or -mdspr2 options are provided.

llvm-svn: 159774
2012-07-05 20:16:22 +00:00
Simon Atanasyan 72244b6e4f MIPS: Define __mips16 macro if -mips16 option is provided.
llvm-svn: 159753
2012-07-05 16:06:06 +00:00
David Chisnall b601c96892 Rename the GCC Objective-C runtime to gcc from gnu-fragile and the GNUstep
runtime to gnustep from gnu.  Fix EH for the GCC runtime.

llvm-svn: 159684
2012-07-03 20:49:52 +00:00