Commit Graph

802 Commits

Author SHA1 Message Date
Richard Smith c2bebe9aca Preserve the FoundDecl when performing overload resolution for constructors.
This is in preparation for C++ P0136R1, which switches the model for inheriting
constructors over from synthesizing a constructor to finding base class
constructors (via using shadow decls) when looking for derived class
constructors.

llvm-svn: 269231
2016-05-11 20:37:46 +00:00
Faisal Vali a734ab9808 [Cxx1z-constexpr-lambda-P0170R1] Support parsing of constexpr specifier (and its inference) on lambda expressions
Support the constexpr specifier on lambda expressions - and support its inference from the lambda call operator's body.

i.e.
  auto L = [] () constexpr { return 5; };
  static_assert(L() == 5); // OK
  auto Implicit = [] (auto a) { return a; };
  static_assert(Implicit(5) == 5); 

We do not support evaluation of lambda's within constant expressions just yet.

Implementation Strategy:
  - teach ParseLambdaExpressionAfterIntroducer to expect a constexpr specifier and mark the invented function call operator's declarator's decl-specifier with it; Have it emit fixits for multiple decl-specifiers (mutable or constexpr) in this location.
  - for cases where constexpr is not explicitly specified, have buildLambdaExpr check whether the invented function call operator satisfies the requirements of a constexpr function, by calling CheckConstexprFunctionDecl/Body.

Much obliged to Richard Smith for his patience and his care, in ensuring the code is clang-worthy.

llvm-svn: 264513
2016-03-26 16:11:37 +00:00
Faisal Vali dc6b596ebb [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)
Implement lambda capture of *this by copy.
For e.g.:
struct A {

  int d = 10;
  auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; }

};

auto L = A{}.foo(); // A{}'s lifetime is gone.

// Below is still ok, because *this was captured by value.
assert(L(10) == 20);
assert(L(100) == 120);

If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined.

Implementation Strategy:
  - amend the parser to accept *this in the lambda introducer
  - add a new king of capture LCK_StarThis
  - teach Sema::CheckCXXThisCapture to handle by copy captures of the
    enclosing object (i.e. *this)
  - when CheckCXXThisCapture does capture by copy, the corresponding 
    initializer expression for the closure's data member 
    direct-initializes it thus making a copy of '*this'.
  - in codegen, when assigning to CXXThisValue, if *this was captured by 
    copy, make sure it points to the corresponding field member, and
    not, unlike when captured by reference, what the field member points
    to.
  - mark feature as implemented in svn

Much gratitude to Richard Smith for his carefully illuminating reviews!   

llvm-svn: 263921
2016-03-21 09:25:37 +00:00
Richard Smith 01694c340d P0184R0: Allow types of 'begin' and 'end' expressions in range-based for loops to differ.
llvm-svn: 263895
2016-03-20 10:33:40 +00:00
Alexey Bataev a839dddf92 [OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.
OpenMP 4.0 allows to define custom reduction operations using '#pragma
omp declare reduction' construct. Patch allows to use this custom
defined reduction operations in 'reduction' clauses.

llvm-svn: 263701
2016-03-17 10:19:46 +00:00
John McCall c8e321d4bc Fix the template instantiation of ExtParameterInfos; tests to follow.
llvm-svn: 262289
2016-03-01 02:09:25 +00:00
Akira Hatanaka be8f522ef3 [Sema] Remove assert in TreeTransform<Derived>::TransformObjCObjectType.
The assert isn't correct since TypeLoc::ObjCObjectTypeLoc doesn't
indicate whether the type is a dependent type. The function returns
false for a type like "<SomeProtocol>" which is a synonym for
"id<SomeProtocol>".

rdar://problem/23838912

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

llvm-svn: 261829
2016-02-25 07:08:33 +00:00
Arpith Chacko Jacob 05bebb578a [OpenMP] Parsing + sema for target parallel for directive.
Summary:
This patch adds parsing + sema for the target parallel for directive along with testcases.

Reviewers: ABataev

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

llvm-svn: 259654
2016-02-03 15:46:42 +00:00
Arpith Chacko Jacob e955b3d3fe [OpenMP] Parsing + sema for target parallel directive.
Summary:
This patch adds parsing + sema for the target parallel directive and its clauses along with testcases.

Reviewers: ABataev

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

Rebased to current trunk and updated test cases.

llvm-svn: 258832
2016-01-26 18:48:41 +00:00
Arpith Chacko Jacob 3cf89040b0 [OpenMP] Parsing + sema for defaultmap clause.
Summary:
This patch adds parsing + sema for the defaultmap clause associated with the target directive (among others).

Reviewers: ABataev

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

llvm-svn: 258817
2016-01-26 16:37:23 +00:00
Samuel Antao 23abd726e6 [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.
Support for the following OpenMP 4.5 restriction on 'target enter data' and 'target exit data':

  - A map-type must be specified in all map clauses.

I have to save 'IsMapTypeImplicit' when parsing a map clause to support this constraint and for more informative error messages. This helps me support the following case:

  #pragma omp target enter data map(r) // expected-error {{map type must be specified for '#pragma omp target enter data'}}

and distinguish it from:

  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}

Patch by Arpith Jacob. Thanks!

llvm-svn: 258179
2016-01-19 20:40:49 +00:00
Samuel Antao 7259076032 [OpenMP] Parsing + sema for "target exit data" directive.
Patch by Arpith Jacob. Thanks!

llvm-svn: 258177
2016-01-19 20:04:50 +00:00
Samuel Antao df67fc468e [OpenMP] Parsing + sema for "target enter data" directive.
Patch by Arpith Jacob. Thanks!

llvm-svn: 258165
2016-01-19 19:15:56 +00:00
Carlo Bertolli b4adf55e0f Add OpenMP dist_schedule clause to distribute directive and related regression tests.
llvm-svn: 257917
2016-01-15 18:50:31 +00:00
Manuel Klimek 4c67fa747b Fix assert hit when tree-transforming template template parameter packs.
Covers significantly more code in the template template pack argument
test and fixes the resulting assert problem.

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

llvm-svn: 257326
2016-01-11 11:39:00 +00:00
Xiuli Pan 9c14e28211 [OpenCL] Pipe type support
Summary:
Support for OpenCL 2.0 pipe type.
This is a bug-fix version for bader's patch reviews.llvm.org/D14441


Reviewers: pekka.jaaskelainen, Anastasia

Subscribers: bader, Anastasia, cfe-commits

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

llvm-svn: 257254
2016-01-09 12:53:17 +00:00
Richard Trieu 43b4c821e1 Improve conditional checking during template instantiation.
When the condition in an if statement, while statement, or for loop is created
during template instantiation, it calls MakeFullExpr with only the condition
expression.  However, when these conditions are created for non-templated
code in the Parser, an additional SourceLocation is passed to MakeFullExpr.
The impact of this was that non-dependent templated code could produce
diagnostics that the same code outside templates would not.  Adding the missing
SourceLocation makes diagnostics consistent between templated and non-templated
code.

llvm-svn: 256976
2016-01-06 21:11:18 +00:00
James Y Knight 7281c357b1 [TrailingObjects] Convert OffsetOfExpr.
That necessitated moving the OffsetOfNode class out of OffsetOfExpr.

llvm-svn: 256590
2015-12-29 22:31:18 +00:00
Alexey Bataev 6402bcad71 [OPENMP 4.5] Sema/parsing support for extended format of 'schedule' clause.
OpenMP 4.0-3.1 supports the next format of ‘schedule’ clause: schedule(kind[, chunk_size])
Where kind can be one of ‘static’, ‘dynamic’, ‘guided’, ‘auto’ or ‘runtime’.
OpenMP 4.5 defines the format: schedule([modifier [, modifier]:]kind[, chunk_size])
Modifier can be one of ‘monotonic’, ‘nonmonotonic’ or ‘simd’.

llvm-svn: 256487
2015-12-28 07:25:51 +00:00
Craig Topper 99d235329f [Sema] ArrayRef-ize SubstExprs. NFC
llvm-svn: 256401
2015-12-24 23:58:29 +00:00
Craig Topper d4336e01d7 [Sema] ArrayRef-ize BuildObjCDictionaryLiteral. NFC
llvm-svn: 256398
2015-12-24 23:58:15 +00:00
Alexey Bataev a636c7f9b9 [OPENMP 4.5] Parsing/sema for 'depend(sink:vec)' clause in 'ordered' directive.
OpenMP 4.5 adds 'depend(sink:vec)' in 'ordered' directive for doacross loop synchronization. Patch adds parsing and semantic analysis for this clause.

llvm-svn: 256330
2015-12-23 10:27:45 +00:00
Alexey Bataev 29c9209357 [OPENMP] Revert r256238 to fix the problem with tests on Linux.
llvm-svn: 256239
2015-12-22 12:44:46 +00:00
Alexey Bataev ef4c5584d5 [OPENMP 4.5] Parsing/sema for 'depend(sink:vec)' clause in 'ordered' directive.
OpenMP 4.5 adds 'depend(sink:vec)' in 'ordered' directive for doacross loop synchronization. Patch adds parsing and semantic analysis for this clause.

llvm-svn: 256238
2015-12-22 12:21:47 +00:00
Alexey Bataev eb48235033 [OPENMP 4.5] Parsing/sema analysis for 'depend(source)' clause in 'ordered' directive.
OpenMP 4.5 adds 'depend(source)' clause for 'ordered' directive to support cross-iteration dependence. Patch adds parsing and semantic analysis for this construct.

llvm-svn: 255986
2015-12-18 05:05:56 +00:00
Alexey Bataev 28c75417b2 [OPENMP 4.5] Parsing/sema for 'hint' clause of 'critical' directive.
OpenMP 4.5 adds 'hint' clause to critical directive. Patch adds parsing/semantic analysis for this clause.

llvm-svn: 255625
2015-12-15 08:19:24 +00:00
Carlo Bertolli 6200a3d0f3 Add parse and sema of OpenMP distribute directive with all clauses except dist_schedule
llvm-svn: 255498
2015-12-14 14:51:25 +00:00
NAKAMURA Takumi 2d5c6ddf74 Revert r255001, "Add parse and sema for OpenMP distribute directive and all its clauses excluding dist_schedule."
It causes memory leak. Some tests in test/OpenMP would fail.

llvm-svn: 255094
2015-12-09 04:35:57 +00:00
Alexey Bataev 382967a2e4 [OPENMP 4.5] Parsing/sema for 'num_tasks' clause.
OpenMP 4.5 adds directives 'taskloop' and 'taskloop simd'. These directives support clause 'num_tasks'. Patch adds parsing/semantic analysis for this clause.

llvm-svn: 255008
2015-12-08 12:06:20 +00:00
Carlo Bertolli b9bfa75b28 Add parse and sema for OpenMP distribute directive and all its clauses excluding dist_schedule.
llvm-svn: 255001
2015-12-08 04:21:03 +00:00
Alexey Bataev 1fd4aed26b [OPENMP 4.5] parsing/sema support for 'grainsize' clause.
OpenMP 4.5 adds 'taksloop' and 'taskloop simd' directives, which have 'grainsize' clause. Patch adds parsing/sema analysis of this clause.

llvm-svn: 254903
2015-12-07 12:52:51 +00:00
Alexey Bataev b825de17b7 [OPENMP 4.5] parsing/sema support for 'nogroup' clause.
OpenMP 4.5 adds 'taskloop' and 'taskloop simd' directives. These directives have new 'nogroup' clause. Patch adds basic parsing/sema support for this clause.

llvm-svn: 254899
2015-12-07 10:51:44 +00:00
Alexey Bataev 0a6ed84a0d [OPENMP 4.5] Parsing/sema support for 'omp taskloop simd' directive.
OpenMP 4.5 adds directive 'taskloop simd'. Patch adds parsing/sema analysis for 'taskloop simd' directive and its clauses.

llvm-svn: 254597
2015-12-03 09:40:15 +00:00
Alexey Bataev a056935a2f [OPENMP 4.5] Parsing/sema analysis for 'priority' clause.
OpenMP 4.5 defines new clause 'priority' for 'task', 'taskloop' and 'taskloop simd' directives. Added parsing and sema analysis for 'priority' clause in 'task' and 'taskloop' directives.

llvm-svn: 254398
2015-12-01 10:17:31 +00:00
Alexey Bataev 49f6e78d71 [OPENMP 4.5] Parsing/sema analysis for 'taskloop' directive.
Adds initial parsing and semantic analysis for 'taskloop' directive.

llvm-svn: 254367
2015-12-01 04:18:41 +00:00
Kelvin Li a15fb1a110 [OpenMP] Parsing and sema support for thread_limit clause.
http://reviews.llvm.org/D15029

llvm-svn: 254207
2015-11-27 18:47:36 +00:00
Alexey Bataev f763027f04 [MSVC] 'property' with an empty array in array subscript expression.
MSVC supports 'property' attribute and allows to apply it to the declaration of an empty array in a class or structure definition.
For example:
```
__declspec(property(get=GetX, put=PutX)) int x[];
```
The above statement indicates that x[] can be used with one or more array indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i);
Differential Revision: http://reviews.llvm.org/D13336

llvm-svn: 254067
2015-11-25 12:01:00 +00:00
Kelvin Li 099bb8c65d [OpenMP] Parsing and sema support for num_teams clause
http://reviews.llvm.org/D14802

llvm-svn: 254019
2015-11-24 20:50:12 +00:00
Kelvin Li 0bff7afab5 [OpenMP] Parsing and sema support for map clause
http://reviews.llvm.org/D14134 

llvm-svn: 253849
2015-11-23 05:32:03 +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 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 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
Reid Kleckner 744e3e7fc7 Re-land r250592 without rejecting field refs in unevaluated contexts
This time, I went with the first approach from
http://reviews.llvm.org/D6700, where clang actually attempts to form an
implicit member reference from an UnresolvedLookupExpr. We know that
there are only two possible outcomes at this point, a DeclRefExpr of the
FieldDecl or an error, but its safer to reuse the existing machinery for
this.

llvm-svn: 250856
2015-10-20 21:04:13 +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
Reid Kleckner 7d3a2f067f Revert "Diagnose UnresolvedLookupExprs that resolve to instance members in static methods"
This reverts commit r250592.

It has issues around unevaluated contexts, like this:
  template <class T> struct A { T i; };
  template <class T>
  struct B : A<T> {
    using A<T>::i;
    typedef decltype(i) U;
  };
  template struct B<int>;

llvm-svn: 250774
2015-10-20 00:31:42 +00:00
Reid Kleckner f438a020bf Diagnose UnresolvedLookupExprs that resolve to instance members in static methods
During the initial template parse for this code, 'member' is unresolved
and we don't know anything about it:

  struct A { int member };
  template <typename T>
  struct B : public T {
    using T::member;
    static void f() {
      (void)member; // Could be static or non-static.
    }
  };
  template class B<A>;

The pattern declaration contains an UnresolvedLookupExpr rather than an
UnresolvedMemberExpr because `f` is static, and `member` should never be
a field. However, if the code is invalid, it may become a field, in
which case we should diagnose it.

Reviewers: rjmccall, rsmith

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

llvm-svn: 250592
2015-10-17 00:19:04 +00:00
Hans Wennborg 59dbe86325 Fix Clang-tidy modernize-use-nullptr warnings in headers and generated files; other minor cleanups.
By Eugene Zelenko!

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

llvm-svn: 248828
2015-09-29 20:56:43 +00:00