Hi ddunbar, rjmccall, eli.friedman, doug.gregor, rafael,
Use clang-tidy to simplify boolean conditional return statements
http://reviews.llvm.org/D10012
Files:
lib/CodeGen/CGClass.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/TargetInfo.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -551,10 +551,7 @@
return true;
// We *must* emit a memcpy for a defaulted union copy or move op.
- if (D->getParent()->isUnion() && D->isDefaulted())
- return true;
-
- return false;
+ return D->getParent()->isUnion() && D->isDefaulted();
}
static void EmitMemberInitializer(CodeGenFunction &CGF,
@@ -715,10 +712,7 @@
return false;
// FIXME: Decide if we can do a delegation of a delegating constructor.
- if (Ctor->isDelegatingConstructor())
- return false;
-
- return true;
+ return !Ctor->isDelegatingConstructor();
}
// Emit code in ctor (Prologue==true) or dtor (Prologue==false)
@@ -877,9 +871,7 @@
if (CGF.getContext().getLangOpts().SanitizeAddressFieldPadding)
return false;
Qualifiers Qual = F->getType().getQualifiers();
- if (Qual.hasVolatile() || Qual.hasObjCLifetime())
- return false;
- return true;
+ return !Qual.hasVolatile() && !Qual.hasObjCLifetime();
}
void addMemcpyableField(FieldDecl *F) {
@@ -1045,11 +1037,7 @@
return false;
// Bail out on volatile fields.
- if (!isMemcpyableField(Field))
- return false;
-
- // Otherwise we're good.
- return true;
+ return isMemcpyableField(Field);
}
public:
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1070,9 +1070,7 @@
static bool isFunctionLocalClass(const CXXRecordDecl *RD) {
if (const CXXRecordDecl *NRD = dyn_cast<CXXRecordDecl>(RD->getDeclContext()))
return isFunctionLocalClass(NRD);
- if (isa<FunctionDecl>(RD->getDeclContext()))
- return true;
- return false;
+ return isa<FunctionDecl>(RD->getDeclContext());
}
/// CreateCXXMemberFunction - A helper function to create a subprogram for
@@ -1509,12 +1507,9 @@
dyn_cast<ClassTemplateSpecializationDecl>(RD))
Spec = SD->getSpecializationKind();
- if (Spec == TSK_ExplicitInstantiationDeclaration &&
- hasExplicitMemberDefinition(CXXDecl->method_begin(),
- CXXDecl->method_end()))
- return true;
-
- return false;
+ return Spec == TSK_ExplicitInstantiationDeclaration &&
+ hasExplicitMemberDefinition(CXXDecl->method_begin(),
+ CXXDecl->method_end());
}
/// CreateType - get structure or union type.
Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -335,9 +335,7 @@
bool CodeGenFunction::ShouldInstrumentFunction() {
if (!CGM.getCodeGenOpts().InstrumentFunctions)
return false;
- if (!CurFuncDecl || CurFuncDecl->hasAttr<NoInstrumentFunctionAttr>())
- return false;
- return true;
+ return CurFuncDecl && !CurFuncDecl->hasAttr<NoInstrumentFunctionAttr>();
}
/// EmitFunctionInstrumentation - Emit LLVM code to call the specified
Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2153,10 +2153,7 @@
return true;
// Check if we have a base destructor.
- if (isa<CXXDestructorDecl>(MD) && GD.getDtorType() == Dtor_Base)
- return true;
-
- return false;
+ return isa<CXXDestructorDecl>(MD) && GD.getDtorType() == Dtor_Base;
}
namespace {
@@ -2485,11 +2482,8 @@
// Check that the class is dynamic iff the base is.
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- if (!BaseDecl->isEmpty() &&
- BaseDecl->isDynamicClass() != RD->isDynamicClass())
- return false;
-
- return true;
+ return BaseDecl->isEmpty() ||
+ BaseDecl->isDynamicClass() == RD->isDynamicClass();
}
void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
Index: lib/CodeGen/TargetInfo.cpp
===================================================================
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -365,10 +365,7 @@
}
// Make sure there are not any holes in the struct.
- if (Size != Context.getTypeSize(Ty))
- return false;
-
- return true;
+ return Size == Context.getTypeSize(Ty);
}
namespace {
@@ -775,10 +772,7 @@
if (Ty->isVectorType()) {
// 64- and 128- bit vectors inside structures are not returned in
// registers.
- if (Size == 64 || Size == 128)
- return false;
-
- return true;
+ return Size != 64 && Size != 128;
}
// If this is a builtin, pointer, enum, complex type, member pointer, or
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits