Skip to content

Commit a9792f6

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:8f68022f8e6e54d1aeae4ed301f5a015963089b7 into amd-gfx:963308497902
Local branch amd-gfx 9633084 Merged main:55d4816393f897054a4721920502d45c645edf1d into amd-gfx:f95c9bf0b616 Remote branch main 8f68022 [clang][analyzer] Fix crash in loop unrolling (llvm#82089)
2 parents 9633084 + 8f68022 commit a9792f6

File tree

55 files changed

+1102
-179
lines changed

Some content is hidden

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

55 files changed

+1102
-179
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "SourceCode.h"
1111
#include "TestTU.h"
1212
#include "support/TestTracer.h"
13+
#include "clang/AST/ASTConcept.h"
1314
#include "clang/AST/Decl.h"
1415
#include "llvm/Support/Casting.h"
1516
#include "gmock/gmock.h"
@@ -893,6 +894,33 @@ TEST(SelectionTest, DeclContextLambda) {
893894
EXPECT_TRUE(ST.commonAncestor()->getDeclContext().isFunctionOrMethod());
894895
}
895896

897+
TEST(SelectionTest, UsingConcepts) {
898+
llvm::Annotations Test(R"cpp(
899+
namespace ns {
900+
template <typename T>
901+
concept Foo = true;
902+
}
903+
904+
using ns::Foo;
905+
906+
template <Fo^o... T, Fo^o auto U>
907+
auto Func(Fo^o auto V) -> Fo^o decltype(auto) {
908+
Fo^o auto W = V;
909+
return W;
910+
}
911+
)cpp");
912+
auto TU = TestTU::withCode(Test.code());
913+
TU.ExtraArgs.emplace_back("-std=c++2c");
914+
auto AST = TU.build();
915+
for (auto Point : Test.points()) {
916+
auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
917+
Point, Point);
918+
auto *C = ST.commonAncestor()->ASTNode.get<ConceptReference>();
919+
EXPECT_TRUE(C && C->getFoundDecl() &&
920+
C->getFoundDecl()->getKind() == Decl::UsingShadow);
921+
}
922+
}
923+
896924
} // namespace
897925
} // namespace clangd
898926
} // namespace clang

clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,7 @@ TEST(WalkAST, Concepts) {
548548
testWalk(Concept, "template<typename T> requires ^Foo<T> void func() {}");
549549
testWalk(Concept, "template<typename T> void func() requires ^Foo<T> {}");
550550
testWalk(Concept, "void func(^Foo auto x) {}");
551-
// FIXME: Foo should be explicitly referenced.
552-
testWalk("template<typename T> concept Foo = true;",
553-
"void func() { ^Foo auto x = 1; }");
551+
testWalk(Concept, "void func() { ^Foo auto x = 1; }");
554552
}
555553

556554
TEST(WalkAST, FriendDecl) {

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,12 @@ Bug Fixes to C++ Support
376376
- Fixed a crash in constant evaluation when trying to access a
377377
captured ``this`` pointer in a lambda with an explicit object parameter.
378378
Fixes (#GH80997)
379+
- Fix an issue where missing set friend declaration in template class instantiation.
380+
Fixes (#GH84368).
379381

380382
Bug Fixes to AST Handling
381383
^^^^^^^^^^^^^^^^^^^^^^^^^
384+
- Clang now properly preserves ``FoundDecls`` within a ``ConceptReference``. (#GH82628)
382385

383386
Miscellaneous Bug Fixes
384387
^^^^^^^^^^^^^^^^^^^^^^^
@@ -489,6 +492,10 @@ libclang
489492
Static Analyzer
490493
---------------
491494

495+
- Fixed crashing on loops if the loop variable was declared in switch blocks
496+
but not under any case blocks if ``unroll-loops=true`` analyzer config is
497+
set. (#GH68819)
498+
492499
New features
493500
^^^^^^^^^^^^
494501

clang/include/clang/Basic/LangStandard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct LangStandard {
139139
bool isOpenCL() const { return Flags & OpenCL; }
140140

141141
static Kind getLangKind(StringRef Name);
142+
static Kind getHLSLLangKind(StringRef Name);
142143
static const LangStandard &getLangStandardForKind(Kind K);
143144
static const LangStandard *getLangStandardForName(StringRef Name);
144145
};

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8578,6 +8578,11 @@ def dxc_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>,
85788578
Group<dxc_Group>,
85798579
Visibility<[DXCOption]>,
85808580
HelpText<"Entry point name">;
8581+
def dxc_hlsl_version : Option<["/", "-"], "HV", KIND_JOINED_OR_SEPARATE>,
8582+
Group<dxc_Group>,
8583+
Visibility<[DXCOption]>,
8584+
HelpText<"HLSL Version">,
8585+
Values<"2016, 2017, 2018, 2021, 202x">;
85818586
def dxc_validator_path_EQ : Joined<["--"], "dxv-path=">, Group<dxc_Group>,
85828587
HelpText<"DXIL validator installation path">;
85838588
def dxc_disable_validation : DXCFlag<"Vd">,

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9215,7 +9215,7 @@ class Sema final {
92159215

92169216
bool AttachTypeConstraint(NestedNameSpecifierLoc NS,
92179217
DeclarationNameInfo NameInfo,
9218-
ConceptDecl *NamedConcept,
9218+
ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
92199219
const TemplateArgumentListInfo *TemplateArgs,
92209220
TemplateTypeParmDecl *ConstrainedParameter,
92219221
SourceLocation EllipsisLoc);

clang/lib/Basic/LangStandards.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ LangStandard::Kind LangStandard::getLangKind(StringRef Name) {
6969
.Default(lang_unspecified);
7070
}
7171

72+
LangStandard::Kind LangStandard::getHLSLLangKind(StringRef Name) {
73+
return llvm::StringSwitch<LangStandard::Kind>(Name)
74+
.Case("2016", LangStandard::lang_hlsl2016)
75+
.Case("2017", LangStandard::lang_hlsl2017)
76+
.Case("2018", LangStandard::lang_hlsl2018)
77+
.Case("2021", LangStandard::lang_hlsl2021)
78+
.Case("202x", LangStandard::lang_hlsl202x)
79+
.Default(LangStandard::lang_unspecified);
80+
}
81+
7282
const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
7383
Kind K = getLangKind(Name);
7484
if (K == lang_unspecified)

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
529529
RISCVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, unsigned XLen,
530530
unsigned FLen, bool EABI)
531531
: TargetCodeGenInfo(
532-
std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, EABI)) {}
532+
std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, EABI)) {
533+
SwiftInfo =
534+
std::make_unique<SwiftABIInfo>(CGT, /*SwiftErrorInRegister=*/false);
535+
}
533536

534537
void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
535538
CodeGen::CodeGenModule &CGM) const override {

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
226226
A->claim();
227227
continue;
228228
}
229+
if (A->getOption().getID() == options::OPT_dxc_hlsl_version) {
230+
// Translate -HV into -std for llvm
231+
// depending on the value given
232+
LangStandard::Kind LangStd = LangStandard::getHLSLLangKind(A->getValue());
233+
if (LangStd != LangStandard::lang_unspecified) {
234+
LangStandard l = LangStandard::getLangStandardForKind(LangStd);
235+
DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_std_EQ),
236+
l.getName());
237+
} else {
238+
getDriver().Diag(diag::err_drv_invalid_value) << "HV" << A->getValue();
239+
}
240+
241+
A->claim();
242+
continue;
243+
}
229244
DAL->append(A);
230245
}
231246

clang/lib/Sema/SemaDecl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,13 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS,
11921192
return ParsedType::make(T);
11931193
}
11941194

1195-
if (isa<ConceptDecl>(FirstDecl))
1195+
if (isa<ConceptDecl>(FirstDecl)) {
1196+
// We want to preserve the UsingShadowDecl for concepts.
1197+
if (auto *USD = dyn_cast<UsingShadowDecl>(Result.getRepresentativeDecl()))
1198+
return NameClassification::Concept(TemplateName(USD));
11961199
return NameClassification::Concept(
11971200
TemplateName(cast<TemplateDecl>(FirstDecl)));
1201+
}
11981202

11991203
if (auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(FirstDecl)) {
12001204
(void)DiagnoseUseOfDecl(EmptyD, NameLoc);

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
11561156

11571157
TemplateName TN = TypeConstr->Template.get();
11581158
ConceptDecl *CD = cast<ConceptDecl>(TN.getAsTemplateDecl());
1159+
UsingShadowDecl *USD = TN.getAsUsingShadowDecl();
11591160

11601161
DeclarationNameInfo ConceptName(DeclarationName(TypeConstr->Name),
11611162
TypeConstr->TemplateNameLoc);
@@ -1174,15 +1175,15 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
11741175
}
11751176
return AttachTypeConstraint(
11761177
SS.isSet() ? SS.getWithLocInContext(Context) : NestedNameSpecifierLoc(),
1177-
ConceptName, CD,
1178+
ConceptName, CD, /*FoundDecl=*/USD ? cast<NamedDecl>(USD) : CD,
11781179
TypeConstr->LAngleLoc.isValid() ? &TemplateArgs : nullptr,
11791180
ConstrainedParameter, EllipsisLoc);
11801181
}
11811182

1182-
template<typename ArgumentLocAppender>
1183+
template <typename ArgumentLocAppender>
11831184
static ExprResult formImmediatelyDeclaredConstraint(
11841185
Sema &S, NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo,
1185-
ConceptDecl *NamedConcept, SourceLocation LAngleLoc,
1186+
ConceptDecl *NamedConcept, NamedDecl *FoundDecl, SourceLocation LAngleLoc,
11861187
SourceLocation RAngleLoc, QualType ConstrainedType,
11871188
SourceLocation ParamNameLoc, ArgumentLocAppender Appender,
11881189
SourceLocation EllipsisLoc) {
@@ -1203,7 +1204,8 @@ static ExprResult formImmediatelyDeclaredConstraint(
12031204
SS.Adopt(NS);
12041205
ExprResult ImmediatelyDeclaredConstraint = S.CheckConceptTemplateId(
12051206
SS, /*TemplateKWLoc=*/SourceLocation(), NameInfo,
1206-
/*FoundDecl=*/NamedConcept, NamedConcept, &ConstraintArgs);
1207+
/*FoundDecl=*/FoundDecl ? FoundDecl : NamedConcept, NamedConcept,
1208+
&ConstraintArgs);
12071209
if (ImmediatelyDeclaredConstraint.isInvalid() || !EllipsisLoc.isValid())
12081210
return ImmediatelyDeclaredConstraint;
12091211

@@ -1233,7 +1235,7 @@ static ExprResult formImmediatelyDeclaredConstraint(
12331235
/// of arguments for the named concept).
12341236
bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
12351237
DeclarationNameInfo NameInfo,
1236-
ConceptDecl *NamedConcept,
1238+
ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
12371239
const TemplateArgumentListInfo *TemplateArgs,
12381240
TemplateTypeParmDecl *ConstrainedParameter,
12391241
SourceLocation EllipsisLoc) {
@@ -1246,24 +1248,24 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
12461248

12471249
QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
12481250

1249-
ExprResult ImmediatelyDeclaredConstraint =
1250-
formImmediatelyDeclaredConstraint(
1251-
*this, NS, NameInfo, NamedConcept,
1252-
TemplateArgs ? TemplateArgs->getLAngleLoc() : SourceLocation(),
1253-
TemplateArgs ? TemplateArgs->getRAngleLoc() : SourceLocation(),
1254-
ParamAsArgument, ConstrainedParameter->getLocation(),
1255-
[&] (TemplateArgumentListInfo &ConstraintArgs) {
1256-
if (TemplateArgs)
1257-
for (const auto &ArgLoc : TemplateArgs->arguments())
1258-
ConstraintArgs.addArgument(ArgLoc);
1259-
}, EllipsisLoc);
1251+
ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
1252+
*this, NS, NameInfo, NamedConcept, FoundDecl,
1253+
TemplateArgs ? TemplateArgs->getLAngleLoc() : SourceLocation(),
1254+
TemplateArgs ? TemplateArgs->getRAngleLoc() : SourceLocation(),
1255+
ParamAsArgument, ConstrainedParameter->getLocation(),
1256+
[&](TemplateArgumentListInfo &ConstraintArgs) {
1257+
if (TemplateArgs)
1258+
for (const auto &ArgLoc : TemplateArgs->arguments())
1259+
ConstraintArgs.addArgument(ArgLoc);
1260+
},
1261+
EllipsisLoc);
12601262
if (ImmediatelyDeclaredConstraint.isInvalid())
12611263
return true;
12621264

12631265
auto *CL = ConceptReference::Create(Context, /*NNS=*/NS,
12641266
/*TemplateKWLoc=*/SourceLocation{},
12651267
/*ConceptNameInfo=*/NameInfo,
1266-
/*FoundDecl=*/NamedConcept,
1268+
/*FoundDecl=*/FoundDecl,
12671269
/*NamedConcept=*/NamedConcept,
12681270
/*ArgsWritten=*/ArgsAsWritten);
12691271
ConstrainedParameter->setTypeConstraint(CL,
@@ -1293,8 +1295,9 @@ bool Sema::AttachTypeConstraint(AutoTypeLoc TL,
12931295
return true;
12941296
ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
12951297
*this, TL.getNestedNameSpecifierLoc(), TL.getConceptNameInfo(),
1296-
TL.getNamedConcept(), TL.getLAngleLoc(), TL.getRAngleLoc(),
1297-
BuildDecltypeType(Ref), OrigConstrainedParm->getLocation(),
1298+
TL.getNamedConcept(), /*FoundDecl=*/TL.getFoundDecl(), TL.getLAngleLoc(),
1299+
TL.getRAngleLoc(), BuildDecltypeType(Ref),
1300+
OrigConstrainedParm->getLocation(),
12981301
[&](TemplateArgumentListInfo &ConstraintArgs) {
12991302
for (unsigned I = 0, C = TL.getNumArgs(); I != C; ++I)
13001303
ConstraintArgs.addArgument(TL.getArgLoc(I));
@@ -5415,7 +5418,7 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
54155418

54165419
if (R.getAsSingle<ConceptDecl>()) {
54175420
return CheckConceptTemplateId(SS, TemplateKWLoc, R.getLookupNameInfo(),
5418-
R.getFoundDecl(),
5421+
R.getRepresentativeDecl(),
54195422
R.getAsSingle<ConceptDecl>(), TemplateArgs);
54205423
}
54215424

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,8 @@ bool Sema::SubstTypeConstraint(
29702970
}
29712971
return AttachTypeConstraint(
29722972
TC->getNestedNameSpecifierLoc(), TC->getConceptNameInfo(),
2973-
TC->getNamedConcept(), &InstArgs, Inst,
2973+
TC->getNamedConcept(),
2974+
/*FoundDecl=*/TC->getConceptReference()->getFoundDecl(), &InstArgs, Inst,
29742975
Inst->isParameterPack()
29752976
? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
29762977
->getEllipsisLoc()

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,7 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
17271727
assert(!Owner->isDependentContext());
17281728
Inst->setLexicalDeclContext(Owner);
17291729
RecordInst->setLexicalDeclContext(Owner);
1730+
Inst->setObjectOfFriendDecl();
17301731

17311732
if (PrevClassTemplate) {
17321733
Inst->setCommonPtr(PrevClassTemplate->getCommonPtr());

clang/lib/Sema/SemaType.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,7 +3499,7 @@ InventTemplateParameter(TypeProcessingState &state, QualType T,
34993499
if (!Invalid) {
35003500
S.AttachTypeConstraint(
35013501
AutoLoc.getNestedNameSpecifierLoc(), AutoLoc.getConceptNameInfo(),
3502-
AutoLoc.getNamedConcept(),
3502+
AutoLoc.getNamedConcept(), /*FoundDecl=*/AutoLoc.getFoundDecl(),
35033503
AutoLoc.hasExplicitTemplateArgs() ? &TAL : nullptr,
35043504
InventedTemplateParam, D.getEllipsisLoc());
35053505
}
@@ -3525,11 +3525,17 @@ InventTemplateParameter(TypeProcessingState &state, QualType T,
35253525
}
35263526
}
35273527
if (!Invalid) {
3528+
UsingShadowDecl *USD =
3529+
TemplateId->Template.get().getAsUsingShadowDecl();
3530+
auto *CD =
3531+
cast<ConceptDecl>(TemplateId->Template.get().getAsTemplateDecl());
35283532
S.AttachTypeConstraint(
35293533
D.getDeclSpec().getTypeSpecScope().getWithLocInContext(S.Context),
35303534
DeclarationNameInfo(DeclarationName(TemplateId->Name),
35313535
TemplateId->TemplateNameLoc),
3532-
cast<ConceptDecl>(TemplateId->Template.get().getAsTemplateDecl()),
3536+
CD,
3537+
/*FoundDecl=*/
3538+
USD ? cast<NamedDecl>(USD) : CD,
35333539
TemplateId->LAngleLoc.isValid() ? &TemplateArgsInfo : nullptr,
35343540
InventedTemplateParam, D.getEllipsisLoc());
35353541
}
@@ -6423,9 +6429,12 @@ namespace {
64236429
DeclarationNameInfo DNI = DeclarationNameInfo(
64246430
TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
64256431
TemplateId->TemplateNameLoc);
6432+
auto TN = TemplateId->Template.get();
64266433
auto *CR = ConceptReference::Create(
64276434
Context, NNS, TemplateId->TemplateKWLoc, DNI,
6428-
/*FoundDecl=*/nullptr,
6435+
/*FoundDecl=*/TN.getKind() == TemplateName::NameKind::UsingTemplate
6436+
? cast<NamedDecl>(TN.getAsUsingShadowDecl())
6437+
: cast_if_present<NamedDecl>(TN.getAsTemplateDecl()),
64296438
/*NamedDecl=*/TL.getTypePtr()->getTypeConstraintConcept(),
64306439
ASTTemplateArgumentListInfo::Create(Context, TemplateArgsInfo));
64316440
TL.setConceptReference(CR);

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,18 @@ bool clang::CanElideDeclDef(const Decl *D) {
281281

282282
if (FD->isDependentContext())
283283
return false;
284+
285+
if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
286+
return false;
284287
}
285288

286289
if (auto *VD = dyn_cast<VarDecl>(D)) {
287290
if (!VD->getDeclContext()->getRedeclContext()->isFileContext() ||
288-
VD->isInline() || VD->isConstexpr() || isa<ParmVarDecl>(VD))
291+
VD->isInline() || VD->isConstexpr() || isa<ParmVarDecl>(VD) ||
292+
// Constant initialized variable may not affect the ABI, but they
293+
// may be used in constant evaluation in the frontend, so we have
294+
// to remain them.
295+
VD->hasConstantInitialization())
289296
return false;
290297

291298
if (VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)

clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ static bool isCapturedByReference(ExplodedNode *N, const DeclRefExpr *DR) {
190190
return FD->getType()->isReferenceType();
191191
}
192192

193+
static bool isFoundInStmt(const Stmt *S, const VarDecl *VD) {
194+
if (const DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
195+
for (const Decl *D : DS->decls()) {
196+
// Once we reach the declaration of the VD we can return.
197+
if (D->getCanonicalDecl() == VD)
198+
return true;
199+
}
200+
}
201+
return false;
202+
}
203+
193204
// A loop counter is considered escaped if:
194205
// case 1: It is a global variable.
195206
// case 2: It is a reference parameter or a reference capture.
@@ -219,13 +230,19 @@ static bool isPossiblyEscaped(ExplodedNode *N, const DeclRefExpr *DR) {
219230
continue;
220231
}
221232

222-
if (const DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
223-
for (const Decl *D : DS->decls()) {
224-
// Once we reach the declaration of the VD we can return.
225-
if (D->getCanonicalDecl() == VD)
226-
return false;
233+
if (isFoundInStmt(S, VD)) {
234+
return false;
235+
}
236+
237+
if (const auto *SS = dyn_cast<SwitchStmt>(S)) {
238+
if (const auto *CST = dyn_cast<CompoundStmt>(SS->getBody())) {
239+
for (const Stmt *CB : CST->body()) {
240+
if (isFoundInStmt(CB, VD))
241+
return false;
242+
}
227243
}
228244
}
245+
229246
// Check the usage of the pass-by-ref function calls and adress-of operator
230247
// on VD and reference initialized by VD.
231248
ASTContext &ASTCtx =

0 commit comments

Comments
 (0)