r366635 - Fix cppcheck reduce scope variable warnings. NFCI
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 20 06:01:17 PDT 2019
Author: rksimon
Date: Sat Jul 20 06:01:16 2019
New Revision: 366635
URL: http://llvm.org/viewvc/llvm-project?rev=366635&view=rev
Log:
Fix cppcheck reduce scope variable warnings. NFCI
Move a couple of variables inside the block where they are actually needed.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=366635&r1=366634&r2=366635&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jul 20 06:01:16 2019
@@ -4090,11 +4090,11 @@ void Sema::notePreviousDefinition(const
// 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(
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() ||
More information about the cfe-commits
mailing list