Manna created this revision. Manna added reviewers: erichkeane, aaron.ballman. Herald added subscribers: manas, ASDenysPetrov, luismarques, s.egerton, dkrupp, donat.nagy, Szelethus, PkmX, a.sidorin, simoncook, baloghadamsoftware, kristof.beyls, arichardson. Herald added a reviewer: NoQ. Herald added a project: All. Manna requested review of this revision. Herald added a subscriber: pcwang-thead. Herald added a project: clang.
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 "SemaExpr.cpp" file, in clang::Sema::BuildCXXDefaultArgExpr(clang::SourceLocation, clang::FunctionDecl *, clang::ParmVarDecl *, clang::Expr *): 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 31 times) 4. Inside "CGStmt.cpp" file, in clang::CodeGen::CodeGenFunction::EmitAsmInput(clang::TargetInfo::ConstraintInfo const &, clang::Expr const *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &): Value returned from a function is not checked for errors before being used. check_return: Calling EvaluateAsRValue without checking return value (as is done elsewhere 21 out of 25 times). 5. Inside "SemaChecking.cpp" file, in clang::Sema::CheckRISCVBuiltinFunctionCall(clang::TargetInfo const &, unsigned int, clang::CallExpr *): Value returned from a function is not checked for errors before being used. check_return: Calling consume_front without checking return value (as is done elsewhere 180 out of 213 times) Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147757 Files: clang/include/clang/Analysis/CallGraph.h clang/lib/CodeGen/CGStmt.cpp clang/lib/Parse/Parser.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaExpr.cpp Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -6033,7 +6033,7 @@ // point where the enclosing initializer is used in a function call. ImmediateCallVisitor V; if (!NestedDefaultChecking) - V.TraverseDecl(Param); + V.(void)TraverseDecl(Param); if (V.HasImmediateCalls) { ExprEvalContexts.back().DelayedDefaultInitializationContext = { CallLoc, Param, CurContext}; Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -4590,7 +4590,7 @@ } // Convert features like "zbr" and "experimental-zbr" to "Zbr". - OF.consume_front("experimental-"); + OF.(void)consume_front("experimental-"); std::string FeatureStr = OF.str(); FeatureStr[0] = std::toupper(FeatureStr[0]); // Combine strings. 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/CodeGen/CGStmt.cpp =================================================================== --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -2213,7 +2213,7 @@ if (!Info.allowsRegister() && !Info.allowsMemory()) { if (Info.requiresImmediateConstant()) { Expr::EvalResult EVResult; - InputExpr->EvaluateAsRValue(EVResult, getContext(), true); + InputExpr->(void)EvaluateAsRValue(EVResult, getContext(), true); llvm::APSInt IntResult; if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(), 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.
Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -6033,7 +6033,7 @@ // point where the enclosing initializer is used in a function call. ImmediateCallVisitor V; if (!NestedDefaultChecking) - V.TraverseDecl(Param); + V.(void)TraverseDecl(Param); if (V.HasImmediateCalls) { ExprEvalContexts.back().DelayedDefaultInitializationContext = { CallLoc, Param, CurContext}; Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -4590,7 +4590,7 @@ } // Convert features like "zbr" and "experimental-zbr" to "Zbr". - OF.consume_front("experimental-"); + OF.(void)consume_front("experimental-"); std::string FeatureStr = OF.str(); FeatureStr[0] = std::toupper(FeatureStr[0]); // Combine strings. 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/CodeGen/CGStmt.cpp =================================================================== --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -2213,7 +2213,7 @@ if (!Info.allowsRegister() && !Info.allowsMemory()) { if (Info.requiresImmediateConstant()) { Expr::EvalResult EVResult; - InputExpr->EvaluateAsRValue(EVResult, getContext(), true); + InputExpr->(void)EvaluateAsRValue(EVResult, getContext(), true); llvm::APSInt IntResult; if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(), 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