Commit Graph

224 Commits

Author SHA1 Message Date
Artem Belevich 8601733c1c [CUDA] Make CUDA compilation usable by default.
Currently clang requires several additional command
line options in order to enable new features needed
during CUDA compilation. This patch makes these
options default.

* Automatically include cuda_runtime.h if we've found
  a valid CUDA installation.
* Disable automatic CUDA header inclusion during unit tests.
* Added test case for command line construction.
* Enabled target overloads and relaxed call checks that are
  needed in order to include CUDA headers.
* Added CUDA-7.5 installation path to the CUDA installation search list.
* Define __CUDA__ macro to indicate CUDA compilation.

llvm-svn: 253389
2015-11-17 22:28:55 +00:00
John McCall 28ea04fc4c Define __unsafe_unretained and __autoreleasing in ObjC GC mode.
This was an accidental regression from the MRC __weak patch.

llvm-svn: 252668
2015-11-10 23:00:25 +00:00
Reid Kleckner 738d48d5fe Sink some PTHManager includes out of Preprocessor.h
This reduces the number of .cpp files needed to be rebuilt after
touching OnDiskHashTable from 120 to 21 for me.

llvm-svn: 251810
2015-11-02 17:53:55 +00:00
John McCall 460ce58fa6 Define weak and __weak to mean ARC-style weak references, even in MRC.
Previously, __weak was silently accepted and ignored in MRC mode.
That makes this a potentially source-breaking change that we have to
roll out cautiously.  Accordingly, for the time being, actual support
for __weak references in MRC is experimental, and the compiler will
reject attempts to actually form such references.  The intent is to
eventually enable the feature by default in all non-GC modes.
(It is, of course, incompatible with ObjC GC's interpretation of
__weak.)

If you like, you can enable this feature with
  -Xclang -fobjc-weak
but like any -Xclang option, this option may be removed at any point,
e.g. if/when it is eventually enabled by default.

This patch also enables the use of the ARC __unsafe_unretained qualifier
in MRC.  Unlike __weak, this is being enabled immediately.  Since
variables are essentially __unsafe_unretained by default in MRC,
the only practical uses are (1) communication and (2) changing the
default behavior of by-value block capture.

As an implementation matter, this means that the ObjC ownership
qualifiers may appear in any ObjC language mode, and so this patch
removes a number of checks for getLangOpts().ObjCAutoRefCount
that were guarding the processing of these qualifiers.  I don't
expect this to be a significant drain on performance; it may even
be faster to just check for these qualifiers directly on a type
(since it's probably in a register anyway) than to do N dependent
loads to grab the LangOptions.

rdar://9674298

llvm-svn: 251041
2015-10-22 18:38:17 +00:00
Richard Smith 3fa73f3602 [coroutines] Add feature-test macro for coroutines, defined to 1 to indicate
the implementation is incomplete.

llvm-svn: 250982
2015-10-22 04:27:47 +00:00
Artem Belevich b5bc923af4 [CUDA] Allow parsing of host and device code simultaneously.
* adds -aux-triple option to specify target triple
 * propagates aux target info to AST context and Preprocessor
 * pulls in target specific preprocessor macros.
 * pulls in target-specific builtins from aux target.
 * sets appropriate host or device attribute on builtins.

Differential Revision: http://reviews.llvm.org/D12917

llvm-svn: 248299
2015-09-22 17:23:22 +00:00
Adrian Prantl fb2398d0c4 Make the clang module container format selectable from the command line.
- introduces a new cc1 option -fmodule-format=[raw,obj]
  with 'raw' being the default
- supports arbitrary module container formats that libclang is agnostic to
- adds the format to the module hash to avoid collisions
- splits the old PCHContainerOperations into PCHContainerWriter and
  a PCHContainerReader.

Thanks to Richard Smith for reviewing this patch!

llvm-svn: 242499
2015-07-17 01:19:54 +00:00
Douglas Gregor 59e3d75537 Add __nonnull/__nullable/__null_unspecified predefines for Darwin.
Addresses the rest of rdar://problem/21530726.

llvm-svn: 240597
2015-06-24 22:02:16 +00:00
Adrian Prantl bb165fb04d Introduce a PCHContainerOperations interface (NFC).
A PCHContainerOperations abstract interface provides operations for
creating and unwrapping containers for serialized ASTs (precompiled
headers and clang modules). The default implementation is
RawPCHContainerOperations, which uses a flat file for the output.

The main application for this interface will be an
ObjectFilePCHContainerOperations implementation that uses LLVM to
wrap the module in an ELF/Mach-O/COFF container to store debug info
alongside the AST.

rdar://problem/20091852

llvm-svn: 240225
2015-06-20 18:53:08 +00:00
Faisal Vali 24d59d14ba "This adds -fconcepts-ts as a cc1 option for enabling the
in-progress implementation of the Concepts TS. The recommended feature
test macro __cpp_experimental_concepts is set to 1 (as opposed to
201501) to indicate that the feature is enabled, but the
implementation is incomplete.

The link to the Concepts TS in cxx_status is updated to refer to the
PDTS (N4377). Additional changes related to __has_feature and
__has_extension are to follow in a later change.

Relevant tests include:

test/Lexer/cxx-features.cpp

The test file is updated with testing of the C++14 + Concepts TS mode.
The expected behaviour is the same as that of the C++14 modes except
for the case of __cpp_experimental_concepts."

- Hubert Tong.

Being committed for Hubert (as per his understanding with Richard Smith) as we start work on the concepts-ts following our preliminary strategy session earlier today. 

The patch is tiny and seems quite standard.

Thanks Hubert!

llvm-svn: 237982
2015-05-22 01:11:10 +00:00
Peter Collingbourne 470d94247d Make GNUInline consistent with whether we use traditional GNU inline semantics.
Previously we were setting LangOptions::GNUInline (which controls whether we
use traditional GNU inline semantics) if the language did not have the C99
feature flag set. The trouble with this is that C++ family languages also
do not have that flag set, so we ended up setting this flag in C++ modes
(and working around it in a few places downstream by also checking CPlusPlus).

The fix is to check whether the C89 flag is set for the target language,
rather than whether the C99 flag is cleared. This also lets us remove most
CPlusPlus checks. We continue to test CPlusPlus when deciding whether to
pre-define the __GNUC_GNU_INLINE__ macro for consistency with GCC.

There is a change in semantics in two other places
where we weren't checking both CPlusPlus and GNUInline
(FunctionDecl::doesDeclarationForceExternallyVisibleDefinition and
FunctionDecl::isInlineDefinitionExternallyVisible), but this change seems to
put us back into line with GCC's semantics (test case: test/CodeGen/inline.c).

While at it, forbid -fgnu89-inline in C++ modes, as GCC doesn't support it,
it didn't have any effect before, and supporting it just makes things more
complicated.

Differential Revision: http://reviews.llvm.org/D9333

llvm-svn: 237299
2015-05-13 22:07:22 +00:00
Ed Schouten 4992099b42 Add C11 *_DECIMAL_DIG.
Before C11 there was only the DECIMAL_DIG definition. As of C11, we now
have one definition per floating point type (e.g. DBL_DECIMAL_DIG).
Change the existing code to define the new versions. To remain backward
compatible, define __DECIMAL_DIG__ as __LDBL_DECIMAL_DIG__.

Also update the tests. It seems that some of the existing test vectors
were incorrect. Change all tests for __DECIMAL_DIG__ to expect
__LDBL_DECIMAL_DIG__. Add tests for *_DECIMAL_DIG for FreeBSD/amd64, as
I happen to have such a system laying around. I've validated that the
values are in sync with <float.h>.

llvm-svn: 230207
2015-02-23 09:12:31 +00:00
Vasileios Kalintiris ea50312b84 [mips] Partially revert r223927: Removing __SIZEOF_INT128__ macro for MIPS64
Partially revert r223927 because LLVM gained support for 128-bit integers
in r227089. Modify and keep the tests that verify the definition of the
macro __SIZEOF_INT128__ for MIPS64 BE & LE in the preprocessor.

llvm-svn: 228918
2015-02-12 11:36:56 +00:00
Tim Northover a6a19f1e38 Preprocessor: support __BIGGEST_ALIGNMENT__ macro
For compatibility with GCC (and because it's generally helpful information
otherwise inaccessible to the preprocessor). This appears to be canonically the
alignment of max_align_t (e.g. on i386, __BIGGEST_ALIGNMENT__ is 4 even though
vector types will be given greater alignment).

Patch mostly by Mats Petersson

llvm-svn: 228367
2015-02-06 01:25:07 +00:00
Simon Atanasyan d83248e60c [mips] Removing __SIZEOF_INT128__ macro for MIPS64
This is a temporary workaround while MIPS64 has not yet fully supported
128-bit integers. But declaration of int128 type is necessary even though
`__SIZEOF_INT128__` is undefined because c++ standard header files like
`limits` throw error message if `__int128` is not available.

Patch by Sagar Thakur.

Differential Revision: http://reviews.llvm.org/D6402

llvm-svn: 223927
2014-12-10 15:44:07 +00:00
Reid Kleckner bbc0178518 CUDA host device code with two code paths
Summary:
Allow CUDA host device functions with two code paths using __CUDA_ARCH__
to differentiate between code path being compiled.

For example:
  __host__ __device__ void host_device_function(void) {
  #ifdef __CUDA_ARCH__
    device_only_function();
  #else
    host_only_function();
  #endif
  }

Patch by Jacques Pienaar.

Reviewed By: rnk

Differential Revision: http://reviews.llvm.org/D6457

llvm-svn: 223271
2014-12-03 21:53:36 +00:00
Reid Kleckner e070b99b84 Remove -fseh-exceptions in favor of checking the triple
This option was misleading because it looked like it enabled the
language feature of SEH (__try / __except), when this option was really
controlling which EH personality function to use. Mingw only supports
SEH and SjLj EH on x86_64, so we can simply do away with this flag.

llvm-svn: 221963
2014-11-14 02:01:10 +00:00
Richard Smith 38af8561f9 Update Clang's SD-6 support to match N4200 (except for __has_cpp_attribute,
which we don't yet implement).

llvm-svn: 221816
2014-11-12 21:16:38 +00:00
David Majnemer 8ef921a48b Frontend: Define __EXCEPTIONS if -fexceptions is passed
GCC defines __EXCEPTIONS, regardless of language mode, if -fexceptions
is passed.  We should do the same.

This fixes PR21358.

llvm-svn: 220714
2014-10-27 20:02:19 +00:00
Aaron Ballman 7a6f36440d Follow-up commit to r211657 which introduced these macros, but not for MSVC. This turns out to break our freestanding tests on Windows when compiling in MSVC-compatible mode. It was decided (http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20141020/116942.html is the start of the thread) to support this as part of Clang's interface on all platforms.
llvm-svn: 220312
2014-10-21 19:24:06 +00:00
Reid Kleckner 8f45c9cc62 Add -fseh-exceptions for MinGW-w64
This adds a flag called -fseh-exceptions that uses the native Windows
.pdata and .xdata unwind mechanism to throw exceptions. The other EH
possibilities are DWARF and SJLJ exceptions.

Patch by Martell Malone!

Reviewed By: asl, rnk

Differential Revision: http://reviews.llvm.org/D3419

llvm-svn: 217790
2014-09-15 17:19:16 +00:00
Aaron Ballman dd69ef38db C++1y is now C++14!
Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording.

llvm-svn: 215982
2014-08-19 15:55:55 +00:00
Manuel Klimek 9af34aeac1 Correctly implement -include search logic.
According to the gcc docs, -include uses the current working directory
for the lookup instead of the main source file.

This patch gets rid of NormalizeIncludePath (which relied on an
implementation detail of FileManager / FileEntry for the include path
logic to work), and instead hands the correct lookup information down to
LookupFile.

This will allow us to change the FileEntry's behavior regarding its Name
caching.

llvm-svn: 215433
2014-08-12 08:25:57 +00:00
Bob Wilson 7400e596a3 Predefine IB_DESIGNABLE and IBInspectable macros. <rdar://problem/17441860>
These macros are used as markers for Interface Builder and need to be defined
to empty strings since they have no impact on the code.

Patch by Ted Kremenek.

llvm-svn: 215259
2014-08-08 23:46:25 +00:00
Joerg Sonnenberger 587deea875 If char/short are shorter than int, do not use U as suffix for
constants. Comparing int against a constant of the given type like
UINT8_MAX will otherwise force a promotion to unsigned int, which is
typically not expected.

llvm-svn: 213301
2014-07-17 20:12:32 +00:00
Joerg Sonnenberger 3042f7e7a1 Always set the C suffix macro, even if it is empty.
llvm-svn: 213299
2014-07-17 19:47:34 +00:00
Joerg Sonnenberger b3a4969b70 Provide __SIG_ATOMIC_MAX__ next to __SIG_ATOMIC_WIDTH__.
llvm-svn: 213289
2014-07-17 18:31:20 +00:00
Joerg Sonnenberger f6432d83c3 Add __INTMAX_C_SUFFIX__ and __UINTMAX_C_SUFFIX__.
llvm-svn: 213097
2014-07-15 21:58:11 +00:00
Joerg Sonnenberger cc43c85855 Don't create non-temporary twines.
llvm-svn: 213066
2014-07-15 12:18:40 +00:00
Joerg Sonnenberger 62277b37db Make sure int64_t and uint64_t are consistent.
llvm-svn: 213065
2014-07-15 11:51:38 +00:00
Joerg Sonnenberger be324f9832 Provide builtin macros as template for PRIab and SCNab, matching the
underlaying types.

llvm-svn: 213063
2014-07-15 11:30:00 +00:00
Pavel Chupin 3362c5fb0f [x32] Add __ILP32__ macro for ILP32 platforms
Summary:
Add __ILP32__ and _ILP32 macro for corresponding platforms.
Cover x86_64-*-*-gnux32 with test.

Test Plan: test added

Reviewers: chandlerc, atanasyan

Subscribers: cfe-commits, dschuff, zinovy.nis

Differential Revision: http://reviews.llvm.org/D4473

llvm-svn: 212931
2014-07-14 09:58:10 +00:00
Ehsan Akhgari f3a896bd22 Avoid definining more GCC specific predefined macros in clang-cl
Reviewers: hansw, rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4419

llvm-svn: 212753
2014-07-10 18:44:24 +00:00
Benjamin Kramer ce416398ef Turn some Twine locals into const char * variables.
No functionality change, just stylistic cleanup. Change made by clang-tidy
and clang-format.

llvm-svn: 212544
2014-07-08 16:07:36 +00:00
Alp Toker c358000ed3 Fix layering of file remapping and header search initialization
These two functions initialize the source manager and header search objects and
shouldn't be in InitPreprocessor which is concerned with priming the
preprocessor itself and predefining macros.

llvm-svn: 212434
2014-07-07 06:05:00 +00:00
Ehsan Akhgari 9be07e1acd Do not define __STRICT_ANSI__ in clang-cl
llvm-svn: 212066
2014-06-30 20:36:33 +00:00
JF Bastien ab8d0a0dd5 Implement predefined stdint macros
Add predefined stdint macros that match the given patterns:

U?INT{_,_FAST,_LEAST}{8,16,32,64}_{MAX,TYPE}
U?INT{PTR,MAX}_{MAX,TYPE}

http://reviews.llvm.org/D4141

Author: binji
llvm-svn: 211657
2014-06-25 01:31:33 +00:00
Richard Smith dbd4d4c837 Add -std=c++1z flag for C++17 features.
llvm-svn: 211030
2014-06-16 15:16:56 +00:00
Hans Wennborg 35bbf1cf8a Do not predefine __EXCEPTIONS in clang-cl (PR19977)
Patch by Ehsan Akhgari! (Test tweak by me.)

Differential Revision: http://reviews.llvm.org/D4065

llvm-svn: 210582
2014-06-10 20:46:38 +00:00
Craig Topper 49a2790fb3 [C++11] Use 'nullptr'. Frontend edition.
llvm-svn: 209389
2014-05-22 04:46:25 +00:00
Reid Kleckner 6f6e76dfe0 Revert "Move -fms-extensions predefined macros into InitPreprocessor"
This reverts commit r206413.

This was proposed before, but it's not clear if this is really a good
idea:
http://reviews.llvm.org/D3034

llvm-svn: 206415
2014-04-16 20:10:16 +00:00
Reid Kleckner ae4759df00 Move -fms-extensions predefined macros into InitPreprocessor
If someone on Linux asks for -fms-extensions, there's no reason not to
define the feature test macros that MSVC defines.

llvm-svn: 206413
2014-04-16 19:47:06 +00:00
Reid Kleckner 0dc06b9a3d -fms-extensions: Don't define __PRETTY_FUNCTION__ to __FUNCTION__
This reverts r90596 from 2009. Having this macro definition makes Clang
strictly less useful with -fms-extensions.

llvm-svn: 205729
2014-04-07 19:27:58 +00:00
Richard Smith ae385084c5 Implement the MS extension __identifier properly: take a token and strip it of
its keywordliness.

llvm-svn: 203987
2014-03-15 00:06:08 +00:00
Robert Lytton 2c942c64fb Make __LITTLE_ENDIAN__/__BIG_ENDOAN__ common PredefinedMacros
llvm-svn: 203455
2014-03-10 12:06:29 +00:00
Alexey Bataev d4dbdf5438 [OPENMP] Updated comments and _OPENMP macro value for OpenMP 4.0 (for 'omp simd' support)
llvm-svn: 203114
2014-03-06 12:27:56 +00:00
David Majnemer dbd6acb64b Revert "Preprocessor: Add __ALIGNOF_MAX_ALIGN_T__"
This commit reverts r201037, it's functionality is not needed given the
definition of std::max_align_t in libcxx circa r201843.

llvm-svn: 202667
2014-03-02 23:01:10 +00:00
Richard Smith 51bacfd9c7 Update __cplusplus to match the value in the C++14 DIS preview (D3937).
llvm-svn: 202003
2014-02-24 01:35:45 +00:00
Josh Magee e0fc1a80cb [stackprotector] Add command line option -fstack-protector-strong
This option has the following effects:
 * It adds the sspstrong IR attribute to each function within the CU.
 * It defines the macro __SSP_STRONG__ with the value of 2.

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

llvm-svn: 201120
2014-02-11 01:35:14 +00:00
David Majnemer 158ba130ee Preprocessor: Add __ALIGNOF_MAX_ALIGN_T__
TargetInfo::getSuitableAlign() was introduced in r146762 and is defined
as alignof(std::max_align_t).

Introduce __ALIGNOF_MAX_ALIGN_T__ which exposes getSuitableAlign() so
that libc++ may take advantage of it.

llvm-svn: 201037
2014-02-09 05:30:48 +00:00