clang 10.0.0git

Macros | Enumerations | Functions
UninitializedValues.cpp File Reference
`#include "clang/Analysis/Analyses/UninitializedValues.h"`
`#include "clang/AST/Attr.h"`
`#include "clang/AST/Decl.h"`
`#include "clang/AST/DeclBase.h"`
`#include "clang/AST/Expr.h"`
`#include "clang/AST/OperationKinds.h"`
`#include "clang/AST/Stmt.h"`
`#include "clang/AST/StmtObjC.h"`
`#include "clang/AST/StmtVisitor.h"`
`#include "clang/AST/Type.h"`
`#include "clang/Analysis/Analyses/PostOrderCFGView.h"`
`#include "clang/Analysis/AnalysisDeclContext.h"`
`#include "clang/Analysis/CFG.h"`
`#include "clang/Analysis/DomainSpecific/ObjCNoReturn.h"`
`#include "clang/Basic/LLVM.h"`
`#include "llvm/ADT/BitVector.h"`
`#include "llvm/ADT/DenseMap.h"`
`#include "llvm/ADT/None.h"`
`#include "llvm/ADT/Optional.h"`
`#include "llvm/ADT/PackedVector.h"`
`#include "llvm/ADT/SmallBitVector.h"`
`#include "llvm/ADT/SmallVector.h"`
`#include "llvm/Support/Casting.h"`
`#include <algorithm>`
`#include <cassert>`
Include dependency graph for UninitializedValues.cpp:

Go to the source code of this file.

## Macros
#define | DEBUG_LOGGING 0

## Enumerations
enum | Value { Unknown = 0x0, Initialized = 0x1, Uninitialized = 0x2, MayUninitialized = 0x3 }

## Functions
static bool | isTrackedVar (const VarDecl *vd, const DeclContext *dc)
static bool | isUninitialized (const Value v)
static bool | isAlwaysUninit (const Value v)
static const Expr * | stripCasts (ASTContext &C, const Expr *Ex)
static FindVarResult | findVar (const Expr *E, const DeclContext *DC)
| If E is an expression comprising a reference to a single variable, find that variable. More...
static const DeclRefExpr * | getSelfInitExpr (VarDecl *VD)
static bool | isPointerToConst (const QualType &QT)
static bool | runOnBlock (const CFGBlock *block, const CFG &cfg, AnalysisDeclContext &ac, CFGBlockValues &vals, const ClassifyRefs &classification, llvm::BitVector &wasAnalyzed, UninitVariablesHandler &handler)

## Macro Definition Documentation

## ◆ DEBUG_LOGGING

#define DEBUG_LOGGING 0

Definition at line 41 of file UninitializedValues.cpp.

## Enumeration Type Documentation

## ◆ Value

enum Value

Enumerator
Unknown |
Initialized |
Uninitialized |
MayUninitialized |

Definition at line 101 of file UninitializedValues.cpp.

## Function Documentation

## ◆ findVar()

static FindVarResult findVar | ( | const Expr * | E,
|  | const DeclContext * | DC
| ) |  |
| static

If E is an expression comprising a reference to a single variable, find that variable.

Definition at line 312 of file UninitializedValues.cpp.

References clang::C, clang::AnalysisDeclContext::getDecl(), clang::DeclContext::getParentASTContext(), isTrackedVar(), and stripCasts().

Referenced by getSelfInitExpr().

## ◆ getSelfInitExpr()

static const DeclRefExpr* getSelfInitExpr | ( | VarDecl * | VD | ) |
| static

Definition at line 373 of file UninitializedValues.cpp.

References clang::C, clang::DeclStmt::decls(), findVar(), clang::Decl::getASTContext(), clang::VarDecl::getInit(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::UnaryOperator::getSubExpr(), clang::ValueDecl::getType(), clang::Expr::IgnoreParens(), clang::BinaryOperator::isCompoundAssignmentOp(), clang::UnaryOperator::isIncrementDecrementOp(), clang::Type::isRecordType(), isTrackedVar(), max(), and stripCasts().

## ◆ isAlwaysUninit()

static bool isAlwaysUninit | ( | const Value | v | ) |
| static

Definition at line 110 of file UninitializedValues.cpp.

References clang::PostOrderCFGView::begin(), clang::PostOrderCFGView::end(), clang::CFGBlock::getBlockID(), clang::CFG::getEntry(), clang::CFG::getNumBlockIDs(), getValue(), clang::CFGBlock::succ_begin(), clang::CFGBlock::succ_end(), Uninitialized, and V.

## ◆ isPointerToConst()

static bool isPointerToConst | ( | const QualType & | QT | ) |
| static

Definition at line 464 of file UninitializedValues.cpp.

References clang::CallExpr::arg_begin(), clang::CallExpr::arg_end(), clang::CallExpr::getArg(), clang::AnalysisDeclContext::getASTContext(), clang::CastExpr::getCastKind(), clang::Type::getPointeeType(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::Type::isAnyPointerType(), clang::CallExpr::isCallToStdMove(), clang::QualType::isConstQualified(), clang::Type::isRecordType(), and stripCasts().

## ◆ isTrackedVar()

static bool isTrackedVar | ( | const VarDecl * | vd,
|  | const DeclContext * | dc
| ) |  |
| static

Definition at line 43 of file UninitializedValues.cpp.

References clang::DeclContext::decls_begin(), clang::DeclContext::decls_end(), clang::Decl::getDeclContext(), clang::ValueDecl::getType(), clang::VarDecl::hasGlobalStorage(), clang::VarDecl::isExceptionVariable(), clang::Decl::isImplicit(), clang::VarDecl::isInitCapture(), clang::VarDecl::isLocalVarDecl(), clang::Type::isRecordType(), clang::Type::isScalarType(), clang::Type::isVectorType(), and clang::None.

Referenced by findVar(), and getSelfInitExpr().

## ◆ isUninitialized()

static bool isUninitialized | ( | const Value | v | ) |
| static

Definition at line 106 of file UninitializedValues.cpp.

References Uninitialized.

## ◆ runOnBlock()

static bool runOnBlock | ( | const CFGBlock * | block,
|  | const CFG & | cfg,
|  | AnalysisDeclContext & | ac,
|  | CFGBlockValues & | vals,
|  | const ClassifyRefs & | classification,
|  | llvm::BitVector & | wasAnalyzed,
|  | UninitVariablesHandler & | handler
| ) |  |
| static

Definition at line 836 of file UninitializedValues.cpp.

References clang::CFGBlock::getBlockID(), clang::CFGBlock::pred_begin(), and clang::CFGBlock::pred_end().

Referenced by clang::runUninitializedVariablesAnalysis(), and writeShouldKill().

## ◆ stripCasts()

static const Expr* stripCasts | ( | ASTContext & | C,
|  | const Expr * | Ex
| ) |  |
| static

Definition at line 296 of file UninitializedValues.cpp.

References clang::Expr::IgnoreParenNoopCasts().

Referenced by findVar(), clang::ento::loc::MemRegionVal::getRegion(), getSelfInitExpr(), and isPointerToConst().