From: Ted Kremenek Date: Thu, 28 Feb 2008 09:25:22 +0000 (+0000) Subject: Renamed "Uninitialized" -> "Undefined" in path-sensitive value tracking engine. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a4e524afef40d6f3ddb25d0e407c814e4ca56a8;p=clang Renamed "Uninitialized" -> "Undefined" in path-sensitive value tracking engine. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47713 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 45dbac7045..e820cfd903 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -117,7 +117,7 @@ GRExprEngine::MarkBranch(StateTy St, Stmt* Terminator, bool branchTaken) { (Op == BinaryOperator::LOr && !branchTaken) ? B->getRHS() : B->getLHS(); - return SetBlkExprRVal(St, B, UninitializedVal(Ex)); + return SetBlkExprRVal(St, B, UndefinedVal(Ex)); } case Stmt::ConditionalOperatorClass: { // ?: @@ -134,7 +134,7 @@ GRExprEngine::MarkBranch(StateTy St, Stmt* Terminator, bool branchTaken) { else Ex = C->getRHS(); - return SetBlkExprRVal(St, C, UninitializedVal(Ex)); + return SetBlkExprRVal(St, C, UndefinedVal(Ex)); } case Stmt::ChooseExprClass: { // ?: @@ -142,7 +142,7 @@ GRExprEngine::MarkBranch(StateTy St, Stmt* Terminator, bool branchTaken) { ChooseExpr* C = cast(Terminator); Expr* Ex = branchTaken ? C->getLHS() : C->getRHS(); - return SetBlkExprRVal(St, C, UninitializedVal(Ex)); + return SetBlkExprRVal(St, C, UndefinedVal(Ex)); } } } @@ -179,12 +179,12 @@ void GRExprEngine::ProcessBranch(Expr* Condition, Stmt* Term, builder.generateNode(MarkBranch(PrevState, Term, false), false); return; - case RVal::UninitializedKind: { + case RVal::UndefinedKind: { NodeTy* N = builder.generateNode(PrevState, true); if (N) { N->markAsSink(); - UninitBranches.insert(N); + UndefBranches.insert(N); } builder.markInfeasible(false); @@ -245,7 +245,7 @@ void GRExprEngine::ProcessIndirectGoto(IndirectGotoNodeBuilder& builder) { // Three possibilities: // // (1) We know the computed label. - // (2) The label is NULL (or some other constant), or Uninitialized. + // (2) The label is NULL (or some other constant), or Undefined. // (3) We have no clue about the label. Dispatch to all targets. // @@ -265,10 +265,10 @@ void GRExprEngine::ProcessIndirectGoto(IndirectGotoNodeBuilder& builder) { return; } - if (isa(V) || isa(V)) { + if (isa(V) || isa(V)) { // Dispatch to the first target and mark it as a sink. NodeTy* N = builder.generateNode(builder.begin(), St, true); - UninitBranches.insert(N); + UndefBranches.insert(N); return; } @@ -290,9 +290,9 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) { Expr* CondE = builder.getCondition(); RVal CondV = GetRVal(St, CondE); - if (CondV.isUninit()) { + if (CondV.isUndef()) { NodeTy* N = builder.generateDefaultCaseNode(St, true); - UninitBranches.insert(N); + UndefBranches.insert(N); return; } @@ -385,9 +385,9 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred, StateTy St = Pred->getState(); RVal X = GetBlkExprRVal(St, B); - assert (X.isUninit()); + assert (X.isUndef()); - Expr* Ex = (Expr*) cast(X).getData(); + Expr* Ex = (Expr*) cast(X).getData(); assert (Ex); @@ -395,9 +395,9 @@ void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred, X = GetBlkExprRVal(St, Ex); - // Handle uninitialized values. + // Handle undefined values. - if (X.isUninit()) { + if (X.isUndef()) { Nodify(Dst, B, Pred, SetBlkExprRVal(St, B, X)); return; } @@ -527,13 +527,13 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred, StateTy St = (*DI)->getState(); RVal L = GetLVal(St, Callee); - // Check for uninitialized control-flow. + // Check for undefined control-flow. - if (L.isUninit()) { + if (L.isUndef()) { NodeTy* N = Builder->generateNode(CE, St, *DI); N->markAsSink(); - UninitBranches.insert(N); + UndefBranches.insert(N); continue; } @@ -617,13 +617,13 @@ void GRExprEngine::VisitDeclStmt(DeclStmt* DS, GRExprEngine::NodeTy* Pred, !isa(VD)); // If there is no initializer, set the value of the - // variable to "Uninitialized". + // variable to "Undefined". // // FIXME: static variables may have an initializer, but the second // time a function is called those values may not be current. St = SetRVal(St, lval::DeclVal(VD), - Ex ? GetRVal(St, Ex) : UninitializedVal()); + Ex ? GetRVal(St, Ex) : UndefinedVal()); } } @@ -641,9 +641,9 @@ void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R, StateTy St = Pred->getState(); RVal X = GetBlkExprRVal(St, Ex); - assert (X.isUninit()); + assert (X.isUndef()); - Expr* SE = (Expr*) cast(X).getData(); + Expr* SE = (Expr*) cast(X).getData(); assert (SE); @@ -703,15 +703,15 @@ void GRExprEngine::VisitDeref(UnaryOperator* U, NodeTy* Pred, NodeSet& Dst) { RVal V = GetRVal(St, Ex); - // Check for dereferences of uninitialized values. + // Check for dereferences of undefined values. - if (V.isUninit()) { + if (V.isUndef()) { NodeTy* Succ = Builder->generateNode(U, St, N); if (Succ) { Succ->markAsSink(); - UninitDeref.insert(Succ); + UndefDeref.insert(Succ); } continue; @@ -810,7 +810,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, continue; } - if (SubV.isUninit()) { + if (SubV.isUndef()) { Nodify(Dst, U, N1, SetRVal(St, U, SubV)); continue; } @@ -827,8 +827,8 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, continue; } - // Propagate uninitialized values. - if (V.isUninit()) { + // Propagate undefined values. + if (V.isUndef()) { Nodify(Dst, U, N1, SetRVal(St, U, V)); continue; } @@ -984,16 +984,16 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, if ((Op == BinaryOperator::Div || Op == BinaryOperator::Rem) && RHS->getType()->isIntegerType()) { - // Check if the denominator is uninitialized. + // Check if the denominator is undefined. if (!RightV.isUnknown()) { - if (RightV.isUninit()) { - NodeTy* DivUninit = Builder->generateNode(B, St, N2); + if (RightV.isUndef()) { + NodeTy* DivUndef = Builder->generateNode(B, St, N2); - if (DivUninit) { - DivUninit->markAsSink(); - BadDivides.insert(DivUninit); + if (DivUndef) { + DivUndef->markAsSink(); + BadDivides.insert(DivUndef); } continue; @@ -1001,7 +1001,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, // Check for divide/remainder-by-zero. // - // First, "assume" that the denominator is 0 or uninitialized. + // First, "assume" that the denominator is 0 or undefined. bool isFeasible = false; StateTy ZeroSt = Assume(St, RightV, false, isFeasible); @@ -1051,8 +1051,8 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, // Simple assignments. - if (LeftV.isUninit()) { - HandleUninitializedStore(B, N2); + if (LeftV.isUndef()) { + HandleUndefinedStore(B, N2); continue; } @@ -1076,10 +1076,10 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, else ((int&) Op) -= BinaryOperator::MulAssign; - // Check if the LHS is uninitialized. + // Check if the LHS is undefined. - if (LeftV.isUninit()) { - HandleUninitializedStore(B, N2); + if (LeftV.isUndef()) { + HandleUndefinedStore(B, N2); continue; } @@ -1106,11 +1106,11 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, RVal V = GetRVal(N1->getState(), LeftLV, B->getLHS()->getType()); - // Propagate uninitialized value (left-side). We - // propogate uninitialized values for the RHS below when + // Propagate undefined value (left-side). We + // propogate undefined values for the RHS below when // we also check for divide-by-zero. - if (V.isUninit()) { + if (V.isUndef()) { St = SetRVal(St, B, V); break; } @@ -1129,7 +1129,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, // At this point: // - // The LHS is not Uninit/Unknown. + // The LHS is not Undef/Unknown. // The RHS is not Unknown. // Get the computation type. @@ -1144,14 +1144,14 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, if ((Op == BinaryOperator::Div || Op == BinaryOperator::Rem) && RHS->getType()->isIntegerType()) { - // Check if the denominator is uninitialized. + // Check if the denominator is undefined. - if (RightV.isUninit()) { - NodeTy* DivUninit = Builder->generateNode(B, St, N2); + if (RightV.isUndef()) { + NodeTy* DivUndef = Builder->generateNode(B, St, N2); - if (DivUninit) { - DivUninit->markAsSink(); - BadDivides.insert(DivUninit); + if (DivUndef) { + DivUndef->markAsSink(); + BadDivides.insert(DivUndef); } continue; @@ -1183,9 +1183,9 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, } else { - // Propagate uninitialized values (right-side). + // Propagate undefined values (right-side). - if (RightV.isUninit()) { + if (RightV.isUndef()) { St = SetRVal(SetRVal(St, B, RightV), LeftLV, RightV); break; } @@ -1202,10 +1202,10 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, } } -void GRExprEngine::HandleUninitializedStore(Stmt* S, NodeTy* Pred) { +void GRExprEngine::HandleUndefinedStore(Stmt* S, NodeTy* Pred) { NodeTy* N = Builder->generateNode(S, Pred->getState(), Pred); N->markAsSink(); - UninitStores.insert(N); + UndefStores.insert(N); } void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) { @@ -1589,9 +1589,9 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : if (GraphPrintCheckerState->isImplicitNullDeref(N) || GraphPrintCheckerState->isExplicitNullDeref(N) || - GraphPrintCheckerState->isUninitDeref(N) || - GraphPrintCheckerState->isUninitStore(N) || - GraphPrintCheckerState->isUninitControlFlow(N) || + GraphPrintCheckerState->isUndefDeref(N) || + GraphPrintCheckerState->isUndefStore(N) || + GraphPrintCheckerState->isUndefControlFlow(N) || GraphPrintCheckerState->isBadDivide(N)) return "color=\"red\",style=\"filled\""; @@ -1627,14 +1627,14 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : else if (GraphPrintCheckerState->isExplicitNullDeref(N)) { Out << "\\|Explicit-Null Dereference.\\l"; } - else if (GraphPrintCheckerState->isUninitDeref(N)) { - Out << "\\|Dereference of uninitialied value.\\l"; + else if (GraphPrintCheckerState->isUndefDeref(N)) { + Out << "\\|Dereference of undefialied value.\\l"; } - else if (GraphPrintCheckerState->isUninitStore(N)) { - Out << "\\|Store to Uninitialized LVal."; + else if (GraphPrintCheckerState->isUndefStore(N)) { + Out << "\\|Store to Undefined LVal."; } else if (GraphPrintCheckerState->isBadDivide(N)) { - Out << "\\|Divide-by zero or uninitialized value."; + Out << "\\|Divide-by zero or undefined value."; } break; @@ -1686,8 +1686,8 @@ struct VISIBILITY_HIDDEN DOTGraphTraits : Out << "\\l"; } - if (GraphPrintCheckerState->isUninitControlFlow(N)) { - Out << "\\|Control-flow based on\\lUninitialized value.\\l"; + if (GraphPrintCheckerState->isUndefControlFlow(N)) { + Out << "\\|Control-flow based on\\lUndefined value.\\l"; } } } diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp index 95a9f85b02..a5e8e57c0f 100644 --- a/Analysis/GRSimpleVals.cpp +++ b/Analysis/GRSimpleVals.cpp @@ -69,19 +69,19 @@ unsigned RunGRSimpleVals(CFG& cfg, FunctionDecl& FD, ASTContext& Ctx, "NULL pointer is dereferenced after it is checked for NULL."); EmitWarning(Diag, SrcMgr, - CheckerState->uninit_derefs_begin(), - CheckerState->uninit_derefs_end(), - "Dereference of uninitialized value."); + CheckerState->undef_derefs_begin(), + CheckerState->undef_derefs_end(), + "Dereference of undefined value."); EmitWarning(Diag, SrcMgr, - CheckerState->uninit_derefs_begin(), - CheckerState->uninit_derefs_end(), - "Dereference of uninitialized value."); + CheckerState->undef_derefs_begin(), + CheckerState->undef_derefs_end(), + "Dereference of undefined value."); EmitWarning(Diag, SrcMgr, CheckerState->bad_divides_begin(), CheckerState->bad_divides_end(), - "Division by zero/uninitialized value."); + "Division by zero/undefined value."); #ifndef NDEBUG if (Visualize) CheckerState->ViewGraph(); diff --git a/Analysis/RValues.cpp b/Analysis/RValues.cpp index bc6a75c7f7..d7c4dac252 100644 --- a/Analysis/RValues.cpp +++ b/Analysis/RValues.cpp @@ -249,8 +249,8 @@ void RVal::print(std::ostream& Out) const { case LValKind: cast(this)->print(Out); break; - case UninitializedKind: - Out << "Uninitialized"; break; + case UndefinedKind: + Out << "Undefined"; break; default: assert (false && "Invalid RVal."); diff --git a/Analysis/ValueState.cpp b/Analysis/ValueState.cpp index b90e265af2..c552bc9e3b 100644 --- a/Analysis/ValueState.cpp +++ b/Analysis/ValueState.cpp @@ -72,7 +72,7 @@ ValueStateManager::RemoveDeadBindings(ValueState St, Stmt* Loc, else { RVal X = I.getData(); - if (X.isUninit() && cast(X).getData()) + if (X.isUndef() && cast(X).getData()) continue; NewSt.BlockExprBindings = Remove(NewSt, BlkExpr); @@ -109,7 +109,7 @@ ValueStateManager::RemoveDeadBindings(ValueState St, Stmt* Loc, RVal X = GetRVal(St, lval::DeclVal(cast(V))); - if (X.isUnknownOrUninit()) + if (X.isUnknownOrUndef()) continue; LVal LV = cast(X); @@ -150,7 +150,7 @@ RVal ValueStateManager::GetRVal(ValueState St, const LVal& LV, QualType T) { if (isa(LV)) return UnknownVal(); - assert (!isa(LV)); + assert (!isa(LV)); switch (LV.getSubKind()) { case lval::DeclValKind: { diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h index 6b96ccf201..051fd1b490 100644 --- a/include/clang/Analysis/PathSensitive/GRExprEngine.h +++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h @@ -88,19 +88,19 @@ protected: /// CurrentStmt - The current block-level statement. Stmt* CurrentStmt; - typedef llvm::SmallPtrSet UninitBranchesTy; - typedef llvm::SmallPtrSet UninitStoresTy; + typedef llvm::SmallPtrSet UndefBranchesTy; + typedef llvm::SmallPtrSet UndefStoresTy; typedef llvm::SmallPtrSet BadDerefTy; typedef llvm::SmallPtrSet BadDividesTy; typedef llvm::SmallPtrSet NoReturnCallsTy; - /// UninitBranches - Nodes in the ExplodedGraph that result from - /// taking a branch based on an uninitialized value. - UninitBranchesTy UninitBranches; + /// UndefBranches - Nodes in the ExplodedGraph that result from + /// taking a branch based on an undefined value. + UndefBranchesTy UndefBranches; - /// UninitStores - Sinks in the ExplodedGraph that result from - /// making a store to an uninitialized lvalue. - UninitStoresTy UninitStores; + /// UndefStores - Sinks in the ExplodedGraph that result from + /// making a store to an undefined lvalue. + UndefStoresTy UndefStores; /// NoReturnCalls - Sinks in the ExplodedGraph that result from // calling a function with the attribute "noreturn". @@ -115,11 +115,11 @@ protected: BadDerefTy ExplicitNullDeref; /// UnitDeref - Nodes in the ExplodedGraph that result from - /// taking a dereference on an uninitialized value. - BadDerefTy UninitDeref; + /// taking a dereference on an undefined value. + BadDerefTy UndefDeref; /// BadDivides - Nodes in the ExplodedGraph that result from evaluating - /// a divide-by-zero or divide-by-uninitialized. + /// a divide-by-zero or divide-by-undefined. BadDividesTy BadDivides; bool StateCleaned; @@ -157,12 +157,12 @@ public: /// in the ExplodedGraph. StateTy getInitialState(); - bool isUninitControlFlow(const NodeTy* N) const { - return N->isSink() && UninitBranches.count(const_cast(N)) != 0; + bool isUndefControlFlow(const NodeTy* N) const { + return N->isSink() && UndefBranches.count(const_cast(N)) != 0; } - bool isUninitStore(const NodeTy* N) const { - return N->isSink() && UninitStores.count(const_cast(N)) != 0; + bool isUndefStore(const NodeTy* N) const { + return N->isSink() && UndefStores.count(const_cast(N)) != 0; } bool isImplicitNullDeref(const NodeTy* N) const { @@ -173,8 +173,8 @@ public: return N->isSink() && ExplicitNullDeref.count(const_cast(N)) != 0; } - bool isUninitDeref(const NodeTy* N) const { - return N->isSink() && UninitDeref.count(const_cast(N)) != 0; + bool isUndefDeref(const NodeTy* N) const { + return N->isSink() && UndefDeref.count(const_cast(N)) != 0; } bool isBadDivide(const NodeTy* N) const { @@ -189,9 +189,9 @@ public: null_deref_iterator null_derefs_begin() { return ExplicitNullDeref.begin(); } null_deref_iterator null_derefs_end() { return ExplicitNullDeref.end(); } - typedef BadDerefTy::iterator uninit_deref_iterator; - uninit_deref_iterator uninit_derefs_begin() { return UninitDeref.begin(); } - uninit_deref_iterator uninit_derefs_end() { return UninitDeref.end(); } + typedef BadDerefTy::iterator undef_deref_iterator; + undef_deref_iterator undef_derefs_begin() { return UndefDeref.begin(); } + undef_deref_iterator undef_derefs_end() { return UndefDeref.end(); } typedef BadDividesTy::iterator bad_divide_iterator; bad_divide_iterator bad_divides_begin() { return BadDivides.begin(); } @@ -298,9 +298,9 @@ protected: /// The states are not guaranteed to be unique. void Nodify(NodeSet& Dst, Stmt* S, NodeTy* Pred, const StateTy::BufferTy& SB); - /// HandleUninitializedStore - Create the necessary sink node to represent - /// a store to an "uninitialized" LVal. - void HandleUninitializedStore(Stmt* S, NodeTy* Pred); + /// HandleUndefinedStore - Create the necessary sink node to represent + /// a store to an "undefined" LVal. + void HandleUndefinedStore(Stmt* S, NodeTy* Pred); /// Visit - Transfer function logic for all statements. Dispatches to /// other functions that handle specific kinds of statements. @@ -344,7 +344,7 @@ protected: void VisitDeref(UnaryOperator* B, NodeTy* Pred, NodeSet& Dst); RVal EvalCast(RVal X, QualType CastT) { - if (X.isUnknownOrUninit()) + if (X.isUnknownOrUndef()) return X; if (isa(X)) @@ -371,8 +371,8 @@ protected: RVal EvalBinOp(BinaryOperator::Opcode Op, RVal L, RVal R) { - if (L.isUninit() || R.isUninit()) - return UninitializedVal(); + if (L.isUndef() || R.isUndef()) + return UndefinedVal(); if (L.isUnknown() || R.isUnknown()) return UnknownVal(); diff --git a/include/clang/Analysis/PathSensitive/RValues.h b/include/clang/Analysis/PathSensitive/RValues.h index 493fc1645c..ca94e4ddba 100644 --- a/include/clang/Analysis/PathSensitive/RValues.h +++ b/include/clang/Analysis/PathSensitive/RValues.h @@ -26,7 +26,7 @@ namespace clang { class RVal { public: - enum BaseKind { UninitializedKind, UnknownKind, LValKind, NonLValKind }; + enum BaseKind { UndefinedKind, UnknownKind, LValKind, NonLValKind }; enum { BaseBits = 2, BaseMask = 0x3 }; protected: @@ -71,11 +71,11 @@ public: return getRawKind() == UnknownKind; } - inline bool isUninit() const { - return getRawKind() == UninitializedKind; + inline bool isUndef() const { + return getRawKind() == UndefinedKind; } - inline bool isUnknownOrUninit() const { + inline bool isUnknownOrUndef() const { return getRawKind() <= UnknownKind; } @@ -103,13 +103,13 @@ public: } }; -class UninitializedVal : public RVal { +class UndefinedVal : public RVal { public: - UninitializedVal() : RVal(UninitializedKind) {} - UninitializedVal(void* D) : RVal(UninitializedKind, D) {} + UndefinedVal() : RVal(UndefinedKind) {} + UndefinedVal(void* D) : RVal(UndefinedKind, D) {} static inline bool classof(const RVal* V) { - return V->getBaseKind() == UninitializedKind; + return V->getBaseKind() == UndefinedKind; } void* getData() const { return Data; } diff --git a/include/clang/Analysis/PathSensitive/SymbolManager.h b/include/clang/Analysis/PathSensitive/SymbolManager.h index 3747f54d7d..a67afed11f 100644 --- a/include/clang/Analysis/PathSensitive/SymbolManager.h +++ b/include/clang/Analysis/PathSensitive/SymbolManager.h @@ -49,7 +49,7 @@ public: class SymbolData { public: - enum Kind { UninitKind, ParmKind, GlobalKind, ContentsOfKind }; + enum Kind { UndefKind, ParmKind, GlobalKind, ContentsOfKind }; private: uintptr_t Data; @@ -60,17 +60,17 @@ protected: SymbolData(void* D, Kind k) : Data(reinterpret_cast(D)), K(k) {} void* getPtr() const { - assert (K != UninitKind); + assert (K != UndefKind); return reinterpret_cast(Data); } uintptr_t getInt() const { - assert (K != UninitKind); + assert (K != UndefKind); return Data; } public: - SymbolData() : Data(0), K(UninitKind) {} + SymbolData() : Data(0), K(UndefKind) {} Kind getKind() const { return K; }