clang
9.0.0
|
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/Type.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Analysis/Analyses/Dominators.h"
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/CFGStmtMap.h"
#include "clang/Analysis/ProgramPoint.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <deque>
#include <memory>
#include <string>
#include <utility>
Go to the source code of this file.
Functions | |
static const Expr * | peelOffPointerArithmetic (const BinaryOperator *B) |
static bool | hasVisibleUpdate (const ExplodedNode *LeftNode, SVal LeftVal, const ExplodedNode *RightNode, SVal RightVal) |
Comparing internal representations of symbolic values (via SVal::operator==()) is a valid way to check if the value was updated, unless it's a LazyCompoundVal that may have a different internal representation every time it is loaded from the state. More... | |
static Optional< const llvm::APSInt * > | getConcreteIntegerValue (const Expr *CondVarExpr, const ExplodedNode *N) |
static StringRef | getMacroName (SourceLocation Loc, BugReporterContext &BRC) |
static bool | isFunctionMacroExpansion (SourceLocation Loc, const SourceManager &SM) |
static bool | wasRegionOfInterestModifiedAt (const SubRegion *RegionOfInterest, const ExplodedNode *N, SVal ValueAfter) |
static bool | potentiallyWritesIntoIvar (const Decl *Parent, const ObjCIvarDecl *Ivar) |
static ArrayRef< ParmVarDecl * > | getCallParameters (CallEventRef<> Call) |
Get parameters associated with runtime definition in order to get the correct parameter name. More... | |
static bool | isPointerToConst (QualType Ty) |
static bool | isInitializationOfVar (const ExplodedNode *N, const VarRegion *VR) |
Returns true if N represents the DeclStmt declaring and initializing VR . More... | |
static void | showBRDiagnostics (const char *action, llvm::raw_svector_ostream &os, const MemRegion *R, SVal V, const DeclStmt *DS) |
Show diagnostics for initializing or declaring a region R with a bad value. More... | |
static void | showBRParamDiagnostics (llvm::raw_svector_ostream &os, const VarRegion *VR, SVal V) |
Display diagnostics for passing bad region as a parameter. More... | |
static void | showBRDefaultDiagnostics (llvm::raw_svector_ostream &os, const MemRegion *R, SVal V) |
Show default diagnostics for storing bad region. More... | |
static CFGBlock * | GetRelevantBlock (const ExplodedNode *Node) |
static std::shared_ptr< PathDiagnosticEventPiece > | constructDebugPieceForTrackedCondition (const Expr *Cond, const ExplodedNode *N, BugReporterContext &BRC) |
static const MemRegion * | getLocationRegionIfReference (const Expr *E, const ExplodedNode *N) |
|
static |
|
static |
Get parameters associated with runtime definition in order to get the correct parameter name.
Definition at line 429 of file BugReporterVisitors.cpp.
Referenced by isPointerToConst().
|
static |
Definition at line 184 of file BugReporterVisitors.cpp.
References State.
|
static |
Definition at line 1730 of file BugReporterVisitors.cpp.
References clang::ProgramPoint::getAs(), clang::CFGBlock::getTerminatorStmt(), clang::Expr::IgnoreParenCasts(), peelOffPointerArithmetic(), and clang::CFGBlock::succ_begin().
|
static |
Loc
. Definition at line 201 of file BugReporterVisitors.cpp.
References clang::Lexer::getImmediateMacroName().
Referenced by isPointerToConst().
|
static |
Definition at line 1658 of file BugReporterVisitors.cpp.
Referenced by constructDebugPieceForTrackedCondition().
|
static |
Comparing internal representations of symbolic values (via SVal::operator==()) is a valid way to check if the value was updated, unless it's a LazyCompoundVal that may have a different internal representation every time it is loaded from the state.
In this function we do an approximate comparison for lazy compound values, checking that they are the immediate snapshots of the tracked region's bindings within the node's respective states but not really checking that these snapshots actually contain the same set of bindings.
Definition at line 165 of file BugReporterVisitors.cpp.
Referenced by showBRDefaultDiagnostics().
|
static |
Definition at line 211 of file BugReporterVisitors.cpp.
References clang::CharSourceRange::getBegin(), clang::SourceManager::getDecomposedLoc(), clang::SrcMgr::SLocEntry::getExpansion(), clang::SourceManager::getImmediateExpansionRange(), clang::SourceManager::getSLocEntry(), clang::SrcMgr::ExpansionInfo::isFunctionMacroExpansion(), clang::SourceManager::isMacroArgExpansion(), and clang::SourceLocation::isMacroID().
Referenced by isPointerToConst().
|
static |
Returns true if N
represents the DeclStmt declaring and initializing VR
.
Definition at line 1149 of file BugReporterVisitors.cpp.
References clang::DeclStmt::getSingleDecl(), clang::LocationContext::getStackFrame(), and P.
Referenced by showBRDefaultDiagnostics().
Ty
points to a const type, or is a const reference. Definition at line 441 of file BugReporterVisitors.cpp.
References clang::ento::PathDiagnosticLocation::create(), clang::RecordDecl::fields(), clang::Type::getAsRecordDecl(), getCallParameters(), clang::QualType::getCanonicalType(), getMacroName(), clang::NamedDecl::getNameAsString(), clang::LocationContext::getParent(), clang::Type::getPointeeType(), clang::LocationContext::getStackFrame(), clang::ValueDecl::getType(), i, clang::StackFrameContext::inTopFrame(), clang::QualType::isConstQualified(), isFunctionMacroExpansion(), clang::SourceLocation::isMacroID(), clang::QualType::isNull(), clang::Type::isReferenceType(), clang::Type::isVoidType(), P, p, potentiallyWritesIntoIvar(), SM, State, V, and wasRegionOfInterestModifiedAt().
|
static |
Definition at line 74 of file BugReporterVisitors.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::BinaryOperator::isAdditiveOp(), and clang::Type::isPointerType().
Referenced by getLocationRegionIfReference().
|
static |
Parent
syntactically has a binary operation writing into the ivar Ivar
. Definition at line 396 of file BugReporterVisitors.cpp.
References clang::ast_matchers::binaryOperator, clang::Decl::hasBody(), clang::ast_matchers::hasDeclaration(), clang::ast_matchers::hasDescendant, clang::ast_matchers::objcIvarRefExpr, and clang::ast_matchers::stmt.
Referenced by isPointerToConst().
|
static |
Show default diagnostics for storing bad region.
Definition at line 1249 of file BugReporterVisitors.cpp.
References b, clang::CallEventManager::getCaller(), hasVisibleUpdate(), clang::Expr::IgnoreParenCasts(), isInitializationOfVar(), P, and V.
|
static |
Show diagnostics for initializing or declaring a region R
with a bad value.
Definition at line 1177 of file BugReporterVisitors.cpp.
References b, and clang::DeclStmt::getSingleDecl().
|
static |
Display diagnostics for passing bad region as a parameter.
Definition at line 1219 of file BugReporterVisitors.cpp.
|
static |
RegionOfInterest
was modified at N
, where ValueAfter
is RegionOfInterest's
value at the end of the stack frame. Definition at line 226 of file BugReporterVisitors.cpp.
References clang::ento::PathDiagnosticLocation::createEndOfPath(), clang::LocationContext::getStackFrame(), P, SM, and State.
Referenced by isPointerToConst().