From 0074b48fb8ea5040de546c79be43916efe0c1f76 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sun, 5 Dec 2010 23:36:20 +0000 Subject: [PATCH] Mark SVal constructors 'explicit'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120970 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Checker/PathSensitive/SVals.h | 30 ++++++++++----------- lib/Checker/GRState.cpp | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/clang/Checker/PathSensitive/SVals.h b/include/clang/Checker/PathSensitive/SVals.h index 77a62a971f..a50d296ea7 100644 --- a/include/clang/Checker/PathSensitive/SVals.h +++ b/include/clang/Checker/PathSensitive/SVals.h @@ -62,14 +62,14 @@ protected: unsigned Kind; protected: - SVal(const void* d, bool isLoc, unsigned ValKind) + explicit SVal(const void* d, bool isLoc, unsigned ValKind) : Data(d), Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {} explicit SVal(BaseKind k, const void* D = NULL) : Data(D), Kind(k) {} public: - SVal() : Data(0), Kind(0) {} + explicit SVal() : Data(0), Kind(0) {} ~SVal() {} /// BufferTy - A temporary buffer to hold a set of SVals. @@ -207,7 +207,7 @@ public: class UnknownVal : public DefinedOrUnknownSVal { public: - UnknownVal() : DefinedOrUnknownSVal(UnknownKind) {} + explicit UnknownVal() : DefinedOrUnknownSVal(UnknownKind) {} static inline bool classof(const SVal *V) { return V->getBaseKind() == UnknownKind; @@ -222,7 +222,7 @@ private: bool isUnknownOrUndef() const; bool isValid() const; protected: - DefinedSVal(const void* d, bool isLoc, unsigned ValKind) + explicit DefinedSVal(const void* d, bool isLoc, unsigned ValKind) : DefinedOrUnknownSVal(d, isLoc, ValKind) {} public: // Implement isa support. @@ -233,7 +233,8 @@ public: class NonLoc : public DefinedSVal { protected: - NonLoc(unsigned SubKind, const void* d) : DefinedSVal(d, false, SubKind) {} + explicit NonLoc(unsigned SubKind, const void* d) + : DefinedSVal(d, false, SubKind) {} public: void dumpToStream(llvm::raw_ostream& Out) const; @@ -246,14 +247,13 @@ public: class Loc : public DefinedSVal { protected: - Loc(unsigned SubKind, const void* D) + explicit Loc(unsigned SubKind, const void* D) : DefinedSVal(const_cast(D), true, SubKind) {} public: void dumpToStream(llvm::raw_ostream& Out) const; Loc(const Loc& X) : DefinedSVal(X.Data, true, X.getSubKind()) {} - Loc& operator=(const Loc& X) { memcpy(this, &X, sizeof(Loc)); return *this; } // Implement isa support. static inline bool classof(const SVal* V) { @@ -295,7 +295,7 @@ public: class SymExprVal : public NonLoc { public: - SymExprVal(const SymExpr *SE) + explicit SymExprVal(const SymExpr *SE) : NonLoc(SymExprValKind, reinterpret_cast(SE)) {} const SymExpr *getSymbolicExpression() const { @@ -314,7 +314,7 @@ public: class ConcreteInt : public NonLoc { public: - ConcreteInt(const llvm::APSInt& V) : NonLoc(ConcreteIntKind, &V) {} + explicit ConcreteInt(const llvm::APSInt& V) : NonLoc(ConcreteIntKind, &V) {} const llvm::APSInt& getValue() const { return *static_cast(Data); @@ -342,7 +342,7 @@ public: class LocAsInteger : public NonLoc { friend class clang::SValBuilder; - LocAsInteger(const std::pair& data) : + explicit LocAsInteger(const std::pair& data) : NonLoc(LocAsIntegerKind, &data) { assert (isa(data.first)); } @@ -376,7 +376,7 @@ public: class CompoundVal : public NonLoc { friend class clang::SValBuilder; - CompoundVal(const CompoundValData* D) : NonLoc(CompoundValKind, D) {} + explicit CompoundVal(const CompoundValData* D) : NonLoc(CompoundValKind, D) {} public: const CompoundValData* getValue() const { @@ -399,7 +399,7 @@ public: class LazyCompoundVal : public NonLoc { friend class clang::SValBuilder; - LazyCompoundVal(const LazyCompoundValData *D) + explicit LazyCompoundVal(const LazyCompoundValData *D) : NonLoc(LazyCompoundValKind, D) {} public: const LazyCompoundValData *getCVData() const { @@ -429,7 +429,7 @@ enum Kind { GotoLabelKind, MemRegionKind, ConcreteIntKind }; class GotoLabel : public Loc { public: - GotoLabel(LabelStmt* Label) : Loc(GotoLabelKind, Label) {} + explicit GotoLabel(LabelStmt* Label) : Loc(GotoLabelKind, Label) {} const LabelStmt* getLabel() const { return static_cast(Data); @@ -448,7 +448,7 @@ public: class MemRegionVal : public Loc { public: - MemRegionVal(const MemRegion* r) : Loc(MemRegionKind, r) {} + explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionKind, r) {} const MemRegion* getRegion() const { return static_cast(Data); @@ -482,7 +482,7 @@ public: class ConcreteInt : public Loc { public: - ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {} + explicit ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {} const llvm::APSInt& getValue() const { return *static_cast(Data); diff --git a/lib/Checker/GRState.cpp b/lib/Checker/GRState.cpp index e5653f8fd8..3282664cda 100644 --- a/lib/Checker/GRState.cpp +++ b/lib/Checker/GRState.cpp @@ -247,7 +247,7 @@ const GRState *GRState::assumeInBound(DefinedOrUnknownSVal Idx, BasicValueFactory &BVF = svalBuilder.getBasicValueFactory(); // FIXME: This should be using ValueManager::ArrayindexTy...somehow. QualType indexTy = Ctx.IntTy; - nonloc::ConcreteInt Min = BVF.getMinValue(indexTy); + nonloc::ConcreteInt Min(BVF.getMinValue(indexTy)); // Adjust the index. SVal newIdx = svalBuilder.evalBinOpNN(this, BO_Add, -- 2.40.0