summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-07-20 13:01:16 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-07-20 13:01:16 +0000
commit12b48b160749f2c0c2f20cd0cb2e1ee5acc7eaa7 (patch)
treed4b69ae88af0e3da8612740a4837a373c6a8cefc /clang
parent7a3d4c15a7fc647abeee0322f2de9aab1caa837e (diff)
downloadbcm5719-llvm-12b48b160749f2c0c2f20cd0cb2e1ee5acc7eaa7.tar.gz
bcm5719-llvm-12b48b160749f2c0c2f20cd0cb2e1ee5acc7eaa7.zip
Fix cppcheck reduce scope variable warnings. NFCI
Move a couple of variables inside the block where they are actually needed. llvm-svn: 366635
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a6c52b7d4b2..2602e52bc45 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4090,11 +4090,11 @@ void Sema::notePreviousDefinition(const NamedDecl *Old, SourceLocation New) {
// Is it the same file and same offset? Provide more information on why
// this leads to a redefinition error.
- bool EmittedDiag = false;
if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
SourceLocation OldIncLoc = SrcMgr.getIncludeLoc(FOldDecLoc.first);
SourceLocation NewIncLoc = SrcMgr.getIncludeLoc(FNewDecLoc.first);
- EmittedDiag = noteFromModuleOrInclude(Old->getOwningModule(), OldIncLoc);
+ bool EmittedDiag =
+ noteFromModuleOrInclude(Old->getOwningModule(), OldIncLoc);
EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
// If the header has no guards, emit a note suggesting one.
@@ -4686,12 +4686,12 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
bool Invalid = false;
if (getLangOpts().CPlusPlus) {
const char *PrevSpec = nullptr;
- unsigned DiagID;
if (Record->isUnion()) {
// C++ [class.union]p6:
// C++17 [class.union.anon]p2:
// Anonymous unions declared in a named namespace or in the
// global namespace shall be declared static.
+ unsigned DiagID;
DeclContext *OwnerScope = Owner->getRedeclContext();
if (DS.getStorageClassSpec() != DeclSpec::SCS_static &&
(OwnerScope->isTranslationUnit() ||
OpenPOWER on IntegriCloud