summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [c++20] P0780R2: Support pack-expansion of init-captures.Richard Smith2019-05-215-102/+210
| | | | | | | | | | | This permits an init-capture to introduce a new pack: template<typename ...T> auto x = [...a = T()] { /* a is a pack */ }; To support this, the mechanism for allowing ParmVarDecls to be packs has been extended to support arbitrary local VarDecls. llvm-svn: 361300
* Do not use the incorrect attribute spelling list index when translating a ↵Aaron Ballman2019-05-211-3/+15
| | | | | | | | no_sanitize_foo attribute into a no_sanitize("foo") attribute. This fixes a crash when AST pretty printing declarations marked with no_sanitize_memory. llvm-svn: 361274
* Added an assertion to constant evaluation enty points that prohibits ↵Dmitri Gribenko2019-05-172-4/+16
| | | | | | | | | | | | | | | | | | dependent expressions Summary: Constant evaluator does not work on value-dependent or type-dependent expressions. Also fixed bugs uncovered by these assertions. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61522 llvm-svn: 361050
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-4/+5
| | | | | | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) This reinstates r360974, reverted in r360988, with a fix for a static_assert failure on 32-bit builds: force Type base class to have 8-byte alignment like the rest of Clang's AST nodes. llvm-svn: 360995
* Revert Refactor constant evaluation of typeid(T) to track a symbolic ↵Chris Bieneman2019-05-171-5/+4
| | | | | | | | type_info object rather than tracking the originating expression. This reverts r360974 (git commit 7ee4307bd4450022c3c8777f43a40cc4f0ccc009) llvm-svn: 360988
* Refactor constant evaluation of typeid(T) to track a symbolic type_infoRichard Smith2019-05-171-4/+5
| | | | | | | | | | object rather than tracking the originating expression. This is groundwork for supporting polymorphic typeid expressions. (Note that this somewhat regresses our support for DR1968, but it turns out that that never actually worked anyway, at least in non-trivial cases.) llvm-svn: 360974
* Implement __builtin_LINE() et. al. to support source location capture.Eric Fiselier2019-05-165-33/+57
| | | | | | | | | | | | | | | | | Summary: This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation). With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong Reviewed By: rsmith Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D37035 llvm-svn: 360937
* [CodeComplete] Complete enumerators when preferred type is an enumIlya Biryukov2019-05-161-21/+44
| | | | | | | | | | | | | | Reviewers: kadircet Reviewed By: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62010 llvm-svn: 360912
* Fix regression in r360311 caused by reversed bool arguments.Richard Smith2019-05-161-1/+2
| | | | llvm-svn: 360837
* Test commitKevin Petit2019-05-151-1/+1
| | | | | | | Remove stray space. Signed-off-by: Kevin Petit <kevin.petit@arm.com> llvm-svn: 360783
* [c++20] P1064R0: Allow virtual function calls in constant expressionRichard Smith2019-05-132-16/+34
| | | | | | | | | | | | | evaluation. This reinstates r360559, reverted in r360580, with a fix to avoid crashing if evaluation-for-overflow mode encounters a virtual call on an object of a class with a virtual base class, and to generally not try to resolve virtual function calls to objects whose (notional) vptrs are not readable. (The standard rules are unclear here, but this seems like a reasonable approach.) llvm-svn: 360635
* Make more friendly with unions. Reviewed as https://reviews.llvm.org/D61858Marshall Clow2019-05-131-1/+8
| | | | llvm-svn: 360614
* Revert r360559 "[c++20] P1064R0: Allow virtual function calls in constant ↵Hans Wennborg2019-05-132-34/+16
| | | | | | | | | expression evaluation." This caused Chromium builds to hit the new "can't handle virtual calls with virtual bases" assert. Reduced repro coming up. llvm-svn: 360580
* PR41845: Detect and reject mismatched inner/outer pack expansion sizesRichard Smith2019-05-132-10/+16
| | | | | | in fold expressions rather than crashing. llvm-svn: 360563
* [c++20] P1064R0: Allow virtual function calls in constant expressionRichard Smith2019-05-132-16/+34
| | | | | | evaluation. llvm-svn: 360559
* make -ftime-trace also print template argumentsLubos Lunak2019-05-122-2/+10
| | | | | | | | | Without this, I get e.g. 'PerformPendingInstantiations' -> 'std::fill', now I get 'std::fill<unsigned long *, int>'. Differential Revision: https://reviews.llvm.org/D61822 llvm-svn: 360539
* Improve interface of APValuePathEntry.Richard Smith2019-05-101-1/+1
| | | | llvm-svn: 360463
* [Sema] Mark array element destructors referenced during initializationErik Pilkington2019-05-103-53/+52
| | | | | | | | | | | | This fixes a crash where we would neglect to mark a destructor referenced for an __attribute__((no_destory)) array. The destructor is needed though, since if an exception is thrown we need to cleanup the elements. rdar://48462498 Differential revision: https://reviews.llvm.org/D61165 llvm-svn: 360446
* Assume `__cxa_allocate_exception` returns an under-aligned memory onAkira Hatanaka2019-05-101-0/+15
| | | | | | | | | | | | | | | | | | | | | Darwin if the version of libc++abi isn't new enough to include the fix in r319123 This patch resurrects r264998, which was committed to work around a bug in libc++abi that was causing _cxa_allocate_exception to return a memory that wasn't double-word aligned. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160328/154332.html In addition, this patch makes clang issue a warning if the type of the thrown object requires an alignment that is larger than the minimum guaranteed by the target C++ runtime. rdar://problem/49864414 Differential Revision: https://reviews.llvm.org/D61667 llvm-svn: 360404
* Remember to decay arrays to pointers before checking whether theRichard Smith2019-05-091-3/+6
| | | | | | left-hand side of an -> operator is a pointer to class type. llvm-svn: 360387
* [OPENMP]Fix PR41767: diagnose DSA for variables in clauses with default(none).Alexey Bataev2019-05-091-3/+95
| | | | | | | | | If the combined directive has default(none) clause and has clauses for inner directive that reference some variables, for which data-sharing attributes are not specified, the error messages should be emitted for such variables. llvm-svn: 360365
* [OPENMP]Fix PR41768: check DSA for globals with default(none) clauses.Alexey Bataev2019-05-092-3/+26
| | | | | | | | If the default(none) was specified for the construct, we might miss diagnostic for the globals without explicitly specified data-sharing attributes. Patch fixes this problem. llvm-svn: 360362
* Revert "[OPENMP]Fix PR41768: check DSA for globals with `default(none)` ↵Roman Lebedev2019-05-091-7/+1
| | | | | | | | | | | | clauses." This has introduced (exposed?) a crash in clang sema, that does not happen without this patch. I'll followup in the original bugreport and commit with reproducer. This reverts commit r360061. llvm-svn: 360327
* Revert "[OPENMP]Fix PR41767: diagnose DSA for variables in clauses with ↵Roman Lebedev2019-05-091-96/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default(none)." This implementation isn't sound as per the standard. It erroneously diagnoses e.g. the following case: ``` $ cat test.cpp void f(int n) { #pragma omp parallel default(none) if(n) ; } ``` ``` $ ./bin/clang -fopenmp test.cpp test.cpp:2:40: error: variable 'n' must have explicitly specified data sharing attributes #pragma omp parallel default(none) if(n) ^ test.cpp:2:31: note: explicit data sharing attribute requested here #pragma omp parallel default(none) if(n) ^ 1 error generated. ``` As per OpenMP Application Programming Interface Version 5.0 November 2018: * 2.19.4.1default Clause The default clause explicitly determines the data-sharing attributes of variables that are referenced *in a parallel, teams, or task generating construct and would otherwise be implicitly determined (see Section 2.19.1.1 on page 270). * 2.6.1 Determining the Number of Threads for a parallel Region Using a variable in an if or num_threads clause expression of a parallel construct causes an implicit reference to the variable in all enclosing constructs. The if clause expression and the num_threads clause expression are evaluated in the context outside of the parallel construct, This reverts commit r360073. llvm-svn: 360326
* [c++20] Add support for explicit(bool), as described in P0892R2.Richard Smith2019-05-0910-161/+287
| | | | | | | | Patch by Tyker! Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 360311
* [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith2019-05-097-73/+224
| | | | | | | | | | | | | | | | | | | | | | | | | template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
* When typo-correcting a function name, consider correcting to a type nameRichard Smith2019-05-092-3/+12
| | | | | | for a function-style cast. llvm-svn: 360302
* [Sema][OpenCL] Make address space conversions a bit stricter.Anastasia Stulova2019-05-082-16/+55
| | | | | | | | | | | | | | | | | | | | | | | | The semantics for converting nested pointers between address spaces are not very well defined. Some conversions which do not really carry any meaning only produce warnings, and in some cases warnings hide invalid conversions, such as 'global int*' to 'local float*'! This patch changes the logic in checkPointerTypesForAssignment and checkAddressSpaceCast to fail properly on implicit conversions that should definitely not be permitted. We also dig deeper into the pointer types and warn on explicit conversions where the address space in a nested pointer changes, regardless of whether the address space is compatible with the corresponding pointer nesting level on the destination type. Fixes PR39674! Patch by ebevhan (Bevin Hansson)! Differential Revision: https://reviews.llvm.org/D58236 llvm-svn: 360258
* Allow 'static' storage specifier on an out-of-line class member template ↵Aaron Ballman2019-05-081-2/+5
| | | | | | | | declaration in MSVCCompat mode. Patch by Soumi Manna. llvm-svn: 360250
* Fix for the greendragon bots.Leonard Chan2019-05-081-1/+3
| | | | | | Adds extra checks for ObjC GC and Ownership. llvm-svn: 360225
* [Sema] Correct typos in return statements so the return types of 'auto' ↵Sam McCall2019-05-081-1/+7
| | | | | | | | | | | | | | | | | | | | | functions are always deduced. Summary: e.g. auto foo() { return no_such_thing; // Return value is a TypoExpr } using T = decltype(foo()); // Uh-oh, undeduced auto. Reviewers: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61649 llvm-svn: 360224
* Split ActOnCallExpr into an ActOnCallExpr to be called by the parser,Richard Smith2019-05-089-23/+29
| | | | | | | and a BuildCallExpr to be called internally within Sema to build / rebuild calls. llvm-svn: 360217
* [OpenCL] Prevent mangling kernel functions.Anastasia Stulova2019-05-071-10/+24
| | | | | | | | | | | | Kernel function names have to be preserved as in the original source to be able to access them from the host API side. This commit also adds restriction to kernels that prevents them from being used in overloading, templates, etc. Differential Revision: https://reviews.llvm.org/D60454 llvm-svn: 360152
* [Sema] Add missing VisitMacroQualifiedTypeLoc to TypeSpecLocFillerLeonard Chan2019-05-071-0/+5
| | | | | | To hopefully fix greenbot failures llvm-svn: 360120
* Improve function / variable disambiguation.Richard Smith2019-05-071-2/+20
| | | | | | | | Keep looking for decl-specifiers after an unknown identifier. Don't issue diagnostics about an error type specifier conflicting with later type specifiers. llvm-svn: 360117
* Recommit r359859 "[Attribute/Diagnostics] Print macro if definition is an ↵Leonard Chan2019-05-074-10/+80
| | | | | | | | attribute declaration" Updated with fix for read of uninitialized memory. llvm-svn: 360109
* [Sema] Fix for P41774 where `ExpectNoDerefChunk` is assigned twiceLeonard Chan2019-05-061-5/+2
| | | | llvm-svn: 360089
* PR41183: Don't emit strict-prototypes warning for an implicit functionJames Y Knight2019-05-061-1/+4
| | | | | | | | | | | declaration. It should emit _only_ an implicit-function-declaration warning, not both of them. Differential Revision: https://reviews.llvm.org/D59711 llvm-svn: 360084
* [OPENMP]Fix PR41767: diagnose DSA for variables in clauses withAlexey Bataev2019-05-061-3/+96
| | | | | | | | | | | default(none). If the combined directive has default(none) clause and has clauses for inner directive that reference some variables, for which data-sharing attributes are not specified, the error messages should be emitted for such variables. llvm-svn: 360073
* [OPENMP]Fix PR41768: check DSA for globals with `default(none)` clauses.Alexey Bataev2019-05-061-1/+7
| | | | | | | | If the `default(none)` was specified for the construct, we might miss diagnostic for the globals without explicitly specified data-sharing attributes. Patch fixes this problem. llvm-svn: 360061
* [CodeComplete] Add a trailing semicolons to some pattern completionsIlya Biryukov2019-05-061-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Where semicolon is required in any case. Here's a list of completions that now have a semicolon: - namespace <name> = <target>; - using namespace <name>; - using <qualifier>::<name>; - continue; - break; - goto <label>; - return; - return <expression>; Reviewers: gribozavr Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61589 llvm-svn: 360042
* Revert r359949 "[clang] adding explicit(bool) from c++2a"Hans Wennborg2019-05-0610-293/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused Clang to start erroring on the following: struct S {   template <typename = int> explicit S(); }; struct T : S {}; struct U : T {   U(); }; U::U() {} $ clang -c /tmp/x.cc /tmp/x.cc:10:4: error: call to implicitly-deleted default constructor of 'T' U::U() {}    ^ /tmp/x.cc:5:12: note: default constructor of 'T' is implicitly deleted because base class 'S' has no default constructor struct T : S {};            ^ 1 error generated. See discussion on the cfe-commits email thread. This also reverts the follow-ups r359966 and r359968. > this patch adds support for the explicit bool specifier. > > Changes: > - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. > - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. > - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. > - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. > - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. > - Test for Semantic and Serialization were added. > > This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. > Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. > > Patch by Tyker > > Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 360024
* P1286R2: Remove restriction that the exception specification of aRichard Smith2019-05-062-67/+19
| | | | | | defaulted special member matches the implicit exception specification. llvm-svn: 360011
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-063-18/+27
| | | | | | | | | where either the modification or the other access is unreachable. This reverts r359984 (which reverted r359962). The bug in clang-tidy's test suite exposed by the original commit was fixed in r360009. llvm-svn: 360010
* [c++20] Implement P1009R2: allow omitting the array bound in an arrayRichard Smith2019-05-062-34/+60
| | | | | | | | | | new expression. This was voted into C++20 as a defect report resolution, so we retroactively apply it to all prior language modes (though it can never actually be used before C++11 mode). llvm-svn: 360006
* Revert rL359962 : Use DiagRuntimeBehavior for -Wunsequenced to weed out ↵Simon Pilgrim2019-05-053-27/+18
| | | | | | | | | | false positives where either the modification or the other access is unreachable. ........ Try to fix buildbots llvm-svn: 359984
* [c++20] Implement P0428R2 - Familiar template syntax for generic lambdasHamza Sood2019-05-043-22/+42
| | | | | | Differential Revision: https://reviews.llvm.org/D36527 llvm-svn: 359967
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-043-18/+27
| | | | | | where either the modification or the other access is unreachable. llvm-svn: 359962
* [clang] adding explicit(bool) from c++2aNicolas Lesser2019-05-0410-161/+293
| | | | | | | | | | | | | | | | | | | | | this patch adds support for the explicit bool specifier. Changes: - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. - Test for Semantic and Serialization were added. This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. Patch by Tyker Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 359949
* CWG issue 727: Fix numerous bugs in support for class-scope explicitRichard Smith2019-05-033-97/+108
| | | | | | specializations for variable templates. llvm-svn: 359947
OpenPOWER on IntegriCloud