r326757 - [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

Eugene Zelenko via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 5 16:47:41 PST 2018


Author: eugenezelenko
Date: Mon Mar  5 16:47:41 2018
New Revision: 326757

URL: http://llvm.org/viewvc/llvm-project?rev=326757&view=rev
Log:
[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
    cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h Mon Mar  5 16:47:41 2018
@@ -14,33 +14,28 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATETRAIT_H
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATETRAIT_H
 
+#include "llvm/ADT/ImmutableList.h"
+#include "llvm/ADT/ImmutableMap.h"
+#include "llvm/ADT/ImmutableSet.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/DataTypes.h"
-
-namespace llvm {
-  template <typename K, typename D, typename I> class ImmutableMap;
-  template <typename K, typename I> class ImmutableSet;
-  template <typename T> class ImmutableList;
-  template <typename T> class ImmutableListImpl;
-}
+#include <cstdint>
 
 namespace clang {
-
 namespace ento {
+
   template <typename T> struct ProgramStatePartialTrait;
 
   /// Declares a program state trait for type \p Type called \p Name, and
-  /// introduce a typedef named \c NameTy.
+  /// introduce a type named \c NameTy.
   /// The macro should not be used inside namespaces, or for traits that must
   /// be accessible from more than one translation unit.
   #define REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, Type) \
     namespace { \
       class Name {}; \
-      typedef Type Name ## Ty; \
+      using Name ## Ty = Type; \
     } \
     namespace clang { \
     namespace ento { \
@@ -52,28 +47,30 @@ namespace ento {
     } \
     }
 
-
   // Partial-specialization for ImmutableMap.
-
   template <typename Key, typename Data, typename Info>
-  struct ProgramStatePartialTrait< llvm::ImmutableMap<Key,Data,Info> > {
-    typedef llvm::ImmutableMap<Key,Data,Info> data_type;
-    typedef typename data_type::Factory&      context_type;
-    typedef Key                               key_type;
-    typedef Data                              value_type;
-    typedef const value_type*                 lookup_type;
+  struct ProgramStatePartialTrait<llvm::ImmutableMap<Key, Data, Info>> {
+    using data_type = llvm::ImmutableMap<Key, Data, Info>;
+    using context_type = typename data_type::Factory &;
+    using key_type = Key;
+    using value_type = Data;
+    using lookup_type = const value_type *;
 
-    static inline data_type MakeData(void *const* p) {
-      return p ? data_type((typename data_type::TreeTy*) *p)
+    static data_type MakeData(void *const *p) {
+      return p ? data_type((typename data_type::TreeTy *) *p)
                : data_type(nullptr);
     }
-    static inline void *MakeVoidPtr(data_type B) {
+
+    static void *MakeVoidPtr(data_type B) {
       return B.getRoot();
     }
+
     static lookup_type Lookup(data_type B, key_type K) {
       return B.lookup(K);
     }
-    static data_type Set(data_type B, key_type K, value_type E,context_type F){
+
+    static data_type Set(data_type B, key_type K, value_type E,
+                         context_type F) {
       return F.add(B, K, E);
     }
 
@@ -85,8 +82,8 @@ namespace ento {
       return B.contains(K);
     }
 
-    static inline context_type MakeContext(void *p) {
-      return *((typename data_type::Factory*) p);
+    static context_type MakeContext(void *p) {
+      return *((typename data_type::Factory *) p);
     }
 
     static void *CreateContext(llvm::BumpPtrAllocator& Alloc) {
@@ -94,7 +91,7 @@ namespace ento {
     }
 
     static void DeleteContext(void *Ctx) {
-      delete (typename data_type::Factory*) Ctx;
+      delete (typename data_type::Factory *) Ctx;
     }
   };
 
@@ -107,21 +104,19 @@ namespace ento {
   /// can deal with.
   #define CLANG_ENTO_PROGRAMSTATE_MAP(Key, Value) llvm::ImmutableMap<Key, Value>
 
-
   // Partial-specialization for ImmutableSet.
-
   template <typename Key, typename Info>
-  struct ProgramStatePartialTrait< llvm::ImmutableSet<Key,Info> > {
-    typedef llvm::ImmutableSet<Key,Info>      data_type;
-    typedef typename data_type::Factory&      context_type;
-    typedef Key                               key_type;
+  struct ProgramStatePartialTrait<llvm::ImmutableSet<Key, Info>> {
+    using data_type = llvm::ImmutableSet<Key, Info>;
+    using context_type = typename data_type::Factory &;
+    using key_type = Key;
 
-    static inline data_type MakeData(void *const* p) {
-      return p ? data_type((typename data_type::TreeTy*) *p)
+    static data_type MakeData(void *const *p) {
+      return p ? data_type((typename data_type::TreeTy *) *p)
                : data_type(nullptr);
     }
 
-    static inline void *MakeVoidPtr(data_type B) {
+    static void *MakeVoidPtr(data_type B) {
       return B.getRoot();
     }
 
@@ -137,27 +132,25 @@ namespace ento {
       return B.contains(K);
     }
 
-    static inline context_type MakeContext(void *p) {
-      return *((typename data_type::Factory*) p);
+    static context_type MakeContext(void *p) {
+      return *((typename data_type::Factory *) p);
     }
 
-    static void *CreateContext(llvm::BumpPtrAllocator& Alloc) {
+    static void *CreateContext(llvm::BumpPtrAllocator &Alloc) {
       return new typename data_type::Factory(Alloc);
     }
 
     static void DeleteContext(void *Ctx) {
-      delete (typename data_type::Factory*) Ctx;
+      delete (typename data_type::Factory *) Ctx;
     }
   };
 
-
   // Partial-specialization for ImmutableList.
-
   template <typename T>
-  struct ProgramStatePartialTrait< llvm::ImmutableList<T> > {
-    typedef llvm::ImmutableList<T>            data_type;
-    typedef T                                 key_type;
-    typedef typename data_type::Factory&      context_type;
+  struct ProgramStatePartialTrait<llvm::ImmutableList<T>> {
+    using data_type = llvm::ImmutableList<T>;
+    using key_type = T;
+    using context_type = typename data_type::Factory &;
 
     static data_type Add(data_type L, key_type K, context_type F) {
       return F.add(K, L);
@@ -167,83 +160,84 @@ namespace ento {
       return L.contains(K);
     }
 
-    static inline data_type MakeData(void *const* p) {
-      return p ? data_type((const llvm::ImmutableListImpl<T>*) *p)
+    static data_type MakeData(void *const *p) {
+      return p ? data_type((const llvm::ImmutableListImpl<T> *) *p)
                : data_type(nullptr);
     }
 
-    static inline void *MakeVoidPtr(data_type D) {
+    static void *MakeVoidPtr(data_type D) {
       return const_cast<llvm::ImmutableListImpl<T> *>(D.getInternalPointer());
     }
 
-    static inline context_type MakeContext(void *p) {
-      return *((typename data_type::Factory*) p);
+    static context_type MakeContext(void *p) {
+      return *((typename data_type::Factory *) p);
     }
 
-    static void *CreateContext(llvm::BumpPtrAllocator& Alloc) {
+    static void *CreateContext(llvm::BumpPtrAllocator &Alloc) {
       return new typename data_type::Factory(Alloc);
     }
 
     static void DeleteContext(void *Ctx) {
-      delete (typename data_type::Factory*) Ctx;
+      delete (typename data_type::Factory *) Ctx;
     }
   };
 
-
   // Partial specialization for bool.
   template <> struct ProgramStatePartialTrait<bool> {
-    typedef bool data_type;
+    using data_type = bool;
 
-    static inline data_type MakeData(void *const* p) {
+    static data_type MakeData(void *const *p) {
       return p ? (data_type) (uintptr_t) *p
                : data_type();
     }
-    static inline void *MakeVoidPtr(data_type d) {
-      return (void*) (uintptr_t) d;
+
+    static void *MakeVoidPtr(data_type d) {
+      return (void *) (uintptr_t) d;
     }
   };
 
   // Partial specialization for unsigned.
   template <> struct ProgramStatePartialTrait<unsigned> {
-    typedef unsigned data_type;
+    using data_type = unsigned;
 
-    static inline data_type MakeData(void *const* p) {
+    static data_type MakeData(void *const *p) {
       return p ? (data_type) (uintptr_t) *p
                : data_type();
     }
-    static inline void *MakeVoidPtr(data_type d) {
-      return (void*) (uintptr_t) d;
+
+    static void *MakeVoidPtr(data_type d) {
+      return (void *) (uintptr_t) d;
     }
   };
 
   // Partial specialization for void*.
-  template <> struct ProgramStatePartialTrait<void*> {
-    typedef void *data_type;
+  template <> struct ProgramStatePartialTrait<void *> {
+    using data_type = void *;
 
-    static inline data_type MakeData(void *const* p) {
+    static data_type MakeData(void *const *p) {
       return p ? *p
                : data_type();
     }
-    static inline void *MakeVoidPtr(data_type d) {
+
+    static void *MakeVoidPtr(data_type d) {
       return d;
     }
   };
 
   // Partial specialization for const void *.
   template <> struct ProgramStatePartialTrait<const void *> {
-    typedef const void *data_type;
+    using data_type = const void *;
 
-    static inline data_type MakeData(void * const *p) {
+    static data_type MakeData(void *const *p) {
       return p ? *p : data_type();
     }
 
-    static inline void *MakeVoidPtr(data_type d) {
+    static void *MakeVoidPtr(data_type d) {
       return const_cast<void *>(d);
     }
   };
 
-} // end ento namespace
-
-} // end clang namespace
+} // namespace ento
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_PROGRAMSTATETRAIT_H

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Mon Mar  5 16:47:41 2018
@@ -16,23 +16,43 @@
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/ImmutableList.h"
+#include "llvm/ADT/Optional.h"
+#include <cstdint>
 
 namespace clang {
 
+class BlockDecl;
 class CXXBoolLiteralExpr;
+class CXXMethodDecl;
+class CXXRecordDecl;
+class DeclaratorDecl;
+class FunctionDecl;
+class LocationContext;
+class StackFrameContext;
+class Stmt;
 
 namespace ento {
 
 class ConditionTruthVal;
+class ProgramStateManager;
+class StoreRef;
 
 class SValBuilder {
   virtual void anchor();
+
 protected:
   ASTContext &Context;
   
@@ -64,14 +84,12 @@ public:
 public:
   SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context,
               ProgramStateManager &stateMgr)
-    : Context(context), BasicVals(context, alloc),
-      SymMgr(context, BasicVals, alloc),
-      MemMgr(context, alloc),
-      StateMgr(stateMgr),
-      ArrayIndexTy(context.LongLongTy),
-      ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
+      : Context(context), BasicVals(context, alloc),
+        SymMgr(context, BasicVals, alloc), MemMgr(context, alloc),
+        StateMgr(stateMgr), ArrayIndexTy(context.LongLongTy),
+        ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {}
 
-  virtual ~SValBuilder() {}
+  virtual ~SValBuilder() = default;
 
   bool haveSameType(const SymExpr *Sym1, const SymExpr *Sym2) {
     return haveSameType(Sym1->getType(), Sym2->getType());
@@ -195,11 +213,11 @@ public:
                                         const LocationContext *LCtx,
                                         QualType type,
                                         unsigned count);
-  
   DefinedOrUnknownSVal conjureSymbolVal(const Stmt *stmt,
                                         const LocationContext *LCtx,
                                         QualType type,
                                         unsigned visitCount);
+
   /// \brief Conjure a symbol representing heap allocated memory region.
   ///
   /// Note, the expression should represent a location.
@@ -362,8 +380,8 @@ SValBuilder* createSimpleSValBuilder(llv
                                      ASTContext &context,
                                      ProgramStateManager &stateMgr);
 
-} // end GR namespace
+} // namespace ento
 
-} // end clang namespace
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALBUILDER_H

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h Mon Mar  5 16:47:41 2018
@@ -1,4 +1,4 @@
-//== SVals.h - Abstract Values for Static Analysis ---------*- C++ -*--==//
+//===- SVals.h - Abstract Values for Static Analysis ------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -16,11 +16,18 @@
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
 
 #include "clang/AST/Expr.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableList.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <cstdint>
+#include <utility>
 
 //==------------------------------------------------------------------------==//
 //  Base SVal types.
@@ -28,34 +35,40 @@
 
 namespace clang {
 
+class CXXBaseSpecifier;
+class DeclaratorDecl;
+class FunctionDecl;
+class LabelDecl;
+
 namespace ento {
 
+class BasicValueFactory;
 class CompoundValData;
 class LazyCompoundValData;
-class PointerToMemberData;
-class ProgramState;
-class BasicValueFactory;
 class MemRegion;
-class TypedValueRegion;
-class MemRegionManager;
-class ProgramStateManager;
+class PointerToMemberData;
 class SValBuilder;
+class TypedValueRegion;
 
 namespace nonloc {
+
 /// Sub-kinds for NonLoc values.
 enum Kind {
 #define NONLOC_SVAL(Id, Parent) Id ## Kind,
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
 };
-}
+
+} // namespace nonloc
 
 namespace loc {
+
 /// Sub-kinds for Loc values.
 enum Kind {
 #define LOC_SVAL(Id, Parent) Id ## Kind,
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
 };
-}
+
+} // namespace loc
 
 /// SVal - This represents a symbolic expression, which can be either
 ///  an L-value or an R-value.
@@ -71,20 +84,19 @@ public:
   enum { BaseBits = 2, BaseMask = 0x3 };
 
 protected:
-  const void *Data;
+  const void *Data = nullptr;
 
   /// The lowest 2 bits are a BaseKind (0 -- 3).
   ///  The higher bits are an unsigned "kind" value.
-  unsigned Kind;
+  unsigned Kind = 0;
 
   explicit SVal(const void *d, bool isLoc, unsigned ValKind)
-  : Data(d), Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {}
+      : Data(d), Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {}
 
-  explicit SVal(BaseKind k, const void *D = nullptr)
-    : Data(D), Kind(k) {}
+  explicit SVal(BaseKind k, const void *D = nullptr) : Data(D), Kind(k) {}
 
 public:
-  explicit SVal() : Data(nullptr), Kind(0) {}
+  explicit SVal() = default;
 
   /// \brief Convert to the specified SVal type, asserting that this SVal is of
   /// the desired type.
@@ -103,38 +115,38 @@ public:
     return *static_cast<const T *>(this);
   }
 
-  inline unsigned getRawKind() const { return Kind; }
-  inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
+  unsigned getRawKind() const { return Kind; }
+  BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
+  unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
 
   // This method is required for using SVal in a FoldingSetNode.  It
   // extracts a unique signature for this SVal object.
-  inline void Profile(llvm::FoldingSetNodeID& ID) const {
+  void Profile(llvm::FoldingSetNodeID &ID) const {
     ID.AddInteger((unsigned) getRawKind());
     ID.AddPointer(Data);
   }
 
-  inline bool operator==(const SVal& R) const {
+  bool operator==(const SVal &R) const {
     return getRawKind() == R.getRawKind() && Data == R.Data;
   }
 
-  inline bool operator!=(const SVal& R) const {
+  bool operator!=(const SVal &R) const {
     return !(*this == R);
   }
 
-  inline bool isUnknown() const {
+  bool isUnknown() const {
     return getRawKind() == UnknownValKind;
   }
 
-  inline bool isUndef() const {
+  bool isUndef() const {
     return getRawKind() == UndefinedValKind;
   }
 
-  inline bool isUnknownOrUndef() const {
+  bool isUnknownOrUndef() const {
     return getRawKind() <= UnknownValKind;
   }
 
-  inline bool isValid() const {
+  bool isValid() const {
     return getRawKind() > UnknownValKind;
   }
 
@@ -175,7 +187,7 @@ public:
   ///  return that expression.  Otherwise return NULL.
   const SymExpr *getAsSymbolicExpression() const;
 
-  const SymExpr* getAsSymExpr() const;
+  const SymExpr *getAsSymExpr() const;
 
   const MemRegion *getAsRegion() const;
 
@@ -206,28 +218,28 @@ public:
 
 private:
   friend class SVal;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == UndefinedValKind;
   }
 };
 
 class DefinedOrUnknownSVal : public SVal {
-private:
+public:
   // We want calling these methods to be a compiler error since they are
   // tautologically false.
   bool isUndef() const = delete;
   bool isValid() const = delete;
   
 protected:
-  DefinedOrUnknownSVal() {}
+  DefinedOrUnknownSVal() = default;
   explicit DefinedOrUnknownSVal(const void *d, bool isLoc, unsigned ValKind)
-    : SVal(d, isLoc, ValKind) {}
-  
-  explicit DefinedOrUnknownSVal(BaseKind k, void *D = nullptr)
-    : SVal(k, D) {}
+      : SVal(d, isLoc, ValKind) {}
+  explicit DefinedOrUnknownSVal(BaseKind k, void *D = nullptr) : SVal(k, D) {}
   
 private:
   friend class SVal;
+
   static bool isKind(const SVal& V) {
     return !V.isUndef();
   }
@@ -239,37 +251,43 @@ public:
   
 private:
   friend class SVal;
+
   static bool isKind(const SVal &V) {
     return V.getBaseKind() == UnknownValKind;
   }
 };
 
 class DefinedSVal : public DefinedOrUnknownSVal {
-private:
+public:
   // We want calling these methods to be a compiler error since they are
   // tautologically true/false.
   bool isUnknown() const = delete;
   bool isUnknownOrUndef() const = delete;
   bool isValid() const = delete;
+
 protected:
-  DefinedSVal() {}
+  DefinedSVal() = default;
   explicit DefinedSVal(const void *d, bool isLoc, unsigned ValKind)
-    : DefinedOrUnknownSVal(d, isLoc, ValKind) {}
+      : DefinedOrUnknownSVal(d, isLoc, ValKind) {}
+
 private:
   friend class SVal;
+
   static bool isKind(const SVal& V) {
     return !V.isUnknownOrUndef();
   }
 };
 
-
 /// \brief Represents an SVal that is guaranteed to not be UnknownVal.
 class KnownSVal : public SVal {
-  KnownSVal() {}
   friend class SVal;
+
+  KnownSVal() = default;
+
   static bool isKind(const SVal &V) {
     return !V.isUnknown();
   }
+
 public:
   KnownSVal(const DefinedSVal &V) : SVal(V) {}
   KnownSVal(const UndefinedVal &V) : SVal(V) {}
@@ -277,20 +295,21 @@ public:
 
 class NonLoc : public DefinedSVal {
 protected:
-  NonLoc() {}
+  NonLoc() = default;
   explicit NonLoc(unsigned SubKind, const void *d)
-    : DefinedSVal(d, false, SubKind) {}
+      : DefinedSVal(d, false, SubKind) {}
 
 public:
   void dumpToStream(raw_ostream &Out) const;
 
-  static inline bool isCompoundType(QualType T) {
+  static bool isCompoundType(QualType T) {
     return T->isArrayType() || T->isRecordType() ||
            T->isComplexType() || T->isVectorType();
   }
 
 private:
   friend class SVal;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind;
   }
@@ -298,20 +317,21 @@ private:
 
 class Loc : public DefinedSVal {
 protected:
-  Loc() {}
+  Loc() = default;
   explicit Loc(unsigned SubKind, const void *D)
-  : DefinedSVal(const_cast<void*>(D), true, SubKind) {}
+      : DefinedSVal(const_cast<void *>(D), true, SubKind) {}
 
 public:
   void dumpToStream(raw_ostream &Out) const;
 
-  static inline bool isLocType(QualType T) {
+  static bool isLocType(QualType T) {
     return T->isAnyPointerType() || T->isBlockPointerType() || 
            T->isReferenceType() || T->isNullPtrType();
   }
 
 private:
   friend class SVal;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == LocKind;
   }
@@ -330,7 +350,7 @@ public:
   SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) { assert(sym); }
 
   SymbolRef getSymbol() const {
-    return (const SymExpr*) Data;
+    return (const SymExpr *) Data;
   }
 
   bool isExpression() const {
@@ -339,6 +359,7 @@ public:
 
 private:
   friend class SVal;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind &&
            V.getSubKind() == SymbolValKind;
@@ -355,7 +376,7 @@ public:
   explicit ConcreteInt(const llvm::APSInt& V) : NonLoc(ConcreteIntKind, &V) {}
 
   const llvm::APSInt& getValue() const {
-    return *static_cast<const llvm::APSInt*>(Data);
+    return *static_cast<const llvm::APSInt *>(Data);
   }
 
   // Transfer functions for binary/unary operations on ConcreteInts.
@@ -368,7 +389,9 @@ public:
 
 private:
   friend class SVal;
-  ConcreteInt() {}
+
+  ConcreteInt() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind &&
            V.getSubKind() == ConcreteIntKind;
@@ -392,7 +415,6 @@ class LocAsInteger : public NonLoc {
   }
 
 public:
-
   Loc getLoc() const {
     const std::pair<SVal, uintptr_t> *D =
       static_cast<const std::pair<SVal, uintptr_t> *>(Data);
@@ -414,7 +436,9 @@ public:
 
 private:
   friend class SVal;
-  LocAsInteger() {}
+
+  LocAsInteger() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind &&
            V.getSubKind() == LocAsIntegerKind;
@@ -432,16 +456,19 @@ class CompoundVal : public NonLoc {
 
 public:
   const CompoundValData* getValue() const {
-    return static_cast<const CompoundValData*>(Data);
+    return static_cast<const CompoundValData *>(Data);
   }
 
-  typedef llvm::ImmutableList<SVal>::iterator iterator;
+  using iterator = llvm::ImmutableList<SVal>::iterator;
+
   iterator begin() const;
   iterator end() const;
 
 private:
   friend class SVal;
-  CompoundVal() {}
+
+  CompoundVal() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind && V.getSubKind() == CompoundValKind;
   }
@@ -455,21 +482,26 @@ class LazyCompoundVal : public NonLoc {
   friend class ento::SValBuilder;
 
   explicit LazyCompoundVal(const LazyCompoundValData *D)
-    : NonLoc(LazyCompoundValKind, D) {}
+      : NonLoc(LazyCompoundValKind, D) {}
+
 public:
   const LazyCompoundValData *getCVData() const {
-    return static_cast<const LazyCompoundValData*>(Data);
+    return static_cast<const LazyCompoundValData *>(Data);
   }
+
   const void *getStore() const;
   const TypedValueRegion *getRegion() const;
 
 private:
   friend class SVal;
-  LazyCompoundVal() {}
+
+  LazyCompoundVal() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind &&
            V.getSubKind() == LazyCompoundValKind;
   }
+
   static bool isKind(const NonLoc& V) {
     return V.getSubKind() == LazyCompoundValKind;
   }
@@ -488,28 +520,36 @@ class PointerToMember : public NonLoc {
   friend class ento::SValBuilder;
 
 public:
-  typedef llvm::PointerUnion<const DeclaratorDecl *,
-                             const PointerToMemberData *> PTMDataType;
+  using PTMDataType =
+      llvm::PointerUnion<const DeclaratorDecl *, const PointerToMemberData *>;
+
   const PTMDataType getPTMData() const {
     return PTMDataType::getFromOpaqueValue(const_cast<void *>(Data));
   }
+
   bool isNullMemberPointer() const {
     return getPTMData().isNull();
   }
+
   const DeclaratorDecl *getDecl() const;
+
   template<typename AdjustedDecl>
-  const AdjustedDecl* getDeclAs() const {
+  const AdjustedDecl *getDeclAs() const {
     return dyn_cast_or_null<AdjustedDecl>(getDecl());
   }
-  typedef llvm::ImmutableList<const CXXBaseSpecifier *>::iterator iterator;
+
+  using iterator = llvm::ImmutableList<const CXXBaseSpecifier *>::iterator;
+
   iterator begin() const;
   iterator end() const;
 
 private:
-  explicit PointerToMember(const PTMDataType D)
-    : NonLoc(PointerToMemberKind, D.getOpaqueValue()) {}
   friend class SVal;
-  PointerToMember() {}
+
+  PointerToMember() = default;
+  explicit PointerToMember(const PTMDataType D)
+      : NonLoc(PointerToMemberKind, D.getOpaqueValue()) {}
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == NonLocKind &&
            V.getSubKind() == PointerToMemberKind;
@@ -520,7 +560,7 @@ private:
   }
 };
 
-} // end namespace ento::nonloc
+} // namespace nonloc
 
 //==------------------------------------------------------------------------==//
 //  Subclasses of Loc.
@@ -535,12 +575,14 @@ public:
   }
 
   const LabelDecl *getLabel() const {
-    return static_cast<const LabelDecl*>(Data);
+    return static_cast<const LabelDecl *>(Data);
   }
 
 private:
   friend class SVal;
-  GotoLabel() {}
+
+  GotoLabel() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == LocKind && V.getSubKind() == GotoLabelKind;
   }
@@ -550,7 +592,6 @@ private:
   }
 };
 
-
 class MemRegionVal : public Loc {
 public:
   explicit MemRegionVal(const MemRegion* r) : Loc(MemRegionValKind, r) {
@@ -558,8 +599,8 @@ public:
   }
 
   /// \brief Get the underlining region.
-  const MemRegion* getRegion() const {
-    return static_cast<const MemRegion*>(Data);
+  const MemRegion *getRegion() const {
+    return static_cast<const MemRegion *>(Data);
   }
 
   /// \brief Get the underlining region and strip casts.
@@ -570,17 +611,19 @@ public:
     return dyn_cast<REGION>(getRegion());
   }
 
-  inline bool operator==(const MemRegionVal& R) const {
+  bool operator==(const MemRegionVal &R) const {
     return getRegion() == R.getRegion();
   }
 
-  inline bool operator!=(const MemRegionVal& R) const {
+  bool operator!=(const MemRegionVal &R) const {
     return getRegion() != R.getRegion();
   }
 
 private:
   friend class SVal;
-  MemRegionVal() {}
+
+  MemRegionVal() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == LocKind &&
            V.getSubKind() == MemRegionValKind;
@@ -595,8 +638,8 @@ class ConcreteInt : public Loc {
 public:
   explicit ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {}
 
-  const llvm::APSInt& getValue() const {
-    return *static_cast<const llvm::APSInt*>(Data);
+  const llvm::APSInt &getValue() const {
+    return *static_cast<const llvm::APSInt *>(Data);
   }
 
   // Transfer functions for binary/unary operations on ConcreteInts.
@@ -605,7 +648,9 @@ public:
 
 private:
   friend class SVal;
-  ConcreteInt() {}
+
+  ConcreteInt() = default;
+
   static bool isKind(const SVal& V) {
     return V.getBaseKind() == LocKind &&
            V.getSubKind() == ConcreteIntKind;
@@ -616,11 +661,11 @@ private:
   }
 };
 
-} // end ento::loc namespace
+} // namespace loc 
 
-} // end ento namespace
+} // namespace ento
 
-} // end clang namespace
+} // namespace clang
 
 namespace llvm {
 
@@ -629,6 +674,6 @@ template <> struct isPodLike<clang::ento
   static const bool value = true;
 };
 
-} // end llvm namespace
+} // namespace llvm
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h Mon Mar  5 16:47:41 2018
@@ -1,4 +1,4 @@
-//== SymbolManager.h - Management of Symbolic Values ------------*- C++ -*--==//
+//===- SymbolManager.h - Management of Symbolic Values ----------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -15,8 +15,8 @@
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H
 
-#include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/Type.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -26,17 +26,17 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/DataTypes.h"
+#include <cassert>
 
 namespace clang {
-  class ASTContext;
-  class StackFrameContext;
+
+class ASTContext;
+class Stmt;
 
 namespace ento {
-  class BasicValueFactory;
-  class SubRegion;
-  class TypedValueRegion;
-  class VarRegion;
+
+class BasicValueFactory;
+class StoreManager;
 
 ///\brief A symbol representing the value stored at a MemRegion.
 class SymbolRegionValue : public SymbolData {
@@ -66,7 +66,7 @@ public:
   QualType getType() const override;
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymbolRegionValueKind;
   }
 };
@@ -118,7 +118,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymbolConjuredKind;
   }
 };
@@ -157,7 +157,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymbolDerivedKind;
   }
 };
@@ -190,7 +190,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymbolExtentKind;
   }
 };
@@ -206,11 +206,12 @@ class SymbolMetadata : public SymbolData
   const LocationContext *LCtx;
   unsigned Count;
   const void *Tag;
+
 public:
   SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
                  const LocationContext *LCtx, unsigned count, const void *tag)
-  : SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), LCtx(LCtx),
-    Count(count), Tag(tag) {
+      : SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), LCtx(LCtx),
+        Count(count), Tag(tag) {
       assert(r);
       assert(s);
       assert(isValidTypeForSymbol(t));
@@ -245,7 +246,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymbolMetadataKind;
   }
 };
@@ -253,8 +254,10 @@ public:
 /// \brief Represents a cast expression.
 class SymbolCast : public SymExpr {
   const SymExpr *Operand;
+
   /// Type of the operand.
   QualType FromTy;
+
   /// The type of the result.
   QualType ToTy;
 
@@ -286,7 +289,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymbolCastKind;
   }
 };
@@ -311,7 +314,7 @@ public:
   BinaryOperator::Opcode getOpcode() const { return Op; }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     Kind k = SE->getKind();
     return k >= BEGIN_BINARYSYMEXPRS && k <= END_BINARYSYMEXPRS;
   }
@@ -349,7 +352,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymIntExprKind;
   }
 };
@@ -386,7 +389,7 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == IntSymExprKind;
   }
 };
@@ -423,20 +426,22 @@ public:
   }
 
   // Implement isa<T> support.
-  static inline bool classof(const SymExpr *SE) {
+  static bool classof(const SymExpr *SE) {
     return SE->getKind() == SymSymExprKind;
   }
 };
 
 class SymbolManager {
-  typedef llvm::FoldingSet<SymExpr> DataSetTy;
-  typedef llvm::DenseMap<SymbolRef, SymbolRefSmallVectorTy*> SymbolDependTy;
+  using DataSetTy = llvm::FoldingSet<SymExpr>;
+  using SymbolDependTy = llvm::DenseMap<SymbolRef, SymbolRefSmallVectorTy *>;
 
   DataSetTy DataSet;
+
   /// Stores the extra dependencies between symbols: the data should be kept
   /// alive as long as the key is live.
   SymbolDependTy SymbolDependencies;
-  unsigned SymbolCounter;
+
+  unsigned SymbolCounter = 0;
   llvm::BumpPtrAllocator& BPAlloc;
   BasicValueFactory &BV;
   ASTContext &Ctx;
@@ -444,9 +449,7 @@ class SymbolManager {
 public:
   SymbolManager(ASTContext &ctx, BasicValueFactory &bv,
                 llvm::BumpPtrAllocator& bpalloc)
-    : SymbolDependencies(16), SymbolCounter(0),
-      BPAlloc(bpalloc), BV(bv), Ctx(ctx) {}
-
+      : SymbolDependencies(16), BPAlloc(bpalloc), BV(bv), Ctx(ctx) {}
   ~SymbolManager();
 
   static bool canSymbolicate(QualType T);
@@ -522,9 +525,9 @@ class SymbolReaper {
     HaveMarkedDependents
   };
 
-  typedef llvm::DenseSet<SymbolRef> SymbolSetTy;
-  typedef llvm::DenseMap<SymbolRef, SymbolStatus> SymbolMapTy;
-  typedef llvm::DenseSet<const MemRegion *> RegionSetTy;
+  using SymbolSetTy = llvm::DenseSet<SymbolRef>;
+  using SymbolMapTy = llvm::DenseMap<SymbolRef, SymbolStatus>;
+  using RegionSetTy = llvm::DenseSet<const MemRegion *>;
 
   SymbolMapTy TheLiving;
   SymbolSetTy MetadataInUse;
@@ -546,10 +549,9 @@ public:
   /// considered live.
   /// If the stack frame context is NULL, everything on stack is considered
   /// dead.
-  SymbolReaper(const StackFrameContext *Ctx, const Stmt *s, SymbolManager& symmgr,
-               StoreManager &storeMgr)
-   : LCtx(Ctx), Loc(s), SymMgr(symmgr),
-     reapedStore(nullptr, storeMgr) {}
+  SymbolReaper(const StackFrameContext *Ctx, const Stmt *s,
+               SymbolManager &symmgr, StoreManager &storeMgr)
+      : LCtx(Ctx), Loc(s), SymMgr(symmgr), reapedStore(nullptr, storeMgr) {}
 
   const LocationContext *getLocationContext() const { return LCtx; }
 
@@ -580,7 +582,8 @@ public:
   ///  Returns true if the symbol is dead, false if live.
   bool maybeDead(SymbolRef sym);
 
-  typedef SymbolSetTy::const_iterator dead_iterator;
+  using dead_iterator = SymbolSetTy::const_iterator;
+
   dead_iterator dead_begin() const { return TheDead.begin(); }
   dead_iterator dead_end() const { return TheDead.end(); }
 
@@ -588,7 +591,8 @@ public:
     return !TheDead.empty();
   }
   
-  typedef RegionSetTy::const_iterator region_iterator;
+  using region_iterator = RegionSetTy::const_iterator;
+
   region_iterator region_begin() const { return RegionRoots.begin(); }
   region_iterator region_end() const { return RegionRoots.end(); }
 
@@ -629,8 +633,8 @@ public:
   virtual bool VisitMemRegion(const MemRegion *region) { return true; }
 };
 
-} // end GR namespace
+} // namespace ento
 
-} // end clang namespace
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SYMBOLMANAGER_H

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Mon Mar  5 16:47:41 2018
@@ -1,4 +1,4 @@
-// SValBuilder.cpp - Basic class for all SValBuilder implementations -*- C++ -*-
+//===- SValBuilder.cpp - Basic class for all SValBuilder implementations --===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -13,12 +13,31 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprObjC.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.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/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include <cassert>
+#include <tuple>
 
 using namespace clang;
 using namespace ento;
@@ -27,7 +46,7 @@ using namespace ento;
 // Basic SVal creation.
 //===----------------------------------------------------------------------===//
 
-void SValBuilder::anchor() { }
+void SValBuilder::anchor() {}
 
 DefinedOrUnknownSVal SValBuilder::makeZeroVal(QualType type) {
   if (Loc::isLocType(type))
@@ -95,7 +114,7 @@ nonloc::ConcreteInt SValBuilder::makeBoo
 }
 
 DefinedOrUnknownSVal
-SValBuilder::getRegionValueSymbolVal(const TypedValueRegion* region) {
+SValBuilder::getRegionValueSymbolVal(const TypedValueRegion *region) {
   QualType T = region->getValueType();
 
   if (T->isNullPtrType())
@@ -149,7 +168,6 @@ DefinedOrUnknownSVal SValBuilder::conjur
   return nonloc::SymbolVal(sym);
 }
 
-
 DefinedOrUnknownSVal SValBuilder::conjureSymbolVal(const Stmt *stmt,
                                                    const LocationContext *LCtx,
                                                    QualType type,
@@ -217,10 +235,10 @@ SValBuilder::getDerivedRegionValueSymbol
   return nonloc::SymbolVal(sym);
 }
 
-DefinedSVal SValBuilder::getMemberPointer(const DeclaratorDecl* DD) {
+DefinedSVal SValBuilder::getMemberPointer(const DeclaratorDecl *DD) {
   assert(!DD || isa<CXXMethodDecl>(DD) || isa<FieldDecl>(DD));
 
-  if (auto *MD = dyn_cast_or_null<CXXMethodDecl>(DD)) {
+  if (const auto *MD = dyn_cast_or_null<CXXMethodDecl>(DD)) {
     // Sema treats pointers to static member functions as have function pointer
     // type, so return a function pointer for the method.
     // We don't need to play a similar trick for static member fields
@@ -277,19 +295,19 @@ Optional<SVal> SValBuilder::getConstantV
     return makeZeroVal(E->getType());
 
   case Stmt::ObjCStringLiteralClass: {
-    const ObjCStringLiteral *SL = cast<ObjCStringLiteral>(E);
+    const auto *SL = cast<ObjCStringLiteral>(E);
     return makeLoc(getRegionManager().getObjCStringRegion(SL));
   }
 
   case Stmt::StringLiteralClass: {
-    const StringLiteral *SL = cast<StringLiteral>(E);
+    const auto *SL = cast<StringLiteral>(E);
     return makeLoc(getRegionManager().getStringRegion(SL));
   }
 
   // Fast-path some expressions to avoid the overhead of going through the AST's
   // constant evaluator
   case Stmt::CharacterLiteralClass: {
-    const CharacterLiteral *C = cast<CharacterLiteral>(E);
+    const auto *C = cast<CharacterLiteral>(E);
     return makeIntVal(C->getValue(), C->getType());
   }
 
@@ -297,7 +315,7 @@ Optional<SVal> SValBuilder::getConstantV
     return makeBoolVal(cast<CXXBoolLiteralExpr>(E));
 
   case Stmt::TypeTraitExprClass: {
-    const TypeTraitExpr *TE = cast<TypeTraitExpr>(E);
+    const auto *TE = cast<TypeTraitExpr>(E);
     return makeTruthVal(TE->getValue(), TE->getType());
   }
 
@@ -311,7 +329,7 @@ Optional<SVal> SValBuilder::getConstantV
     return makeNull();
 
   case Stmt::ImplicitCastExprClass: {
-    const CastExpr *CE = cast<CastExpr>(E);
+    const auto *CE = cast<CastExpr>(E);
     switch (CE->getCastKind()) {
     default:
       break;
@@ -348,8 +366,6 @@ Optional<SVal> SValBuilder::getConstantV
   }
 }
 
-//===----------------------------------------------------------------------===//
-
 SVal SValBuilder::makeSymExprValNN(ProgramStateRef State,
                                    BinaryOperator::Opcode Op,
                                    NonLoc LHS, NonLoc RHS,
@@ -378,10 +394,8 @@ SVal SValBuilder::makeSymExprValNN(Progr
   return UnknownVal();
 }
 
-
 SVal SValBuilder::evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op,
                             SVal lhs, SVal rhs, QualType type) {
-
   if (lhs.isUndef() || rhs.isUndef())
     return UndefinedVal();
 
@@ -463,7 +477,6 @@ static bool shouldBeModeledWithNoOp(ASTC
 // of the original value is known to be greater than the max of the target type.
 SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val,
                                    QualType castTy, QualType originalTy) {
-
   // No truncations if target type is big enough.
   if (getContext().getTypeSize(castTy) >= getContext().getTypeSize(originalTy))
     return evalCast(val, castTy, originalTy);
@@ -557,8 +570,8 @@ SVal SValBuilder::evalCast(SVal val, Qua
   }
 
   // Check for casts from array type to another type.
-  if (const ArrayType *arrayT =
-                      dyn_cast<ArrayType>(originalTy.getCanonicalType())) {
+  if (const auto *arrayT =
+          dyn_cast<ArrayType>(originalTy.getCanonicalType())) {
     // We will always decay to a pointer.
     QualType elemTy = arrayT->getElementType();
     val = StateMgr.ArrayToPointer(val.castAs<Loc>(), elemTy);

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp Mon Mar  5 16:47:41 2018
@@ -1,4 +1,4 @@
-//= RValues.cpp - Abstract RValues for Path-Sens. Value Tracking -*- C++ -*-==//
+//===- RValues.cpp - Abstract RValues for Path-Sens. Value Tracking -------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -12,20 +12,31 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
-#include "clang/AST/ExprObjC.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "llvm/Support/raw_ostream.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+
 using namespace clang;
 using namespace ento;
-using llvm::APSInt;
 
 //===----------------------------------------------------------------------===//
 // Symbol iteration within an SVal.
 //===----------------------------------------------------------------------===//
 
-
 //===----------------------------------------------------------------------===//
 // Utility methods.
 //===----------------------------------------------------------------------===//
@@ -39,7 +50,7 @@ bool SVal::hasConjuredSymbol() const {
 
   if (Optional<loc::MemRegionVal> RV = getAs<loc::MemRegionVal>()) {
     const MemRegion *R = RV->getRegion();
-    if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R)) {
+    if (const auto *SR = dyn_cast<SymbolicRegion>(R)) {
       SymbolRef sym = SR->getSymbol();
       if (isa<SymbolConjured>(sym))
         return true;
@@ -53,12 +64,12 @@ const FunctionDecl *SVal::getAsFunctionD
   if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
     const MemRegion* R = X->getRegion();
     if (const FunctionCodeRegion *CTR = R->getAs<FunctionCodeRegion>())
-      if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CTR->getDecl()))
+      if (const auto *FD = dyn_cast<FunctionDecl>(CTR->getDecl()))
         return FD;
   }
 
   if (auto X = getAs<nonloc::PointerToMember>()) {
-    if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(X->getDecl()))
+    if (const auto *MD = dyn_cast_or_null<CXXMethodDecl>(X->getDecl()))
       return MD;
   }
   return nullptr;
@@ -95,8 +106,8 @@ SymbolRef SVal::getLocSymbolInBase() con
 
   const MemRegion *R = X->getRegion();
 
-  while (const SubRegion *SR = dyn_cast<SubRegion>(R)) {
-    if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(SR))
+  while (const auto *SR = dyn_cast<SubRegion>(R)) {
+    if (const auto *SymR = dyn_cast<SymbolicRegion>(SR))
       return SymR->getSymbol();
     else
       R = SR->getSuperRegion();
@@ -189,14 +200,14 @@ nonloc::CompoundVal::iterator nonloc::Co
 nonloc::PointerToMember::iterator nonloc::PointerToMember::begin() const {
   const PTMDataType PTMD = getPTMData();
   if (PTMD.is<const DeclaratorDecl *>())
-    return nonloc::PointerToMember::iterator();
+    return {};
   return PTMD.get<const PointerToMemberData *>()->begin();
 }
 
 nonloc::PointerToMember::iterator nonloc::PointerToMember::end() const {
   const PTMDataType PTMD = getPTMData();
   if (PTMD.is<const DeclaratorDecl *>())
-    return nonloc::PointerToMember::iterator();
+    return {};
   return PTMD.get<const PointerToMemberData *>()->end();
 }
 
@@ -220,7 +231,6 @@ bool SVal::isZeroConstant() const {
   return isConstant(0);
 }
 
-
 //===----------------------------------------------------------------------===//
 // Transfer function dispatch for Non-Locs.
 //===----------------------------------------------------------------------===//
@@ -254,7 +264,6 @@ nonloc::ConcreteInt::evalMinus(SValBuild
 SVal loc::ConcreteInt::evalBinOp(BasicValueFactory& BasicVals,
                                  BinaryOperator::Opcode Op,
                                  const loc::ConcreteInt& R) const {
-
   assert(BinaryOperator::isComparisonOp(Op) || Op == BO_Sub);
 
   const llvm::APSInt *X = BasicVals.evalAPSInt(Op, getValue(), R.getValue());
@@ -300,10 +309,10 @@ void NonLoc::dumpToStream(raw_ostream &o
          << C.getValue().getBitWidth() << 'b';
       break;
     }
-    case nonloc::SymbolValKind: {
+    case nonloc::SymbolValKind:
       os << castAs<nonloc::SymbolVal>().getSymbol();
       break;
-    }
+
     case nonloc::LocAsIntegerKind: {
       const nonloc::LocAsInteger& C = castAs<nonloc::LocAsInteger>();
       os << C.getLoc() << " [as " << C.getNumBits() << " bit integer]";
@@ -313,14 +322,14 @@ void NonLoc::dumpToStream(raw_ostream &o
       const nonloc::CompoundVal& C = castAs<nonloc::CompoundVal>();
       os << "compoundVal{";
       bool first = true;
-      for (nonloc::CompoundVal::iterator I=C.begin(), E=C.end(); I!=E; ++I) {
+      for (const auto &I : C) {
         if (first) {
           os << ' '; first = false;
         }
         else
           os << ", ";
 
-        (*I).dumpToStream(os);
+        I.dumpToStream(os);
       }
       os << "}";
       break;
@@ -353,7 +362,7 @@ void NonLoc::dumpToStream(raw_ostream &o
       break;
     }
     default:
-      assert (false && "Pretty-printed not implemented for this NonLoc.");
+      assert(false && "Pretty-printed not implemented for this NonLoc.");
       break;
   }
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp?rev=326757&r1=326756&r2=326757&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp Mon Mar  5 16:47:41 2018
@@ -1,4 +1,4 @@
-//== SymbolManager.h - Management of Symbolic Values ------------*- C++ -*--==//
+//===- SymbolManager.h - Management of Symbolic Values --------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -13,15 +13,27 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
+#include <cassert>
 
 using namespace clang;
 using namespace ento;
 
-void SymExpr::anchor() { }
+void SymExpr::anchor() {}
 
 LLVM_DUMP_METHOD void SymExpr::dump() const {
   dumpToStream(llvm::errs());
@@ -88,7 +100,7 @@ void SymbolMetadata::dumpToStream(raw_os
      << getRegion() << ',' << T.getAsString() << '}';
 }
 
-void SymbolData::anchor() { }
+void SymbolData::anchor() {}
 
 void SymbolRegionValue::dumpToStream(raw_ostream &os) const {
   os << "reg_$" << getSymbolID()
@@ -138,7 +150,7 @@ void SymExpr::symbol_iterator::expand()
       itr.push_back(cast<IntSymExpr>(SE)->getRHS());
       return;
     case SymExpr::SymSymExprKind: {
-      const SymSymExpr *x = cast<SymSymExpr>(SE);
+      const auto *x = cast<SymSymExpr>(SE);
       itr.push_back(x->getLHS());
       itr.push_back(x->getRHS());
       return;
@@ -192,7 +204,6 @@ const SymbolConjured* SymbolManager::con
 const SymbolDerived*
 SymbolManager::getDerivedSymbol(SymbolRef parentSymbol,
                                 const TypedValueRegion *R) {
-
   llvm::FoldingSetNodeID profile;
   SymbolDerived::Profile(profile, parentSymbol, R);
   void *InsertPos;
@@ -227,7 +238,6 @@ const SymbolMetadata *
 SymbolManager::getMetadataSymbol(const MemRegion* R, const Stmt *S, QualType T,
                                  const LocationContext *LCtx,
                                  unsigned Count, const void *SymbolTag) {
-
   llvm::FoldingSetNodeID profile;
   SymbolMetadata::Profile(profile, R, S, T, LCtx, Count, SymbolTag);
   void *InsertPos;
@@ -382,11 +392,10 @@ void SymbolReaper::markDependentsLive(Sy
   LI->second = HaveMarkedDependents;
 
   if (const SymbolRefSmallVectorTy *Deps = SymMgr.getDependentSymbols(sym)) {
-    for (SymbolRefSmallVectorTy::const_iterator I = Deps->begin(),
-                                                E = Deps->end(); I != E; ++I) {
-      if (TheLiving.find(*I) != TheLiving.end())
+    for (const auto I : *Deps) {
+      if (TheLiving.find(I) != TheLiving.end())
         continue;
-      markLive(*I);
+      markLive(I);
     }
   }
 }
@@ -405,7 +414,7 @@ void SymbolReaper::markLive(const MemReg
 void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
   for (auto SR = dyn_cast<SubRegion>(region); SR;
        SR = dyn_cast<SubRegion>(SR->getSuperRegion())) {
-    if (auto ER = dyn_cast<ElementRegion>(SR)) {
+    if (const auto ER = dyn_cast<ElementRegion>(SR)) {
       SVal Idx = ER->getIndex();
       for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI)
         markLive(*SI);
@@ -432,10 +441,10 @@ bool SymbolReaper::isLiveRegion(const Me
 
   MR = MR->getBaseRegion();
 
-  if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR))
+  if (const auto *SR = dyn_cast<SymbolicRegion>(MR))
     return isLive(SR->getSymbol());
 
-  if (const VarRegion *VR = dyn_cast<VarRegion>(MR))
+  if (const auto *VR = dyn_cast<VarRegion>(MR))
     return isLive(VR, true);
 
   // FIXME: This is a gross over-approximation. What we really need is a way to
@@ -547,7 +556,7 @@ bool SymbolReaper::isLive(const VarRegio
       return false;
 
     unsigned &cachedQuery =
-      const_cast<SymbolReaper*>(this)->includedRegionCache[VR];
+      const_cast<SymbolReaper *>(this)->includedRegionCache[VR];
 
     if (cachedQuery) {
       return cachedQuery == 1;




More information about the cfe-commits mailing list