summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert 266186 as it breaks anything that includes type_traits on some platformsNemanja Ivanovic2016-04-154-14/+0
| | | | | | | | | | Since this patch provided support for the __float128 type but disabled it on all platforms by default, some platforms can't compile type_traits with -std=gnu++11 since there is a specialization with __float128. This reverts the patch until D19125 is approved (i.e. we know which platforms need this support enabled). llvm-svn: 266460
* Revert r266415, it broke parsing SDK headers (PR27367).Nico Weber2016-04-152-12/+5
| | | | llvm-svn: 266431
* [MSVC Compat] Implementation of __unaligned (MS extension) as a type qualifierAndrey Bokhanko2016-04-152-5/+12
| | | | | | | | | | | This patch implements __unaligned as a type qualifier; before that, it was modeled as an attribute. Proper mangling of __unaligned is implemented as well. Some OpenCL code/tests are tangenially affected, as they relied on existing number and sizes of type qualifiers. Differential Revision: http://reviews.llvm.org/D18596 llvm-svn: 266415
* [SemaObjC] Properly handle mix between type arguments and protocols.Bruno Cardoso Lopes2016-04-131-4/+43
| | | | | | | | | | | | | | | | | | | | | | | Under certain conditions clang currently fails to properly diagnostic ObjectC parameter list when type args and protocols are mixed in the same list. This happens when the first item in the parameter list is a (1) protocol, (2) unknown type or (3) a list of protocols/unknown types up to the first type argument. Fix the problem to report the proper error, example: NSArray<M, NSValue *, NSURL, NSArray <id <M>>> *foo = @[@"a"]; NSNumber *bar = foo[0]; NSLog(@"%@", bar); $ clang ... x.m:7:13: error: angle brackets contain both a type ('NSValue') and a protocol ('M') NSArray<M, NSValue *, NSURL, NSArray <id <M>>> *foo = @[@"a"]; ~ ^ Differential Revision: http://reviews.llvm.org/D18997 rdar://problem/22204367 llvm-svn: 266245
* Remove redundant null-check; NFCHubert Tong2016-04-131-1/+1
| | | | llvm-svn: 266226
* Enable support for __float128 in ClangNemanja Ivanovic2016-04-134-0/+14
| | | | | | | | | | | | | | | | This patch corresponds to review: http://reviews.llvm.org/D15120 It adds support for the __float128 keyword, literals and a target feature to enable it. This support is disabled by default on all targets and any target that has support for this type is free to add it. Based on feedback that I've received from target maintainers, this appears to be the right thing for most targets. I have not heard from the maintainers of X86 which I believe supports this type. I will subsequently investigate the impact of enabling this on X86. llvm-svn: 266186
* [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.Alexey Bader2016-04-133-6/+6
| | | | | | | | | | Putting OpenCLImageTypes.def to clangAST library violates layering requirement: "It's not OK for a Basic/ header to include an AST/ header". This fixes the modules build. Differential revision: http://reviews.llvm.org/D18954 Reviewers: Richard Smith, Vassil Vassilev. llvm-svn: 266180
* [OPENMP 4.0] Support for 'linear' clause in 'declare simd' directive.Alexey Bataev2016-04-121-13/+27
| | | | | | | | | | The linear clause declares one or more list items to be private to a SIMD lane and to have a linear relationship with respect to the iteration space of a loop. 'linear' '(' <linear-list> [ ':' <linear-step> ] ')' When a linear-step expression is specified in a linear clause it must be either a constant integer expression or an integer-typed parameter that is specified in a uniform clause on the directive. The special this pointer can be used as if was one of the arguments to the function in any of the linear, aligned, or uniform clauses. llvm-svn: 266056
* [OPENMP 4.0] Support for 'aligned' clause in 'declare simd' directive.Alexey Bataev2016-04-121-60/+77
| | | | | | | | | The aligned clause declares that the object to which each list item points is aligned to the number of bytes expressed in the optional parameter of the aligned clause. 'aligned' '(' <argument-list> [ ':' <alignment> ] ')' The optional parameter of the aligned clause, alignment, must be a constant positive integer expression. If no optional parameter is specified, implementation-defined default alignments for SIMD instructions on the target platforms are assumed. The special this pointer can be used as if was one of the arguments to the function in any of the linear, aligned, or uniform clauses. llvm-svn: 266052
* [OPENMP 4.0] Support for 'uniform' clause in 'declare simd' directive.Alexey Bataev2016-04-121-130/+139
| | | | | | | | | OpenMP 4.0 defines clause 'uniform' in 'declare simd' directive: 'uniform' '(' <argument-list> ')' The uniform clause declares one or more arguments to have an invariant value for all concurrent invocations of the function in the execution of a single SIMD loop. The special this pointer can be used as if was one of the arguments to the function in any of the linear, aligned, or uniform clauses. llvm-svn: 266041
* Remove redundant conditions of the form (A || (!A && B)) -> (A || B)Benjamin Kramer2016-04-111-2/+1
| | | | | | Found by cppcheck! PR27286 PR27287 PR27288 PR27289 llvm-svn: 265918
* [OpenCL] Complete image types support.Alexey Bader2016-04-083-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I. Current implementation of images is not conformant to spec in the following points: 1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine: void write_image(write_only image2d_t img); kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code which is disallowed according to s6.13.14. 2. It discards access qualifier on generated code, which leads to generated code for the above example: call void @write_image(%opencl.image2d_t* %img); In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images. Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently. 3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names. 4. Default access qualifier read_only is to be added if not provided explicitly. II. This patch corrects the above points as follows: 1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type. 2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers). 3. Improves testing of images in Clang. Author: Anastasia Stulova Reviewers: bader, mgrang. Subscribers: pxli168, pekka.jaaskelainen, yaxunl. Differential Revision: http://reviews.llvm.org/D17821 llvm-svn: 265783
* [OPENMP 4.0] Parsing/sema analysis for 'simdlen' clause in 'declare simd'Alexey Bataev2016-04-071-39/+140
| | | | | | | | | | | | construct. OpenMP 4.0 defines '#pragma omp declare simd' construct that may have associated 'simdlen' clause with constant positive expression as an argument: simdlen(<const_expr>) Patch adds parsin and semantic analysis for simdlen clause. llvm-svn: 265668
* [OPENMP] Parsing and Sema support for 'omp declare target' directiveDmitry Polukhin2016-04-061-0/+56
| | | | | | | | | | | | | | | | | | | | Add parsing, sema analysis for 'declare target' construct for OpenMP 4.0 (4.5 support will be added in separate patch). The declare target directive specifies that variables, functions (C, C++ and Fortran), and subroutines (Fortran) are mapped to a device. The declare target directive is a declarative directive. In Clang declare target is implemented as implicit attribute for the declaration. The syntax of the declare target directive is as follows: #pragma omp declare target declarations-definition-seq #pragma omp end declare target Based on patch from Michael Wong http://reviews.llvm.org/D15321 llvm-svn: 265530
* [OPENMP 4.0] Support for 'inbranch|noinbranch' clauses in 'declareAlexey Bataev2016-04-041-6/+41
| | | | | | | | | simd'. Added parsing/semantic analysis for 'inbranch|notinbranch' clauses of '#pragma omp declare simd' construct. llvm-svn: 265287
* Revert "[OPENMP] Allow skip expression after comma in clauses with lists."Alexey Bataev2016-04-011-5/+4
| | | | | | | This reverts commit http://reviews.llvm.org/rL265003. After some thoughts decided to emit errors here. llvm-svn: 265119
* [OPENMP] Allow skip expression after comma in clauses with lists.Alexey Bataev2016-03-311-4/+5
| | | | | | Compatibility fix for better compatibility with the existing software. llvm-svn: 265003
* [OPENMP 4.0] Initial support for '#pragma omp declare simd' directive.Alexey Bataev2016-03-304-7/+65
| | | | | | | | | | | | | | | | Initial parsing/sema/serialization/deserialization support for '#pragma omp declare simd' directive. The 'declare simd' construct can be applied to a function to enable the creation of one or more versions that can process multiple arguments using SIMD instructions from a single invocation from a SIMD loop. If the function has any declarations, then the declare simd construct for any declaration that has one must be equivalent to the one specified for the definition. Otherwise, the result is unspecified. This pragma can be applied many times to the same declaration. Internally this pragma is represented as an attribute. But we need special processing for this pragma because it must be used before function declaration, this directive is applied to. Differential Revision: http://reviews.llvm.org/D10599 llvm-svn: 264853
* For MS ABI, emit dllexport friend functions defined inline in classStephan Bergmann2016-03-301-2/+4
| | | | | | | | | | | | | | ...as that is apparently what MSVC does. This is an updated version of r263738, which had to be reverted in r263740 due to test failures. The original version had erroneously emitted functions that are defined in class templates, too (see the updated "Handle friend functions" code in EmitDeferredDecls, lib/CodeGen/ModuleBuilder.cpp). (The updated tests needed to be split out into their own dllexport-ms-friend.cpp because of the CHECK-NOTs which would have interfered with subsequent CHECK-DAGs in dllexport.cpp.) Differential Revision: http://reviews.llvm.org/D18430 llvm-svn: 264841
* [Cxx1z-constexpr-lambda-P0170R1] Support parsing of constexpr specifier ↵Faisal Vali2016-03-261-4/+61
| | | | | | | | | | | | | | | | | | | | | | (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
* Add replacement = "xxx" to AvailabilityAttr.Manman Ren2016-03-212-7/+18
| | | | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This was commited in r263687 and reverted in 263752 due to misaligned access. rdar://20588929 llvm-svn: 263958
* clang-cl: support __cdecl-on-struct anachronismReid Kleckner2016-03-211-0/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: The Microsoft compiler emits warning C4229: anachronism used : modifiers on data are ignored for struct {} __cdecl s; but ICU's gendict can generate such (and does when building LibreOffice), so accepting this in clang-cl too would be useful. Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D16628 llvm-svn: 263947
* [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)Faisal Vali2016-03-211-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert r263687 for ubsan bot failure.Manman Ren2016-03-172-18/+7
| | | | llvm-svn: 263752
* Revert "For MS ABI, emit dllexport friend functions defined inline in class"Reid Kleckner2016-03-171-4/+2
| | | | | | | | | This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp llvm-svn: 263740
* For MS ABI, emit dllexport friend functions defined inline in classReid Kleckner2016-03-171-2/+4
| | | | | | | | | | | | Summary: ...as that is apparently what MSVC does Reviewers: rnk Patch by Stephan Bergmann Differential Revision: http://reviews.llvm.org/D15267 llvm-svn: 263738
* [OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.Alexey Bataev2016-03-171-5/+16
| | | | | | | | 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
* Add an optional named argument (replacement = "xxx") to AvailabilityAttr.Manman Ren2016-03-172-7/+18
| | | | | | | | | | This commit adds a named argument to AvailabilityAttr, while r263652 adds an optional string argument to __attribute__((deprecated)). This enables the compiler to provide Fix-Its for deprecated declarations. rdar://20588929 llvm-svn: 263687
* Implement support for [[maybe_unused]] in C++1z that is based off existing ↵Aaron Ballman2016-03-091-0/+2
| | | | | | support for unused, and treat it as an extension pre-C++1z. This also means extending the existing unused attribute so that it can be placed on an enum and enumerator, in addition to the other subjects. llvm-svn: 263025
* Silence duplicate diagnostics because parsing of a standards-based attribute ↵Aaron Ballman2016-03-081-0/+2
| | | | | | triggers parsing diagnostics that may also be picked up during semantic analysis. llvm-svn: 262960
* Implement support for [[nodiscard]] in C++1z that is based off existing ↵Aaron Ballman2016-03-071-1/+2
| | | | | | support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class. llvm-svn: 262872
* [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + ↵Marina Yatsina2016-03-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | fix bag with curly braces Until now curly braces could only be used in MS inline assembly to mark block start/end. All curly braces were removed completely at a very early stage. This approach caused bugs like: "m{o}v eax, ebx" turned into "mov eax, ebx" without any error. In addition, AVX-512 added special operands (e.g., k registers), which are also surrounded by curly braces that mark them as such. Now, we need to keep the curly braces and identify at a later stage if they are marking block start/end (if so, ignore them), or surrounding special AVX-512 operands (if so, parse them as such). This patch fixes the bug described above and enables the use of AVX-512 special operands. This commit is the the clang part of the patch. The clang part of the review is: http://reviews.llvm.org/D17766 The llvm part of the review is: http://reviews.llvm.org/D17767 Differential Revision: http://reviews.llvm.org/D17766 llvm-svn: 262842
* Test commit: Fix run-on sentence in commentMike Spertus2016-03-051-2/+2
| | | | llvm-svn: 262764
* [OPENMP 4.0] Initial support for 'omp declare reduction' construct.Alexey Bataev2016-03-034-11/+265
| | | | | | | | | | | | | | | | | Add parsing, sema analysis and serialization/deserialization for 'declare reduction' construct. User-defined reductions are defined as #pragma omp declare reduction( reduction-identifier : typename-list : combiner ) [initializer ( initializer-expr )] These custom reductions may be used in 'reduction' clauses of OpenMP constructs. The combiner specifies how partial results can be combined into a single value. The combiner can use the special variable identifiers omp_in and omp_out that are of the type of the variables being reduced with this reduction-identifier. Each of them will denote one of the values to be combined before executing the combiner. It is assumed that the special omp_out identifier will refer to the storage that holds the resulting combined value after executing the combiner. As the initializer-expr value of a user-defined reduction is not known a priori the initializer-clause can be used to specify one. Then the contents of the initializer-clause will be used as the initializer for private copies of reduction list items where the omp_priv identifier will refer to the storage to be initialized. The special identifier omp_orig can also appear in the initializer-clause and it will refer to the storage of the original variable to be reduced. Differential Revision: http://reviews.llvm.org/D11182 llvm-svn: 262582
* Serialize `pragma ms_struct` state.Nico Weber2016-03-021-6/+5
| | | | | | | | | | | pragma ms_struct has an effect on struct decls, and the effect is serialized correctly already. But the "is ms_struct currently on" state wasn't before this change. This uses the same approach as `pragma clang optimize`: When writing a module, the state isn't serialized, only when writing a pch file. llvm-svn: 262539
* Serialize `#pragma detect_mismatch`.Nico Weber2016-03-021-4/+4
| | | | | | | This is like r262493, but for pragma detect_mismatch instead of pragma comment. The two pragmas have similar behavior, so use the same approach for both. llvm-svn: 262506
* Serialize `#pragma comment`.Nico Weber2016-03-021-11/+12
| | | | | | | | | | | | | | `#pragma comment` was handled by Sema calling a function on ASTConsumer, and CodeGen then implementing this function and writing things to its output. Instead, introduce a PragmaCommentDecl AST node and hang one off the TranslationUnitDecl for every `#pragma comment` line, and then use the regular serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's eagerly deserialized.) http://reviews.llvm.org/D17799 llvm-svn: 262493
* [OpenMP] Fix parsing of delete map clause modifier in C++ mode.Samuel Antao2016-02-271-8/+16
| | | | | | | | | | | | Summary: The map modifier 'delete' is parser in c++ mode as a delete keyword, which requires special handling in the map clause parsing. Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev Subscribers: cfe-commits, fraggamuffin, caomhin Differential Revision: http://reviews.llvm.org/D17629 llvm-svn: 262094
* [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttrXiuli Pan2016-02-261-1/+2
| | | | | | | | | | | | | | | Summary: OpenCL access qualifiers are now not only used for image types, refine it to avoid misleading, Add semacheck for OpenCL access qualifier as well as test caees. Reviewers: pekka.jaaskelainen, Anastasia, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D16040 llvm-svn: 261961
* [ms-inline-asm] Fixing bug in single asm statement supportMarina Yatsina2016-02-231-0/+4
| | | | | | | | | | | | | | Fixing a crash caused by trying to merge a single-line asm statement with an asm block that follows it, e.g: asm int 4 asm { int 5 } Now, only adjacent single-line asm statements that are not surrounded by braces will be merged into one asm call. Differential Revision: http://reviews.llvm.org/D17496 llvm-svn: 261618
* Addressing review comments for r261163.Manman Ren2016-02-222-12/+12
| | | | | | | | | Use "strict" instead of "nopartial". Also make strictly not-introduced share the same diagnostics as Obsolete and Unavailable. rdar://23791325 llvm-svn: 261512
* [OpenCL] Generate metadata for opencl_unroll_hint attributeAnastasia Stulova2016-02-192-2/+20
| | | | | | | | | | | | | | | Add support for opencl_unroll_hint attribute from OpenCL v2.0 s6.11.5. Reusing most of metadata generation from CGLoopInfo helper class. The code is based on Khronos OpenCL compiler: https://github.com/KhronosGroup/SPIR/tree/spirv-1.0 Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16686 llvm-svn: 261350
* Correct typos after acting on invalid subscript expressionsDavid Majnemer2016-02-191-2/+8
| | | | llvm-svn: 261312
* [Sema] PR25181 Fix crash when method declaration with throw spec fails to ↵Reid Kleckner2016-02-191-1/+2
| | | | | | | | | | | | | | | parse correctly Fixes crash referenced in PR25181 where dyn_cast is called on a null instance of LM.Method. Reviewers: majnemer, rnk Patch by Don Hinton Differential Revision: http://reviews.llvm.org/D17072 llvm-svn: 261292
* [Parse] Code complete expressions in bracket declarators.Benjamin Kramer2016-02-181-0/+3
| | | | | | | | | | Currently we return no results when completing inside of the brackets in a 'char foo[]' declaration. Let the generic expression completion code handle it instead. We could get fancier here (e.g. filter non-constant expressions in contexts where VLAs are not allowed), but it's a strict improvement over the existing version. llvm-svn: 261217
* [Parse] Make sure we don't forget to diagnose typos in exprsDavid Majnemer2016-02-181-3/+7
| | | | | | | If ActOn*Op fails, we will forget to diagnose typos in the LHS of expressions. llvm-svn: 261191
* Add 'nopartial' qualifier for availability attributes.Manman Ren2016-02-172-5/+20
| | | | | | | | | | | | | | | | | | | | | | An optional nopartial can be placed after the platform name. int bar() __attribute__((availability(macosx,nopartial,introduced=10.12)) When deploying back to a platform version prior to when the declaration was introduced, with 'nopartial', Clang emits an error specifying that the function is not introduced yet; without 'nopartial', the behavior stays the same: the declaration is `weakly linked`. A member is added to the end of AttributeList to save the location of the 'nopartial' keyword. A bool member is added to AvailabilityAttr. The diagnostics for 'nopartial' not-yet-introduced is handled in the same way as we handle unavailable cases. Reviewed by Doug Gregor and Jordan Rose. rdar://23791325 llvm-svn: 261163
* Correct more typos in conditional expressionsDavid Majnemer2016-02-171-2/+4
| | | | | | | We didn't correctly handle some edge cases, causing us to bail out before correcting all the typos. llvm-svn: 261109
* [OPENMP] NFC rewrite ParseOpenMPDirectiveKindDmitry Polukhin2016-02-131-58/+64
| | | | | | | | New implementation is easier to read and extend. Differential Revision: http://reviews.llvm.org/D17197 llvm-svn: 260811
* Fix remaining Clang-tidy readability-redundant-control-flow warnings; other ↵Eugene Zelenko2016-02-121-5/+6
| | | | | | | | minor fixes. Differential revision: http://reviews.llvm.org/D17218 llvm-svn: 260757
OpenPOWER on IntegriCloud