summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* [NFC] Extract method to SourceManager for traversing the macro "stack"George Karpenkov2018-02-091-5/+2
| | | | | | | | | | | | The code for going up the macro arg expansion is duplicated in many places (and we need it for the analyzer as well, so I did not want to duplicate it two more times). This patch is an NFC, so the semantics should remain the same. Differential Revision: https://reviews.llvm.org/D42458 llvm-svn: 324780
* Fif for an issue when Clang permits assignment to vector/extvector elements ↵Andrew V. Tischenko2018-02-092-3/+20
| | | | | | in a const method. llvm-svn: 324721
* PR36055: fix computation of *-dependence in nested initializer lists.Richard Smith2018-02-071-12/+37
| | | | | | | | | | | | | | | | When we synthesize an implicit inner initializer list when analyzing an outer initializer list, we add it to the outer list immediately, and then fill in the inner list. This gives the outer list no chance to update its *-dependence bits with those of the completed inner list. To fix this, re-add the inner list to the outer list once it's completed. Note that we do not recompute the *-dependence bits from scratch when we complete an outer list; this would give the wrong result for the case where a designated initializer overwrites a dependent initializer with a non-dependent one. The resulting list in that case should still be dependent, even though all traces of the dependence were removed from the semantic form. llvm-svn: 324537
* [PR36008] Avoid -Wsign-compare warning for enum constants inAlex Lorenz2018-02-071-0/+10
| | | | | | | | | | | | | typeof expressions This commit looks through typeof type at the original expression when diagnosing -Wsign-compare to avoid an unfriendly diagnostic. rdar://36588828 Differential Revision: https://reviews.llvm.org/D42561 llvm-svn: 324514
* [Sema][ObjC] Use SmallSetVector to fix a failing test on the reverseAkira Hatanaka2018-02-062-6/+4
| | | | | | | | | | | | | iteration bot. This commit reverts r315639, which was causing clang to print diagnostics that weren't printed before. Instead, it declares OverrideSearch::Overridden as a SmallSetVector to fix the non-deterministic behavior r315639 was trying to fix. rdar://problem/36445528 llvm-svn: 324425
* Fix crash on invalid.Richard Trieu2018-02-061-1/+2
| | | | | | Don't call a method when the pointer is null. llvm-svn: 324308
* Add support for attribute 'trivial_abi'.Akira Hatanaka2018-02-055-43/+146
| | | | | | | | | | | | | | | | | | | | | | | | | The 'trivial_abi' attribute can be applied to a C++ class, struct, or union. It makes special functions of the annotated class (the destructor and copy/move constructors) to be trivial for the purpose of calls and, as a result, enables the annotated class or containing classes to be passed or returned using the C ABI for the underlying type. When a type that is considered trivial for the purpose of calls despite having a non-trivial destructor (which happens only when the class type or one of its subobjects is a 'trivial_abi' class) is passed to a function, the callee is responsible for destroying the object. For more background, see the discussions that took place on the mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-November/055955.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180101/thread.html#214043 rdar://problem/35204524 Differential Revision: https://reviews.llvm.org/D41039 llvm-svn: 324269
* Fix crash when trying to pack-expand a GNU statement expression.Richard Smith2018-02-033-6/+16
| | | | | | | | We could in principle support such pack expansion, using techniques similar to what we do for pack expansion of lambdas, but it's not clear it's worthwhile. For now at least, cleanly reject these cases rather than crashing. llvm-svn: 324160
* Add missing direct-init / parameter-declaration-clause disambiguation whenRichard Smith2018-02-021-0/+4
| | | | | | parsing a trailing-return-type of a (function pointer) variable declaration. llvm-svn: 324151
* [Sema] Add implicit members even for invalid CXXRecordDeclsIlya Biryukov2018-02-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It should be safe, since other code paths are already generating implicit members even in invalid CXXRecordDecls (e.g. lookup). If we don't generate implicit members on CXXRecordDecl's completion, they will be generated by next lookup of constructors. This causes a crash when the following conditions are met: - a CXXRecordDecl is invalid, - it is provided via ExternalASTSource (e.g. from PCH), - it has inherited constructors (they create ShadowDecls), - lookup of its constructors was not run before ASTWriter serialized it. This may require the ShadowDecls created for inherited constructors to be removed from the class, but that's no longer possible since class is provided by ExternalASTSource. See provided lit test for an example. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42810 llvm-svn: 324062
* [coroutines] Fix application of NRVO to Coroutine "Gro" or return object.Eric Fiselier2018-02-011-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix NRVO for Gro variable. Previously, we only marked the GRO declaration as an NRVO variable when its QualType and the function return's QualType matched exactly (using operator==). However, this was incorrect for two reasons: 1. We were marking non-class types, such as ints, as being NRVO variables. 2. We failed to handle cases where the canonical types were the same, but the actual `QualType` objects were different. For example, if one was represented by a typedef. (Example: https://godbolt.org/g/3UFgsL) This patch fixes these bugs by marking the Gro variable as supporting NRVO only when `BuildReturnStmt` marks the Gro variable as a coroutine candidate. Reviewers: rsmith, GorNishanov, nicholas Reviewed By: GorNishanov Subscribers: majnemer, cfe-commits Differential Revision: https://reviews.llvm.org/D42343 llvm-svn: 324037
* PR36157: When injecting an implicit function declaration in C89, find the rightRichard Smith2018-02-011-0/+10
| | | | | | | | DeclContext rather than injecting it wherever we happen to be. This avoids creating functions whose DeclContext is a struct or similar. llvm-svn: 323998
* Revert "[coroutines] Fix application of NRVO to Coroutine "Gro" or return ↵Eric Fiselier2018-01-301-2/+4
| | | | | | | | | object." This reverts commit r323712. It's causing some test failures on certain machines. Not sure why, will investigate. llvm-svn: 323717
* [coroutines] Fix application of NRVO to Coroutine "Gro" or return object.Eric Fiselier2018-01-291-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix NRVO for Gro variable. Previously, we only marked the GRO declaration as an NRVO variable when its QualType and the function return's QualType matched exactly (using operator==). However, this was incorrect for two reasons: 1. We were marking non-class types, such as ints, as being NRVO variables. 2. We failed to handle cases where the canonical types were the same, but the actual `QualType` objects were different. For example, if one was represented by a typedef. (Example: https://godbolt.org/g/3UFgsL) This patch fixes these bugs by marking the Gro variable as supporting NRVO only when `BuildReturnStmt` marks the Gro variable as a coroutine candidate. Reviewers: rsmith, GorNishanov, nicholas Reviewed By: GorNishanov Subscribers: majnemer, cfe-commits Differential Revision: https://reviews.llvm.org/D42343 llvm-svn: 323712
* [NFC] Fixup comment with function name, actually incorrect name!Erich Keane2018-01-291-3/+2
| | | | llvm-svn: 323679
* [coroutines] Pass coro func args to promise ctorBrian Gesiak2018-01-244-36/+96
| | | | | | | | | | | | | | | | | | | Summary: Use corutine function arguments to initialize a promise type, but only if the promise type defines a constructor that takes those arguments. Otherwise, fall back to the default constructor. Test Plan: check-clang Reviewers: rsmith, GorNishanov, eric_niebler Reviewed By: GorNishanov Subscribers: toby-allsopp, lewissbaker, EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D41820 llvm-svn: 323381
* [CodeComplete] only respect LoadExternal hint at namespace/tu scopeSam McCall2018-01-241-2/+5
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42428 llvm-svn: 323347
* [OPENMP] Remove more empty SourceLocations() from the code.Alexey Bataev2018-01-231-4/+4
| | | | | | | Removed more empty SourceLocations() from the OpenMP code and replaced with the correct locations for better debug info emission. llvm-svn: 323232
* [CodeComplete] Omit templated constructors from member list too.Sam McCall2018-01-221-3/+9
| | | | | | Also avoid printing a 'void' return type for constructor expressions. llvm-svn: 323148
* [modules] Correctly overload getModule in the MultiplexExternalSemaSourceRaphael Isemann2018-01-221-0/+7
| | | | | | | | | | | | | | | | Summary: The MultiplexExternalSemaSource doesn't correctly overload the `getModule` function, causing the multiplexer to not forward this call as intended. Reviewers: v.g.vassilev Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39416 llvm-svn: 323122
* [AArch64] Add ARMv8.2-A FP16 scalar intrinsicsAbderrazek Zaafrani2018-01-191-0/+2
| | | | | | https://reviews.llvm.org/D41792 llvm-svn: 323006
* [Refactor] Use enum instead of magic number in ↵Hongbin Zheng2018-01-191-1/+1
| | | | | | | | handleX86ForceAlignArgPointerAttr, NFC Differential revision: https://reviews.llvm.org/D42227 llvm-svn: 322918
* Fix Scope::dump()Richard Trieu2018-01-181-64/+35
| | | | | | | | | The dump function for Scope only has 20 out of the 24 flags. Since it looped until no flags were left, having an unknown flag lead to an infinite loop. That loop has been changed to a single pass for each flag, plus an assert to alert if new flags are added. llvm-svn: 322813
* [Sema] Allow conversion between long double and __float128.Benjamin Kramer2018-01-172-8/+7
| | | | | | | We should only ban this if long double is a double double. x86's 80 bit long double is fine and supported by the backend. llvm-svn: 322779
* [Parse] Forward brace locations to TypeConstructExprVedant Kumar2018-01-175-72/+90
| | | | | | | | | | | | | | | | | | | | | | | | When parsing C++ type construction expressions with list initialization, forward the locations of the braces to Sema. Without these locations, the code coverage pass crashes on the given test case, because the pass relies on getLocEnd() returning a valid location. Here is what this patch does in more detail: - Forwards init-list brace locations to Sema (ParseExprCXX), - Builds an InitializationKind with these locations (SemaExprCXX), and - Uses these locations for constructor initialization (SemaInit). The remaining changes fall out of introducing a new overload for creating direct-list InitializationKinds. Testing: check-clang, and a stage2 coverage-enabled build of clang with asserts enabled. Differential Revision: https://reviews.llvm.org/D41921 llvm-svn: 322729
* [Sema] Add visited contexts to CodeCompleteContextHaojian Wu2018-01-172-1/+12
| | | | | | | | | | | | | | | | | | | Summary: This would allow code completion clients to know which context is visited during Sema code completion. Also some changes: * add `EnteredContext` callback in VisibleDeclConsumer. * add a simple unittest for sema code completion (only for visited contexts at the moment). Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgorny, bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D42071 llvm-svn: 322661
* [OPENMP] Add support for `depend` clauses on `target teams distributeAlexey Bataev2018-01-161-1/+1
| | | | | | | | | parallel for simd` directives. Added codegen for `depend` clauses on `#pragma omp target teams distribute parallel for simd` directives. llvm-svn: 322587
* [OPENMP] Add support for `depend` on `target teams distribute parallelAlexey Bataev2018-01-161-1/+6
| | | | | | | | | for` directives. Added codegen for `depend` clauses on `#pragma omp target teams distribute parallel for` directives. llvm-svn: 322585
* [OPENMP] Add support for `depend` clauses on `target parallel for simd`Alexey Bataev2018-01-161-1/+1
| | | | | | | | | directives. Added codegen for `depend` clauses on `#pragma omp target parallel for simd` directives. llvm-svn: 322578
* [OPENMP] Add support for `depend` clauses on `target parallel for`Alexey Bataev2018-01-161-1/+1
| | | | | | | | | directives. Added codegen for `depend` clause on `#pragma omp target parallel for` directives. llvm-svn: 322577
* [OPENMP] Add support for `depend` clauses on `target teams distributeAlexey Bataev2018-01-161-1/+1
| | | | | | | | | simd` directives. Added codegen for `depend` clauses on `#pragma omp target teams distribute simd` directives. llvm-svn: 322575
* [OPENMP] Add support for `depend` clause on `target teams distribute`.Alexey Bataev2018-01-161-1/+1
| | | | | | | Added codegen for `depend` clauses on `#pragma omp target teams distribute` directives. llvm-svn: 322571
* [OPENMP] Add support for `depend` clauses on `target parallel` directive.Alexey Bataev2018-01-161-1/+1
| | | | | | | Added codegen for `depend` clauses on `#pragma omp target parallel` directives. llvm-svn: 322570
* [OPENMP] Add support for `depend` clauses on `target teams`.Alexey Bataev2018-01-161-1/+6
| | | | | | | Added codegen for `depend` clause on `#pragma omp target teams` directives. llvm-svn: 322569
* [OPENMP] Add support for `depend` clauses on `target simd`.Alexey Bataev2018-01-161-1/+1
| | | | | | | Added codegen for `depend` clauses on `#pragma omp target simd` directives. llvm-svn: 322559
* Ensure code complete with !LoadExternal sees all local decls.Sam McCall2018-01-161-1/+2
| | | | | | | | | | | | | | | | | | | | | Summary: noload_lookups() was too lazy: in addition to avoiding external decls, it avoided populating the lazy lookup structure for internal decls. This is the right behavior for the existing callsite in ASTDumper, but I think it's not a very useful default, so we populate it by default. While here: - remove an unused test file accidentally added in r322371. - remove lookups_begin()/lookups_end() in favor of lookups().begin(), which is more common and more efficient. Reviewers: ilya-biryukov Subscribers: cfe-commits, rsmith Differential Revision: https://reviews.llvm.org/D42077 llvm-svn: 322548
* [Sema] Fix a crash on invalid features in multiversioningGeorge Burgess IV2018-01-161-3/+3
| | | | | | | | | We were trying to emit a diag::err_bad_multiversion_option diagnostic, which expects an int as its first argument, with a string argument. As it happens, the string `Feature` that was causing this was shadowing an int `Feature` from the surrounding scope. :) llvm-svn: 322530
* [OPENMP] Initial codegen for `target teams distribute parallel forAlexey Bataev2018-01-151-10/+31
| | | | | | | | | simd`. Added host codegen + codegen for devices with default codegen for `#pragma omp target teams distribute parallel for simd` directive. llvm-svn: 322515
* [OPENMP] Add codegen for `depend` clauses on `target` directive.Alexey Bataev2018-01-151-8/+83
| | | | | | | Added basic support for codegen of `depend` clauses on `target` directive. llvm-svn: 322501
* [Sema] Fix crash for type-dependent base classesJan Korous2018-01-131-0/+7
| | | | llvm-svn: 322438
* DR126: partially implement the const-correct rules for exception handler ↵Richard Smith2018-01-132-104/+109
| | | | | | | | | matching. While here, fix up the myriad other ways in which Sema's two "can this handler catch that exception?" implementations get things wrong and unify them. llvm-svn: 322431
* When rebuilding an InitListExpr, don't give it a type.Richard Smith2018-01-121-16/+5
| | | | | | | | InitListExprs without types (well, with type 'void') represent not-yet-analyzed initializer lists; InitListExpr with types fool Sema into thinking they don't need further analysis in some cases (particularly C++17 copy omission). llvm-svn: 322414
* [OPENMP] Replace calls of getAssociatedStmt().Alexey Bataev2018-01-121-5/+1
| | | | | | | | | | | | | getAssociatedStmt() returns the outermost captured statement for the OpenMP directive. It may return incorrect region in case of combined constructs. Reworked the code to reduce the number of calls of getAssociatedStmt() and used getInnermostCapturedStmt() and getCapturedStmt() functions instead. In case of firstprivate variables it may lead to an extra allocas generation for private copies even if the variable is passed by value into outlined function and could be used directly as private copy. llvm-svn: 322393
* [CodeComplete] Add an option to omit results from the preamble.Sam McCall2018-01-122-50/+79
| | | | | | | | | | | | | | | | | | | | | | | Summary: Enumerating the contents of a namespace or global scope will omit any decls that aren't already loaded, instead of deserializing them from the PCH. This allows a fast hybrid code completion where symbols from headers are provided by an external index. (Sema already exposes the information needed to do a reasonabl job of filtering them). Clangd plans to implement this hybrid. This option is just a hint - callers still need to postfilter results if they want to *avoid* completing decls outside the main file. Reviewers: bkramer, ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41989 llvm-svn: 322371
* Add `__reference_binds_to_temporary` trait for checking safe reference ↵Eric Fiselier2018-01-121-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialization. Summary: The STL types `std::pair` and `std::tuple` can both store reference types. However their constructors cannot adequately check if the initialization of reference types is safe. For example: ``` std::tuple<std::tuple<int> const&> t = 42; // The stored reference is already dangling. ``` Libc++ has a best effort attempts in tuple to diagnose this, but they're not able to handle all valid cases (If I'm not mistaken). For example initialization of a reference from the result of a class's conversion operator. Libc++ would benefit from having a builtin traits which can provide a much better implementation. This patch introduce the `__reference_binds_to_temporary(T, U)` trait that determines whether a reference of type `T` bound to an expression of type `U` would bind to a materialized temporary object. Note that the trait simply returns false if `T` is not a reference type instead of reporting it as an error. ``` static_assert(__is_constructible(int const&, long)); static_assert(__reference_binds_to_temporary(int const&, long)); ``` Reviewers: majnemer, rsmith Reviewed By: rsmith Subscribers: compnerd, cfe-commits Differential Revision: https://reviews.llvm.org/D29930 llvm-svn: 322334
* [X86][Sema] Range check the constant argument for the vpshld/vpshrd builtins ↵Craig Topper2018-01-111-0/+18
| | | | | | to ensure it fits in 8-bits. llvm-svn: 322247
* [X86][Sema] Remove constant range checks on on builtins that take a char.Craig Topper2018-01-111-37/+0
| | | | | | The constant is already reduced to 8-bits by the time we get here and the checks were just ensuring that it was 8 bits. Thus I don't think there's anyway for them to fail. llvm-svn: 322244
* In C++17, when instantiating an out-of-line definition of an inline static dataRichard Smith2018-01-101-1/+2
| | | | | | member, don't forget to instantiate the initializer too. llvm-svn: 322236
* Track in the AST whether the operand to a UnaryOperator can overflow and ↵Aaron Ballman2018-01-095-39/+61
| | | | | | then use that logic when evaluating constant expressions and emitting codegen. llvm-svn: 322074
* PR35862: Suppress -Wmissing-variable-declarations warning on inline variables,Richard Smith2018-01-081-0/+2
| | | | | | variable templates, and instantiations thereof. llvm-svn: 322030
OpenPOWER on IntegriCloud