Skip to content

Commit 0f8f66e

Browse files
committed
Address first feedback
1 parent 798b3f2 commit 0f8f66e

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
@@ -13378,56 +13378,56 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc,
1337813378
}
1337913379

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

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

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

13402-
// Update the target and target_is_inline property if necessary
13403-
if (dcl->isStaticLocal()) {
13404-
const DeclContext *ctx = dcl->getDeclContext();
13405-
if (!ctx)
13402+
// Update the Target and TargetIsInline property if necessary
13403+
if (Dcl->isStaticLocal()) {
13404+
const DeclContext *Ctx = Dcl->getDeclContext();
13405+
if (!Ctx)
1340613406
return false;
1340713407

13408-
const FunctionDecl *f_dcl =
13409-
dyn_cast_if_present<FunctionDecl>(ctx->getNonClosureAncestor());
13410-
if (!f_dcl)
13408+
const FunctionDecl *FunDcl =
13409+
dyn_cast_if_present<FunctionDecl>(Ctx->getNonClosureAncestor());
13410+
if (!FunDcl)
1341113411
return false;
1341213412

13413-
target = f_dcl;
13413+
Target = FunDcl;
1341413414
// IsInlined() checks for the C++ inline property
13415-
target_is_inline = f_dcl->isInlined();
13415+
TargetIsInline = FunDcl->isInlined();
1341613416
}
1341713417

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

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

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

1343313433
return true;

0 commit comments

Comments
 (0)