Skip to content

Commit 3968936

Browse files
committed
Revert "[clang] Implement ElaboratedType sugaring for types written bare"
This reverts commit bdc6974 because it breaks all the LLDB tests that import the std module. import-std-module/array.TestArrayFromStdModule.py import-std-module/deque-basic.TestDequeFromStdModule.py import-std-module/deque-dbg-info-content.TestDbgInfoContentDequeFromStdModule.py import-std-module/forward_list.TestForwardListFromStdModule.py import-std-module/forward_list-dbg-info-content.TestDbgInfoContentForwardListFromStdModule.py import-std-module/list.TestListFromStdModule.py import-std-module/list-dbg-info-content.TestDbgInfoContentListFromStdModule.py import-std-module/queue.TestQueueFromStdModule.py import-std-module/stack.TestStackFromStdModule.py import-std-module/vector.TestVectorFromStdModule.py import-std-module/vector-bool.TestVectorBoolFromStdModule.py import-std-module/vector-dbg-info-content.TestDbgInfoContentVectorFromStdModule.py import-std-module/vector-of-vectors.TestVectorOfVectorsFromStdModule.py https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45301/
1 parent bb3f99c commit 3968936

File tree

285 files changed

+2138
-2346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+2138
-2346
lines changed

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,14 @@ void ChangeNamespaceTool::run(
567567
if (Loc.getTypeLocClass() == TypeLoc::Elaborated) {
568568
NestedNameSpecifierLoc NestedNameSpecifier =
569569
Loc.castAs<ElaboratedTypeLoc>().getQualifierLoc();
570-
// FIXME: avoid changing injected class names.
571-
if (auto *NNS = NestedNameSpecifier.getNestedNameSpecifier()) {
572-
const Type *SpecifierType = NNS->getAsType();
573-
if (SpecifierType && SpecifierType->isRecordType())
574-
return;
575-
}
570+
// This happens for friend declaration of a base class with injected class
571+
// name.
572+
if (!NestedNameSpecifier.getNestedNameSpecifier())
573+
return;
574+
const Type *SpecifierType =
575+
NestedNameSpecifier.getNestedNameSpecifier()->getAsType();
576+
if (SpecifierType && SpecifierType->isRecordType())
577+
return;
576578
}
577579
fixTypeLoc(Result, startLocationForType(Loc), endLocationForType(Loc), Loc);
578580
} else if (const auto *VarRef =

clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) {
215215
// Uses of most types: just look at what the typeLoc refers to.
216216
MatchFinder->addMatcher(
217217
typeLoc(isExpansionInMainFile(),
218-
loc(qualType(allOf(unless(elaboratedType()),
219-
hasDeclaration(Types.bind("use")))))),
218+
loc(qualType(hasDeclaration(Types.bind("use"))))),
220219
this);
221220
// Uses of typedefs: these are often transparent to hasDeclaration, so we need
222221
// to handle them explicitly.

clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
8787
const auto ConstantExpr = ignoringParenImpCasts(
8888
anyOf(integerLiteral(), unaryOperator(hasUnaryOperand(IntegerExpr)),
8989
binaryOperator(hasLHS(IntegerExpr), hasRHS(IntegerExpr))));
90-
const auto IntegerCallExpr = ignoringParenImpCasts(callExpr(
91-
anyOf(hasType(isInteger()), hasType(hasCanonicalType(enumType()))),
92-
unless(isInTemplateInstantiation())));
90+
const auto IntegerCallExpr = ignoringParenImpCasts(
91+
callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
92+
unless(isInTemplateInstantiation())));
9393
const auto SizeOfExpr = sizeOfExpr(hasArgumentOfType(
9494
hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type"))));
9595
const auto SizeOfZero =
@@ -147,8 +147,8 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
147147
const auto StructAddrOfExpr = unaryOperator(
148148
hasOperatorName("&"), hasUnaryOperand(ignoringParenImpCasts(
149149
hasType(hasCanonicalType(recordType())))));
150-
const auto PointerToStructType = hasUnqualifiedDesugaredType(
151-
pointerType(pointee(hasCanonicalType(recordType()))));
150+
const auto PointerToStructType =
151+
hasUnqualifiedDesugaredType(pointerType(pointee(recordType())));
152152
const auto PointerToStructExpr = ignoringParenImpCasts(expr(
153153
hasType(hasCanonicalType(PointerToStructType)), unless(cxxThisExpr())));
154154

clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ void SmartPtrArrayMismatchCheck::registerMatchers(MatchFinder *Finder) {
6767
auto FindConstructExpr =
6868
cxxConstructExpr(
6969
hasDeclaration(FindConstructor), argumentCountIs(1),
70-
hasArgument(0,
71-
cxxNewExpr(isArray(),
72-
hasType(hasCanonicalType(pointerType(
73-
pointee(equalsBoundNode(PointerTypeN))))))
74-
.bind(NewExprN)))
70+
hasArgument(
71+
0, cxxNewExpr(isArray(), hasType(pointerType(pointee(
72+
equalsBoundNode(PointerTypeN)))))
73+
.bind(NewExprN)))
7574
.bind(ConstructExprN);
7675
Finder->addMatcher(FindConstructExpr, this);
7776
}
@@ -102,7 +101,7 @@ void SmartPtrArrayMismatchCheck::check(const MatchFinder::MatchResult &Result) {
102101
SourceRange TemplateArgumentRange = TSTypeLoc.getArgLoc(0)
103102
.getTypeSourceInfo()
104103
->getTypeLoc()
105-
.getSourceRange();
104+
.getLocalSourceRange();
106105
D << TemplateArgumentRange;
107106

108107
if (isInSingleDeclStmt(VarOrField)) {

clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,7 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) {
130130
// case of overloaded functions, so detection of redundant casts is trickier
131131
// in this case. Don't emit "redundant cast" warnings for function
132132
// pointer/reference types.
133-
QualType Src = SourceTypeAsWritten, Dst = DestTypeAsWritten;
134-
if (const auto *ElTy = dyn_cast<ElaboratedType>(Src))
135-
Src = ElTy->getNamedType();
136-
if (const auto *ElTy = dyn_cast<ElaboratedType>(Dst))
137-
Dst = ElTy->getNamedType();
138-
if (Src == Dst) {
133+
if (SourceTypeAsWritten == DestTypeAsWritten) {
139134
diag(CastExpr->getBeginLoc(), "redundant cast to the same type")
140135
<< FixItHint::CreateRemoval(ReplaceRange);
141136
return;

clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
3636
// otherwise the matcher does not work correctly, because it
3737
// will not explicitly ignore enum conditions.
3838
unless(ignoringImpCasts(
39-
declRefExpr(hasType(hasCanonicalType(enumType())))
40-
.bind("enum-condition"))))))
39+
declRefExpr(hasType(enumType())).bind("enum-condition"))))))
4140
.bind("switch"),
4241
this);
4342

clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ void MisplacedConstCheck::registerMatchers(MatchFinder *Finder) {
2121
pointee(anyOf(isConstQualified(), ignoringParens(functionType()))))));
2222

2323
Finder->addMatcher(
24-
valueDecl(hasType(qualType(
25-
isConstQualified(),
26-
elaboratedType(namesType(typedefType(hasDeclaration(
27-
anyOf(typedefDecl(NonConstAndNonFunctionPointerType)
28-
.bind("typedef"),
29-
typeAliasDecl(NonConstAndNonFunctionPointerType)
30-
.bind("typeAlias")))))))))
24+
valueDecl(
25+
hasType(isConstQualified()),
26+
hasType(typedefType(hasDeclaration(anyOf(
27+
typedefDecl(NonConstAndNonFunctionPointerType).bind("typedef"),
28+
typeAliasDecl(NonConstAndNonFunctionPointerType)
29+
.bind("typeAlias"))))))
3130
.bind("decl"),
3231
this);
3332
}

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static bool canBeModified(ASTContext *Context, const Expr *E) {
400400
return true;
401401
if (const auto *Cast = Parents[0].get<ImplicitCastExpr>()) {
402402
if ((Cast->getCastKind() == CK_NoOp &&
403-
Context->hasSameType(Cast->getType(), E->getType().withConst())) ||
403+
Cast->getType() == E->getType().withConst()) ||
404404
(Cast->getCastKind() == CK_LValueToRValue &&
405405
!Cast->getType().isNull() && Cast->getType()->isFundamentalType()))
406406
return false;

clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ AST_MATCHER(CXXRecordDecl, isMoveConstructible) {
4848

4949
static TypeMatcher notTemplateSpecConstRefType() {
5050
return lValueReferenceType(
51-
pointee(unless(elaboratedType(namesType(templateSpecializationType()))),
52-
isConstQualified()));
51+
pointee(unless(templateSpecializationType()), isConstQualified()));
5352
}
5453

5554
static TypeMatcher nonConstValueType() {

clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,22 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context,
153153
// ((Base*)this)->operator=((Base)Other);
154154
//
155155
// So we are looking for a member call that fulfills:
156-
if (match(traverse(
157-
TK_AsIs,
158-
compoundStmt(has(ignoringParenImpCasts(cxxMemberCallExpr(
159-
// - The object is an implicit cast of 'this' to a
160-
// pointer to
161-
// a base class.
162-
onImplicitObjectArgument(implicitCastExpr(
163-
hasImplicitDestinationType(hasCanonicalType(pointsTo(
164-
type(equalsNode(Base->getCanonicalTypeInternal()
165-
.getTypePtr()))))),
166-
hasSourceExpression(cxxThisExpr()))),
167-
// - The called method is the operator=.
168-
callee(cxxMethodDecl(isCopyAssignmentOperator())),
169-
// - The argument is (an implicit cast to a Base of)
170-
// the argument taken by "Operator".
171-
argumentCountIs(1),
172-
hasArgument(
173-
0, declRefExpr(to(varDecl(equalsNode(Param)))))))))),
156+
if (match(traverse(TK_AsIs,
157+
compoundStmt(has(ignoringParenImpCasts(cxxMemberCallExpr(
158+
// - The object is an implicit cast of 'this' to a
159+
// pointer to
160+
// a base class.
161+
onImplicitObjectArgument(implicitCastExpr(
162+
hasImplicitDestinationType(
163+
pointsTo(type(equalsNode(Base)))),
164+
hasSourceExpression(cxxThisExpr()))),
165+
// - The called method is the operator=.
166+
callee(cxxMethodDecl(isCopyAssignmentOperator())),
167+
// - The argument is (an implicit cast to a Base of)
168+
// the argument taken by "Operator".
169+
argumentCountIs(1),
170+
hasArgument(0, declRefExpr(to(varDecl(
171+
equalsNode(Param)))))))))),
174172
*Compound, *Context)
175173
.empty())
176174
return false;

clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
9797
if (TL.getQualifierLoc() &&
9898
!TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()))
9999
return false;
100-
const auto *T = TL.getTypePtr();
101-
return TraverseTypeLoc(TL.getNamedTypeLoc(),
102-
T->getKeyword() != ETK_None || T->getQualifier());
100+
return TraverseTypeLoc(TL.getNamedTypeLoc(), true);
103101
}
104102

105103
bool VisitDeclRefExpr(DeclRefExpr *S) {

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,7 @@ class ExplicitReferenceCollector
950950
// ElaboratedTypeLoc will reports information for its inner type loc.
951951
// Otherwise we loose information about inner types loc's qualifier.
952952
TypeLoc Inner = L.getNamedTypeLoc().getUnqualifiedLoc();
953-
if (L.getBeginLoc() == Inner.getBeginLoc())
954-
return RecursiveASTVisitor::TraverseTypeLoc(Inner);
955-
else
956-
TypeLocsToSkip.insert(Inner.getBeginLoc());
953+
TypeLocsToSkip.insert(Inner.getBeginLoc());
957954
return RecursiveASTVisitor::TraverseElaboratedTypeLoc(L);
958955
}
959956

clang-tools-extra/clangd/unittests/ASTTests.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
7272
template<typename T> class Foo {};
7373
^auto v = Foo<X>();
7474
)cpp",
75-
"Foo<X>",
75+
"Foo<class X>",
7676
},
7777
{
7878
R"cpp( // auto on initializer list.
@@ -93,7 +93,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
9393
return Foo();
9494
}
9595
)cpp",
96-
"Foo",
96+
"struct Foo",
9797
},
9898
{
9999
R"cpp( // decltype in trailing return type
@@ -102,7 +102,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
102102
return Foo();
103103
}
104104
)cpp",
105-
"Foo",
105+
"struct Foo",
106106
},
107107
{
108108
R"cpp( // auto in function return type
@@ -111,7 +111,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
111111
return Foo();
112112
}
113113
)cpp",
114-
"Foo",
114+
"struct Foo",
115115
},
116116
{
117117
R"cpp( // auto& in function return type
@@ -121,7 +121,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
121121
return x;
122122
}
123123
)cpp",
124-
"Foo",
124+
"struct Foo",
125125
},
126126
{
127127
R"cpp( // auto* in function return type
@@ -131,7 +131,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
131131
return x;
132132
}
133133
)cpp",
134-
"Foo",
134+
"struct Foo",
135135
},
136136
{
137137
R"cpp( // const auto& in function return type
@@ -141,7 +141,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
141141
return x;
142142
}
143143
)cpp",
144-
"Foo",
144+
"struct Foo",
145145
},
146146
{
147147
R"cpp( // decltype(auto) in function return (value)
@@ -150,7 +150,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
150150
return Foo();
151151
}
152152
)cpp",
153-
"Foo",
153+
"struct Foo",
154154
},
155155
{
156156
R"cpp( // decltype(auto) in function return (ref)
@@ -160,7 +160,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
160160
return (x);
161161
}
162162
)cpp",
163-
"Foo &",
163+
"struct Foo &",
164164
},
165165
{
166166
R"cpp( // decltype(auto) in function return (const ref)
@@ -170,7 +170,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
170170
return (x);
171171
}
172172
)cpp",
173-
"const Foo &",
173+
"const struct Foo &",
174174
},
175175
{
176176
R"cpp( // auto on alias

clang-tools-extra/clangd/unittests/DumpASTTests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ declaration: Var - root
121121
expression: DeclRef - operator+
122122
expression: MaterializeTemporary - lvalue
123123
expression: CXXTemporaryObject - Foo
124-
type: Elaborated
125-
type: Record - Foo
124+
type: Record - Foo
126125
expression: IntegerLiteral - 42
127126
)"},
128127
{R"cpp(

clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,14 +1612,13 @@ TEST_F(FindExplicitReferencesTest, All) {
16121612
{
16131613
R"cpp(
16141614
void foo() {
1615-
$0^class {} $1^x;
1616-
int (*$2^fptr)(int $3^a, int) = nullptr;
1615+
class {} $0^x;
1616+
int (*$1^fptr)(int $2^a, int) = nullptr;
16171617
}
16181618
)cpp",
1619-
"0: targets = {}\n"
1620-
"1: targets = {x}, decl\n"
1621-
"2: targets = {fptr}, decl\n"
1622-
"3: targets = {a}, decl\n"},
1619+
"0: targets = {x}, decl\n"
1620+
"1: targets = {fptr}, decl\n"
1621+
"2: targets = {a}, decl\n"},
16231622
// Namespace aliases should be handled properly.
16241623
{
16251624
R"cpp(

0 commit comments

Comments
 (0)