summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Add missing diagnostic for explicit instantiation declarations namingRichard Smith2019-04-261-20/+46
| | | | | | | | | | | | | | | | | internal linkage entities. Such constructs are ill-formed by [temp.explicit]p13. We make a special exception to permit an invalid construct used by libc++ in some build modes: its <valarray> header declares some functions with the internal_linkage attribute and then (meaninglessly) provides explicit instantiation declarations for them. Luckily, Clang happens to effectively ignore the explicit instantiation declaration when generating code in this case, and this change codifies that behavior. This reinstates part of r359048, reverted in r359076. (The libc++ issue triggering the rollback has been addressed.) llvm-svn: 359259
* [OPENMP] Improved check for the linear dependency in the non-rectangularAlexey Bataev2019-04-251-5/+29
| | | | | | | | | loop nests. Added a checks that the initializer/condition expressions depend only only of the single previous loop iteration variable. llvm-svn: 359200
* [OPENMP]Initial support for non-rectangular loop nest.Alexey Bataev2019-04-241-13/+87
| | | | | | | Added basic semantic analysis for the non-rectangular loop nests for OpenMP 5.0 support. llvm-svn: 359132
* Use llvm::stable_sortFangrui Song2019-04-244-26/+20
| | | | llvm-svn: 359098
* Revert r359048: C++ DR2387: a variable template declared wthiIlya Biryukov2019-04-241-32/+20
| | | | | | | | | | | | | The change breaks libc++ with the follwing error: In file included from valarray:4: .../include/c++/v1/valarray:1062:60: error: explicit instantiation declaration of 'valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t)) ^ .../include/c++/v1/valarray:1063:60: error: explicit instantiation declaration of '~valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray()) llvm-svn: 359076
* Revert r350917 "[Sema] If CheckPlaceholderExpr rewrites the initializerRichard Smith2019-04-243-13/+14
| | | | | | | | | | | | | | of an auto" This commit changed the initializer expression passed into initialization (stripping off an enclosing pair of parentheses or braces) and subtly changing the meaning of programs, typically by inserting bogus calls to copy constructors. See the added testcase in test/SemaCXX/cxx1y-init-captures.cpp for an example of the breakage. llvm-svn: 359066
* Fix interactions between __builtin_constant_p and constexpr to matchRichard Smith2019-04-241-1/+5
| | | | | | | | | | | | | | | | | | current trunk GCC. GCC permits information from outside the operand of __builtin_constant_p (but in the same constant evaluation context) to be used within that operand; clang now does so too. A few other minor deviations from GCC's behavior showed up in my testing and are also fixed (matching GCC): * Clang now supports nullptr_t as the argument type for __builtin_constant_p * Clang now returns true from __builtin_constant_p if called with a null pointer * Clang now returns true from __builtin_constant_p if called with an integer cast to pointer type llvm-svn: 359059
* Add missing diagnostic for anonymous struct/union definitions that don'tRichard Smith2019-04-241-0/+12
| | | | | | introduce any names. llvm-svn: 359051
* Improve -Wuninitialized warning under ARC for block variables that areAkira Hatanaka2019-04-231-1/+2
| | | | | | | | | | | recursively captured. Under ARC, a block variable is zero-initialized when it is recursively captured by the block literal initializer. rdar://problem/11022762 llvm-svn: 359049
* C++ DR2387: a variable template declared wtih (or instantiated with) aRichard Smith2019-04-231-20/+32
| | | | | | | const-qualified type is not implicitly given internal linkage. But a variable template declared 'static' is. llvm-svn: 359048
* [c++2a] Implement semantic restrictions for 'export' declarations.Richard Smith2019-04-222-8/+162
| | | | llvm-svn: 358932
* [sema][objc] Minor refactor to OverrideSearch. NFCI.Matt Davis2019-04-221-26/+22
| | | | | | | | | | | | | | | | | | Summary: * Removed a member that was only used during construction. * Use range-based for iteration when accessing the result of the search. * Require an `ObjCMethodDecl` reference upon construction of an * Constify. Reviewers: rjmccall Reviewed By: rjmccall Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D60850 llvm-svn: 358898
* [Sema] ADL: Associated namespaces for class types and enumeration types (CWG ↵Bruno Ricci2019-04-221-27/+35
| | | | | | | | | | | | | | | | | | | 1691) CWG 1691 changed the definition of the namespaces associated with a class type or enumeration type. For a class type, the associated namespaces are the innermost enclosing namespaces of the associated classes. For an enumeration type, the associated namespace is the innermost enclosing namespace of its declaration. This also fixes CWG 1690 and CWG 1692. Differential Revision: https://reviews.llvm.org/D60573 Reviewed By: rjmccall, rsmith llvm-svn: 358882
* [Sema][MSVC] Fix bogus microsoft-pure-definition warning on member function ↵Bruno Ricci2019-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | of class template Clang emits a warning when using a pure specifier =0 in a function definition at class scope (a MS-specific construct), when using -fms-extensions. However, to detect this, it was using FD->isCanonicalDecl() on function declaration, which was also detecting out-of-class definition of member functions of class templates. Fix this by using !FD->isOutOfLine() instead. Fixes PR21334. Differential Revision: https://reviews.llvm.org/D29707 Reviewed By: riccibruno Reviewers: rnk, riccibruno Patch By: Rudy Pons llvm-svn: 358849
* Modules: Search for a visible definition of the decl context when computing ↵David Blaikie2019-04-191-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | visibility of a default template parameter The code is/was already correct for the case where a parameter is a parameter of its enclosing lexical DeclContext (functions and classes). But for other templates (alias and variable templates) they don't create their own scope to be members of - in those cases, they parameter should be considered visible if any definition of the lexical decl context is visible. [this should cleanup the failure on the libstdc++ modules buildbot] [this doesn't actually fix the variable template case for a secondary/compounding reason (its lexical decl context is incorrectly considered to be the translation unit)] Test covers all 4 kinds of templates with default args, including a regression test for the still broken variable template case. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D60892 llvm-svn: 358795
* [c++2a] Add semantic support for private module fragments.Richard Smith2019-04-183-61/+162
| | | | llvm-svn: 358713
* [OpenMP] Add checks for requires and target directives.Gheorghe-Teodor Bercea2019-04-181-0/+43
| | | | | | | | | | | | | | | | Summary: The requires directive containing target related clauses must appear before any target region in the compilation unit. Reviewers: ABataev, AlexEichenberger, caomhin Reviewed By: ABataev Subscribers: guansong, jfb, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60875 llvm-svn: 358709
* [Sema] Delete unused parameters/variablesFangrui Song2019-04-181-6/+2
| | | | llvm-svn: 358661
* Split out modules-specific declaration handling from SemaDecl.cpp into aRichard Smith2019-04-183-465/+486
| | | | | | new SemaModule.cpp. llvm-svn: 358633
* [c++2a] Improve diagnostic for use of declaration from another TU'sRichard Smith2019-04-181-21/+49
| | | | | | | | | | global module fragment. We know that the declaration in question should have been introduced by a '#include', so try to figure out which one and suggest it. Don't suggest importing the global module fragment itself! llvm-svn: 358631
* [Sema][ObjC] Don't warn about an implicitly retained self if theAkira Hatanaka2019-04-173-5/+35
| | | | | | | | | | | | | | | | | retaining block and all of the enclosing blocks are non-escaping. If the block implicitly retaining self doesn't escape, there is no risk of creating retain cycles, so clang shouldn't diagnose it and force users to add self-> to silence the diagnostic. Also, fix a bug where clang was failing to diagnose an implicitly retained self inside a c++ lambda nested inside a block. rdar://problem/25059955 Differential Revision: https://reviews.llvm.org/D60736 llvm-svn: 358624
* [NFC] Remove unused function (Sema::pushExternalDeclIntoScope)Leonard Chan2019-04-161-5/+0
| | | | llvm-svn: 358538
* [c++20] Parsing support for module-declarations, import-declarations,Richard Smith2019-04-142-37/+116
| | | | | | | | | and the global and private module fragment. For now, the private module fragment introducer is ignored, but use of the global module fragment introducer should be properly enforced. llvm-svn: 358353
* Add support for attributes on @implementations in Objective-CErik Pilkington2019-04-111-2/+10
| | | | | | | | | We want to make objc_nonlazy_class apply to implementations, but ran into this. There doesn't seem to be any reason that this isn't supported. Differential revision: https://reviews.llvm.org/D60542 llvm-svn: 358200
* Check i < FD->getNumParams() before queryingDmitri Gribenko2019-04-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: As was already stated in a previous comment, the parameter isn't necessarily referring to one of the DeclContext's parameter. We should check the index is within the range to avoid out-of-boundary access. Reviewers: gribozavr, rsmith, lebedev.ri Reviewed By: gribozavr, rsmith Subscribers: lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60055 Patch by Violet. llvm-svn: 358134
* [OPENMP]Allow allocate directive on parameters.Alexey Bataev2019-04-091-3/+0
| | | | | | Patch allows to use allocate directives on the function parameters. llvm-svn: 358016
* [X86] Add some fp to integer conversion intrinsics to ↵Craig Topper2019-04-081-0/+4
| | | | | | | | Sema::CheckX86BuiltinRoundingOrSAE so their rounding controls will be checked. If we don't check this in the frontend we'll get an isel error in the backend later. This is far less friendly to users. llvm-svn: 357924
* [OPENMP]Fix lookup of the user-defined reductions in C.Alexey Bataev2019-04-041-11/+13
| | | | | | Fixed the regression of the lookup of user-defined reductions for C. llvm-svn: 357708
* [CodeComplete] Fix crash when completing ObjC block parameter with a broken typeSam McCall2019-04-041-0/+5
| | | | | | | | | | | | | | | | | | | Summary: The fix isn't great, but it's hard to fix properly because the completion code sensibly uses ParmVarDecl to represent parameters, but the AST-building code sensibly doesn't synthesize them if the type is broken. Also this case is apparently really rare, so it's probably not worth bending over backwards for. Reviewers: ilya-biryukov Subscribers: javed.absar, kristof.beyls, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60258 llvm-svn: 357686
* [PR41157][OpenCL] Prevent implicit init of local addr space var in C++ mode.Anastasia Stulova2019-04-041-1/+5
| | | | | | | | | | | Prevent adding initializers implicitly to variables declared in local address space. This happens when they get converted into global variables and therefore theoretically have to be default initialized in C++. Differential Revision: https://reviews.llvm.org/D59646 llvm-svn: 357684
* [PR41276] Fixed incorrect generation of addr space cast for 'this' in C++.Anastasia Stulova2019-04-041-3/+13
| | | | | | | | | | | | | | | Improved classification of address space cast when qualification conversion is performed - prevent adding addr space cast for non-pointer and non-reference types. Take address space correctly from the pointee. Also pass correct address space from 'this' object using AggValueSlot when generating addrspacecast in the constructor call. Differential Revision: https://reviews.llvm.org/D59988 llvm-svn: 357682
* [Sema] Fix a use-after-deallocate of a ParsedAttrErik Pilkington2019-04-021-2/+2
| | | | | | | | | | | | | | | moveAttrFromListToList only makes sense when moving an attribute to a list with a pool that's either equivalent, or has a shorter lifetime. Therefore, using it to move a ParsedAttr from a declarator to a declaration specifier doesn't make sense, since the declaration specifier's pool outlives the declarator's. The patch adds a new function, ParsedAttributes::takeOneFrom, which transfers the attribute from one pool to another, fixing the use-after-deallocate. rdar://49175426 Differential revision: https://reviews.llvm.org/D60101 llvm-svn: 357516
* [OPENMP]Allocate clause allocator in target region.Alexey Bataev2019-04-011-0/+9
| | | | | | | | | | According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, allocate clauses that appear on a target construct or on constructs in a target region must specify an allocator expression unless a requires directive with the dynamic_allocators clause is present in the same compilation unit. Patch adds a check for this restriction. llvm-svn: 357412
* [OPENMP] Check that allocated variables are used in private clauses.Alexey Bataev2019-04-011-131/+226
| | | | | | | | | | According to OpenMP 5.0 standard, 2.11.4 allocate Clause, Restrictions, For any list item that is specified in the allocate clause on a directive, a data-sharing attribute clause that may create a private copy of that list item must be specified on the same directive. Patch adds the checks for this restriction. llvm-svn: 357390
* Range-style std::find{,_if} -> llvm::find{,_if}. NFCFangrui Song2019-03-316-18/+12
| | | | llvm-svn: 357359
* Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` ↵Anton Afanasyev2019-03-303-2/+29
| | | | | | | | | | | | | | compatible JSON profiling output dumps. This change adds hierarchical "time trace" profiling blocks that can be visualized in Chrome, in a "flame chart" style. Each profiling block can have a "detail" string that for example indicates the file being processed, template name being instantiated, function being optimized etc. This is taken from GitHub PR: https://github.com/aras-p/llvm-project-20170507/pull/2 Patch by Aras Pranckevičius. Differential Revision: https://reviews.llvm.org/D58675 llvm-svn: 357340
* [Sema] Avoid sending a dependent expression to the constant evaluator.Erik Pilkington2019-03-291-0/+3
| | | | | | Fixes llvm.org/PR41286 llvm-svn: 357304
* [Sema] Fix assertion when `auto` parameter in lambda has an attribute.Volodymyr Sapsai2019-03-291-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the assertion > no Attr* for AttributedType* > UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298! In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes` types with `auto` but later in `TypeProcessingState::takeAttrForAttributedType` we use transformed types and that's why cannot find `Attr` corresponding to `AttributedType`. Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`. rdar://problem/47689465 Reviewers: rsmith, arphaman, aaron.ballman Reviewed By: aaron.ballman Subscribers: jkorous, dexonsmith, jdoerfert, cfe-commits Differential Revision: https://reviews.llvm.org/D58659 llvm-svn: 357298
* [Sema] Fix a crash when nonnull checkingMichael Liao2019-03-291-0/+3
| | | | | | | | | | | | | | | | | | | | Summary: - If a parameter is used, nonnull checking needs function prototype to retrieve the corresponding parameter's attributes. However, at the prototype substitution phase when a template is being instantiated, expression may be created and checked without a fully specialized prototype. Under such a scenario, skip nonnull checking on that argument. Reviewers: rjmccall, tra, yaxunl Subscribers: javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59900 llvm-svn: 357236
* [OPENMP]Add check for undefined behavior with thread allocators onAlexey Bataev2019-03-281-0/+33
| | | | | | | | | | | | target and task-based directives. According to OpenMP 5.0, 2.11.4 allocate Clause, Restrictions, For task, taskloop or target directives, allocation requests to memory allocators with the trait access set to thread result in unspecified behavior. Patch introduces a check for omp_thread_mem_alloc predefined allocator on target- and trask-based directives. llvm-svn: 357205
* Make helper functions static. NFC.Benjamin Kramer2019-03-281-4/+5
| | | | llvm-svn: 357187
* [OPENMP]Initial support for 'allocate' clause.Alexey Bataev2019-03-272-1/+92
| | | | | | Added parsing/sema analysis of the allocate clause. llvm-svn: 357068
* Emit -Wfortify-source using DiagRuntimeBehaviourErik Pilkington2019-03-261-3/+4
| | | | | | | | | | This fixes a false positive on the following, where st is configured to have different sizes based on some preprocessor logic: if (sizeof(buf) == sizeof(*st)) memcpy(&buf, st, sizeof(*st)); llvm-svn: 357041
* [Sema] Fix an assert when a block captures a constexpr localErik Pilkington2019-03-261-3/+8
| | | | | | | | | | | | | | MarkVarDeclODRUsed indirectly calls captureInBlock, which creates a copy expression. The copy expression is insulated in it's own ExpressionEvaluationContext, so it saves, mutates, and restores MaybeODRUseExprs as CleanupVarDeclMarking is iterating through it, leading to a crash. Fix this by iterating through a local copy of MaybeODRUseExprs. rdar://47493525 https://reviews.llvm.org/D59670 llvm-svn: 357040
* Basic: Return a reference from FileManager::getVirtualFileSystem, NFCDuncan P. N. Exon Smith2019-03-261-2/+3
| | | | | | | | | | FileManager constructs a VFS in its constructor if it isn't passed one, and there's no way to reset it. Make that contract clear by returning a reference from its accessor. https://reviews.llvm.org/D59388 llvm-svn: 357038
* [MS] Add frontend support for __declspec(allocator)Reid Kleckner2019-03-251-0/+18
| | | | | | | | | | The intention is to add metadata to direct call sites of functions marked with __declspec(allocator), which will ultimately result in some S_HEAPALLOCSITE debug info records when emitting codeview. This is a piece of PR38491 llvm-svn: 356964
* [Sema] Don't check for array bounds when the types in the base expression ↵Bruno Ricci2019-03-251-0/+2
| | | | | | | | | | | | | | are dependent Bail-out of CheckArrayAccess when the types of the base expression before and after eventual casts are dependent. We will get another chance to check for array bounds during instantiation. Fixes PR41087. Differential Revision: https://reviews.llvm.org/D59776 Reviewed By: efriedma llvm-svn: 356957
* [Sema][NFCI] Don't allocate storage for the various ↵Bruno Ricci2019-03-2516-176/+237
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CorrectionCandidateCallback unless we are going to do some typo correction The various CorrectionCandidateCallbacks are currently heap-allocated unconditionally. This was needed because of delayed typo correction. However these allocations represent currently 15.4% of all allocations (number of allocations) when parsing all of Boost (!), mostly because of ParseCastExpression, ParseStatementOrDeclarationAfterAttrtibutes and isCXXDeclarationSpecifier. Note that all of these callback objects are small. Let's not do this. Instead initially allocate the callback on the stack, and only do a heap allocation if we are going to do some typo correction. Do this by: 1. Adding a clone function to each callback, which will do a polymorphic clone of the callback. This clone function is required to be implemented by every callback (of which there is a fair amount). Make sure this is the case by making it pure virtual. 2. Use this clone function when we are going to try to correct a typo. This additionally cut the time of -fsyntax-only on all of Boost by 0.5% (not that much, but still something). No functional changes intended. Differential Revision: https://reviews.llvm.org/D58827 Reviewed By: rnk llvm-svn: 356925
* Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block"Brian Gesiak2019-03-252-16/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/D59076 added a new coroutine error that prevented users from using 'co_await' or 'co_yield' within a exception handler. However, it was reverted in https://reviews.llvm.org/rC356774 because it caused a regression in nested scopes in C++ catch statements, as documented by https://bugs.llvm.org/show_bug.cgi?id=41171. The issue was due to an incorrect use of a `clang::ParseScope`. To fix: 1. Add a regression test for catch statement parsing that mimics the bug report from https://bugs.llvm.org/show_bug.cgi?id=41171. 2. Re-apply the coroutines error patch from https://reviews.llvm.org/D59076, but this time with the correct ParseScope behavior. Reviewers: GorNishanov, tks2103, rsmith, riccibruno, jbulow Reviewed By: riccibruno Subscribers: EricWF, jdoerfert, lewissbaker, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59752 llvm-svn: 356865
* Revert "[coroutines][PR40978] Emit error for co_yield within catch block"Brian Gesiak2019-03-222-52/+16
| | | | | | | | The commit https://reviews.llvm.org/rC356296 is causing a regression in nested catch scopes, https://bugs.llvm.org/show_bug.cgi?id=41171. Revert this change for now in order to un-break that problem report. llvm-svn: 356774
OpenPOWER on IntegriCloud