aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-06-28[Clang] Fix: Restore warning inadvertently removed by D126061.Martin Boehme1-4/+4
Before D126061, Clang would warn about this code ``` struct X { [[deprecated]] struct Y {}; }; ``` with the warning attribute 'deprecated' is ignored, place it after "struct" to apply attribute to type declaration D126061 inadvertently caused this warning to no longer be emitted. This patch restores the previous behavior. The reason for the bug is that after D126061, C++11 attributes applied to a member declaration are no longer placed in `DS.getAttributes()` but are instead tracked in a separate list (`DeclAttrs`). In the case of a free-standing decl-specifier-seq, we would simply ignore the contents of this list. Instead, we now pass the list on to `Sema::ParsedFreeStandingDeclSpec()` so that it can issue the appropriate warning. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D128499
2022-06-15[clang] Reject non-declaration C++11 attributes on declarationsMartin Boehme1-49/+87
For backwards compatiblity, we emit only a warning instead of an error if the attribute is one of the existing type attributes that we have historically allowed to "slide" to the `DeclSpec` just as if it had been specified in GNU syntax. (We will call these "legacy type attributes" below.) The high-level changes that achieve this are: - We introduce a new field `Declarator::DeclarationAttrs` (with appropriate accessors) to store C++11 attributes occurring in the attribute-specifier-seq at the beginning of a simple-declaration (and other similar declarations). Previously, these attributes were placed on the `DeclSpec`, which made it impossible to reconstruct later on whether the attributes had in fact been placed on the decl-specifier-seq or ahead of the declaration. - In the parser, we propgate declaration attributes and decl-specifier-seq attributes separately until we can place them in `Declarator::DeclarationAttrs` or `DeclSpec::Attrs`, respectively. - In `ProcessDeclAttributes()`, in addition to processing declarator attributes, we now also process the attributes from `Declarator::DeclarationAttrs` (except if they are legacy type attributes). - In `ConvertDeclSpecToType()`, in addition to processing `DeclSpec` attributes, we also process any legacy type attributes that occur in `Declarator::DeclarationAttrs` (and emit a warning). - We make `ProcessDeclAttribute` emit an error if it sees any non-declaration attributes in C++11 syntax, except in the following cases: - If it is being called for attributes on a `DeclSpec` or `DeclaratorChunk` - If the attribute is a legacy type attribute (in which case we only emit a warning) The standard justifies treating attributes at the beginning of a simple-declaration and attributes after a declarator-id the same. Here are some relevant parts of the standard: - The attribute-specifier-seq at the beginning of a simple-declaration "appertains to each of the entities declared by the declarators of the init-declarator-list" (https://eel.is/c++draft/dcl.dcl#dcl.pre-3) - "In the declaration for an entity, attributes appertaining to that entity can appear at the start of the declaration and after the declarator-id for that declaration." (https://eel.is/c++draft/dcl.dcl#dcl.pre-note-2) - "The optional attribute-specifier-seq following a declarator-id appertains to the entity that is declared." (https://eel.is/c++draft/dcl.dcl#dcl.meaning.general-1) The standard contains similar wording to that for a simple-declaration in other similar types of declarations, for example: - "The optional attribute-specifier-seq in a parameter-declaration appertains to the parameter." (https://eel.is/c++draft/dcl.fct#3) - "The optional attribute-specifier-seq in an exception-declaration appertains to the parameter of the catch clause" (https://eel.is/c++draft/except.pre#1) The new behavior is tested both on the newly added type attribute `annotate_type`, for which we emit errors, and for the legacy type attribute `address_space` (chosen somewhat randomly from the various legacy type attributes), for which we emit warnings. Depends On D111548 Reviewed By: aaron.ballman, rsmith Differential Revision: https://reviews.llvm.org/D126061
2022-06-15[Clang] Add the `annotate_type` attributeMartin Boehme1-4/+17
This is an analog to the `annotate` attribute but for types. The intent is to allow adding arbitrary annotations to types for use in static analysis tools. For details, see this RFC: https://discourse.llvm.org/t/rfc-new-attribute-annotate-type-iteration-2/61378 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D111548
2022-06-10[clang] Construct SmallVector with iterator ranges (NFC)Kazu Hirata1-2/+1
2022-06-06Allow use of an elaborated type specifier in a _Generic association in C++Aaron Ballman1-1/+3
Currently, Clang accepts this code in C mode (where the tag is required to be used) but rejects it in C++ mode thinking that the association is defining a new type. void foo(void) { struct S { int a; }; _Generic(something, struct S : 1); } Clang thinks this in C++ because it sees struct S : when parsing the class specifier and decides that must be a type definition (because the colon signifies the presence of a base class type). This patch adds a new declarator context to represent a _Generic association so that we can distinguish these situations properly. Fixes #55562 Differential Revision: https://reviews.llvm.org/D126969
2022-06-03[Attributes] Remove AttrSyntax and migrate uses to ↵Leonard Grey1-3/+4
AttributeCommonInfo::Syntax (NFC) This is setup for allowing hasAttribute to work for plugin-provided attributes Differential Revision: https://reviews.llvm.org/D126902
2022-05-12Check for resource exhaustion when recursively parsing declaratorsAaron Ballman1-5/+10
With sufficiently tortured code, it's possible to cause a stack overflow when parsing declarators. Thus, we now check for resource exhaustion when recursively parsing declarators so that we can at least warn the user we're about to crash before we actually crash. Fixes #51642 Differential Revision: https://reviews.llvm.org/D124915
2022-05-10[CUDA][HIP] support __noinline__ as keywordYaxun (Sam) Liu1-0/+14
CUDA/HIP programs use __noinline__ like a keyword e.g. __noinline__ void foo() {} since __noinline__ is defined as a macro __attribute__((noinline)) in CUDA/HIP runtime header files. However, gcc and clang supports __attribute__((__noinline__)) the same as __attribute__((noinline)). Some C++ libraries use __attribute__((__noinline__)) in their header files. When CUDA/HIP programs include such header files, clang will emit error about invalid attributes. This patch fixes this issue by supporting __noinline__ as a keyword, so that CUDA/HIP runtime could remove the macro definition. Reviewed by: Aaron Ballman, Artem Belevich Differential Revision: https://reviews.llvm.org/D124866
2022-05-05No longer accept scoped enumerations in CAaron Ballman1-1/+1
We had a think-o that would allow a user to declare a scoped enumeration in C language modes "as a C++11 extension". This is a think-o because there's no way for the user to spell the name of the enumerators; C does not have '::' for a fully-qualified name. See commit d0d87b597259a2b74ae5c2825a081c7e336cb1d0 for details on why this is unintentional for C. Fixes #42372
2022-05-04Change the behavior of implicit int diagnosticsAaron Ballman1-2/+2
C89 allowed a type specifier to be elided with the resulting type being int, aka implicit int behavior. This feature was subsequently removed in C99 without a deprecation period, so implementations continued to support the feature. Now, as with implicit function declarations, is a good time to reevaluate the need for this support. This patch allows -Wimplicit-int to issue warnings in C89 mode (off by default), defaults the warning to an error in C99 through C17, and disables support for the feature entirely in C2x. It also removes a warning about missing declaration specifiers that really was just an implicit int warning in disguise and other minor related cleanups.
2022-04-20[C2x] Disallow functions without prototypes/functions with identifier listsAaron Ballman1-3/+10
WG14 has elected to remove support for K&R C functions in C2x. The feature was introduced into C89 already deprecated, so after this long of a deprecation period, the committee has made an empty parameter list mean the same thing in C as it means in C++: the function accepts no arguments exactly as if the function were written with (void) as the parameter list. This patch implements WG14 N2841 No function declarators without prototypes (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm) and WG14 N2432 Remove support for function definitions with identifier lists (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf). It also adds The -fno-knr-functions command line option to opt into this behavior in other language modes. Differential Revision: https://reviews.llvm.org/D123955
2022-04-16Add some helpers to better check Scope's kind. NFCJun Zhang1-5/+4
Signed-off-by: Jun Zhang <jun@junz.org>
2022-04-14[HLSL] Add Semantic syntax, and SV_GroupIndexChris Bieneman1-0/+1
HLSL has a language feature called Semantics which get attached to declarations like attributes and are used in a variety of ways. One example of semantic use is here with the `SV_GroupIndex` semantic which, when applied to an input for a compute shader is pre-populated by the driver with a flattened thread index. Differential Revision: https://reviews.llvm.org/D122699 # Conflicts: # clang/include/clang/Basic/Attr.td # clang/include/clang/Basic/AttrDocs.td
2022-04-12[Clang] Fix unknown type attributes diagnosed twice with [[]] spellingJun Zhang1-5/+7
Don't warn on unknown type attributes in Parser::ProhibitCXX11Attributes for most cases, but left the diagnostic to the later checks. module declaration and module import declaration are special cases. Fixes https://github.com/llvm/llvm-project/issues/54817 Differential Revision: https://reviews.llvm.org/D123447
2022-04-06[Clang][Sema] Prohibit statement expression in the default argumentJun Zhang1-1/+9
As statement expression makes no sense in the default argument, this patch tries to disable it in the all cases. Please note that the statement expression is a GNU extension, which means that Clang should be consistent with GCC. However, there's no response from GCC devs since we have raised the issue for several weeks. In this case, I think we can disallow statement expressions as a default parameter in general for now, and relax the restriction if GCC folks decide to retain the feature for functions but not lambdas in the future. Related discussion: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104765 Fixes https://github.com/llvm/llvm-project/issues/53488 Differential Revision: https://reviews.llvm.org/D119609
2022-03-28[clang][NFC] Remove unused parameter in `Sema::ActOnDuplicateDefinition`.Volodymyr Sapsai1-1/+1
2022-03-24[clang][parse] Move source range into ParsedAttibutesViewTimm Bäder1-71/+53
Move the SourceRange from the old ParsedAttributesWithRange into ParsedAttributesView, so we have source range information available everywhere we use attributes. This also removes ParsedAttributesWithRange (replaced by simply using ParsedAttributes) and ParsedAttributesVieWithRange (replaced by using ParsedAttributesView). Differential Revision: https://reviews.llvm.org/D121201
2022-03-18[Clang] Support multiple attributes in a single pragmaEgor Zhdan1-1/+3
This adds support for multiple attributes in `#pragma clang attribute push`, for example: ``` ``` or ``` ``` Related attributes can now be applied with a single pragma, which makes it harder for developers to make an accidental error later when editing the code. rdar://78269653 Differential Revision: https://reviews.llvm.org/D121283
2022-03-07[clang][parser] Stop dragging an EndLoc around when parsing attributesTimm Bäder1-19/+16
It's almost always entirely unused and if it is used, the end of the attribute range can be used instead. Differential Revision: https://reviews.llvm.org/D120888
2022-03-05[NFC][Clang] Fix a couple of typosCorentin Jabot1-2/+2
2022-02-08Allow parameter pack expansions and initializer lists in annotate attributeSteffen Larsen1-32/+82
These changes make the Clang parser recognize expression parameter pack expansion and initializer lists in attribute arguments. Because expression parameter pack expansion requires additional handling while creating and instantiating templates, the support for them must be explicitly supported through the AcceptsExprPack flag. Handling expression pack expansions may require a delay to when the arguments of an attribute are correctly populated. To this end, attributes that are set to accept these - through setting the AcceptsExprPack flag - will automatically have an additional variadic expression argument member named DelayedArgs. This member is not exposed the same way other arguments are but is set through the new CreateWithDelayedArgs creator function generated for applicable attributes. To illustrate how to implement support for expression pack expansion support, clang::annotate is made to support pack expansions. This is done by making handleAnnotationAttr delay setting the actual attribute arguments until after template instantiation if it was unable to populate the arguments due to dependencies in the parsed expressions.
2022-01-26Revert "Rename llvm::array_lengthof into llvm::size to match std::size from ↵Benjamin Kramer1-2/+2
C++17" This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2. - It conflicts with the existing llvm::size in STLExtras, which will now never be called. - Calling it without llvm:: breaks C++17 compat
2022-01-26Rename llvm::array_lengthof into llvm::size to match std::size from C++17serge-sans-paille1-2/+2
As a conquence move llvm::array_lengthof from STLExtras.h to STLForwardCompat.h (which is included by STLExtras.h so no build breakage expected).
2022-01-19[AST] Fix the incorrect auto-keyword loc for constrained auto type loc.Haojian Wu1-1/+1
E.g. `Concept auto Func();` The nameLoc for the constained auto type loc pointed to the concept name loc, it should be the auto token loc. This patch fixes it, and remove a relevant hack in clang-tidy check. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D117009
2022-01-17Reland (2) "[AST] Add RParen loc for decltype AutoTypeloc.""Haojian Wu1-0/+1
The patch was reverted because it caused a crash during PCH build -- we missed to update the RParenLoc in TreeTransform<Derived>::TransformAutoType. This relands 55d96ac and 37ec65e with a test and fix.
2022-01-12Revert (2) "[AST] Add RParen loc for decltype AutoTypeloc."Florian Hahn1-1/+0
This reverts commit 41fbdfa4d5601cccbcdc0ded8ef35190d502f7f3. The commit breaks stage 2 builds with debug info, e.g. https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/5088/console Clang crashes with the following assertion when building llvm-project/llvm/lib/Support/Timer.cpp /usr/local/bin/sccache /Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/host-compiler/bin/clang++ -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support -I/Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/llvm-project/llvm/lib/Support -Iinclude -I/Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/llvm-project/llvm/include -fno-stack-protector -fno-common -Wno-profile-instr-unprofiled -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/clang-build/Build/module.cache -fcxx-modules -Xclang -fmodules-local-submodule-visibility -gmodules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -flto=thin -O2 -g -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -std=c++14 -fno-exceptions -fno-rtti -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o -c /Users/buildslave/jenkins/workspace/clang-stage2-Rthinlto/llvm-project/llvm/lib/Support/Timer.cpp Assertion failed: (((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow"), function getLocWithOffset, file /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/clang/include/clang/Basic/SourceLocation.h, line 135.
2022-01-11Reland "[AST] Add RParen loc for decltype AutoTypeloc."Haojian Wu1-0/+1
Reland 55d96ac and 37ec65e with a clang-tidy fix.
2022-01-09[clang] Fix bugprone argument comments (NFC)Kazu Hirata1-4/+4
Identified with bugprone-argument-comment.
2022-01-09[clang] Use true/false instead of 1/0 (NFC)Kazu Hirata1-4/+4
Identified with modernize-use-bool-literals.
2022-01-04[CodeComplete] drop unused Scope param. NFCSam McCall1-2/+2
2022-01-03[CodeCompletion] Signature help for braced constructor callsSam McCall1-2/+4
Implementation is based on the "expected type" as used for designated-initializers in braced init lists. This means it can deduce the type in some cases where it's not written: void foo(Widget); foo({ /*help here*/ }); Only basic constructor calls are in scope of this patch, excluded are: - aggregate initialization (no help is offered for aggregates) - initializer_list initialization (no help is offered for these constructors) Fixes https://github.com/clangd/clangd/issues/306 Differential Revision: https://reviews.llvm.org/D116317
2021-12-06Introduce _BitInt, deprecate _ExtIntAaron Ballman1-3/+30
WG14 adopted the _ExtInt feature from Clang for C23, but renamed the type to be _BitInt. This patch does the vast majority of the work to rename _ExtInt to _BitInt, which accounts for most of its size. The new type is exposed in older C modes and all C++ modes as a conforming extension. However, there are functional changes worth calling out: * Deprecates _ExtInt with a fix-it to help users migrate to _BitInt. * Updates the mangling for the type. * Updates the documentation and adds a release note to warn users what is going on. * Adds new diagnostics for use of _BitInt to call out when it's used as a Clang extension or as a pre-C23 compatibility concern. * Adds new tests for the new diagnostic behaviors. I want to call out the ABI break specifically. We do not believe that this break will cause a significant imposition for early adopters of the feature, and so this is being done as a full break. If it turns out there are critical uses where recompilation is not an option for some reason, we can consider using ABI tags to ease the transition.
2021-11-26[clang] Fix crash on broken parameter declaratorsKadir Cetinkaya1-7/+7
Differential Revision: https://reviews.llvm.org/D114609
2021-10-18[Parse] Improve diagnostic and recovery when there is an extra override in ↵Haojian Wu1-0/+12
the outline method definition. The clang behavior was poor before this patch: ``` void B::foo() override {} // Before: clang emited "expcted function body after function // declarator", and skiped all contents until it hits a ";", the // following function f() is discarded. // VS // Now "override is not allowed" with a remove fixit, and following f() // is retained. void f(); ``` Differential Revision: https://reviews.llvm.org/D111883
2021-09-06[Clang] Add __ibm128 type to represent ppc_fp128Qiu Chaofan1-0/+7
Currently, we have no front-end type for ppc_fp128 type in IR. PowerPC target generates ppc_fp128 type from long double now, but there's option (-mabi=(ieee|ibm)longdouble) to control it and we're going to do transition from IBM extended double-double ppc_fp128 to IEEE fp128 in the future. This patch adds type __ibm128 which always represents ppc_fp128 in IR, as what GCC did for that type. Without this type in Clang, compilation will fail if compiling against future version of libstdcxx (which uses __ibm128 in headers). Although all operations in backend for __ibm128 is done by software, only PowerPC enables support for it. There's something not implemented in this commit, which can be done in future ones: - Literal suffix for __ibm128 type. w/W is suitable as GCC documented. - __attribute__((mode(IF))) should be for __ibm128. - Complex __ibm128 type. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D93377
2021-08-31[OpenCL] Defines helper function for kernel language compatible OpenCL versionJustas Janickas1-6/+6
This change defines a helper function getOpenCLCompatibleVersion() inside LangOptions class. The function contains mapping between C++ for OpenCL versions and their corresponding compatible OpenCL versions. This mapping function should be updated each time a new C++ for OpenCL language version is introduced. The helper function is expected to simplify conditions on OpenCL C and C++ for OpenCL versions inside compiler code. Code refactoring performed. Differential Revision: https://reviews.llvm.org/D108693
2021-08-13[OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.Justas Janickas1-3/+2
Some Clang diagnostics could only report OpenCL C version. Because C++ for OpenCL can be used as an alternative to OpenCL C, the text for diagnostics should reflect that. Desrciptions modified for these diagnostics: `err_opencl_unknown_type_specifier` `warn_option_invalid_ocl_version` `err_attribute_requires_opencl_version` `warn_opencl_attr_deprecated_ignored` `ext_opencl_ext_vector_type_rgba_selector` Differential Revision: https://reviews.llvm.org/D107648
2021-08-12[CodeComplete] Basic code completion for attribute names.Sam McCall1-0/+11
Only the bare name is completed, with no args. For args to be useful we need arg names. These *are* in the tablegen but not currently emitted in usable form, so left this as future work. C++11, C2x, GNU, declspec, MS syntax is supported, with the appropriate spellings of attributes suggested. `#pragma clang attribute` is supported but not terribly useful as we only reach completion if parens are balanced (i.e. the line is not truncated) There's no filtering of which attributes might make sense in this grammatical context (e.g. attached to a function). In code-completion context this is hard to do, and will only work in few cases :-( There's also no filtering by langopts: this is because currently the only way of checking is to try to produce diagnostics, which requires a valid ParsedAttr which is hard to get. This should be fairly simple to fix but requires some tablegen changes to expose the logic without the side-effect. Differential Revision: https://reviews.llvm.org/D107696
2021-08-10[clang] Implement P0692R1 from C++20 (access checking on specializations and ↵Alex Orlov1-1/+30
instantiations) This patch implements paper P0692R1 from the C++20 standard. Disable usual access checking rules to template argument names in a declaration of partial specializations, explicit instantiation or explicit specialization (C++20 13.7.5/10, 13.9.1/6). Fixes: https://llvm.org/PR37424 This patch also implements option *A* from this paper P0692R1 from the C++20 standard. This patch follows the @rsmith suggestion from D78404. Reviewed By: krisb Differential Revision: https://reviews.llvm.org/D92024
2021-07-30[OpenCL] Add support of __opencl_c_pipes feature macro.Anton Zabaznov1-4/+12
'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while parsing and then later on check for language options to construct actual pipe. This feature requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well. This is the same patch as in D106748 but with a tiny fix in checking of diagnostic messages. Also added tests when program scope global variables are not supported. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D107154
2021-07-30Revert "[OpenCL] Add support of __opencl_c_pipes feature macro."Anton Zabaznov1-12/+4
This reverts commit d1e4b25756730576996457ba7324e9bf210e3693.
2021-07-30[OpenCL] Add support of __opencl_c_pipes feature macro.Anton Zabaznov1-4/+12
'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while parsing and then later on check for language options to construct actual pipe. This feature requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D106748
2021-07-13[OpenCL] Add support of __opencl_c_generic_address_space feature macroAnton Zabaznov1-0/+2
Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D103401
2021-07-12[OpenMP] Support OpenMP 5.1 attributesAaron Ballman1-1/+1
OpenMP 5.1 added support for writing OpenMP directives using [[]] syntax in addition to using #pragma and this introduces support for the new syntax. In OpenMP, the attributes take one of two forms: [[omp::directive(...)]] or [[omp::sequence(...)]]. A directive attribute contains an OpenMP directive clause that is identical to the analogous #pragma syntax. A sequence attribute can contain either sequence or directive arguments and is used to ensure that the attributes are processed sequentially for situations where the order of the attributes matter (remember: https://eel.is/c++draft/dcl.attr.grammar#4.sentence-4). The approach taken here is somewhat novel and deserves mention. We could refactor much of the OpenMP parsing logic to work for either pragma annotation tokens or for attribute clauses. It would be a fair amount of effort to share the logic for both, but it's certainly doable. However, the semantic attribute system is not designed to handle the arbitrarily complex arguments that OpenMP directives contain. Adding support to thread the novel parsed information until we can produce a semantic attribute would be considerably more effort. What's more, existing OpenMP constructs are not (often) represented as semantic attributes. So doing this through Attr.td would be a massive undertaking that would likely only benefit OpenMP and comes with additional risks. Rather than walk down that path, I am taking advantage of the fact that the syntax of the directives within the directive clause is identical to that of the #pragma form. Once the parser recognizes that we're processing an OpenMP attribute, it caches all of the directive argument tokens and then replays them as though the user wrote a pragma. This reuses the same OpenMP parsing and semantic logic directly, but does come with a risk if the OpenMP committee decides to purposefully diverge their pragma and attribute syntaxes. So, despite this being a novel approach that does token replay, I think it's actually a better approach than trying to do this through the declarative syntax in Attr.td.
2021-06-01[clang][Parse] Add parsing support for C++ attributes on using-declarationsLouis Dionne1-0/+7
This is a re-application of dc67299 which was reverted in f63adf5b because it broke the build. The issue should now be fixed. Attribution note: The original author of this patch is Erik Pilkington. I'm only trying to land it after rebasing. Differential Revision: https://reviews.llvm.org/D91630
2021-05-28Revert "[clang][Parse] Add parsing support for C++ attributes on ↵Nico Weber1-7/+0
using-declarations" This reverts commit dc672999a9b12a156991891dc400308b52d569ba. Breaks check-clang everywhere, see https://reviews.llvm.org/D91630
2021-05-28[clang][Parse] Add parsing support for C++ attributes on using-declarationsErik Pilkington1-0/+7
Differential Revision: https://reviews.llvm.org/D91630
2021-05-13Parse vector bool when stdbool.h and altivec.h are includedZarko Todorovski1-3/+8
Currently when including stdbool.h and altivec.h declaration of `vector bool` leads to errors due to `bool` being expanded to '_Bool`. This patch allows the parser to recognize `_Bool`. Reviewed By: hubert.reinterpretcast, Everybody0523 Differential Revision: https://reviews.llvm.org/D102064
2021-05-07[OpenCL] Fix optional image types.Anastasia Stulova1-5/+21
This change allows the use of identifiers for image types from `cl_khr_gl_msaa_sharing` freely in the kernel code if the extension is not supported since they are not in the list of the reserved identifiers. This change also removed the need for pragma for the types in the extensions since the spec does not require the pragma uses. Differential Revision: https://reviews.llvm.org/D100983
2021-05-04[OpenCL] Allow pipe as a valid identifier prior to OpenCL 2.0.Anastasia Stulova1-0/+1
Pipe has not been a reserved keyword in the earlier OpenCL standards. However we failed to allow its use as an identifier in the original commit. This issues is fixed now and testing is improved accordingly. Differential Revision: https://reviews.llvm.org/D101052