aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ASTStructuralEquivalence.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-10-02[C++] Implement "Deducing this" (P0847R7)Corentin Jabot1-0/+2
This patch implements P0847R7 (partially), CWG2561 and CWG2653. Reviewed By: aaron.ballman, #clang-language-wg Differential Revision: https://reviews.llvm.org/D140828
2023-09-21[clang][AST] fix lack comparison of declRefExpr in ASTStructuralEquivalence ↵Sunrise1-0/+9
(#66041) Fixed #66047 Before fix,the following testcase expected true. ```cpp TEST_F(StructuralEquivalenceStmtTest, DeclRefENoEq) { std::string Prefix = "enum Test { AAA, BBB };"; auto t = makeStmts( Prefix + "void foo(int i) {if (i > 0) {i = AAA;} else {i = BBB;}}", Prefix + "void foo(int i) {if (i > 0) {i = BBB;} else {i = AAA;}}", Lang_CXX03, ifStmt()); EXPECT_FALSE(testStructuralMatch(t)); // EXPECT_TRUE } ```
2023-09-21[clang][AST][ASTImporter] improve AST comparasion on VarDecl & GotoStmt (#66976)Qizhi Hu1-0/+27
improve AST comparasion on VarDecl & GotoStmt: 1. VarDecl should not be ignored, 2. GotoStmt has no children, it should be handle explicitly. Reviewed By: donat.nagy Differential Revision: https://reviews.llvm.org/D159519 Co-authored-by: huqizhi <836744285@qq.com>
2023-09-08[ASTImport]CXXBoolLiteralExpr should be handled explicitly in statement ↵huqizhi1-0/+4
comparation In the comparation of return statement, return value(if it is CXXBoolLiteralExpr) should be handled explicitly, otherwise an incorrect result would be returned. Reviewed By: steakhal, donat.nagy Differential Revision: https://reviews.llvm.org/D159479
2023-08-22[clang][ASTImporter]Skip check depth of friend template parameterhuqizhi1-1/+2
Depth of the parameter of friend template class declaration in a template class is 1, while in the specialization the depth is 0. This will cause failure on 'IsStructurallyEquivalent' as a name conflict in 'VisitClassTemplateDecl'(see testcase of 'SkipComparingFriendTemplateDepth'). The patch fix it by ignore the depth only in this special case. Reviewed By: balazske Differential Revision: https://reviews.llvm.org/D156693
2023-06-09[ASTStructuralEquivalence] Fix crash when ObjCCategoryDecl doesn't have ↵Volodymyr Sapsai1-3/+9
corresponding ObjCInterfaceDecl. When this happens, it is invalid code and there is diagnostic ``` error: cannot find interface declaration for '...' ``` But clang shouldn't crash even if code is invalid. Though subsequent diagnostic can be imperfect because without ObjCInterfaceDecl we don't have a type for error messages. rdar://108818430 Differential Revision: https://reviews.llvm.org/D151523
2023-05-08[clang][AST][NFC] Factor out check for structural equivalence of names.David Stone1-18/+15
We have four places that we try to decide which name to use for the test for structural equivalence, and in each of those we evaluate getTypedefNameForAnonDecl twice. Pull out the check into a function to reduce duplication and evaluate things only once. Differential Revision: https://reviews.llvm.org/D149981
2023-01-14[clang] Remove remaining uses of llvm::Optional (NFC)Kazu Hirata1-1/+0
This patch removes several "using" declarations and #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-3/+3
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-21[clang][AST] Compare UnresolvedLookupExpr in structural equivalence.Balázs Kéri1-0/+35
Reviewed By: gamesh411 Differential Revision: https://reviews.llvm.org/D136848
2022-12-10Don't include None.h (NFC)Kazu Hirata1-1/+0
I've converted all known uses of None to std::nullopt, so we no longer need to include None.h. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-09[STLExtras] Convert deref_or_none and zip_longest to std::optionalKrzysztof Parzyszek1-6/+7
2022-12-03[AST] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-10-25NFC: [clang] Template argument cleanups.Matheus Izvekov1-30/+26
Removes a bunch of obsolete methods in favor of a single one returning an ArrayRef of TemplateArgument. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D136602
2022-10-15[clang] Track the templated entity in type substitution.Matheus Izvekov1-11/+20
This is a change to how we represent type subsitution in the AST. Instead of only storing the replaced type, we track the templated entity we are substituting, plus an index. We modify MLTAL to track the templated entity at each level. Otherwise, it's much more expensive to go from the template parameter back to the templated entity, and not possible to do in some cases, as when we instantiate outer templates, parameters might still reference the original entity. This also allows us to very cheaply lookup the templated entity we saw in the naming context and find the corresponding argument it was replaced from, such as for implementing template specialization resugaring. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D131858
2022-10-03[clang] Implement divergence for TypedefType and UsingTypeMatheus Izvekov1-1/+7
With this patch, TypedefTypes and UsingTypes can have an underlying type which diverges from their corresponding declarations. For the TypedefType case, this can be seen when getting the common sugared type between two redeclarations with different sugar. For both cases, this will become important as resugaring is implemented, as this will allow us to resugar these when they were dependent before instantiation. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D133468
2022-09-28[C2x] implement typeof and typeof_unqualAaron Ballman1-2/+2
This implements WG14 N2927 and WG14 N2930, which together define the feature for typeof and typeof_unqual, which get the type of their argument as either fully qualified or fully unqualified. The argument to either operator is either a type name or an expression. If given a type name, the type information is pulled directly from the given name. If given an expression, the type information is pulled from the expression. Recursive use of these operators is allowed and has the expected behavior (the innermost operator is resolved to a type, and that's used to resolve the next layer of typeof specifier, until a fully resolved type is determined. Note, we already supported typeof in GNU mode as a non-conforming extension and we are *not* exposing typeof_unqual as a non-conforming extension in that mode, nor are we exposing typeof or typeof_unqual as a nonconforming extension in other language modes. The GNU variant of typeof supports a form where the parentheses are elided from the operator when given an expression (e.g., typeof 0 i = 12;). When in C2x mode, we do not support this extension. Differential Revision: https://reviews.llvm.org/D134286
2022-09-17[clang] Fix AST representation of expanded template arguments.Matheus Izvekov1-0/+2
Extend clang's SubstTemplateTypeParm to represent the pack substitution index. Fixes PR56099. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D128113
2022-08-26Revert "Clang: fix AST representation of expanded template arguments."Matheus Izvekov1-2/+0
This reverts commit 1d1a56929b725f9a79d98877f12d0a14f8418b38.
2022-08-09Clang: fix AST representation of expanded template arguments.Matheus Izvekov1-0/+2
Extend clang's SubstTemplateTypeParm to represent the pack substitution index. Fixes PR56099. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Differential Revision: https://reviews.llvm.org/D128113
2022-08-08[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-1/+1
With C++17 there is no Clang pedantic warning or MSVC C5051. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D131346
2022-05-10[NFC]Add Missing Break in switch that we didn't notice because it wasErich Keane1-0/+1
last.
2022-04-22[ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.Volodymyr Sapsai1-6/+135
Differential Revision: https://reviews.llvm.org/D121176
2022-04-14Reland "[AST] Add a new TemplateKind for template decls found via a using ↵Haojian Wu1-0/+1
decl."" This is the template version of https://reviews.llvm.org/D114251. This patch introduces a new template name kind (UsingTemplateName). The UsingTemplateName stores the found using-shadow decl (and underlying template can be retrieved from the using-shadow decl). With the new template name, we can be able to find the using decl that a template typeloc (e.g. TemplateSpecializationTypeLoc) found its underlying template, which is useful for tooling use cases (include cleaner etc). This patch merely focuses on adding the node to the AST. Next steps: - support using-decl in qualified template name; - update the clangd and other tools to use this new node; - add ast matchers for matching different kinds of template names; Differential Revision: https://reviews.llvm.org/D123127
2022-04-12Revert "[AST] Add a new TemplateKind for template decls found via a using decl."Haojian Wu1-1/+0
It breaks arm build, there is no free bit for the extra UsingShadowDecl in TemplateName::StorageType. Reverting it to build the buildbot back until we comeup with a fix. This reverts commit 5a5be4044f0bceb71bb6a81f6955704691b389ed.
2022-04-12[AST] Add a new TemplateKind for template decls found via a using decl.Haojian Wu1-0/+1
This is the template version of https://reviews.llvm.org/D114251. This patch introduces a new template name kind (UsingTemplateName). The UsingTemplateName stores the found using-shadow decl (and underlying template can be retrieved from the using-shadow decl). With the new template name, we can be able to find the using decl that a template typeloc (e.g. TemplateSpecializationTypeLoc) found its underlying template, which is useful for tooling use cases (include cleaner etc). This patch merely focuses on adding the node to the AST. Next steps: - support using-decl in qualified template name; - update the clangd and other tools to use this new node; - add ast matchers for matching different kinds of template names; Differential Revision: https://reviews.llvm.org/D123127
2022-03-16[Attr] Fix a btf_type_tag AST generationYonghong Song1-0/+7
Current ASTContext.getAttributedType() takes attribute kind, ModifiedType and EquivType as the hash to decide whether an AST node has been generated or note. But this is not enough for btf_type_tag as the attribute might have the same ModifiedType and EquivType, but still have different string associated with attribute. For example, for a data structure like below, struct map_value { int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a; int __attribute__((btf_type_tag("tag2"))) __attribute__((btf_type_tag("tag4"))) *b; }; The current ASTContext.getAttributedType() will produce an AST similar to below: struct map_value { int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a; int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *b; }; and this is incorrect. It is very difficult to use the current AttributedType as it is hard to get the tag information. To fix the problem, this patch introduced BTFTagAttributedType which is similar to AttributedType in many ways but with an additional BTFTypeTagAttr. The tag itself can be retrieved with BTFTypeTagAttr. With the new BTFTagAttributed type, the debuginfo code can be greatly simplified compared to previous TypeLoc based approach. Differential Revision: https://reviews.llvm.org/D120296
2021-12-20Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl"Sam McCall1-0/+6
This reverts commit cc56c66f27e131b914082d3bd21180646e842e9a. Fixed a bad assertion, the target of a UsingShadowDecl must not have *local* qualifiers, but it can be a typedef whose underlying type is qualified.
2021-12-20Revert "[AST] Add UsingType: a sugar type for types found via UsingDecl"Sam McCall1-6/+0
This reverts commit e1600db19d6303f84b995acb9340459694e06ea9. Breaks sanitizer tests, at least on windows: https://lab.llvm.org/buildbot/#/builders/127/builds/21592/steps/4/logs/stdio
2021-12-20[AST] Add UsingType: a sugar type for types found via UsingDeclSam McCall1-0/+6
Currently there's no way to find the UsingDecl that a typeloc found its underlying type through. Compare to DeclRefExpr::getFoundDecl(). Design decisions: - a sugar type, as there are many contexts this type of use may appear in - UsingType is a leaf like TypedefType, the underlying type has no TypeLoc - not unified with UnresolvedUsingType: a single name is appealing, but being sometimes-sugar is often fiddly. - not unified with TypedefType: the UsingShadowDecl is not a TypedefNameDecl or even a TypeDecl, and users think of these differently. - does not cover other rarer aliases like objc @compatibility_alias, in order to be have a concrete API that's easy to understand. - implicitly desugared by the hasDeclaration ASTMatcher, to avoid breaking existing patterns and following the precedent of ElaboratedType. Scope: - This does not cover types associated with template names introduced by using declarations. A future patch should introduce a sugar TemplateName variant for this. (CTAD deduced types fall under this) - There are enough AST matchers to fix the in-tree clang-tidy tests and probably any other matchers, though more may be useful later. Caveats: - This changes a fairly common pattern in the AST people may depend on matching. Previously, typeLoc(loc(recordType())) matched whether a struct was referred to by its original scope or introduced via using-decl. Now, the using-decl case is not matched, and needs a separate matcher. This is similar to the case of typedefs but nevertheless both adds complexity and breaks existing code. Differential Revision: https://reviews.llvm.org/D114251
2021-12-06Introduce _BitInt, deprecate _ExtIntAaron Ballman1-6/+6
WG14 adopted the _ExtInt feature from Clang for C23, but renamed the type to be _BitInt. This patch does the vast majority of the work to rename _ExtInt to _BitInt, which accounts for most of its size. The new type is exposed in older C modes and all C++ modes as a conforming extension. However, there are functional changes worth calling out: * Deprecates _ExtInt with a fix-it to help users migrate to _BitInt. * Updates the mangling for the type. * Updates the documentation and adds a release note to warn users what is going on. * Adds new diagnostics for use of _BitInt to call out when it's used as a Clang extension or as a pre-C23 compatibility concern. * Adds new tests for the new diagnostic behaviors. I want to call out the ABI break specifically. We do not believe that this break will cause a significant imposition for early adopters of the feature, and so this is being done as a full break. If it turns out there are critical uses where recompilation is not an option for some reason, we can consider using ABI tags to ease the transition.
2021-11-26[clang][AST] Check context of record in structural equivalence.Balázs Kéri1-0/+42
The AST structural equivalence check did not differentiate between a struct and a struct with same name in different namespace. When type of a member is checked it is possible to encounter such a case and wrongly decide that the types are similar. This problem is fixed by check for the namespaces of a record declaration. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D113118
2021-11-25Revert "[clang][AST] Check context of record in structural equivalence."Balázs Kéri1-42/+0
Revert commit 6b96b2a0bf65ff838d4dbf909a5120d4d1083e29 because Windows test failure.
2021-11-24[clang][AST] Check context of record in structural equivalence.Balázs Kéri1-0/+42
The AST structural equivalence check did not differentiate between a struct and a struct with same name in different namespace. When type of a member is checked it is possible to encounter such a case and wrongly decide that the types are similar. This problem is fixed by check for the namespaces of a record declaration. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D113118
2021-10-30[ASTImporter] Remove ASTNodeImporter::IsStructuralMatch overload for ↵Raphael Isemann1-0/+20
EnumConstantDecl 1. Moves the check to ASTStructuralEquivalence.cpp like all the other checks. 2. Adds the missing checks for identifier and init expression. Also add the respective tests for that stuff. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D112804
2021-06-11[ADT] Remove APInt/APSInt toString() std::string variantsSimon Pilgrim1-4/+5
<string> is currently the highest impact header in a clang+llvm build: https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps. This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the <string> from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code. Differential Revision: https://reviews.llvm.org/D103888
2021-01-20Revert "Following up on PR48517, fix handling of template arguments that refer"Hans Wennborg1-4/+0
Combined with 'da98651 - Revert "DR2064: decltype(E) is only a dependent', this change (5a391d3) caused verifier errors when building Chromium. See https://crbug.com/1168494#c1 for a reproducer. Additionally it reverts changes that were dependent on this one, see below. > Following up on PR48517, fix handling of template arguments that refer > to dependent declarations. > > Treat an id-expression that names a local variable in a templated > function as being instantiation-dependent. > > This addresses a language defect whereby a reference to a dependent > declaration can be formed without any construct being value-dependent. > Fixing that through value-dependence turns out to be problematic, so > instead this patch takes the approach (proposed on the core reflector) > of allowing the use of pointers or references to (but not values of) > dependent declarations inside value-dependent expressions, and instead > treating template arguments as dependent if they evaluate to a constant > involving such dependent declarations. > > This ends up affecting a bunch of OpenMP tests, due to OpenMP > imprecisely handling instantiation-dependent constructs, bailing out > early instead of processing dependent constructs to the extent possible > when handling the template. > > Previously committed as 8c1f2d15b826591cdf6bd6b468b8a7d23377b29e, and > reverted because a dependency commit was reverted. This reverts commit 5a391d38ac6c561ba908334d427f26124ed9132e. It also restores clang/test/SemaCXX/coroutines.cpp to its state before da986511fb9da1a46a0ca4dba2e49e2426036303. Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type." > Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and > reverted because a dependency commit was reverted. This incorporates the > following follow-on commits that were also reverted: > > 7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim > ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me > 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall > 430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki This reverts commit 4b574008aef5a7235c1f894ab065fe300d26e786. Revert "[msabi] Mangle a template argument referring to array-to-pointer decay" > [msabi] Mangle a template argument referring to array-to-pointer decay > applied to an array the same as the array itself. > > This follows MS ABI, and corrects a regression from the implementation > of generalized non-type template parameters, where we "forgot" how to > mangle this case. This reverts commit 18e093faf726d15f210ab4917142beec51848258.
2021-01-18[c++20] P1907R1: Support for generalized non-type template arguments of ↵Richard Smith1-0/+4
scalar type. Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and reverted because a dependency commit was reverted. This incorporates the following follow-on commits that were also reverted: 7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me 95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall 430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki
2020-12-22Revert "[c++20] P1907R1: Support for generalized non-type template arguments ↵Arthur Eubanks1-4/+0
of scalar type." This reverts commit 9e08e51a20d0d2b1c5724bb17e969d036fced4cd. This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
2020-12-18[c++20] P1907R1: Support for generalized non-type template arguments of ↵Richard Smith1-0/+4
scalar type.
2020-12-16[ASTImporter] Add support for importing GenericSelectionExpr AST nodes.Tom Roeder1-0/+18
This allows ASTs to be merged when they contain GenericSelectionExpr nodes (this is _Generic from C11). This is needed, for example, for CTU analysis of C code that makes use of _Generic, like the Linux kernel. The node is already supported in the AST, but it didn't have a matcher in ASTMatchers. So, this change adds the matcher and adds support to ASTImporter. Additionally, this change adds support for structural equivalence of _Generic in the AST. Reviewed By: martong, aaron.ballman Differential Revision: https://reviews.llvm.org/D92600
2020-10-05[ASTImporter][AST] Fix structural equivalency crash on dependent FieldDeclGabor Marton1-42/+3
Differential Revision: https://reviews.llvm.org/D88665
2020-09-21[ASTImporter] Refactor IsStructurallyEquivalent's Decl overloads to be more ↵Raphael Isemann1-129/+60
consistent There are several `::IsStructurallyEquivalent` overloads for Decl subclasses that are used for comparing declarations. There is also one overload that takes just two Decl pointers which ends up queuing the passed Decls to be later compared in `CheckKindSpecificEquivalence`. `CheckKindSpecificEquivalence` implements the dispatch logic for the different Decl subclasses. It is supposed to hand over the queued Decls to the subclass-specific `::IsStructurallyEquivalent` overload that will actually compare the Decl instance. It also seems to implement a few pieces of actual node comparison logic inbetween the dispatch code. This implementation causes that the different overloads of `::IsStructurallyEquivalent` do different (and sometimes no) comparisons depending on which overload of `::IsStructurallyEquivalent` ends up being called. For example, if I want to compare two FieldDecl instances, then I could either call the `::IsStructurallyEquivalent` with `Decl *` or with `FieldDecl *` parameters. The overload that takes FieldDecls is doing a correct comparison. However, the `Decl *` overload just queues the Decl pair. `CheckKindSpecificEquivalence` has no dispatch logic for `FieldDecl`, so it always returns true and never does any actual comparison. On the other hand, if I try to compare two FunctionDecl instances the two possible overloads of `::IsStructurallyEquivalent` have the opposite behaviour: The overload that takes `FunctionDecl` pointers isn't comparing the names of the FunctionDecls while the overload taking a plain `Decl` ends up comparing the function names (as the comparison logic for that is implemented in `CheckKindSpecificEquivalence`). This patch tries to make this set of functions more consistent by making `CheckKindSpecificEquivalence` a pure dispatch function without any subclass-specific comparison logic. Also the dispatch logic is now autogenerated so it can no longer miss certain subclasses. The comparison code from `CheckKindSpecificEquivalence` is moved to the respective `::IsStructurallyEquivalent` overload so that the comparison result no longer depends if one calls the `Decl *` overload or the overload for the specific subclass. The only difference is now that the `Decl *` overload is queuing the parameter while the subclass-specific overload is directly doing the comparison. `::IsStructurallyEquivalent` is an implementation detail and I don't think the behaviour causes any bugs in the current implementation (as carefully calling the right overload for the different classes works around the issue), so the test for this change is that I added some new code for comparing `MemberExpr`. The new comparison code always calls the dispatching overload and it previously failed as the dispatch didn't support FieldDecls. Reviewed By: martong, a_sidorin Differential Revision: https://reviews.llvm.org/D87619
2020-09-13[ASTImporter] Add basic support for comparing Stmts and compare function bodiesRaphael Isemann1-16/+228
Right now the ASTImporter assumes for most Expr nodes that they are always equal which leads to non-compatible declarations ending up being merged. This patch adds the basic framework for comparing Stmts (and with that also Exprs) and implements the custom checks for a few Stmt subclasses. I'll implement the remaining subclasses in follow up patches (mostly because there are a lot of subclasses and some of them require further changes like having GNU language in the testing framework) The motivation for this is that in LLDB we try to import libc++ source code and some of the types we are importing there contain expressions (e.g. because they use `enable_if<expr>`), so those declarations are currently merged even if they are completely different (e.g. `enable_if<value> ...` and `enable_if<!value> ...` are currently considered equal which is clearly not true). Reviewed By: martong, balazske Differential Revision: https://reviews.llvm.org/D87444
2020-05-11[Matrix] Add matrix type to Clang.Florian Hahn1-0/+28
This patch adds a matrix type to Clang as described in the draft specification in clang/docs/MatrixSupport.rst. It introduces a new option -fenable-matrix, which can be used to enable the matrix support. The patch adds new MatrixType and DependentSizedMatrixType types along with the plumbing required. Loads of and stores to pointers to matrix values are lowered to memory operations on 1-D IR arrays. After loading, the loaded values are cast to a vector. This ensures matrix values use the alignment of the element type, instead of LLVM's large vector alignment. The operators and builtins described in the draft spec will will be added in follow-up patches. Reviewers: martong, rsmith, Bigcheese, anemet, dexonsmith, rjmccall, aaron.ballman Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D72281
2020-04-17Reland Implement _ExtInt as an extended int type specifier.Erich Keane1-0/+18
I fixed the LLDB issue, so re-applying the patch. This reverts commit a4b88c044980337bb14390be654fe76864aa60ec.
2020-04-17Revert "Implement _ExtInt as an extended int type specifier."Sterling Augustine1-18/+0
This reverts commit 61ba1481e200b5b35baa81ffcff81acb678e8508. I'm reverting this because it breaks the lldb build with incomplete switch coverage warnings. I would fix it forward, but am not familiar enough with lldb to determine the correct fix. lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3958:11: error: enumeration values 'DependentExtInt' and 'ExtInt' not handled in switch [-Werror,-Wswitch] switch (qual_type->getTypeClass()) { ^ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4633:11: error: enumeration values 'DependentExtInt' and 'ExtInt' not handled in switch [-Werror,-Wswitch] switch (qual_type->getTypeClass()) { ^ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4889:11: error: enumeration values 'DependentExtInt' and 'ExtInt' not handled in switch [-Werror,-Wswitch] switch (qual_type->getTypeClass()) {
2020-04-17Implement _ExtInt as an extended int type specifier.Erich Keane1-0/+18
Introduction/Motivation: LLVM-IR supports integers of non-power-of-2 bitwidth, in the iN syntax. Integers of non-power-of-two aren't particularly interesting or useful on most hardware, so much so that no language in Clang has been motivated to expose it before. However, in the case of FPGA hardware normal integer types where the full bitwidth isn't used, is extremely wasteful and has severe performance/space concerns. Because of this, Intel has introduced this functionality in the High Level Synthesis compiler[0] under the name "Arbitrary Precision Integer" (ap_int for short). This has been extremely useful and effective for our users, permitting them to optimize their storage and operation space on an architecture where both can be extremely expensive. We are proposing upstreaming a more palatable version of this to the community, in the form of this proposal and accompanying patch. We are proposing the syntax _ExtInt(N). We intend to propose this to the WG14 committee[1], and the underscore-capital seems like the active direction for a WG14 paper's acceptance. An alternative that Richard Smith suggested on the initial review was __int(N), however we believe that is much less acceptable by WG14. We considered _Int, however _Int is used as an identifier in libstdc++ and there is no good way to fall back to an identifier (since _Int(5) is indistinguishable from an unnamed initializer of a template type named _Int). [0]https://www.intel.com/content/www/us/en/software/programmable/quartus-prime/hls-compiler.html) [1]http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2472.pdf Differential Revision: https://reviews.llvm.org/D73967
2020-02-21[AST][NFC] Update outdated comments in ASTStructuralEquivalence.cppGabor Marton1-9/+3
2020-01-23[Concepts] Placeholder constraints and abbreviated templatesSaar Raz1-3/+23
This patch implements P1141R2 "Yet another approach for constrained declarations". General strategy for this patch was: - Expand AutoType to include optional type-constraint, reflecting the wording and easing the integration of constraints. - Replace autos in parameter type specifiers with invented parameters in GetTypeSpecTypeForDeclarator, using the same logic previously used for generic lambdas, now unified with abbreviated templates, by: - Tracking the template parameter lists in the Declarator object - Tracking the template parameter depth before parsing function declarators (at which point we can match template parameters against scope specifiers to know if we have an explicit template parameter list to append invented parameters to or not). - When encountering an AutoType in a parameter context we check a stack of InventedTemplateParameterInfo structures that contain the info required to create and accumulate invented template parameters (fields that were already present in LambdaScopeInfo, which now inherits from this class and is looked up when an auto is encountered in a lambda context). Resubmit after fixing MSAN failures caused by incomplete initialization of AutoTypeLocs in TypeSpecLocFiller. Differential Revision: https://reviews.llvm.org/D65042