Skip to content

Commit 31ae747

Browse files
committed
Address first feedback
1 parent 486c329 commit 31ae747

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13381,56 +13381,56 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc,
1338113381
}
1338213382

1338313383
bool Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
13384-
const VarDecl *dcl) {
13385-
if (!dcl || !getLangOpts().CPlusPlus)
13386-
return false;
13387-
13388-
// If an object is defined in a source file, its definition can't get
13389-
// duplicated since it will never appear in more than one TU.
13390-
if (dcl->getASTContext().getSourceManager().isInMainFile(dcl->getLocation()))
13384+
const VarDecl *Dcl) {
13385+
if (!Dcl || !getLangOpts().CPlusPlus)
1339113386
return false;
1339213387

1339313388
// We only need to warn if the definition is in a header file, so wait to
1339413389
// diagnose until we've seen the definition.
13395-
if (!dcl->isThisDeclarationADefinition())
13390+
if (!Dcl->isThisDeclarationADefinition())
13391+
return false;
13392+
13393+
// If an object is defined in a source file, its definition can't get
13394+
// duplicated since it will never appear in more than one TU.
13395+
if (Dcl->getASTContext().getSourceManager().isInMainFile(Dcl->getLocation()))
1339613396
return false;
1339713397

1339813398
// If the variable we're looking at is a static local, then we actually care
1339913399
// about the properties of the function containing it.
13400-
const ValueDecl *target = dcl;
13400+
const ValueDecl *Target = Dcl;
1340113401
// VarDecls and FunctionDecls have different functions for checking
1340213402
// inline-ness, so we have to do it manually.
13403-
bool target_is_inline = dcl->isInline();
13403+
bool TargetIsInline = Dcl->isInline();
1340413404

13405-
// Update the target and target_is_inline property if necessary
13406-
if (dcl->isStaticLocal()) {
13407-
const DeclContext *ctx = dcl->getDeclContext();
13408-
if (!ctx)
13405+
// Update the Target and TargetIsInline property if necessary
13406+
if (Dcl->isStaticLocal()) {
13407+
const DeclContext *Ctx = Dcl->getDeclContext();
13408+
if (!Ctx)
1340913409
return false;
1341013410

13411-
const FunctionDecl *f_dcl =
13412-
dyn_cast_if_present<FunctionDecl>(ctx->getNonClosureAncestor());
13413-
if (!f_dcl)
13411+
const FunctionDecl *FunDcl =
13412+
dyn_cast_if_present<FunctionDecl>(Ctx->getNonClosureAncestor());
13413+
if (!FunDcl)
1341413414
return false;
1341513415

13416-
target = f_dcl;
13416+
Target = FunDcl;
1341713417
// IsInlined() checks for the C++ inline property
13418-
target_is_inline = f_dcl->isInlined();
13418+
TargetIsInline = FunDcl->isInlined();
1341913419
}
1342013420

1342113421
// Non-inline variables can only legally appear in one TU
1342213422
// FIXME: This also applies to templated variables, but that can rarely lead
1342313423
// to false positives so templates are disabled for now.
13424-
if (!target_is_inline)
13424+
if (!TargetIsInline)
1342513425
return false;
1342613426

1342713427
// If the object isn't hidden, the dynamic linker will prevent duplication.
13428-
clang::LinkageInfo lnk = target->getLinkageAndVisibility();
13429-
if (lnk.getVisibility() != HiddenVisibility)
13428+
clang::LinkageInfo Lnk = Target->getLinkageAndVisibility();
13429+
if (Lnk.getVisibility() != HiddenVisibility)
1343013430
return false;
1343113431

1343213432
// If the obj doesn't have external linkage, it's supposed to be duplicated.
13433-
if (!isExternalFormalLinkage(lnk.getLinkage()))
13433+
if (!isExternalFormalLinkage(Lnk.getLinkage()))
1343413434
return false;
1343513435

1343613436
return true;

0 commit comments

Comments
 (0)