summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* reland "[DebugInfo] Support to emit debugInfo for extern variables"Yonghong Song2019-12-222-0/+11
| | | | | | | | | | | | | Commit d77ae1552fc21a9f3877f3ed7e13d631f517c825 ("[DebugInfo] Support to emit debugInfo for extern variables") added deebugInfo for extern variables for BPF target. The commit is reverted by 891e25b02d760d0de18c7d46947913b3166047e7 as the committed tests using %clang instead of %clang_cc1 causing test failed in certain scenarios as reported by Reid Kleckner. This patch fixed the tests by using %clang_cc1. Differential Revision: https://reviews.llvm.org/D71818
* Revert "[DebugInfo] Support to emit debugInfo for extern variables"Reid Kleckner2019-12-222-11/+0
| | | | | | | This reverts commit d77ae1552fc21a9f3877f3ed7e13d631f517c825. The tests committed along with this change do not pass, and should be changed to use %clang_cc1.
* Revert "[Concepts] Constrained partial specializations and function overloads."Reid Kleckner2019-12-225-619/+49
| | | | | | This reverts commit d3f5769d5e93b30d4a8b4696381d5e4a304992fa. Causes crashes on Chromium. Have reproducer, will reduce and send along.
* [Sema] SequenceChecker: C++17 sequencing rules for built-in operators <<, ↵Bruno Ricci2019-12-221-25/+83
| | | | | | | | | | | >>, .*, ->*, =, op= Implement the C++17 sequencing rules for the built-in operators <<, >>, .*, ->*, = and op=. Differential Revision: https://reviews.llvm.org/D58297 Reviewed By: rsmith
* [Sema] SequenceChecker: Fix handling of operator ||, && and ?:Bruno Ricci2019-12-221-31/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | The current handling of the operators ||, && and ?: has a number of false positive and false negative. The issues for operator || and && are: 1. We need to add sequencing regions for the LHS and RHS as is done for the comma operator. Not doing so causes false positives in expressions like `((a++, false) || (a++, false))` (from PR39779, see PR22197 for another example). 2. In the current implementation when the evaluation of the LHS fails, the RHS is added to a worklist to be processed later. This results in false negatives in expressions like `(a && a++) + a`. Fix these issues by introducing sequencing regions for the LHS and RHS, and by not deferring the visitation of the RHS. The issues with the ternary operator ?: are similar, with the added twist that we should not warn on expressions like `(x ? y += 1 : y += 2)` since exactly one of the 2nd and 3rd expression is going to be evaluated, but we should still warn on expressions like `(x ? y += 1 : y += 2) = y`. Differential Revision: https://reviews.llvm.org/D57747 Reviewed By: rsmith
* [Sema] SequenceChecker: Add some comments + related small NFCsBruno Ricci2019-12-221-73/+122
| | | | | | | | | | | | NFCs factored out of the following patches: - Change all of the `Expr *` to `const Expr *` in SequenceChecker for const-correctness. SequenceChecker should not modify AST nodes. - Add some comments. - clang-format Differential Revision: https://reviews.llvm.org/D57659 Reviewed By: xbolva00
* [Concepts] Constrained partial specializations and function overloads.Saar Raz2019-12-225-49/+619
| | | | | | | Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads. Re-commit after fixing some crashes and warnings. Differential Revision: https://reviews.llvm.org/D41910
* Fix `-Wunused-variable` warning. NFC.Michael Liao2019-12-211-1/+1
|
* [attributes][analyzer] Add annotations for handles.Gabor Horvath2019-12-202-0/+49
| | | | | | | These annotations will be used in an upcomming static analyzer check that finds handle leaks, use after releases, and double releases. Differential Revision: https://reviews.llvm.org/D70469
* Apply the alignment specifier attribute to anonymous unions and structs.Kamlesh Kumar2019-12-201-0/+3
|
* [objc_direct] Tigthen checks for direct methodsPierre Habouzit2019-12-201-13/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because the name of a direct method must be agreed upon by the caller and the implementation, certain bad practices that one can get away with when using dynamism are fatal with direct methods. To avoid really weird and unscruttable linker error, tighten the front-end error reporting. Rule 1: Direct methods can only have at most one declaration in an @interface container. Any redeclaration is strictly forbidden. Today some amount of redeclaration is tolerated between the main interface and categories for dynamic methods, but we can't have that. Rule 2: Direct method implementations can only be declared in a matching @interface container: when implemented in the primary @implementation then the declaration must be in the primary @interface or an extension, and when implemented in a category, the declaration must be in the @interface for the same category. Also fix another issue with ObjCMethod::getCanonicalDecl(): when an implementation lives in the primary @interface, then its canonical declaration can be in any extension, even when it's not an accessor. Add Sema tests to cover the new errors, and CG tests to beef up testing around function names for categories and extensions. Radar-Id: <rdar://problem/58054563> Differential Revision: https://reviews.llvm.org/D71694
* CWG2352: Allow qualification conversions during reference binding.Richard Smith2019-12-193-136/+164
| | | | | | | | | | | | | | | The language wording change forgot to update overload resolution to rank implicit conversion sequences based on qualification conversions in reference bindings. The anticipated resolution for that oversight is implemented here -- we order candidates based on qualification conversion, not only on top-level cv-qualifiers. For OpenCL/C++, this allows reference binding between pointers with differing (nested) address spaces. This makes the behavior of reference binding consistent with that of implicit pointer conversions, as is the purpose of this change, but that pre-existing behavior for pointer conversions is itself probably not correct. In any case, it's now consistently the same behavior and implemented in only one place.
* Fix crash on init-capture packs where the type of the initializer is ↵Richard Smith2019-12-191-1/+2
| | | | non-dependent.
* Revert concepts changes from D41910Vedant Kumar2019-12-185-619/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | These changes caused LibcxxVariantDataFormatterTestCase in lldb to fail with an assert: Assertion failed: (Idx < size() && "Out-of-bounds Bit access."), function operator[], file /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/ADT/SmallBitVector.h, line 452. In: 7 clang-10 0x00000001094b79d9 isAtLeastAsSpecializedAs(clang::Sema&, clang::SourceLocation, clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, clang::TemplatePartialOrderingContext, unsigned int) + 1865 8 clang-10 0x00000001094b7111 clang::Sema::getMoreSpecializedTemplate(clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, clang::SourceLocation, clang::TemplatePartialOrderingContext, unsigned int, unsigned int) + 97 9 clang-10 0x000000010939bf88 clang::isBetterOverloadCandidate(clang::Sema&, clang::OverloadCandidate const&, clang::OverloadCandidate const&, clang::SourceLocation, clang::OverloadCandidateSet::CandidateSetKind) + 1128 Revert "[Concepts] Fix incorrect move out of temporary in D41910" This reverts commit 11d5fa6e87e3584f72056ecc2b17f88c58323dde. Revert "[Concepts] Fix crash in D41910" This reverts commit 12038be20ee6a903cdbd3fddce65535ef683e31d. Revert "[Concepts] Constrained partial specializations and function overloads." This reverts commit fc0731b98a67c793862288f8ae334322666214dc.
* Refactor CompareReferenceRelationship and its callers in preparation forRichard Smith2019-12-184-139/+107
| | | | | | | | | | | | | | implementing the resolution of CWG2352. No functionality change, except that we now convert the referent of a reference binding to the underlying type of the reference in more cases; we used to happen to preserve the type sugar from the referent if the only type change was in the cv-qualifiers. This exposed a bug in how we generate code for trivial assignment operators: if the type sugar (particularly the may_alias attribute) got lost during reference binding, we'd use the "wrong" TBAA information for the load during the assignment.
* [Concepts] Fix incorrect move out of temporary in D41910Saar Raz2019-12-181-2/+2
| | | | Moves out of temporaries caused warnings that failed builds.
* [Concepts] Fix crash in D41910Saar Raz2019-12-181-1/+1
| | | | Differential Revision: https://reviews.llvm.org/D41910
* [Concepts] Constrained partial specializations and function overloads.Saar Raz2019-12-185-49/+619
| | | | | | Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads. Phabricator: D41910
* Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.Amy Huang2019-12-183-26/+55
| | | | | | | | | | | | | | | | | | | | Summary: This adds parsing of the qualifiers __ptr32, __ptr64, __sptr, and __uptr and lowers them to the corresponding address space pointer for 32-bit and 64-bit pointers. (32/64-bit pointers added in https://reviews.llvm.org/D69639) A large part of this patch is making these pointers ignore the address space when doing things like overloading and casting. https://bugs.llvm.org/show_bug.cgi?id=42359 Reviewers: rnk, rsmith Subscribers: jholewinski, jvesely, nhaehnle, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71039
* [OpenCL] Add builtin function extension handlingSven van Haastregt2019-12-182-13/+44
| | | | | | | | | | Provide a mechanism to attach OpenCL extension information to builtin functions, so that their use can be restricted according to the extension(s) the builtin is part of. Patch by Pierre Gondois and Sven van Haastregt. Differential Revision: https://reviews.llvm.org/D71476
* [Sema] Fixes -Wrange-loop-analysis warningsMark de Wever2019-12-172-2/+2
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71529
* [OPENMP50]Add parsing/sema analysis for nontemporal clause.Alexey Bataev2019-12-172-7/+112
| | | | | Add basic support for parsing/sema analysis of the nontemporal clause in simd-based directives.
* Reland [NFC-I] Remove hack for fp-classification builtinsErich Keane2019-12-171-34/+24
| | | | | | | | | | | | | | | | | | The FP-classification builtins (__builtin_isfinite, etc) use variadic packs in the definition file to mean an overload set. Because of that, floats were converted to doubles, which is incorrect. There WAS a patch to remove the cast after the fact. THis patch switches these builtins to just be custom type checking, calls the implicit conversions for the integer members, and makes sure the correct L->R casts are put into place, then does type checking like normal. A future direction (that wouldn't be NFC) would consider making conversions for the floating point parameter legal. Note: The initial patch for this missed that certain systems need to still convert half to float, since they dont' support that type.
* Check whether the destination is a complete type in a static_cast (orRichard Smith2019-12-161-3/+8
| | | | | | | | | C-style cast) to an enumeration type. We previously forgot to check this, and happened to get away with it (with bad diagnostics) only because we misclassified incomplete enumeration types as not being unscoped enumeration types. This also fixes the misclassification.
* [c++20] P1959R0: Remove support for std::*_equality.Richard Smith2019-12-162-41/+41
|
* [c++20] Add deprecation warnings for the expression forms deprecated by P1120R0.Richard Smith2019-12-163-77/+104
| | | | | | | | | | | | | | | | | | | This covers: * usual arithmetic conversions (comparisons, arithmetic, conditionals) between different enumeration types * usual arithmetic conversions between enums and floating-point types * comparisons between two operands of array type The deprecation warnings are on-by-default (in C++20 compilations); it seems likely that these forms will become ill-formed in C++23, so warning on them now by default seems wise. For the first two bullets, off-by-default warnings were also added for all the cases where we didn't already have warnings (covering language modes prior to C++20). These warnings are in subgroups of the existing -Wenum-conversion (except that the first case is not warned on if either enumeration type is anonymous, consistent with our existing -Wenum-conversion warnings).
* [WebAssembly] Setting export_name implies llvm.usedSam Clegg2019-12-161-2/+2
| | | | | | | This change updates the clang front end to add symbols to llvm.used when they have explicit export_name attribute. Differential Revision: https://reviews.llvm.org/D71493
* [coroutines][PR41909] Generalize fix from D62550Brian Gesiak2019-12-161-14/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In https://reviews.llvm.org/D62550 @rsmith pointed out that there are many situations in which a coroutine body statement may be transformed/rebuilt as part of a template instantiation, and my naive check whether the coroutine was a generic lambda was insufficient. This is indeed true, as I've learned by reading more of the TreeTransform code. Most transformations are written in a way that doesn't assume the resulting types are not dependent types. So the assertion in 'TransformCoroutineBodyStmt', that the promise type must no longer be dependent, is out of place. This patch removes the assertion, spruces up some code comments, and adds a test that would have failed with my naive check from https://reviews.llvm.org/D62550. Reviewers: GorNishanov, rsmith, lewissbaker Reviewed By: rsmith Subscribers: junparser, EricWF, rsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70579
* Revert "[NFC-I] Remove hack for fp-classification builtins"Erich Keane2019-12-161-18/+34
| | | | | | | | | | | This reverts commit b1e542f302c1ed796ad9f703d4d36e010afcb914. The original 'hack' didn't chop out fp-16 to double conversions, so systems that use FP16ConversionIntrinsics end up in IR-CodeGen with an i16 type isntead of a float type (like PPC64-BE). The bots noticed this. Reverting until I figure out how to fix this
* [NFC-I] Remove hack for fp-classification builtinsErich Keane2019-12-161-34/+18
| | | | | | | | | | | | | | | The FP-classification builtins (__builtin_isfinite, etc) use variadic packs in the definition file to mean an overload set. Because of that, floats were converted to doubles, which is incorrect. There WAS a patch to remove the cast after the fact. THis patch switches these builtins to just be custom type checking, calls the implicit conversions for the integer members, and makes sure the correct L->R casts are put into place, then does type checking like normal. A future direction (that wouldn't be NFC) would consider making conversions for the floating point parameter legal.
* [OPENMP50]Add if clause in target teams idistribute simd directive.Alexey Bataev2019-12-161-1/+3
| | | | | | According to OpenMP 5.0, if clause can be used in for simd directive. If condition in the if clause if false, the non-vectorized version of the loop must be executed.
* [OPENMP50]Add if clause in target teams distribute parallel for simd directive.Alexey Bataev2019-12-161-1/+9
| | | | | | According to OpenMP 5.0, if clause can be used in for simd directive. If condition in the if clause if false, the non-vectorized version of the loop must be executed.
* [c++20] Compute exception specifications for defaulted comparisons.Richard Smith2019-12-152-56/+119
| | | | | | | | This requires us to essentially fully form the body of the defaulted comparison, but from an unevaluated context. Naively this would require generating the function definition twice; instead, we ensure that the function body is implicitly defined before performing the check, and walk the actual body where possible.
* Properly compute whether statement expressions can throw, rather thanRichard Smith2019-12-151-60/+269
| | | | | | | | | conservatively assuming they always can. Also fix cases where we would not consider the computation of a VLA type when determining whether an expression can throw. We don't yet properly determine whether a VLA can throw, but no longer incorrectly claim it can never throw.
* Resolve exception specifications after marking the correspondingRichard Smith2019-12-153-30/+50
| | | | | | | | function as referenced, not before. No functionality change intended. This is groundwork for computing the exception specification of a defaulted comparison, for which we'd like to use the implicit body where possible.
* [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSourceRaphael Isemann2019-12-152-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We currently have some very basic LLVM-style RTTI support in the ExternalASTSource class hierarchy based on the `SemaSource` bool( to discriminate it form the ExternalSemaSource). As ExternalASTSource is supposed to be subclassed we should have extendable LLVM-style RTTI in this class hierarchy to make life easier for projects building on top of Clang. Most notably the current RTTI implementation forces LLDB to implement RTTI for its own ExternalASTSource class (ClangExternalASTSourceCommon) by keeping a global set of ExternalASTSources that are known to be ClangExternalASTSourceCommon. Projects using Clang currently have to dosimilar workarounds to get RTTI support for their subclasses. This patch turns this into full-fledged LLVM-style RTTI based on a static `ID` variable similar to other LLVM class hierarchies. Also removes the friend declaration from ExternalASTSource to its child class that was only used to grant access to the `SemaSource` member. Reviewers: aprantl, dblaikie, rjmccall Reviewed By: aprantl Subscribers: riccibruno, labath, lhames, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71397
* [c++20] Improve phrasing of diagnostic for missing #include <compare>.Richard Smith2019-12-132-6/+11
|
* Call objc_retainBlock before passing a block as a variadic argumentAkira Hatanaka2019-12-131-0/+3
| | | | | | | | | Copy the block to the heap before passing it to the callee in case the block escapes in the callee. rdar://problem/55683462 Differential Revision: https://reviews.llvm.org/D71431
* Correct gcc vector splat conversion from float to int-vectorErich Keane2019-12-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | In looking into some other code, I came across this issue where a float converted to a gcc integer vector via a splat causes it to miss the float-to-integral cast, which causes some REALLY strange codegen bugs. The AST looked like: `-ImplicitCastExpr <col:13> 'gcc_int_2':'__attribute__((__vector_size__(2 * sizeof(int)))) int' <VectorSplat> `-ImplicitCastExpr <col:13> 'float' <LValueToRValue> `-DeclRefExpr <col:13> 'float' lvalue ParmVar 0x556f16a5dc90 'f' 'float' Despite the type of the VectorSplat cast as printed, it ended up becoming a vector of float, which caused non-matching instructions. For example, IntVector + a float constant resulted in: add <2 x i32> %8, <2 x float> <float 3.000000e+00, float 3.000000e+00> This patch corrects the conversion so that the float is first converted to an integral, THEN splatted.
* [Sema] Improve diagnostic about addr spaces for overload candidatesAnastasia Stulova2019-12-131-4/+11
| | | | | | | | | | Allow sending address spaces into diagnostics to simplify and improve error reporting. Improved wording of diagnostics for address spaces in overloading. Tags: #clang Differential Revision: https://reviews.llvm.org/D71111
* [OPENMP50]Improve checks for declare variant functions compatibility.Alexey Bataev2019-12-122-7/+52
| | | | | Added check for functions compatibility in C and removed restriction for functions with no prototypes in declare variant constrcut.
* Suppress -Wwarn-unused-variables when we don't know the constructorErich Keane2019-12-121-0/+7
| | | | | | | | | | | | | | This warning is supposed to be suppressed when the constructor/destructor are non-trivial, since it might be a RAII type. However, if the type has a trivial destructor and the constructor hasn't been resolved (since it is called with dependent arguments), we were still warning. This patch suppresses the warning if the type could possibly have a be a non-trivial constructor call. Note that this does not take the arity of the constructors into consideration, so it might suppress the warning in cases where it isn't possible to call a non-trivial constructor.
* Suppress false-positive -Wuninitialized warnings in the constructor of aRichard Smith2019-12-111-1/+1
| | | | templated but non-template class.
* [OPENMP50]Add if clause in teams distribute parallel for simd directive.Alexey Bataev2019-12-111-1/+9
| | | | | | According to OpenMP 5.0, if clause can be used in for simd directive. If condition in the if clause if false, the non-vectorized version of the loop must be executed.
* [WebAssembly] Add new `export_name` clang attribute for controlling wasm ↵Sam Clegg2019-12-111-0/+25
| | | | | | | | | | | | | | | | | | | | export names This is equivalent to the existing `import_name` and `import_module` attributes which control the import names in the final wasm binary produced by lld. This maps the existing This attribute currently requires a string rather than using the symbol name for a couple of reasons: 1. Avoid confusion with static and dynamic linking which is based on symbol name. Exporting a function from a wasm module using this directive is orthogonal to both static and dynamic linking. 2. Avoids name mangling. Differential Revision: https://reviews.llvm.org/D70520
* [OPENMP50]Fix capturing of if condition in target parallel for simdAlexey Bataev2019-12-111-1/+3
| | | | | | | | directive. Fixed capturing of the if condition if no modifer was specified in this condition. Previously could capture it only in outer region and it could lead to a compiler crash.
* [OPENMP50]Add if clause in teams distribute simd directive.Alexey Bataev2019-12-111-1/+7
| | | | | | According to OpenMP 5.0, if clause can be used in for simd directive. If condition in the if clause if false, the non-vectorized version of the loop must be executed.
* [Support] Add TimeTraceScope constructor without detail argRussell Gallop2019-12-111-2/+1
| | | | | | | This simplifies code where no extra details are required Also don't write out detail when it is empty. Differential Revision: https://reviews.llvm.org/D71347
* [c++20] Implement P1946R0: allow defaulted comparisons to take theirRichard Smith2019-12-101-6/+25
| | | | arguments by value.
* [c++20] Delete defaulted comparison functions if they would invoke anRichard Smith2019-12-102-12/+39
| | | | inaccessible comparison function.
OpenPOWER on IntegriCloud