r231619 - Simplify boolean expressions in clang with clang-tidy
David Blaikie
dblaikie at gmail.com
Sun Mar 8 19:02:07 PDT 2015
Author: dblaikie
Date: Sun Mar 8 21:02:07 2015
New Revision: 231619
URL: http://llvm.org/viewvc/llvm-project?rev=231619&view=rev
Log:
Simplify boolean expressions in clang with clang-tidy
Patch by Richard (legalize at xmission dot com).
Differential Revision: http://reviews.llvm.org/D8155
Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Lex/PreprocessingRecord.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sun Mar 8 21:02:07 2015
@@ -1713,7 +1713,7 @@ bool FunctionProtoType::isNothrow(const
if (EST == EST_DynamicNone || EST == EST_BasicNoexcept)
return true;
- if (EST == EST_Dynamic && ResultIfDependent == true) {
+ if (EST == EST_Dynamic && ResultIfDependent) {
// A dynamic exception specification is throwing unless every exception
// type is an (unexpanded) pack expansion type.
for (unsigned I = 0, N = NumExceptions; I != N; ++I)
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Sun Mar 8 21:02:07 2015
@@ -841,12 +841,12 @@ private:
// must be false.
llvm::APSInt IntVal;
if (Bop->getLHS()->EvaluateAsInt(IntVal, *Context)) {
- if (IntVal.getBoolValue() == false) {
+ if (!IntVal.getBoolValue()) {
return TryResult(false);
}
}
if (Bop->getRHS()->EvaluateAsInt(IntVal, *Context)) {
- if (IntVal.getBoolValue() == false) {
+ if (!IntVal.getBoolValue()) {
return TryResult(false);
}
}
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Sun Mar 8 21:02:07 2015
@@ -528,7 +528,7 @@ static bool getDiagnosticsInGroup(diag::
// An empty group is considered to be a warning group: we have empty groups
// for GCC compatibility, and GCC does not have remarks.
if (!Group->Members && !Group->SubGroups)
- return Flavor == diag::Flavor::Remark ? true : false;
+ return Flavor == diag::Flavor::Remark;
bool NotFound = true;
Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Sun Mar 8 21:02:07 2015
@@ -297,10 +297,7 @@ std::string ToolChain::ComputeLLVMTriple
// '-mbig-endian'/'-EB'.
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
options::OPT_mbig_endian)) {
- if (A->getOption().matches(options::OPT_mlittle_endian))
- IsBigEndian = false;
- else
- IsBigEndian = true;
+ IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian);
}
// Thumb2 is the default for V7 on Darwin.
Modified: cfe/trunk/lib/Lex/PreprocessingRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PreprocessingRecord.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PreprocessingRecord.cpp (original)
+++ cfe/trunk/lib/Lex/PreprocessingRecord.cpp Sun Mar 8 21:02:07 2015
@@ -73,11 +73,8 @@ static bool isPreprocessedEntityIfInFile
SourceLocation Loc = PPE->getSourceRange().getBegin();
if (Loc.isInvalid())
return false;
-
- if (SM.isInFileID(SM.getFileLoc(Loc), FID))
- return true;
- else
- return false;
+
+ return SM.isInFileID(SM.getFileLoc(Loc), FID);
}
/// \brief Returns true if the preprocessed entity that \arg PPEI iterator
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Mar 8 21:02:07 2015
@@ -547,7 +547,7 @@ void Parser::ParseMicrosoftDeclSpec(Pars
// We expect either a well-known identifier or a generic string. Anything
// else is a malformed declspec.
- bool IsString = Tok.getKind() == tok::string_literal ? true : false;
+ bool IsString = Tok.getKind() == tok::string_literal;
if (!IsString && Tok.getKind() != tok::identifier &&
Tok.getKind() != tok::kw_restrict) {
Diag(Tok, diag::err_ms_declspec_type);
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=231619&r1=231618&r2=231619&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Mar 8 21:02:07 2015
@@ -9497,10 +9497,7 @@ struct CompareOverloadCandidatesForDispl
numLFixes = (numLFixes == 0) ? UINT_MAX : numLFixes;
numRFixes = (numRFixes == 0) ? UINT_MAX : numRFixes;
if (numLFixes != numRFixes) {
- if (numLFixes < numRFixes)
- return true;
- else
- return false;
+ return numLFixes < numRFixes;
}
// If there's any ordering between the defined conversions...
More information about the cfe-commits
mailing list