summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Refactor code for parsing omp declare target directive and its ↵Kelvin Li2018-11-211-50/+56
| | | | | | | | | | | | | | clauses (NFC) This patch refactor the code for parsing omp declare target directive and its clauses. Patch by pjeeva01 (Jeeva P.) Differential Revision: https://reviews.llvm.org/D54708 llvm-svn: 347411
* [OPENMP] remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp (NFC)Kelvin Li2018-11-211-8/+1
| | | | | | | | | | | Whether the map type modifier is specified or not, the flag MapTypeModifierSpecified is always set to true. Patch by Ahsan Saghir Differential Revision: https://reviews.llvm.org/D54638 llvm-svn: 347408
* [clang][Parse] Diagnose useless null statements / empty init-statementsRoman Lebedev2018-11-202-1/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang has `-Wextra-semi` (D43162), which is not dictated by the currently selected standard. While that is great, there is at least one more source of need-less semis - 'null statements'. Sometimes, they are needed: ``` for(int x = 0; continueToDoWork(x); x++) ; // Ugly code, but the semi is needed here. ``` But sometimes they are just there for no reason: ``` switch(X) { case 0: return -2345; case 5: return 0; default: return 42; }; // <- oops ;;;;;;;;;;; <- OOOOPS, still not diagnosed. Clearly this is junk. ``` Additionally: ``` if(; // <- empty init-statement true) ; switch (; // empty init-statement x) { ... } for (; // <- empty init-statement int y : S()) ; } As usual, things may or may not go sideways in the presence of macros. While evaluating this diag on my codebase of interest, it was unsurprisingly discovered that Google Test macros are *very* prone to this. And it seems many issues are deep within the GTest itself, not in the snippets passed from the codebase that uses GTest. So after some thought, i decided not do issue a diagnostic if the semi is within *any* macro, be it either from the normal header, or system header. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=39111 | PR39111 ]] Reviewers: rsmith, aaron.ballman, efriedma Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52695 llvm-svn: 347339
* NFC cleanup: Prefer make_unique over reset(new T())David Blaikie2018-11-151-40/+43
| | | | llvm-svn: 346929
* [NFC] Move storage of dispatch-version to GlobalDeclErich Keane2018-11-131-4/+5
| | | | | | | | | | | | | | | | | | | As suggested by Richard Smith, and initially put up for review here: https://reviews.llvm.org/D53341, this patch removes a hack that was used to ensure that proper target-feature lists were used when emitting cpu-dispatch (and eventually, target-clones) implementations. As a part of this, the GlobalDecl object is proliferated to a bunch more locations. Originally, this was put up for review (see above) to get acceptance on the approach, though discussion with Richard in San Diego showed he approved of the approach taken here. Thus, I believe this is acceptable for Review-After-commit Differential Revision: https://reviews.llvm.org/D53341 Change-Id: I0a0bd673340d334d93feac789d653e03d9f6b1d5 llvm-svn: 346757
* Fix the 'fixit' for inline namespace replacement.Erich Keane2018-11-121-1/+4
| | | | | | | | I'd neglected to add to the fixit for r346677. Richard Smith mentioned this in a review-after-commit, so fixing it here. Change-Id: I77e612be978d4eedda8d5bbd60b812b88f875cda llvm-svn: 346705
* Implement P1094R2 (nested inline namespaces)Erich Keane2018-11-121-41/+63
| | | | | | | | As approved for the Working Paper in San Diego, support annotating inline namespaces with 'inline'. Change-Id: I51a654e11ffb475bf27cccb2458768151619e384 llvm-svn: 346677
* Support Swift in platform availability attributeMichael Wu2018-11-121-0/+15
| | | | | | | | | | | | | | Summary: This adds support for Swift platform availability attributes. It's largely a port of the changes made to https://github.com/apple/swift-clang/ for Swift availability attributes. Specifically, https://github.com/apple/swift-clang/commit/84b5a21c31cb5b0d7d958a478bc01964939b6952 and https://github.com/apple/swift-clang/commit/e5b87f265aede41c8381094bbf54e2715c8293b0 . The implementation of attribute_availability_swift is a little different and additional tests in test/Index/availability.c were added. Reviewers: manmanren, friss, doug.gregor, arphaman, jfb, erik.pilkington, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, ColinKinloch, jrmuizel, cfe-commits Differential Revision: https://reviews.llvm.org/D50318 llvm-svn: 346633
* Introduce the _Clang scoped attribute token.Aaron Ballman2018-11-091-12/+32
| | | | | | Currently, we only accept clang as the scoped attribute identifier for double square bracket attributes provided by Clang, but this has the potential to conflict with user-defined macros. To help alleviate these concerns, this introduces the _Clang scoped attribute identifier as an alias for clang. It also introduces a warning with a fixit on the off chance someone attempts to use __clang__ as the scoped attribute (which is a predefined compiler identification macro). llvm-svn: 346521
* Add support for 'atomic_default_mem_order' clause on 'requires' directive. ↵Patrick Lyster2018-11-021-0/+4
| | | | | | Also renamed test files relating to 'requires'. Differntial review: https://reviews.llvm.org/D53513 llvm-svn: 345967
* Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner2018-11-016-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch should not introduce any behavior changes. It consists of mostly one of two changes: 1. Replacing fall through comments with the LLVM_FALLTHROUGH macro 2. Inserting 'break' before falling through into a case block consisting of only 'break'. We were already using this warning with GCC, but its warning behaves slightly differently. In this patch, the following differences are relevant: 1. GCC recognizes comments that say "fall through" as annotations, clang doesn't 2. GCC doesn't warn on "case N: foo(); default: break;", clang does 3. GCC doesn't warn when the case contains a switch, but falls through the outer case. I will enable the warning separately in a follow-up patch so that it can be cleanly reverted if necessary. Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu Differential Revision: https://reviews.llvm.org/D53950 llvm-svn: 345882
* NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington2018-10-309-47/+47
| | | | | | | | | | We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
* Revert "Revert "Support for groups of attributes in #pragma clang attribute""Erik Pilkington2018-10-291-17/+39
| | | | | | | This reverts commit r345487, which reverted r345486. I think the crashes were caused by an OOM on the builder, trying again to confirm... llvm-svn: 345517
* Revert "Support for groups of attributes in #pragma clang attribute"Erik Pilkington2018-10-291-40/+18
| | | | | | | | | This reverts commit r345486. Looks like it causes some old versions of GCC to crash, I'll see if I can work around it and recommit... llvm-svn: 345487
* Support for groups of attributes in #pragma clang attributeErik Pilkington2018-10-291-18/+40
| | | | | | | | | | | | | | | | | | This commit enables pushing an empty #pragma clang attribute push, then adding multiple attributes to it, then popping them all with #pragma clang attribute pop, just like #pragma clang diagnostic. We still support the current way of adding these, #pragma clang attribute push(__attribute__((...))), by treating it like a combined push/attribute. This is needed to create macros like: DO_SOMETHING_BEGIN(attr1, attr2, attr3) // ... DO_SOMETHING_END rdar://45496947 Differential revision: https://reviews.llvm.org/D53621 llvm-svn: 345486
* PR26547: alignof should return ABI alignment, not preferred alignmentRichard Smith2018-10-261-1/+3
| | | | | | | | | | | | Summary: - Add `UETT_PreferredAlignOf` to account for the difference between `__alignof` and `alignof` - `AlignOfType` now returns ABI alignment instead of preferred alignment iff clang-abi-compat > 7, and one uses _Alignof or alignof Patch by Nicole Mazzuca! Differential Revision: https://reviews.llvm.org/D53207 llvm-svn: 345419
* [ms] Prevent explicit constructor name lookup if scope is missingWill Wilson2018-10-251-1/+2
| | | | | | | | | | | MicrosoftExt allows explicit constructor calls. Prevent lookup of constructor name unless the name has explicit scope. This avoids a compile-time crash due to confusing a member access for a constructor name. Test case included. All tests pass. Differential Revision: https://reviews.llvm.org/D53441 llvm-svn: 345258
* Support accepting __gnu__ as a scoped attribute namespace that aliases to gnu.Aaron Ballman2018-10-241-7/+8
| | | | | | This is useful in libstdc++ to avoid clashes with identifiers in the user's namespace. llvm-svn: 345132
* Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFCFangrui Song2018-10-201-2/+2
| | | | llvm-svn: 344859
* Add support for 'dynamic_allocators' clause on 'requires' directive. ↵Patrick Lyster2018-10-111-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D53079 llvm-svn: 344249
* [SEMA] split ExtWarn dupl-decl-spec's into Extension and ExtWarnNick Desaulniers2018-10-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: For types deduced from typedef's and typeof's, don't warn for duplicate declaration specifiers in C90 unless -pedantic. Create a third diagnostic type for duplicate declaration specifiers. Previously, we had an ExtWarn and a Warning. This change adds a third, Extension, which only warns when -pedantic is set, staying silent otherwise. Fixes PR32985. Reviewers: rsmith Reviewed By: rsmith Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D52849 llvm-svn: 343740
* [OPENMP] Add reverse_offload clause to requires directivePatrick Lyster2018-10-031-0/+1
| | | | llvm-svn: 343711
* Add support for unified_shared_memory clause on requires directivePatrick Lyster2018-10-011-0/+1
| | | | llvm-svn: 343472
* Support enums with a fixed underlying type in all language modes.Erik Pilkington2018-09-281-13/+11
| | | | | | | | | | Previously we supported these in C++, ObjC, and C with -fms-extensions. rdar://43831380 Differential revision: https://reviews.llvm.org/D52339 llvm-svn: 343360
* [cxx2a] P0614R1: Support init-statements in range-based for loops.Richard Smith2018-09-283-41/+124
| | | | | | | We don't yet support this for the case where a range-based for loop is implicitly rewritten to an ObjC for..in statement. llvm-svn: 343350
* [OPENMP] Add support for OMP5 requires directive + unified_address clauseKelvin Li2018-09-261-0/+48
| | | | | | | | | Add support for OMP5.0 requires directive and unified_address clause. Patches to follow will include support for additional clauses. Differential Revision: https://reviews.llvm.org/D52359 llvm-svn: 343063
* [CUDA] Fixed parsing of optional template-argument-list.Artem Belevich2018-09-211-1/+3
| | | | | | | | | We need to consider all tokens that start with '>' when we're checking for the end of an empty template argument list. Differential Revision: https://reviews.llvm.org/D52321 llvm-svn: 342752
* [CodeComplete] Generate completion fix-its for C code as wellIvan Donchevskii2018-09-211-0/+2
| | | | | | | | | Current completion fix-its approach does not provide OtherOpBase for C code. But we can easily proceed in this case taking the original Base type. Differential Revision: https://reviews.llvm.org/D52261 llvm-svn: 342721
* [CodeComplete] Add completions for filenames in #include directives.Sam McCall2018-09-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The dir component ("somedir" in #include <somedir/fo...>) is considered fixed. We append "foo" to each directory on the include path, and then list its files. Completions are of the forms: #include <somedir/fo^ foo.h> fox/ The filter is set to the filename part ("fo"), so fuzzy matching can be applied to the filename only. No fancy scoring/priorities are set, and no information is added to CodeCompleteResult to make smart scoring possible. Could be in future. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52076 llvm-svn: 342449
* [OPENMP] Fix PR38903: Crash on instantiation of the non-dependentAlexey Bataev2018-09-131-2/+8
| | | | | | | | | | | declare reduction. If the declare reduction construct with the non-dependent type is defined in the template construct, the compiler might crash on the template instantition. Reworked the whole instantiation scheme for the declare reduction constructs to fix this problem correctly. llvm-svn: 342151
* [clang-cl, PCH] Support for /Yc and /Yu without filename and #pragma hdrstopMike Rice2018-09-111-17/+17
| | | | | | | | | | | | | With clang-cl, when the user specifies /Yc or /Yu without a filename the compiler uses a #pragma hdrstop in the main source file to determine the end of the PCH. If a header is specified with /Yc or /Yu #pragma hdrstop has no effect. The optional #pragma hdrstop filename argument is not yet supported. Differential Revision: https://reviews.llvm.org/D51391 llvm-svn: 341963
* [CodeCompletion] Enable signature help when initializing class/struct/union ↵Kadir Cetinkaya2018-09-111-1/+15
| | | | | | | | | | | | | | | | | | | | members. Summary: Factors out member decleration gathering and uses it in parsing to call signature help. Doesn't support signature help for base class constructors, the code was too coupled with diagnostic handling, but still can be factored out but just needs more afford. Reviewers: sammccall, ilya-biryukov, ioeric Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51917 llvm-svn: 341949
* [clang] Make sure codecompletion is called for calls even when inside a token.Kadir Cetinkaya2018-09-104-3/+44
| | | | | | | | | | | | | | | | | Summary: Currently CodeCompleteCall only gets called after a comma or parantheses. This patch makes sure it is called even at the cases like: ```foo(1^);``` Reviewers: ilya-biryukov, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51038 llvm-svn: 341824
* [OpenMP] Add support for nested 'declare target' directivesKelvin Li2018-09-101-2/+2
| | | | | | | | | | | Add the capability to nest multiple declare target directives - including header files within a declare target region. Differential Revision: https://reviews.llvm.org/D51378 Patch by Patrick Lyster llvm-svn: 341766
* [CodeComplete] Clearly distinguish signature help and code completion.Ilya Biryukov2018-09-074-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Code completion in clang is actually a mix of two features: - Code completion is a familiar feature. Results are exposed via the CodeCompleteConsumer::ProcessCodeCompleteResults callback. - Signature help figures out if the current expression is an argument of some function call and shows corresponding signatures if so. Results are exposed via CodeCompleteConsumer::ProcessOverloadCandidates. This patch refactors the implementation to untangle those two from each other and makes some naming tweaks to avoid confusion when reading the code. The refactoring is required for signature help fixes, see D51038. The only intended behavior change is the order of callbacks. ProcessOverloadCandidates is now called before ProcessCodeCompleteResults. Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51782 llvm-svn: 341660
* [CodeComplete] Report location of opening parens for signature helpIlya Biryukov2018-08-304-11/+16
| | | | | | | | | | | | | | Summary: Used in clangd. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51436 llvm-svn: 341063
* [Parser] Support alternative operator token keyword args in Objective-C++Erik Pilkington2018-08-211-0/+13
| | | | | | | | rdar://30741878 Differential revision: https://reviews.llvm.org/D50527 llvm-svn: 340301
* Improve diagnostic for missing comma in template parameter list.Richard Smith2018-08-171-15/+23
| | | | | | | | | | Given 'typename T typename U', we would correctly diagnose the missing comma, but incorrectly disambiguate the first parameter as being a non-type parameter and complain that the 'T' is not a qualified-id. See also gcc.gnu.org/PR86998. llvm-svn: 340074
* We have in place support for parsing #pragma FENV_ACCESS, but that Kevin P. Neal2018-08-143-1/+47
| | | | | | | | | | | | | information is then discarded with a warning to the user that we don't support it. This patch gets us one step closer by getting the info down into the AST in most cases. Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D49865 llvm-svn: 339693
* Revert test commitKevin P. Neal2018-08-141-1/+0
| | | | llvm-svn: 339691
* Test commitKevin P. Neal2018-08-141-0/+1
| | | | llvm-svn: 339690
* Port getLocEnd -> getEndLocStephen Kelly2018-08-092-14/+13
| | | | | | | | | | Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50351 llvm-svn: 339386
* Port getLocStart -> getBeginLocStephen Kelly2018-08-095-14/+14
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Append new attributes to the end of an AttributeList.Michael Kruse2018-08-032-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommit of r335084 after revert in r335516. ... instead of prepending it at the beginning (the original behavior since implemented in r122535 2010-12-23). This builds up an AttributeList in the the order in which the attributes appear in the source. The reverse order caused nodes for attributes in the AST (e.g. LoopHint) to be in the reverse order, and therefore printed in the wrong order in -ast-dump. Some TODO comments mention this. The order was explicitly reversed for enable_if attribute overload resolution and name mangling, which is not necessary anymore with this patch. The change unfortunately has some secondary effect, especially on diagnostic output. In the simplest cases, the CHECK lines or expected diagnostic were changed to the the new output. If the kind of error/warning changed, the attributes' order was changed instead. This unfortunately causes some 'previous occurrence here' hints to be textually after the main marker. This typically happens when attributes are merged, but are incompatible to each other. Interchanging the role of the the main and note SourceLocation will also cause the case where two different declaration's attributes (in contrast to multiple attributes of the same declaration) are merged to be reverse. There is no easy fix because sometimes previous attributes are merged into a new declaration's attribute list, sometimes new attributes are added to a previous declaration's attribute list. Since 'previous occurrence here' pointing to locations after the main marker is not rare, I left the markers as-is; it is only relevant when the attributes are declared in the same declaration anyway. Differential Revision: https://reviews.llvm.org/D48100 llvm-svn: 338800
* [UnrollAndJam] Add unroll_and_jam pragma handlingDavid Green2018-08-011-13/+40
| | | | | | | | | | | | | | This adds support for the unroll_and_jam pragma, to go with the recently added unroll and jam pass. The name of the pragma is the same as is used in the Intel compiler, and most of the code works the same as for unroll. #pragma clang loop unroll_and_jam has been separated into a different patch. This part adds #pragma unroll_and_jam with an optional count, and #pragma no_unroll_and_jam to disable the transform. Differential Revision: https://reviews.llvm.org/D47267 llvm-svn: 338566
* Remove trailing spaceFangrui Song2018-07-3013-456/+456
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Parse a possible trailing postfix expression suffix after a fold expressionNicolas Lesser2018-07-271-5/+15
| | | | | | | | | | | | | | | | | Summary: This patch allows the parsing of a postfix expression involving a fold expression, which is legal as a fold-expression is a primary-expression. See also https://llvm.org/pr38282 Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49848 llvm-svn: 338170
* [MS] Add L__FUNCSIG__ for compatibilityReid Kleckner2018-07-262-0/+4
| | | | | | | | | | Clang already has L__FUNCTION__ as a workaround for dealing with pre-processor code that expects to be able to do L##__FUNCTION__ in a macro. This patch implements the same logic for __FUNCSIG__. Fixes PR38295. llvm-svn: 338083
* Refactor checking of switch conditions and case values.Richard Smith2018-07-262-19/+15
| | | | | | | | | | | | | | | | | | | Check each case value in turn while parsing it, performing the conversion to the switch type within the context of the expression itself. This will become necessary in order to properly handle cleanups for temporaries created as part of the case label (in an upcoming patch). For now it's just good hygiene. This necessitates moving the checking for the switch condition itself to earlier, so that the destination type is available when checking the case labels. As a nice side-effect, we get slightly improved diagnostic quality and error recovery by separating the case expression checking from the case statement checking and from tracking whether there are discarded case labels. llvm-svn: 338056
* Implement cpu_dispatch/cpu_specific MultiversioningErich Keane2018-07-201-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As documented here: https://software.intel.com/en-us/node/682969 and https://software.intel.com/en-us/node/523346. cpu_dispatch multiversioning is an ICC feature that provides for function multiversioning. This feature is implemented with two attributes: First, cpu_specific, which specifies the individual function versions. Second, cpu_dispatch, which specifies the location of the resolver function and the list of resolvable functions. This is valuable since it provides a mechanism where the resolver's TU can be specified in one location, and the individual implementions each in their own translation units. The goal of this patch is to be source-compatible with ICC, so this implementation diverges from the ICC implementation in a few ways: 1- Linux x86/64 only: This implementation uses ifuncs in order to properly dispatch functions. This is is a valuable performance benefit over the ICC implementation. A future patch will be provided to enable this feature on Windows, but it will obviously more closely fit ICC's implementation. 2- CPU Identification functions: ICC uses a set of custom functions to identify the feature list of the host processor. This patch uses the cpu_supports functionality in order to better align with 'target' multiversioning. 1- cpu_dispatch function def/decl: ICC's cpu_dispatch requires that the function marked cpu_dispatch be an empty definition. This patch supports that as well, however declarations are also permitted, since the linker will solve the issue of multiple emissions. Differential Revision: https://reviews.llvm.org/D47474 llvm-svn: 337552
OpenPOWER on IntegriCloud