summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* NFC; clean up this file based on our coding standards. The impetus was ↵Aaron Ballman2018-02-151-1500/+1467
| | | | | | | | | | considerable use of a type name as an identifier for an object. Changed identifier names (especially function parameters) to not clash with type names and to follow the proper naming conventions. Use of explicit type names changed to use auto where appropriate. Removed unused parameters that should have never been added in the first place. Minor formatting cleanups. The changes were mostly mechanical and should have no functional impact. llvm-svn: 325256
* [Debug] Annotate compiler generated range-for loop variables.Matt Davis2018-02-141-4/+8
| | | | | | | | | | | | | | | | | | Summary: This change aims to simplify debugging by annotating the range-for loop artificial variables (range, begin, end) with the scope depth. Reviewers: rsmith, dblaikie Reviewed By: dblaikie Subscribers: dblaikie, cfe-commits Tags: #debug-info Differential Revision: https://reviews.llvm.org/D42813 llvm-svn: 325175
* [CUDA] Allow external variables in separate compilationJonas Hahnfeld2018-02-141-1/+2
| | | | | | | | | | | | According to the CUDA Programming Guide this is prohibited in whole program compilation mode. This makes sense because external references cannot be satisfied in that mode anyway. However, such variables are allowed in separate compilation mode which is a valid use case. Differential Revision: https://reviews.llvm.org/D42923 llvm-svn: 325136
* Revert r324991 "Fix for PR32992. Static const classes not exported."Hans Wennborg2018-02-141-13/+3
| | | | | | | | | | | | This broke the Chromium build on Windows; see https://crbug.com/812231 > Fix for PR32992. Static const classes not exported. > > Patch by zahiraam! > > Differential Revision: https://reviews.llvm.org/D42968 llvm-svn: 325133
* [Sema] Fix decltype of static data membersMikhail Maltsev2018-02-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: According to the C++11 standard [dcl.type.simple]p4: The type denoted by decltype(e) is defined as follows: - if e is an unparenthesized id-expression or an unparenthesized class member access (5.2.5), decltype(e) is the type of the entity named by e. Currently Clang handles the 'member access' case incorrectly for static data members (decltype returns T& instead of T). This patch fixes the issue. Reviewers: faisalv, rsmith, rogfer01 Reviewed By: rogfer01 Subscribers: rogfer01, cfe-commits Differential Revision: https://reviews.llvm.org/D42969 llvm-svn: 325117
* Fix a couple of places where we assumed that non-type template parameters ↵Richard Smith2018-02-142-7/+9
| | | | | | are always rvalues. llvm-svn: 325095
* Implement function attribute artificialErich Keane2018-02-141-0/+3
| | | | | | | | | | | | Added support in clang for GCC function attribute 'artificial'. This attribute is used to control stepping behavior of debugger with respect to inline functions. Patch By: Elizabeth Andrews (eandrews) Differential Revision: https://reviews.llvm.org/D43259 llvm-svn: 325081
* Fix for PR32992. Static const classes not exported.Hans Wennborg2018-02-131-3/+13
| | | | | | | | Patch by zahiraam! Differential Revision: https://reviews.llvm.org/D42968 llvm-svn: 324991
* [Sema] Don't mark plain MS enums as fixedReid Kleckner2018-02-122-26/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a flaw in our AST: PR27098 MSVC always gives plain enums the underlying type 'int'. Clang does this as well, but we claim the enum is "fixed", as if the user actually wrote ': int'. It means we end up emitting spurious -Wsign-compare warnings on code like this: enum Vals { E1, E2, E3 }; bool f(unsigned v1, Vals v2) { return v1 == v2; } We think 'v2' can take on negative values because we think 'Vals' is fixed. This fixes that. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43110 llvm-svn: 324913
* [Templight] Template Instantiation ObserverGabor Horvath2018-02-104-2/+30
| | | | | | | | | | | | | | | | | | | | | This patch adds a base-class called TemplateInstantiationObserver which gets notified whenever a template instantiation is entered or exited during semantic analysis. This is a base class used to implement the template profiling and debugging tool called Templight (https://github.com/mikael-s-persson/templight). The patch also makes a few more changes: * ActiveTemplateInstantiation class is moved out of the Sema class (so it can be used with inclusion of Sema.h). * CreateFrontendAction function in front-end utilities is given external linkage (not longer a hidden static function). * TemplateInstObserverChain data member added to Sema class to hold the list of template-inst observers. * Notifications to the template-inst observer are added at the key places where templates are instantiated. Patch by: Abel Sinkovics! Differential Revision: https://reviews.llvm.org/D5767 llvm-svn: 324808
* [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
OpenPOWER on IntegriCloud