Commit Graph

2702 Commits

Author SHA1 Message Date
Craig Topper abb83aed5c Move diagnostics from Parse to Sema to remove Sema's dependency on ParserDiagnostic.h diagnostics.
llvm-svn: 253143
2015-11-14 19:31:56 +00:00
Craig Topper 54a6a68c70 Merge some similar diagnostics using %select.
llvm-svn: 253136
2015-11-14 18:16:08 +00:00
Craig Topper 3110a5cb93 Minor formatting fixes. NFC
llvm-svn: 253135
2015-11-14 18:16:02 +00:00
Craig Topper ff35428593 Fix 80 column violation. NFC.
llvm-svn: 253134
2015-11-14 18:16:00 +00:00
Craig Topper 3f13d4d20d Fix spelling error in comment.
llvm-svn: 253133
2015-11-14 18:15:55 +00:00
Richard Smith e301ba2b48 Add support for GCC's '__auto_type' extension, per the GCC manual:
https://gcc.gnu.org/onlinedocs/gcc/Typeof.html

Differences from the GCC extension:
 * __auto_type is also permitted in C++ (but only in places where
   it could appear in C), allowing its use in headers that might
   be shared across C and C++, or used from C++98
 * __auto_type can be combined with a declarator, as with C++ auto
   (for instance, "__auto_type *p")
 * multiple variables can be declared in a single __auto_type
   declaration, with the C++ semantics (the deduced type must be
   the same in each case)

This patch also adds a missing restriction on applying typeof to
a bit-field, which GCC has historically rejected in C (due to
lack of clarity as to whether the operand should be promoted).
The same restriction also applies to __auto_type in C (in both
GCC and Clang).

This also fixes PR25449.

Patch by Nicholas Allegra!

llvm-svn: 252690
2015-11-11 02:02:15 +00:00
Richard Smith 42b1057244 N3922: direct-list-initialization of an auto-typed variable no longer deduces a
std::initializer_list<T> type. Instead, the list must contain a single element
and the type is deduced from that.

In Clang 3.7, we warned by default on all the cases that would change meaning
due to this change. In Clang 3.8, we will support only the new rules -- per
the request in N3922, this change is applied as a Defect Report against earlier
versions of the C++ standard.

This change is not entirely trivial, because for lambda init-captures we
previously did not track the difference between direct-list-initialization and
copy-list-initialization. The difference was not previously observable, because
the two forms of initialization always did the same thing (the elements of the
initializer list were always copy-initialized regardless of the initialization
style used for the init-capture).

llvm-svn: 252688
2015-11-11 01:36:17 +00:00
Richard Smith 3df3f1d27f Switch to using an explicit scope object to ensure we don't forget to pop ObjC
type parameters off the scope, and fix the cases where we failed to do so.

llvm-svn: 251875
2015-11-03 01:19:56 +00:00
Benjamin Kramer e003ca2a03 Put global classes into the appropriate namespace.
Most of the cases belong into an anonymous namespace. No functionality
change intended.

llvm-svn: 251514
2015-10-28 13:54:16 +00:00
Richard Smith 9f690bd80b [coroutines] Creation of promise object, lookup of operator co_await, building
of await_* calls, and AST representation for same.

llvm-svn: 251387
2015-10-27 06:02:45 +00:00
Richard Smith cfd53b4e99 [coroutines] Initial stub Sema functionality for handling coroutine await / yield / return.
llvm-svn: 250993
2015-10-22 06:13:50 +00:00
Craig Topper 0f723bb90b Convert ActOnForwardProtocolDeclaration to take an ArrayRef and use a range-based for loop. NFC
llvm-svn: 250990
2015-10-22 05:00:01 +00:00
Craig Topper b5518246b2 Use an ArrayRef<OffsetOfComponent> instead of pointer and size throughout offsetof handling code. Also use a range-based for loop. NFC
llvm-svn: 250989
2015-10-22 04:59:59 +00:00
Craig Topper a9247eb2b1 Change FindProtocolDeclaration to take an ArrayRef and use a range-based for loop. NFC
llvm-svn: 250988
2015-10-22 04:59:56 +00:00
Richard Smith 0e304ea8a1 [coroutines] Add parsing support for co_await expression, co_yield expression,
co_await modifier on range-based for loop, co_return statement.

llvm-svn: 250985
2015-10-22 04:46:14 +00:00
Angel Garcia Gomez 637d1e6694 Roll-back r250822.
Summary: It breaks the build for the ASTMatchers

Subscribers: klimek, cfe-commits

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

llvm-svn: 250827
2015-10-20 13:23:58 +00:00
Angel Garcia Gomez b5250d3448 Apply modernize-use-default to clang.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: bkramer, klimek

Subscribers: klimek, alexfh, cfe-commits

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

llvm-svn: 250822
2015-10-20 12:52:55 +00:00
Alexey Bataev 1d97d2a3d2 [OPENMP] Fix for http://llvm.org/PR25221: Infinite loop while parsing OpenMP directive
Clang skipped annot_pragma_openmp token, while it should be considered as a stop token while skipping tokens.

llvm-svn: 250684
2015-10-19 06:40:17 +00:00
Hans Wennborg 7357bbc6c3 Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)
We already silently ignore the /RTC, which controls the same functionality.

llvm-svn: 250099
2015-10-12 20:47:58 +00:00
Richard Smith e87aeb378d When pretty-printing a C++11 literal operator, don't insert whitespace between
the "" and the suffix; that breaks names such as 'operator""if'. For symmetry,
also remove the space between the 'operator' and the '""'.

llvm-svn: 249641
2015-10-08 00:17:59 +00:00
Hans Wennborg dcfba33481 Fix Clang-tidy modernize-use-nullptr warnings in source directories; other minor cleanups
Patch by Eugene Zelenko!

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

llvm-svn: 249484
2015-10-06 23:40:43 +00:00
Saleem Abdulrasool d170c4b57a Add -f[no-]declspec to control recognition of __declspec as a keyword
In versions of clang prior to r238238, __declspec was recognized as a keyword in
all modes.  It was then changed to only be enabled when Microsoft or Borland
extensions were enabled (and for CUDA, as a temporary measure).  There is a
desire to support __declspec in Playstation code, and possibly other
environments.  This commit adds a command-line switch to allow explicit
enabling/disabling of the recognition of __declspec as a keyword.  Recognition
is enabled by default in Microsoft, Borland, CUDA, and PS4 environments, and
disabled in all other environments.

Patch by Warren Ristow!

llvm-svn: 249279
2015-10-04 17:51:05 +00:00
Craig Topper e335f25949 SourceRanges are small and trivially copyable, don't them by reference.
llvm-svn: 249259
2015-10-04 04:53:55 +00:00
Alexey Bataev d14d1e6f25 [OPENMP 4.1] Add 'simd' clause for 'ordered' directive.
Parsing and sema analysis for 'simd' clause in 'ordered' directive.
Description
If the simd clause is specified, the ordered regions encountered by any thread will use only a single SIMD lane to execute the ordered
regions in the order of the loop iterations.
Restrictions
An ordered construct with the simd clause is the only OpenMP construct that can appear in the simd region

llvm-svn: 248696
2015-09-28 06:39:35 +00:00
Alexey Bataev 346265e3bc [OPENMP 4.1] Add 'threads' clause for '#pragma omp ordered'.
OpenMP 4.1 extends format of '#pragma omp ordered'. It adds 3 additional clauses: 'threads', 'simd' and 'depend'.
If no clause is specified, the ordered construct behaves as if the threads clause had been specified. If the threads clause is specified, the threads in the team executing the loop region execute ordered regions sequentially in the order of the loop iterations.
The loop region to which an ordered region without any clause or with a threads clause binds must have an ordered clause without the parameter specified on the corresponding loop directive.

llvm-svn: 248569
2015-09-25 10:37:12 +00:00
Serge Pavlov c4e04a2964 [Modules] More descriptive diagnostics for misplaced import directive
If an import directive was put into wrong context, the error message was obscure,
complaining on misbalanced braces. To get more descriptive messages, annotation
tokens related to modules are processed where they must not be seen.

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

llvm-svn: 248085
2015-09-19 05:32:57 +00:00
Daniel Sanders 50f17235dd Revert r247692: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Eric has replied and has demanded the patch be reverted.

llvm-svn: 247702
2015-09-15 16:17:27 +00:00
Daniel Sanders 153010c52d Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).

For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.

This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.

This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.

Reviewers: rengolin

Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin

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

llvm-svn: 247692
2015-09-15 14:08:28 +00:00
Daniel Sanders c40de48041 Revert r247684 - Replace Triple with a new TargetTuple ...
LLDB needs to be updated in the same commit.

llvm-svn: 247686
2015-09-15 13:46:21 +00:00
Daniel Sanders 18d4b0dab7 Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.
Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).

For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.

This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.

This commit also contains a trivial patch to clang to account for the C++ API
change.

Reviewers: rengolin

Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin

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

llvm-svn: 247683
2015-09-15 13:17:40 +00:00
Alexey Bataev 6b8046addf [OPENMP 4.1] Parsing/sema analysis for extended format of 'if' clause.
OpenMP 4.1 added special 'directive-name-modifier' to the 'if' clause.
Format of 'if' clause is as follows:
```
if([ directive-name-modifier :] scalar-logical-expression)
```

The restriction rules are also changed.
1. If any 'if' clause on the directive includes a 'directive-name-modifier' then all 'if' clauses on the directive must include a 'directive-name-modifier'.
2. At most one 'if' clause without a 'directive-name-modifier' can appear on the directive.
3. At most one 'if' clause with some particular 'directive-name-modifier' can appear on the directive.

'directive-name-modifier' is important for combined directives and allows to separate conditions in 'if' clause for simple sub-directives in combined directive. This 'directive-name-modifier' identifies the sub-directive to which this 'if' clause must be applied.

llvm-svn: 246747
2015-09-03 07:23:48 +00:00
Reid Kleckner 14e96b4930 [ms-inline-asm] Add field access to MS inline asm identifier lookup
Now we can parse code like this:
  struct A {
    int field;
  };
  int f(A o) {
    __asm mov eax, o.field
  }

Fixes PR19117.

llvm-svn: 246088
2015-08-26 21:57:20 +00:00
Nathan Wilson e23a9a4514 Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange
Summary:
- Store the exception specification range's begin and end SourceLocation in DeclaratorChuck::FunctionTypeInfo. These SourceLocations can be used in a FixItHint Range.
- Add diagnostic; function concept having an exception specification.


Reviewers: hubert.reinterpretcast, fraggamuffin, faisalv, aaron.ballman, rsmith

Subscribers: cfe-commits

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

llvm-svn: 246005
2015-08-26 04:19:36 +00:00
Alexey Bataev 1a3320e463 [OPENMP 4.0] Initial support for array sections.
Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0).
Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions.
Differential Revision: http://reviews.llvm.org/D10732

llvm-svn: 245937
2015-08-25 14:24:04 +00:00
Alexey Bataev 66b15b505f [OPENMP 4.1] Initial support for 'simdlen' clause.
Add parsing/sema analysis for 'simdlen' clause in simd directives. Also add check that if both 'safelen' and 'simdlen' clauses are specified, the value of 'simdlen' parameter is less than the value of 'safelen' parameter.

llvm-svn: 245692
2015-08-21 11:14:16 +00:00
Richard Smith b9fa99649b [modules] When we see a definition of a function for which we already have a
non-visible definition, skip the new definition to avoid ending up with a
function with multiple definitions.

llvm-svn: 245664
2015-08-21 03:04:33 +00:00
Alexey Bataev 1185e193a4 [OPENMP 4.1] Allow to use 'uval' and 'ref' modifiers for reference types only.
Standard allows to use 'uval' and 'ref' modifiers in 'linear' clause for variables with reference types only. Added check for it and modified test.

llvm-svn: 245556
2015-08-20 12:15:57 +00:00
Alexey Bataev 182227bd5b [OPENMP 4.1] Initial support for modifiers in 'linear' clause.
OpenMP 4.1 adds 3 optional modifiers to 'linear' clause.
Format of 'linear' clause has changed to:
```
linear(linear-list[ : linear-step])
```
where linear-list is one of the following
```
list
modifier(list)
```
where modifier is one of the following:
```
 ref (C++)
 val (C/C++)
 uval (C++)
```
Patch adds parsing and sema analysis for these modifiers.

llvm-svn: 245550
2015-08-20 10:54:39 +00:00
Hans Wennborg 99000c24c9 Delay emitting members of dllexport classes until the class is fully parsed (PR23542)
This enables Clang to correctly handle code such as:

  struct __declspec(dllexport) S {
    int x = 42;
  };

where it would otherwise error due to trying to generate the default
constructor before the in-class initializer for x has been parsed.

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

llvm-svn: 245139
2015-08-15 01:18:16 +00:00
Alexey Bataev 4652e4baaf [OPENMP] Fix for http://llvm.org/PR24430: clang hangs on invalid input with openmp directive
Add parsing of openmp directives inside structs/unions in C mode.

llvm-svn: 244719
2015-08-12 07:10:54 +00:00
Mark Heffernan 397a98d86d Add new llvm.loop.unroll.enable metadata for use with "#pragma unroll".
This change adds the new unroll metadata "llvm.loop.unroll.enable" which directs
the optimizer to unroll a loop fully if the trip count is known at compile time, and
unroll partially if the trip count is not known at compile time. This differs from
"llvm.loop.unroll.full" which explicitly does not unroll a loop if the trip count is not
known at compile time

With this change "#pragma unroll" generates "llvm.loop.unroll.enable" rather than
"llvm.loop.unroll.full" metadata. This changes the semantics of "#pragma unroll" slightly
to mean "unroll aggressively (fully or partially)" rather than "unroll fully or not at all".

The motivating example for this change was some internal code with a loop marked
with "#pragma unroll" which only sometimes had a compile-time trip count depending
on template magic. When the trip count was a compile-time constant, everything works
as expected and the loop is fully unrolled. However, when the trip count was not a
compile-time constant the "#pragma unroll" explicitly disabled unrolling of the loop(!).
Removing "#pragma unroll" caused the loop to be unrolled partially which was desirable
from a performance perspective.

llvm-svn: 244467
2015-08-10 17:29:39 +00:00
Nico Weber 6362745a76 Restore PrettyStackTrace state on crash.
Last part of PR11974.

llvm-svn: 244339
2015-08-07 17:48:57 +00:00
Michael Wong e710d5459e This patch commits OpenMP 4 target device clauses
This is committed on behalf of Kelvin Li
http://reviews.llvm.org/D11469?id=31227

llvm-svn: 244325
2015-08-07 16:16:36 +00:00
Benjamin Kramer fa7f85523f [Parse] ArrayRefize PragmaLoopHintInfo. No functionality change.
llvm-svn: 244024
2015-08-05 09:39:57 +00:00
Alexey Bataev 05c25d64c1 Outline function Parser::ParseCXXClassMemberDeclarationWithPragmas(), NFC.
Parsing of pragmas followed by a class member declaration is outlined into a separate function Parser::ParseCXXClassMemberDeclarationWithPragmas().

llvm-svn: 243739
2015-07-31 08:42:25 +00:00
Ulrich Weigand d6665178a8 Fix sanitizer fallout from r243642
The memory-sanitizer build bot reported:

==5574== WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f03089e15f6 in
clang::Parser::TryAltiVecTokenOutOfLine(clang::DeclSpec&,
clang::SourceLocation, char const*&, unsigned int&, bool&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:6290:11

This is because the "Ident_pixel" variable was uninitialized
in the getLangOpts().ZVector case, but we'd still call into
clang::Parser::TryAltiVecTokenOutOfLine, which uses the variable.

The simplest fix for this without sprinkling !getLangOpts().ZVector
checks all over the code seems to be to just initialize the variable
to nullptr; this will then do the right thing on ZVector.

Checked in to unbreak the build bots.

llvm-svn: 243644
2015-07-30 15:53:58 +00:00
Ulrich Weigand 3c5038a535 Add support for System z vector language extensions
The z13 vector facility has an associated language extension,
closely modeled on AltiVec/VSX.  The main differences are:

- vector long, vector float and vector pixel are not supported

- vector long long and vector double are supported (like VSX)

- comparison operators return a vector rather than a scalar integer

- shift operators behave like the OpenCL shift operators

- vector bool is only supported as argument to certain operators;
  some operators allow mixing a bool with a non-bool vector 

This patch adds clang support for the extension.  It is closely modelled
on the AltiVec support.  Similarly to the -faltivec option, there's a
new -fzvector option to enable the extensions (as well as an -mzvector
alias for compatibility with GCC).  There's also a separate LangOpt.

The extension as implemented here is intended to be compatible with
the -mzvector extension recently implemented by GCC.

Based on a patch by Richard Sandiford.

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

llvm-svn: 243642
2015-07-30 14:08:36 +00:00
Alexey Bataev 10e775f4a8 [OPENMP 4.1] Initial support for extended 'ordered' clause.
OpenMP 4.1 introduces optional argument '(n)' for 'ordered' clause, where 'n' is a number of loops that immediately follow the directive.
'n' must be constant positive integer expressions and it must be less or equal than the number of the loops in the resulting loop nest.
Patch adds parsing and semantic analysis for this optional argument.

llvm-svn: 243635
2015-07-30 11:36:16 +00:00
David Majnemer 51fd8a020b [MS Compat] Allow _Atomic(Type) and 'struct _Atomic' to coexist
MSVC 2013 ships, as part of its STL implementation, a class named
'_Atomic'.  This is unfortunate because this keyword is in conflict with
the C11 keyword with the same name.  Our solution was to disable this
keyword when targeting MSVC 2013 and reenable it for 2015.

However, this makes it impossible for clang's headers to make use of
_Atomic.  This is problematic in the case of libc++ as it makes heavy
use of this keyword.

Let the keywordness of _Atomic float under certain circumstances:
the body of a class named _Atomic, or a class with a base specifier
named _Atomic, will not have the keyword variant of _Atomic for the
duration of the class body.  This is sufficient to allow us to correctly
handle _Atomic in the STL while permitting us to use _Atomic as a
keyword everywhere else.

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

llvm-svn: 242970
2015-07-22 23:46:18 +00:00
Samuel Antao 5b0688edfd [OpenMP] Make target data directive generate unexpected directive diagnostic.
llvm-svn: 242906
2015-07-22 16:02:46 +00:00