summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [Concepts] Constrained partial specializations and function overloads.Saar Raz2019-12-222-28/+85
| | | | | | | 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
* [Wdocumentation] Implement \anchorMark de Wever2019-12-213-0/+7
| | | | Differential revision: https://reviews.llvm.org/D69223
* [attributes][analyzer] Add annotations for handles.Gabor Horvath2019-12-201-0/+3
| | | | | | | 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
* [objc_direct] Tigthen checks for direct methodsPierre Habouzit2019-12-201-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ASTImporter][LLDB] Modifying ImportDeclContext(...) to ensure that we ↵shafik2019-12-191-1/+28
| | | | | | | | | | complete each FieldDecl of a RecordDecl when we are importing the definiton This fix was motivated by a crashes in expression parsing during code generation in which we had a RecordDecl that had incomplete FieldDecl. During code generation when computing the layout for the RecordDecl we crash because we have several incomplete FieldDecl. This fixes the issue by assuring that during ImportDefinition(...) for a RecordDecl we also import the definitions for each FieldDecl. Differential Revision: https://reviews.llvm.org/D71378
* Revert concepts changes from D41910Vedant Kumar2019-12-182-85/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add method to ignore invisible AST nodesStephen Kelly2019-12-182-0/+30
| | | | | | | | | | Reviewers: aaron.ballman Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70613
* Move TypeSourceInfo to Type.hReid Kleckner2019-12-181-0/+6
| | | | | | | | | | | | | | | TypeSourceInfo is a thin wrapper around TypeLocs. Notionally, the best place for it to live would be TypeLoc.h, but Decl.h requires it to be complete, so it needs to be lower in the dependency graph. Type.h seems like the next best place. By itself, this change has no impact on build time, because it doesn't remove a single dependency edge from a .cpp file to a .h file, but it is an incremental step towards making the AST headers less interdependent. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D71427
* [Concepts] Constrained partial specializations and function overloads.Saar Raz2019-12-182-28/+85
| | | | | | 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-184-16/+82
| | | | | | | | | | | | | | | | | | | | 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
* recommit: [ASTImporter] Friend class decl should not be visible in its contextGabor Marton2019-12-181-35/+47
| | | | | | | | | | | | | | | | | | | Summary: In the past we had to use DeclContext::makeDeclVisibleInContext to make friend declarations available for subsequent lookup calls and this way we could chain (redecl) the structurally equivalent decls. By doing this we created an AST that improperly made declarations visible in some contexts, so the AST was malformed. Since we use the importer specific lookup this is no longer necessary, because with that we can find every previous nodes. Reviewers: balazske, a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71020
* [OPENMP50]Add parsing/sema analysis for nontemporal clause.Alexey Bataev2019-12-172-0/+31
| | | | | Add basic support for parsing/sema analysis of the nontemporal clause in simd-based directives.
* [objc_direct] fix uniquing when re-declaring a readwrite-direct propertyPierre Habouzit2019-12-171-1/+9
| | | | | | | | | | | | | ObjCMethodDecl::getCanonicalDecl() for re-declared readwrite properties, only looks in the ObjCInterface for the declaration of the setter method, which it won't find. When the method is a property accessor, we must look in extensions for a possible redeclaration. Radar-Id: rdar://problem/57991337 Differential Revision: https://reviews.llvm.org/D71588
* Revert "[ASTImporter] Friend class decl should not be visible in its context"Nico Weber2019-12-171-44/+35
| | | | | This reverts commit 4becf68c6f17fe143539ceac954b21175914e1c1. Breaks building on Windows, see comments on D71020
* [ASTImporter] Friend class decl should not be visible in its contextGabor Marton2019-12-171-35/+44
| | | | | | | | | | | | | | | | | | | Summary: In the past we had to use DeclContext::makeDeclVisibleInContext to make friend declarations available for subsequent lookup calls and this way we could chain (redecl) the structurally equivalent decls. By doing this we created an AST that improperly made declarations visible in some contexts, so the AST was malformed. Since we use the importer specific lookup this is no longer necessary, because with that we can find every previous nodes. Reviewers: balazske, a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71020
* [OpenCL] Add ExtVectorElementExpr constant evaluation (PR42387)Sven van Haastregt2019-12-171-0/+25
| | | | | | | | Add constexpr evaluation for ExtVectorElementExpr nodes by evaluating the underlying vector expression. Add basic folding for the case that Evaluate does not return an LValue. Differential Revision: https://reviews.llvm.org/D71133
* Check whether the destination is a complete type in a static_cast (orRichard Smith2019-12-161-5/+1
| | | | | | | | | 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-163-81/+69
|
* If constant evaluation fails due to an unspecified pointer comparison,Richard Smith2019-12-161-2/+4
| | | | | produce a note saying that rather than the default "evaluation failed" note.
* [c++20] Add deprecation warnings for the expression forms deprecated by P1120R0.Richard Smith2019-12-161-0/+3
| | | | | | | | | | | | | | | | | | | 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).
* Properly compute whether statement expressions can throw, rather thanRichard Smith2019-12-151-0/+6
| | | | | | | | | 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.
* [AST] Use a reference in a range-based forMark de Wever2019-12-151-2/+2
| | | | | | | | This avoids unneeded copies when using a range-based for loops. This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71526
* [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSourceRaphael Isemann2019-12-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* PR44268: Fix crash if __builtin_object_size is applied to a heapRichard Smith2019-12-131-1/+1
| | | | allocation.
* [Sema] Improve diagnostic about addr spaces for overload candidatesAnastasia Stulova2019-12-132-37/+52
| | | | | | | | | | 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
* [ASTImporter] Support functions with placeholder return types ...Gabor Marton2019-12-121-15/+79
| | | | | | | | | | | | | | | Summary: Support functions with placeholder return types even in cases when the type is declared in the body of the function. Example: auto f() { struct X{}; return X(); } Reviewers: balazske, a_sidorin, a.sidorin, shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, teemperor, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70819
* [c++20] Return type deduction for defaulted three-way comparisons.Richard Smith2019-12-101-0/+35
|
* [Wdocumentation] Use C2x/C++14 deprecated attributeMark de Wever2019-12-101-10/+27
| | | | | | | | | This replaces the non-standard __attribute__((deprecated)) with the standard [[deprecated]] when compiling in C2x/C++14 mode. Discovered while looking at https://bugs.llvm.org/show_bug.cgi?id=43753 Differential Revision: https://reviews.llvm.org/D71141
* [Wdocumentation] Properly place deprecated attributeMark de Wever2019-12-101-5/+5
| | | | | | | | | | It is now placed before the function: - allows to replace __attribute__((deprecated)) with [[deprecated]]. - required for trailing returns. Fixes bug: https://bugs.llvm.org/show_bug.cgi?id=43753 Differential Revision: https://reviews.llvm.org/D71140
* [Wdocumentation] Use the command marker.Mark de Wever2019-12-101-3/+2
| | | | | | | | | Use the proper marker for -Wdocumentation-deprecated-sync instead of hard-coded the backslash. Discovered while looking at https://bugs.llvm.org/show_bug.cgi?id=43753 Differential Revision: https://reviews.llvm.org/D71139
* [OpenMP][NFCI] Introduce llvm/IR/OpenMPConstants.hJohannes Doerfert2019-12-103-1/+3
| | | | | | | | | | | | | | | | | | | Summary: The new OpenMPConstants.h is a location for all OpenMP related constants (and helpers) to live. This patch moves the directives there (the enum OpenMPDirectiveKind) and rewires Clang to use the new location. Initially part of D69785. Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim Subscribers: jholewinski, ppenzin, penzn, llvm-commits, cfe-commits, jfb, guansong, bollu, hiraditya, mgorny Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D69853
* [c++20] Fix handling of unqualified lookups from a defaulted comparisonRichard Smith2019-12-091-7/+36
| | | | | | | | | | function. We need to perform unqualified lookups from the context of a defaulted comparison, but not until we implicitly define the function, at which point we can't do those lookups any more. So perform the lookup from the end of the class containing the =default declaration and store the lookup results on the defaulted function until we synthesize the body.
* [c++20] Fix incorrect assumptions in checks for comparison category types.Richard Smith2019-12-091-3/+3
| | | | | | In the presence of modules, we can have multiple lookup results for the same entity, and we need to re-check for completeness each time we consider a type.
* [OpenCL] Handle address space conversions for constexpr (PR44177)Sven van Haastregt2019-12-091-0/+7
| | | | | | | | | | | | The AST for the constexpr.cl test contains address space conversion nodes to cast through the implicit generic address space. These caused the evaluator to reject the input as constexpr in C++ for OpenCL mode, whereas the input was considered constexpr in plain C++ mode as the AST won't have address space cast nodes then. Fixes PR44177. Differential Revision: https://reviews.llvm.org/D71015
* [c++20] Synthesis of defaulted comparison functions.Richard Smith2019-12-081-0/+30
| | | | | | Array members are not yet handled. In addition, defaulted comparisons can't yet find comparison operators by unqualified lookup (only by member lookup and ADL). These issues will be fixed in follow-on changes.
* Revert "[Sema][X86] Consider target attribute into the checks in ↵Reid Kleckner2019-12-061-63/+0
| | | | | | | | | validateOutputSize and validateInputSize." This reverts commit e1578fd2b79fe5af5f80c0c166a8abd0f816c022. It introduces a dependency on Attr.h which I am removing from ASTContext.h.
* [Sema][X86] Consider target attribute into the checks in validateOutputSize ↵Craig Topper2019-12-061-0/+63
| | | | | | | | | | | | | | | | and validateInputSize. The validateOutputSize and validateInputSize need to check whether AVX or AVX512 are enabled. But this can be affected by the target attribute so we need to factor that in. This patch copies some of the code from CodeGen to create an appropriate feature map that we can pass to the function. Probably need some refactoring here to share more code with Codegen. Is there a good place to do that? Also need to support the cpu_specific attribute as well. Differential Revision: https://reviews.llvm.org/D68627
* Remove Expr.h include from ASTContext.h, NFCReid Kleckner2019-12-066-5/+22
| | | | | | | ASTContext.h is popular, prune its includes. Expr.h brings in Attr.h, which is also expensive. Move BlockVarCopyInit to Expr.h to accomplish this.
* Make it possible control matcher traversal kind with ASTContextStephen Kelly2019-12-061-9/+39
| | | | | | | | | | | | | | | | Summary: This will eventually allow traversal of an AST while ignoring invisible AST nodes. Currently it depends on the available enum values for TraversalKinds. That can be extended to ignore all invisible nodes in the future. Reviewers: klimek, aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61837
* Stop checking whether std::strong_* has ::equivalent members.Richard Smith2019-12-061-6/+3
| | | | | Any attempt to use these would be a bug, so we shouldn't even look for them.
* [ASTImporter] Implicitly declare parameters for imported ObjCMethodDeclsRaphael Isemann2019-12-061-0/+8
| | | | | | | | | | | | | | | | | | | | Summary: When Sema encounters a ObjCMethodDecl definition it declares the implicit parameters for the ObjCMethodDecl. When importing such a method with the ASTImporter we need to do the same for the imported method otherwise we will crash when generating code (where CodeGen expects that this was called by Sema). Note I had to implement Objective-C[++] support in Language.cpp as this is the first test for Objective-C and this would otherwise just hit this 'not implemented' assert when running the unit test. Reviewers: martong, a.sidorin, shafik Reviewed By: martong Subscribers: rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71112
* Fix crash if a user-defined conversion is applied in the middle of aRichard Smith2019-12-052-1/+12
| | | | rewrite of an operator in terms of operator<=>.
* [Concepts] Fix build failures in D41569Saar Raz2019-12-061-2/+2
| | | | Fix build failures in previous commit.
* [Concepts] Constraint Enforcement & DiagnosticsSaar Raz2019-12-065-9/+67
| | | | | | | | | Part of the C++20 concepts implementation effort. - Associated constraints (requires clauses, currently) are now enforced when instantiating/specializing templates and when considering partial specializations and function overloads. - Elaborated diagnostics give helpful insight as to why the constraints were not satisfied. Phabricator: D41569 Re-commit, after fixing some memory bugs.
* [OpenMP50] Add parallel master constructcchen2019-12-053-0/+35
| | | | | | | | | | | | Reviewers: ABataev, jdoerfert Reviewed By: ABataev Subscribers: rnk, jholewinski, guansong, arphaman, jfb, cfe-commits, sandoval, dreachem Tags: #clang Differential Revision: https://reviews.llvm.org/D70726
* [ASTImporter] Various source location and range import fixes.Balázs Kéri2019-12-051-17/+39
| | | | | | | | | | | | | | | | | | | | Summary: ASTImporter contained wrong or missing imports of SourceLocation and SourceRange for some objects. At least a part of such errors is fixed now. Source location import fixes in namespace, enum, record, class template specialization declarations and DeclRefExpr, UnresolvedLookupExpr, UnresolvedMemberExpr, NestedNameSpecifierLoc. Reviewers: martong, a.sidorin, shafik Reviewed By: shafik Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60499
* Reapply af57dbf12e54 "Add support for options -frounding-math, ↵Melanie Blower2019-12-051-0/+1
| | | | | | | | | | | | ftrapping-math, -ffp-model=, and -ffp-exception-behavior=" Patch was reverted because https://bugs.llvm.org/show_bug.cgi?id=44048 The original patch is modified to set the strictfp IR attribute explicitly in CodeGen instead of as a side effect of IRBuilder. In the 2nd attempt to reapply there was a windows lit test fail, the tests were fixed to use wildcard matching. Differential Revision: https://reviews.llvm.org/D62731
* Revert "[OpenMP50] Add parallel master construct, by Chi Chun Chen."Reid Kleckner2019-12-043-35/+0
| | | | | | This reverts commit 713dab21e27c987b9114547ce7136bac2e775de9. Tests do not pass on Windows.
* Revert " Reapply af57dbf12e54 "Add support for options ↵Melanie Blower2019-12-041-1/+0
| | | | | | | -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior="" This reverts commit cdbed2dd856c14687efd741c2d8321686102acb8. Build break on Windows (lit fail)
* Fix crash-on-invalid-code in lambda constant evaluation.James Y Knight2019-12-041-0/+5
| | | | | | | | | | If the lambda used 'this' without without capturing it, an error was emitted, but the constant evaluator would still attempt to lookup the capture, and failing to find it, dereference a null pointer. This only happens in C++17 (as that's when lambdas were made potentially-constexpr). Therefore, I also updated the lambda-expressions.cpp test to run in both C++14 and C++17 modes.
OpenPOWER on IntegriCloud