Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Reported by Coverity:

Unchecked return value
If the function returns an error value, the error value may be mistaken for a 
normal value.

1. Inside "Parser.cpp" file, in 
clang::Parser::ParseKNRParamDeclarations(clang::Declarator &): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TryConsumeToken without checking return value (as is done 
elsewhere 75 out of 86 times).

2. Inside "CallGraph.h" file, in clang::CallGraph::addToCallGraph(clang::Decl 
*): Value returned from a function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 22 out of 23 times).

3. Inside "TokenAnnotator.cpp" file ,in 
clang::​format::​<unnamed>::​AnnotatingParser::​consumeToken(): Value returned 
from a function is not checked for errors before being used.

  check_return: Calling consumeToken without checking return value (as is done 
elsewhere 6 out of 7 times).

4. Inside "UnsafeBufferUsage.cpp" file, In 
clang::​ast_matchers::​MatchDescendantVisitor::​findMatch(clang::​DynTypedNode 
const &): Value returned from a function is not checked for errors before being 
used.

check_return: Calling TraverseStmt without checking return value (as is done 
elsewhere 485 out of 489 times)

5. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser<llvm::​itanium_demangle::​ManglingParser<<unnamed>::​CanonicalizerAllocator>,
 <unnamed>::​CanonicalizerAllocator>::​parseFunctionType(): Value returned from 
a function is not checked for errors before being used.

  check_return: Calling consumeIf without checking return value (as is done 
elsewhere 47 out of 50 times).

6. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser<llvm::​itanium_demangle::​ManglingParser<<unnamed>::​CanonicalizerAllocator>,
 <unnamed>::​CanonicalizerAllocator>::​parseBaseUnresolvedName(): Value 
returned from a function is not checked for errors before being used.

check_return: Calling consumeIf without checking return value (as is done 
elsewhere 47 out of 50 times).

7. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser<llvm::​itanium_demangle::​ManglingParser<llvm::​esimd::​SimpleAllocator>,
 llvm::​esimd::​SimpleAllocator>::​parseNumber(bool): Value returned from a 
function is not checked for errors before being used.

check_return: Calling consumeIf without checking return value (as is done 
elsewhere 95 out of 102 times).

8. Inside "ExprConstant.cpp" file, in 
clang::​Expr::​isPotentialConstantExprUnevaluated(clang::​Expr *, 
clang::​FunctionDecl const *, 
llvm::​SmallVectorImpl<std::​pair<clang::​SourceLocation, 
clang::​PartialDiagnostic>> &): Value returned from a function is not checked 
for errors before being used.

check_return: Calling Evaluate without checking return value (as is done 
elsewhere 23 out of 27 times).

9. Inside "ASTMatchFinder.cpp" file, in 
clang::​ast_matchers::​internal::​<unnamed>::​MatchASTVisitor::​dataTraverseNode(clang::​Stmt
 *, llvm::​SmallVectorImpl<llvm::​PointerIntPair<clang::​Stmt *, 1u, bool, 
llvm::​PointerLikeTypeTraits<clang::​Stmt *>, 
llvm::​PointerIntPairInfo<clang::​Stmt *, 1u, 
llvm::​PointerLikeTypeTraits<clang::​Stmt *>>>> *): Value returned from a 
function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 29 out of 33 times).

10. Inside "ParseObjc.cpp" file, in 
clang::​Parser::​isStartOfObjCClassMessageMissingOpenBracket(): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TryAnnotateTypeOrScopeToken without checking return value 
(as is done elsewhere 19 out of 21 times).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147791

Files:
  clang/include/clang/Analysis/CallGraph.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/Parser.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h

Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===================================================================
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -3333,7 +3333,7 @@
   if (consumeIf("dn"))
     return getDerived().parseDestructorName();
 
-  consumeIf("on");
+  (void)consumeIf("on");
 
   Node *Oper = getDerived().parseOperatorName(/*NameState=*/nullptr);
   if (Oper == nullptr)
@@ -3466,7 +3466,7 @@
 AbstractManglingParser<Alloc, Derived>::parseNumber(bool AllowNegative) {
   const char *Tmp = First;
   if (AllowNegative)
-    consumeIf('n');
+    (void)consumeIf('n');
   if (numLeft() == 0 || !std::isdigit(*First))
     return StringView();
   while (numLeft() != 0 && std::isdigit(*First))
@@ -3535,7 +3535,7 @@
       return nullptr;
   }
 
-  consumeIf("Dx"); // transaction safe
+  (void)consumeIf("Dx"); // transaction safe
 
   if (!consumeIf('F'))
     return nullptr;
Index: clang/lib/Parse/Parser.cpp
===================================================================
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1603,7 +1603,7 @@
     // Otherwise recover by skipping to next semi or mandatory function body.
     if (SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch))
       break;
-    TryConsumeToken(tok::semi);
+    (void)TryConsumeToken(tok::semi);
   }
 
   // The actions module must verify that all arguments were declared.
Index: clang/lib/Parse/ParseObjc.cpp
===================================================================
--- clang/lib/Parse/ParseObjc.cpp
+++ clang/lib/Parse/ParseObjc.cpp
@@ -3052,7 +3052,7 @@
     const Token &AfterNext = GetLookAheadToken(2);
     if (AfterNext.isOneOf(tok::colon, tok::r_square)) {
       if (Tok.is(tok::identifier))
-        TryAnnotateTypeOrScopeToken();
+        (void)TryAnnotateTypeOrScopeToken();
 
       return Tok.is(tok::annot_typename);
     }
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1272,7 +1272,7 @@
         if (Next->is(tok::less))
           next();
         else
-          consumeToken();
+          (void)consumeToken();
         if (!CurrentToken)
           break;
         auto Previous = CurrentToken->getPreviousNonComment();
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===================================================================
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -44,7 +44,7 @@
   bool findMatch(const DynTypedNode &DynNode) {
     Matches = false;
     if (const Stmt *StmtNode = DynNode.get<Stmt>()) {
-      TraverseStmt(const_cast<Stmt *>(StmtNode));
+      (void)TraverseStmt(const_cast<Stmt *>(StmtNode));
       *Builder = ResultBindings;
       return Matches;
     }
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===================================================================
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -569,7 +569,7 @@
         if (LE->hasExplicitParameters()) {
           // Visit parameters.
           for (ParmVarDecl *Param : Proto.getParams())
-            TraverseDecl(Param);
+            (void)TraverseDecl(Param);
         }
 
         const auto *T = Proto.getTypePtr();
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -16244,7 +16244,7 @@
   CallStackFrame Frame(Info, SourceLocation(), FD, /*This*/ nullptr, CallRef());
 
   APValue ResultScratch;
-  Evaluate(ResultScratch, Info, E);
+  (void)Evaluate(ResultScratch, Info, E);
   return Diags.empty();
 }
 
Index: clang/include/clang/Analysis/CallGraph.h
===================================================================
--- clang/include/clang/Analysis/CallGraph.h
+++ clang/include/clang/Analysis/CallGraph.h
@@ -60,7 +60,7 @@
   ///
   /// Recursively walks the declaration to find all the dependent Decls as well.
   void addToCallGraph(Decl *D) {
-    TraverseDecl(D);
+    (void)TraverseDecl(D);
   }
 
   /// Determine if a declaration should be included in the graph.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to