]> granicus.if.org Git - clang/commitdiff
Refactor: Simplify boolean conditional return statements in tools/libclang
authorAlexander Kornienko <alexfh@google.com>
Mon, 28 Dec 2015 15:24:08 +0000 (15:24 +0000)
committerAlexander Kornienko <alexfh@google.com>
Mon, 28 Dec 2015 15:24:08 +0000 (15:24 +0000)
Summary: Use clang-tidy to simplify boolean conditional return statements.

Reviewers: alexfh

Subscribers: alexfh, chfast, cfe-commits

Patch by Richard Thomson!

Differential Revision: http://reviews.llvm.org/D10024

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256498 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndex.cpp
tools/libclang/Indexing.cpp
tools/libclang/IndexingContext.cpp

index 11cd7bc25d593d589cc7c3723c6f8139ada15dea..477bf0902ba1b4d610e6638bf6d678d98bf77797 100644 (file)
@@ -717,11 +717,8 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl(
           return true;
     }
   }
-  
-  if (ShouldVisitBody && VisitCXXRecordDecl(D))
-    return true;
-  
-  return false;
+
+  return ShouldVisitBody && VisitCXXRecordDecl(D);
 }
 
 bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl(
@@ -946,11 +943,8 @@ bool CursorVisitor::VisitObjCMethodDecl(ObjCMethodDecl *ND) {
       return true;
   }
 
-  if (ND->isThisDeclarationADefinition() &&
-      Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest)))
-    return true;
-
-  return false;
+  return ND->isThisDeclarationADefinition() &&
+         Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest));
 }
 
 template <typename DeclIt>
@@ -6239,10 +6233,7 @@ static bool lexNext(Lexer &Lex, Token &Tok,
 
   ++NextIdx;
   Lex.LexFromRawLexer(Tok);
-  if (Tok.is(tok::eof))
-    return true;
-
-  return false;
+  return Tok.is(tok::eof);
 }
 
 static void annotatePreprocessorTokens(CXTranslationUnit TU,
index 5bfc4245eac1b0a55a373ba3d15054041cbdd430..d6e35b0019c9c1941cd0cb8e5f3ee154dd4ad87c 100644 (file)
@@ -681,9 +681,7 @@ static void indexPreprocessingRecord(ASTUnit &Unit, IndexingContext &IdxCtx) {
 static bool topLevelDeclVisitor(void *context, const Decl *D) {
   IndexingContext &IdxCtx = *static_cast<IndexingContext*>(context);
   IdxCtx.indexTopLevelDecl(D);
-  if (IdxCtx.shouldAbort())
-    return false;
-  return true;
+  return !IdxCtx.shouldAbort();
 }
 
 static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) {
index bf6e172fc074bb8b055a495cfe2b5b92a9842d36..f7640c63e05c1e7c0b321697cc28c209a30ce31d 100644 (file)
@@ -804,10 +804,7 @@ bool IndexingContext::markEntityOccurrenceInFile(const NamedDecl *D,
   RefFileOccurrence RefOccur(FE, D);
   std::pair<llvm::DenseSet<RefFileOccurrence>::iterator, bool>
   res = RefFileOccurrences.insert(RefOccur);
-  if (!res.second)
-    return true; // already in map.
-
-  return false;
+  return !res.second; // already in map
 }
 
 const NamedDecl *IndexingContext::getEntityDecl(const NamedDecl *D) const {