r329115 - [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
Tue Apr 3 14:31:50 PDT 2018


Author: eugenezelenko
Date: Tue Apr  3 14:31:50 2018
New Revision: 329115

URL: http://llvm.org/viewvc/llvm-project?rev=329115&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/CheckerRegistry.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h
    cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h?rev=329115&r1=329114&r2=329115&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerRegistry.h Tue Apr  3 14:31:50 2018
@@ -1,4 +1,4 @@
-//===--- CheckerRegistry.h - Maintains all available checkers ---*- C++ -*-===//
+//===- CheckerRegistry.h - Maintains all available checkers -----*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -12,6 +12,9 @@
 
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include <cstddef>
 #include <vector>
 
 // FIXME: move this information to an HTML file in docs/.
@@ -64,8 +67,9 @@
 #endif
 
 namespace clang {
-class DiagnosticsEngine;
+
 class AnalyzerOptions;
+class DiagnosticsEngine;
 
 namespace ento {
 
@@ -81,17 +85,18 @@ class CheckerRegistry {
 public:
   /// Initialization functions perform any necessary setup for a checker.
   /// They should include a call to CheckerManager::registerChecker.
-  typedef void (*InitializationFunction)(CheckerManager &);
+  using InitializationFunction = void (*)(CheckerManager &);
+
   struct CheckerInfo {
     InitializationFunction Initialize;
     StringRef FullName;
     StringRef Desc;
 
     CheckerInfo(InitializationFunction fn, StringRef name, StringRef desc)
-    : Initialize(fn), FullName(name), Desc(desc) {}
+        : Initialize(fn), FullName(name), Desc(desc) {}
   };
 
-  typedef std::vector<CheckerInfo> CheckerInfoList;
+  using CheckerInfoList = std::vector<CheckerInfo>;
 
 private:
   template <typename T>
@@ -136,7 +141,8 @@ private:
   mutable llvm::StringMap<size_t> Packages;
 };
 
-} // end namespace ento
-} // end namespace clang
+} // namespace ento
 
-#endif
+} // namespace clang
+
+#endif // LLVM_CLANG_STATICANALYZER_CORE_CHECKERREGISTRY_H

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=329115&r1=329114&r2=329115&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Tue Apr  3 14:31:50 2018
@@ -1,4 +1,4 @@
-//== MemRegion.h - Abstract memory regions for static analysis --*- C++ -*--==//
+//==- MemRegion.h - Abstract memory regions for static analysis -*- C++ -*--==//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -19,24 +19,39 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExprObjC.h"
-#include "clang/Analysis/AnalysisDeclContext.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <cstdint>
+#include <limits>
 #include <string>
+#include <utility>
 
 namespace clang {
 
+class AnalysisDeclContext;
+class CXXRecordDecl;
+class Decl;
 class LocationContext;
 class StackFrameContext;
 
 namespace ento {
 
 class CodeTextRegion;
+class MemRegion;
 class MemRegionManager;
 class MemSpaceRegion;
 class SValBuilder;
@@ -46,7 +61,7 @@ class VarRegion;
 /// Represent a region's offset within the top level base region.
 class RegionOffset {
   /// The base region.
-  const MemRegion *R;
+  const MemRegion *R = nullptr;
 
   /// The bit offset within the base region. Can be negative.
   int64_t Offset;
@@ -54,9 +69,9 @@ class RegionOffset {
 public:
   // We're using a const instead of an enumeration due to the size required;
   // Visual Studio will only create enumerations of size int, not long long.
-  static const int64_t Symbolic = INT64_MAX;
+  static const int64_t Symbolic = std::numeric_limits<int64_t>::max();
 
-  RegionOffset() : R(nullptr) {}
+  RegionOffset() = default;
   RegionOffset(const MemRegion *r, int64_t off) : R(r), Offset(off) {}
 
   const MemRegion *getRegion() const { return R; }
@@ -153,7 +168,6 @@ public:
 
   virtual bool isBoundable() const { return false; }
 
-
   /// Get descriptive name for memory region. The name is obtained from
   /// the variable/field declaration retrieved from the memory region.
   /// Regions that point to an element of an array are returned as: "arr[0]".
@@ -164,7 +178,6 @@ public:
   /// \returns variable name for memory region
   std::string getDescriptiveName(bool UseQuotes = true) const;
 
-
   /// Retrieve source range from memory region. The range retrieval
   /// is based on the decl obtained from the memory region.
   /// For a VarRegion the range of the base region is returned.
@@ -173,7 +186,7 @@ public:
   /// The client is responsible for checking if the returned range is valid.
   ///
   /// \returns source range for declaration retrieved from memory region
-  clang::SourceRange sourceRange() const;
+  SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
@@ -242,7 +255,7 @@ class StaticGlobalSpaceRegion : public G
   const CodeTextRegion *CR;
   
   StaticGlobalSpaceRegion(MemRegionManager *mgr, const CodeTextRegion *cr)
-    : GlobalsSpaceRegion(mgr, StaticGlobalSpaceRegionKind), CR(cr) {
+      : GlobalsSpaceRegion(mgr, StaticGlobalSpaceRegionKind), CR(cr) {
     assert(cr);
   }
 
@@ -265,7 +278,7 @@ public:
 /// RegionStoreManager::invalidateRegions (instead of finding all the dependent
 /// globals, we invalidate the whole parent region).
 class NonStaticGlobalSpaceRegion : public GlobalsSpaceRegion {
-  virtual void anchor() override;
+  void anchor() override;
 
 protected:
   NonStaticGlobalSpaceRegion(MemRegionManager *mgr, Kind k)
@@ -274,7 +287,6 @@ protected:
   }
 
 public:
-
   static bool classof(const MemRegion *R) {
     Kind k = R->getKind();
     return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
@@ -288,10 +300,9 @@ class GlobalSystemSpaceRegion : public N
   friend class MemRegionManager;
 
   GlobalSystemSpaceRegion(MemRegionManager *mgr)
-    : NonStaticGlobalSpaceRegion(mgr, GlobalSystemSpaceRegionKind) {}
+      : NonStaticGlobalSpaceRegion(mgr, GlobalSystemSpaceRegionKind) {}
 
 public:
-
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -308,10 +319,9 @@ class GlobalImmutableSpaceRegion : publi
   friend class MemRegionManager;
 
   GlobalImmutableSpaceRegion(MemRegionManager *mgr)
-    : NonStaticGlobalSpaceRegion(mgr, GlobalImmutableSpaceRegionKind) {}
+      : NonStaticGlobalSpaceRegion(mgr, GlobalImmutableSpaceRegionKind) {}
 
 public:
-
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -326,10 +336,9 @@ class GlobalInternalSpaceRegion : public
   friend class MemRegionManager;
 
   GlobalInternalSpaceRegion(MemRegionManager *mgr)
-    : NonStaticGlobalSpaceRegion(mgr, GlobalInternalSpaceRegionKind) {}
+      : NonStaticGlobalSpaceRegion(mgr, GlobalInternalSpaceRegionKind) {}
 
 public:
-
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -341,9 +350,9 @@ class HeapSpaceRegion : public MemSpaceR
   friend class MemRegionManager;
   
   HeapSpaceRegion(MemRegionManager *mgr)
-    : MemSpaceRegion(mgr, HeapSpaceRegionKind) {}
-public:
+      : MemSpaceRegion(mgr, HeapSpaceRegionKind) {}
 
+public:
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -353,11 +362,11 @@ public:
   
 class UnknownSpaceRegion : public MemSpaceRegion {
   friend class MemRegionManager;
+
   UnknownSpaceRegion(MemRegionManager *mgr)
       : MemSpaceRegion(mgr, UnknownSpaceRegionKind) {}
 
 public:
-
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -372,7 +381,7 @@ class StackSpaceRegion : public MemSpace
 
 protected:
   StackSpaceRegion(MemRegionManager *mgr, Kind k, const StackFrameContext *sfc)
-    : MemSpaceRegion(mgr, k), SFC(sfc) {
+      : MemSpaceRegion(mgr, k), SFC(sfc) {
     assert(classof(this));
     assert(sfc);
   }
@@ -390,10 +399,11 @@ public:
 
 class StackLocalsSpaceRegion : public StackSpaceRegion {
   friend class MemRegionManager;
+
   StackLocalsSpaceRegion(MemRegionManager *mgr, const StackFrameContext *sfc)
-    : StackSpaceRegion(mgr, StackLocalsSpaceRegionKind, sfc) {}
-public:
+      : StackSpaceRegion(mgr, StackLocalsSpaceRegionKind, sfc) {}
 
+public:
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -404,10 +414,11 @@ public:
 class StackArgumentsSpaceRegion : public StackSpaceRegion {
 private:
   friend class MemRegionManager;
+
   StackArgumentsSpaceRegion(MemRegionManager *mgr, const StackFrameContext *sfc)
-    : StackSpaceRegion(mgr, StackArgumentsSpaceRegionKind, sfc) {}
-public:
+      : StackSpaceRegion(mgr, StackArgumentsSpaceRegionKind, sfc) {}
 
+public:
   void dumpToStream(raw_ostream &os) const override;
 
   static bool classof(const MemRegion *R) {
@@ -415,7 +426,6 @@ public:
   }
 };
 
-
 /// SubRegion - A region that subsets another larger region.  Most regions
 ///  are subclasses of SubRegion.
 class SubRegion : public MemRegion {
@@ -423,6 +433,7 @@ class SubRegion : public MemRegion {
 
 protected:
   const MemRegion* superRegion;
+
   SubRegion(const MemRegion *sReg, Kind k) : MemRegion(k), superRegion(sReg) {
     assert(classof(this));
     assert(sReg);
@@ -456,8 +467,10 @@ public:
 class AllocaRegion : public SubRegion {
   friend class MemRegionManager;
 
-  unsigned Cnt; // Block counter.  Used to distinguish different pieces of
-                // memory allocated by alloca at the same call site.
+  // Block counter. Used to distinguish different pieces of memory allocated by
+  // alloca at the same call site.
+  unsigned Cnt;
+
   const Expr *Ex;
 
   AllocaRegion(const Expr *ex, unsigned cnt, const MemSpaceRegion *superRegion)
@@ -469,7 +482,6 @@ class AllocaRegion : public SubRegion {
                             unsigned Cnt, const MemRegion *superRegion);
 
 public:
-
   const Expr *getExpr() const { return Ex; }
 
   bool isBoundable() const override { return true; }
@@ -487,7 +499,7 @@ public:
 
 /// TypedRegion - An abstract class representing regions that are typed.
 class TypedRegion : public SubRegion {
-  virtual void anchor() override;
+  void anchor() override;
 
 protected:
   TypedRegion(const MemRegion *sReg, Kind k) : SubRegion(sReg, k) {
@@ -511,7 +523,7 @@ public:
 
 /// TypedValueRegion - An abstract class representing regions having a typed value.
 class TypedValueRegion : public TypedRegion {
-  virtual void anchor() override;
+  void anchor() override;
 
 protected:
   TypedValueRegion(const MemRegion* sReg, Kind k) : TypedRegion(sReg, k) {
@@ -543,9 +555,8 @@ public:
   }
 };
 
-
 class CodeTextRegion : public TypedRegion {
-  virtual void anchor() override;
+  void anchor() override;
 
 protected:
   CodeTextRegion(const MemSpaceRegion *sreg, Kind k) : TypedRegion(sreg, k) {
@@ -568,7 +579,7 @@ class FunctionCodeRegion : public CodeTe
   const NamedDecl *FD;
 
   FunctionCodeRegion(const NamedDecl *fd, const CodeSpaceRegion* sreg)
-    : CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
+      : CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
     assert(isa<ObjCMethodDecl>(fd) || isa<FunctionDecl>(fd));
   }
 
@@ -578,7 +589,7 @@ class FunctionCodeRegion : public CodeTe
 public:
   QualType getLocationType() const override {
     const ASTContext &Ctx = getContext();
-    if (const FunctionDecl *D = dyn_cast<FunctionDecl>(FD)) {
+    if (const auto *D = dyn_cast<FunctionDecl>(FD)) {
       return Ctx.getPointerType(D->getType());
     }
 
@@ -587,7 +598,7 @@ public:
 
     // TODO: We might want to return a different type here (ex: id (*ty)(...))
     //       depending on how it is used.
-    return QualType();
+    return {};
   }
 
   const NamedDecl *getDecl() const {
@@ -603,7 +614,6 @@ public:
   }
 };
   
-  
 /// BlockCodeRegion - A region that represents code texts of blocks (closures).
 ///  Blocks are represented with two kinds of regions.  BlockCodeRegions
 ///  represent the "code", while BlockDataRegions represent instances of blocks,
@@ -659,15 +669,15 @@ class BlockDataRegion : public TypedRegi
   friend class MemRegionManager;
 
   const BlockCodeRegion *BC;
-  const LocationContext *LC; // Can be null */
+  const LocationContext *LC; // Can be null
   unsigned BlockCount;
-  void *ReferencedVars;
-  void *OriginalVars;
+  void *ReferencedVars = nullptr;
+  void *OriginalVars = nullptr;
 
   BlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc,
                   unsigned count, const MemSpaceRegion *sreg)
       : TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
-        BlockCount(count), ReferencedVars(nullptr), OriginalVars(nullptr) {
+        BlockCount(count) {
     assert(bc);
     assert(lc);
     assert(isa<GlobalImmutableSpaceRegion>(sreg) ||
@@ -681,7 +691,7 @@ class BlockDataRegion : public TypedRegi
 
 public:
   const BlockCodeRegion *getCodeRegion() const { return BC; }
-  
+
   const BlockDecl *getDecl() const { return BC->getDecl(); }
 
   QualType getLocationType() const override { return BC->getLocationType(); }
@@ -689,14 +699,16 @@ public:
   class referenced_vars_iterator {
     const MemRegion * const *R;
     const MemRegion * const *OriginalR;
+
   public:
     explicit referenced_vars_iterator(const MemRegion * const *r,
                                       const MemRegion * const *originalR)
-      : R(r), OriginalR(originalR) {}
+        : R(r), OriginalR(originalR) {}
 
     const VarRegion *getCapturedRegion() const {
       return cast<VarRegion>(*R);
     }
+
     const VarRegion *getOriginalRegion() const {
       return cast<VarRegion>(*OriginalR);
     }
@@ -705,10 +717,12 @@ public:
       assert((R == nullptr) == (I.R == nullptr));
       return I.R == R;
     }
+
     bool operator!=(const referenced_vars_iterator &I) const {
       assert((R == nullptr) == (I.R == nullptr));
       return I.R != R;
     }
+
     referenced_vars_iterator &operator++() {
       ++R;
       ++OriginalR;
@@ -730,6 +744,7 @@ public:
   static bool classof(const MemRegion* R) {
     return R->getKind() == BlockDataRegionKind;
   }
+
 private:
   void LazyInitializeReferencedVars();
   std::pair<const VarRegion *, const VarRegion *>
@@ -756,9 +771,7 @@ class SymbolicRegion : public SubRegion
   }
 
 public:
-  SymbolRef getSymbol() const {
-    return sym;
-  }
+  SymbolRef getSymbol() const { return sym; }
 
   bool isBoundable() const override { return true; }
 
@@ -781,24 +794,21 @@ public:
 class StringRegion : public TypedValueRegion {
   friend class MemRegionManager;
 
-  const StringLiteral* Str;
+  const StringLiteral *Str;
 
   StringRegion(const StringLiteral *str, const GlobalInternalSpaceRegion *sreg)
       : TypedValueRegion(sreg, StringRegionKind), Str(str) {
     assert(str);
   }
 
-  static void ProfileRegion(llvm::FoldingSetNodeID& ID,
-                            const StringLiteral* Str,
-                            const MemRegion* superRegion);
+  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
+                            const StringLiteral *Str,
+                            const MemRegion *superRegion);
 
 public:
+  const StringLiteral *getStringLiteral() const { return Str; }
 
-  const StringLiteral* getStringLiteral() const { return Str; }
-
-  QualType getValueType() const override {
-    return Str->getType();
-  }
+  QualType getValueType() const override { return Str->getType(); }
 
   DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override;
 
@@ -819,7 +829,7 @@ public:
 class ObjCStringRegion : public TypedValueRegion {
   friend class MemRegionManager;
 
-  const ObjCStringLiteral* Str;
+  const ObjCStringLiteral *Str;
 
   ObjCStringRegion(const ObjCStringLiteral *str,
                    const GlobalInternalSpaceRegion *sreg)
@@ -827,17 +837,14 @@ class ObjCStringRegion : public TypedVal
     assert(str);
   }
 
-  static void ProfileRegion(llvm::FoldingSetNodeID& ID,
-                            const ObjCStringLiteral* Str,
-                            const MemRegion* superRegion);
+  static void ProfileRegion(llvm::FoldingSetNodeID &ID,
+                            const ObjCStringLiteral *Str,
+                            const MemRegion *superRegion);
   
 public:
-  
-  const ObjCStringLiteral* getObjCStringLiteral() const { return Str; }
+  const ObjCStringLiteral *getObjCStringLiteral() const { return Str; }
 
-  QualType getValueType() const override {
-    return Str->getType();
-  }
+  QualType getValueType() const override { return Str->getType(); }
 
   bool isBoundable() const override { return false; }
 
@@ -871,10 +878,9 @@ class CompoundLiteralRegion : public Typ
   static void ProfileRegion(llvm::FoldingSetNodeID& ID,
                             const CompoundLiteralExpr *CL,
                             const MemRegion* superRegion);
+
 public:
-  QualType getValueType() const override {
-    return CL->getType();
-  }
+  QualType getValueType() const override { return CL->getType(); }
 
   bool isBoundable() const override { return !CL->isFileScope(); }
 
@@ -945,13 +951,13 @@ public:
 
   void dumpToStream(raw_ostream &os) const override;
 
-  static bool classof(const MemRegion* R) {
-    return R->getKind() == VarRegionKind;
-  }
-
   bool canPrintPrettyAsExpr() const override;
 
   void printPrettyAsExpr(raw_ostream &os) const override;
+
+  static bool classof(const MemRegion* R) {
+    return R->getKind() == VarRegionKind;
+  }
 };
   
 /// CXXThisRegion - Represents the region for the implicit 'this' parameter
@@ -993,7 +999,7 @@ class FieldRegion : public DeclRegion {
   friend class MemRegionManager;
 
   FieldRegion(const FieldDecl *fd, const SubRegion* sReg)
-    : DeclRegion(fd, sReg, FieldRegionKind) {}
+      : DeclRegion(fd, sReg, FieldRegionKind) {}
 
   static void ProfileRegion(llvm::FoldingSetNodeID& ID, const FieldDecl *FD,
                             const MemRegion* superRegion) {
@@ -1010,16 +1016,16 @@ public:
 
   DefinedOrUnknownSVal getExtent(SValBuilder &svalBuilder) const override;
 
-  static bool classof(const MemRegion* R) {
-    return R->getKind() == FieldRegionKind;
-  }
-
   void dumpToStream(raw_ostream &os) const override;
 
   bool canPrintPretty() const override;
   void printPretty(raw_ostream &os) const override;
   bool canPrintPrettyAsExpr() const override;
   void printPrettyAsExpr(raw_ostream &os) const override;
+
+  static bool classof(const MemRegion* R) {
+    return R->getKind() == FieldRegionKind;
+  }
 };
 
 class ObjCIvarRegion : public DeclRegion {
@@ -1043,12 +1049,11 @@ public:
     return R->getKind() == ObjCIvarRegionKind;
   }
 };
+
 //===----------------------------------------------------------------------===//
 // Auxiliary data classes for use with MemRegions.
 //===----------------------------------------------------------------------===//
 
-class ElementRegion;
-
 class RegionRawOffset {
   friend class ElementRegion;
 
@@ -1056,7 +1061,7 @@ class RegionRawOffset {
   CharUnits Offset;
 
   RegionRawOffset(const MemRegion* reg, CharUnits offset = CharUnits::Zero())
-    : Region(reg), Offset(offset) {}
+      : Region(reg), Offset(offset) {}
 
 public:
   // FIXME: Eventually support symbolic offsets.
@@ -1075,8 +1080,8 @@ class ElementRegion : public TypedValueR
   NonLoc Index;
 
   ElementRegion(QualType elementType, NonLoc Idx, const SubRegion *sReg)
-      : TypedValueRegion(sReg, ElementRegionKind),
-        ElementType(elementType), Index(Idx) {
+      : TypedValueRegion(sReg, ElementRegionKind), ElementType(elementType),
+        Index(Idx) {
     assert((!Idx.getAs<nonloc::ConcreteInt>() ||
             Idx.castAs<nonloc::ConcreteInt>().getValue().isSigned()) &&
            "The index must be signed");
@@ -1088,16 +1093,12 @@ class ElementRegion : public TypedValueR
                             SVal Idx, const MemRegion* superRegion);
 
 public:
-
   NonLoc getIndex() const { return Index; }
 
-  QualType getValueType() const override {
-    return ElementType;
-  }
+  QualType getValueType() const override { return ElementType; }
+
+  QualType getElementType() const { return ElementType; }
 
-  QualType getElementType() const {
-    return ElementType;
-  }
   /// Compute the offset within the array. The array might also be a subobject.
   RegionRawOffset getAsArrayOffset() const;
 
@@ -1129,9 +1130,7 @@ class CXXTempObjectRegion : public Typed
 public:
   const Expr *getExpr() const { return Ex; }
 
-  QualType getValueType() const override {
-    return Ex->getType();
-  }
+  QualType getValueType() const override { return Ex->getType(); }
 
   void dumpToStream(raw_ostream &os) const override;
 
@@ -1168,18 +1167,18 @@ public:
 
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 
-  static bool classof(const MemRegion *region) {
-    return region->getKind() == CXXBaseObjectRegionKind;
-  }
-
   bool canPrintPrettyAsExpr() const override;
 
   void printPrettyAsExpr(raw_ostream &os) const override;
+
+  static bool classof(const MemRegion *region) {
+    return region->getKind() == CXXBaseObjectRegionKind;
+  }
 };
 
 template<typename RegionTy>
 const RegionTy* MemRegion::getAs() const {
-  if (const RegionTy* RT = dyn_cast<RegionTy>(this))
+  if (const auto *RT = dyn_cast<RegionTy>(this))
     return RT;
 
   return nullptr;
@@ -1194,11 +1193,10 @@ class MemRegionManager {
   llvm::BumpPtrAllocator& A;
   llvm::FoldingSet<MemRegion> Regions;
 
-  GlobalInternalSpaceRegion *InternalGlobals;
-  GlobalSystemSpaceRegion *SystemGlobals;
-  GlobalImmutableSpaceRegion *ImmutableGlobals;
+  GlobalInternalSpaceRegion *InternalGlobals = nullptr;
+  GlobalSystemSpaceRegion *SystemGlobals = nullptr;
+  GlobalImmutableSpaceRegion *ImmutableGlobals = nullptr;
 
-  
   llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *> 
     StackLocalsSpaceRegions;
   llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *>
@@ -1206,16 +1204,12 @@ class MemRegionManager {
   llvm::DenseMap<const CodeTextRegion *, StaticGlobalSpaceRegion *>
     StaticsGlobalSpaceRegions;
 
-  HeapSpaceRegion *heap;
-  UnknownSpaceRegion *unknown;
-  CodeSpaceRegion *code;
+  HeapSpaceRegion *heap = nullptr;
+  UnknownSpaceRegion *unknown = nullptr;
+  CodeSpaceRegion *code = nullptr;
 
 public:
-  MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
-    : C(c), A(a), InternalGlobals(nullptr), SystemGlobals(nullptr),
-      ImmutableGlobals(nullptr), heap(nullptr), unknown(nullptr),
-      code(nullptr) {}
-
+  MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a) : C(c), A(a) {}
   ~MemRegionManager();
 
   ASTContext &getContext() { return C; }
@@ -1269,7 +1263,7 @@ public:
   /// \brief Return a unique symbolic region belonging to heap memory space.
   const SymbolicRegion *getSymbolicHeapRegion(SymbolRef sym);
 
-  const StringRegion *getStringRegion(const StringLiteral* Str);
+  const StringRegion *getStringRegion(const StringLiteral *Str);
 
   const ObjCStringRegion *getObjCStringRegion(const ObjCStringLiteral *Str);
 
@@ -1388,24 +1382,28 @@ inline ASTContext &MemRegion::getContext
 
 /// Information about invalidation for a particular region/symbol.
 class RegionAndSymbolInvalidationTraits {
-  typedef unsigned char StorageTypeForKinds;
+  using StorageTypeForKinds = unsigned char;
+
   llvm::DenseMap<const MemRegion *, StorageTypeForKinds> MRTraitsMap;
   llvm::DenseMap<SymbolRef, StorageTypeForKinds> SymTraitsMap;
 
-  typedef llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator
-      const_region_iterator;
-  typedef llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator
-      const_symbol_iterator;
+  using const_region_iterator =
+      llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator;
+  using const_symbol_iterator =
+      llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator;
 
 public:
   /// \brief Describes different invalidation traits.
   enum InvalidationKinds {
     /// Tells that a region's contents is not changed.
     TK_PreserveContents = 0x1,
+
     /// Suppress pointer-escaping of a region.
     TK_SuppressEscape = 0x2,
+
     // Do not invalidate super region.
     TK_DoNotInvalidateSuperRegion = 0x4,
+
     /// When applied to a MemSpaceRegion, indicates the entire memory space
     /// should be invalidated.
     TK_EntireMemSpace = 0x8
@@ -1423,8 +1421,7 @@ public:
 //===----------------------------------------------------------------------===//
 // Pretty-printing regions.
 //===----------------------------------------------------------------------===//
-inline raw_ostream &operator<<(raw_ostream &os,
-                               const clang::ento::MemRegion *R) {
+inline raw_ostream &operator<<(raw_ostream &os, const MemRegion *R) {
   R->dumpToStream(os);
   return os;
 }
@@ -1433,4 +1430,4 @@ inline raw_ostream &operator<<(raw_ostre
 
 } // namespace clang
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h?rev=329115&r1=329114&r2=329115&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h Tue Apr  3 14:31:50 2018
@@ -1,4 +1,4 @@
-//== TaintManager.h - Managing taint --------------------------- -*- C++ -*--=//
+//===- TaintManager.h - Managing taint --------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,9 +14,9 @@
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTMANAGER_H
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTMANAGER_H
 
-#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h"
 #include "llvm/ADT/ImmutableMap.h"
 
@@ -29,28 +29,37 @@ namespace ento {
 // FIXME: This does not use the nice trait macros because it must be accessible
 // from multiple translation units.
 struct TaintMap {};
-typedef llvm::ImmutableMap<SymbolRef, TaintTagType> TaintMapImpl;
+
+using TaintMapImpl = llvm::ImmutableMap<SymbolRef, TaintTagType>;
+
 template<> struct ProgramStateTrait<TaintMap>
     :  public ProgramStatePartialTrait<TaintMapImpl> {
-  static void *GDMIndex() { static int index = 0; return &index; }
+  static void *GDMIndex() {
+    static int index = 0;
+    return &index;
+  }
 };
 
 /// The GDM component mapping derived symbols' parent symbols to their
 /// underlying regions. This is used to efficiently check whether a symbol is
 /// tainted when it represents a sub-region of a tainted symbol.
 struct DerivedSymTaint {};
-typedef llvm::ImmutableMap<SymbolRef, TaintedSubRegions> DerivedSymTaintImpl;
+
+using DerivedSymTaintImpl = llvm::ImmutableMap<SymbolRef, TaintedSubRegions>;
+
 template<> struct ProgramStateTrait<DerivedSymTaint>
     :  public ProgramStatePartialTrait<DerivedSymTaintImpl> {
-  static void *GDMIndex() { static int index; return &index; }
+  static void *GDMIndex() {
+    static int index;
+    return &index;
+  }
 };
 
 class TaintManager {
-
-  TaintManager() {}
+  TaintManager() = default;
 };
 
-}
-}
+} // namespace ento
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTMANAGER_H

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h?rev=329115&r1=329114&r2=329115&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintTag.h Tue Apr  3 14:31:50 2018
@@ -1,4 +1,4 @@
-//== TaintTag.h - Path-sensitive "State" for tracking values -*- C++ -*--=//
+//===- TaintTag.h - Path-sensitive "State" for tracking values --*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,6 +11,7 @@
 // of taint.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTTAG_H
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTTAG_H
 
@@ -19,9 +20,11 @@ namespace ento {
 
 /// The type of taint, which helps to differentiate between different types of
 /// taint.
-typedef unsigned TaintTagType;
+using TaintTagType = unsigned;
+
 static const TaintTagType TaintTagGeneric = 0;
 
-}}
+} // namespace ento
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_TAINTTAG_H

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp?rev=329115&r1=329114&r2=329115&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp Tue Apr  3 14:31:50 2018
@@ -1,4 +1,4 @@
-//===--- CheckerRegistry.cpp - Maintains all available checkers -*- C++ -*-===//
+//===- CheckerRegistry.cpp - Maintains all available checkers -------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -9,18 +9,26 @@
 
 #include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/CheckerOptInfo.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cstddef>
+#include <tuple>
 
 using namespace clang;
 using namespace ento;
 
 static const char PackageSeparator = '.';
-typedef llvm::SetVector<const CheckerRegistry::CheckerInfo *> CheckerInfoSet;
 
+using CheckerInfoSet = llvm::SetVector<const CheckerRegistry::CheckerInfo *>;
 
 static bool checkerNameLT(const CheckerRegistry::CheckerInfo &a,
                           const CheckerRegistry::CheckerInfo &b) {
@@ -50,8 +58,7 @@ static void collectCheckers(const Checke
   // Use a binary search to find the possible start of the package.
   CheckerRegistry::CheckerInfo packageInfo(nullptr, opt.getName(), "");
   auto end = checkers.cend();
-  CheckerRegistry::CheckerInfoList::const_iterator i =
-    std::lower_bound(checkers.cbegin(), end, packageInfo, checkerNameLT);
+  auto i = std::lower_bound(checkers.cbegin(), end, packageInfo, checkerNameLT);
 
   // If we didn't even find a possible package, give up.
   if (i == end)
@@ -73,12 +80,11 @@ static void collectCheckers(const Checke
     size = packageSize->getValue();
 
   // Step through all the checkers in the package.
-  for (auto checkEnd = i+size; i != checkEnd; ++i) {
+  for (auto checkEnd = i+size; i != checkEnd; ++i)
     if (opt.isEnabled())
       collected.insert(&*i);
     else
       collected.remove(&*i);
-  }
 }
 
 void CheckerRegistry::addChecker(InitializationFunction fn, StringRef name,
@@ -101,38 +107,34 @@ void CheckerRegistry::initializeManager(
 
   // Collect checkers enabled by the options.
   CheckerInfoSet enabledCheckers;
-  for (SmallVectorImpl<CheckerOptInfo>::iterator
-         i = opts.begin(), e = opts.end(); i != e; ++i) {
-    collectCheckers(Checkers, Packages, *i, enabledCheckers);
-  }
+  for (auto &i : opts)
+    collectCheckers(Checkers, Packages, i, enabledCheckers);
 
   // Initialize the CheckerManager with all enabled checkers.
-  for (CheckerInfoSet::iterator
-         i = enabledCheckers.begin(), e = enabledCheckers.end(); i != e; ++i) {
-    checkerMgr.setCurrentCheckName(CheckName((*i)->FullName));
-    (*i)->Initialize(checkerMgr);
+  for (const auto *i :enabledCheckers) {
+    checkerMgr.setCurrentCheckName(CheckName(i->FullName));
+    i->Initialize(checkerMgr);
   }
 }
 
 void CheckerRegistry::validateCheckerOptions(const AnalyzerOptions &opts,
                                              DiagnosticsEngine &diags) const {
-  for (auto &config : opts.Config) {
+  for (const auto &config : opts.Config) {
     size_t pos = config.getKey().find(':');
     if (pos == StringRef::npos)
       continue;
 
     bool hasChecker = false;
     StringRef checkerName = config.getKey().substr(0, pos);
-    for (auto &checker : Checkers) {
+    for (const auto &checker : Checkers) {
       if (checker.FullName.startswith(checkerName) &&
           (checker.FullName.size() == pos || checker.FullName[pos] == '.')) {
         hasChecker = true;
         break;
       }
     }
-    if (!hasChecker) {
+    if (!hasChecker)
       diags.Report(diag::err_unknown_analyzer_checker) << checkerName;
-    }
   }
 }
 
@@ -149,28 +151,26 @@ void CheckerRegistry::printHelp(raw_ostr
 
   // Find the maximum option length.
   size_t optionFieldWidth = 0;
-  for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
-       i != e; ++i) {
+  for (const auto &i : Checkers) {
     // Limit the amount of padding we are willing to give up for alignment.
     //   Package.Name     Description  [Hidden]
-    size_t nameLength = i->FullName.size();
+    size_t nameLength = i.FullName.size();
     if (nameLength <= maxNameChars)
       optionFieldWidth = std::max(optionFieldWidth, nameLength);
   }
 
   const size_t initialPad = 2;
-  for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
-       i != e; ++i) {
-    out.indent(initialPad) << i->FullName;
+  for (const auto &i : Checkers) {
+    out.indent(initialPad) << i.FullName;
 
-    int pad = optionFieldWidth - i->FullName.size();
+    int pad = optionFieldWidth - i.FullName.size();
 
     // Break on long option names.
     if (pad < 0) {
       out << '\n';
       pad = optionFieldWidth + initialPad;
     }
-    out.indent(pad + 2) << i->Desc;
+    out.indent(pad + 2) << i.Desc;
 
     out << '\n';
   }
@@ -182,15 +182,9 @@ void CheckerRegistry::printList(
 
   // Collect checkers enabled by the options.
   CheckerInfoSet enabledCheckers;
-  for (SmallVectorImpl<CheckerOptInfo>::iterator i = opts.begin(),
-                                                       e = opts.end();
-       i != e; ++i) {
-    collectCheckers(Checkers, Packages, *i, enabledCheckers);
-  }
+  for (auto &i : opts)
+    collectCheckers(Checkers, Packages, i, enabledCheckers);
 
-  for (CheckerInfoSet::const_iterator i = enabledCheckers.begin(),
-                                      e = enabledCheckers.end();
-       i != e; ++i) {
-    out << (*i)->FullName << '\n';
-  }
+  for (const auto *i : enabledCheckers)
+    out << i->FullName << '\n';
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=329115&r1=329114&r2=329115&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Tue Apr  3 14:31:50 2018
@@ -1,4 +1,4 @@
-//== MemRegion.cpp - Abstract memory regions for static analysis --*- C++ -*--//
+//===- MemRegion.cpp - Abstract memory regions for static analysis --------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,24 +14,50 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/CharUnits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecordLayout.h"
+#include "clang/AST/Type.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/Support/BumpVector.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
-#include "llvm/Support/raw_ostream.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
-
-#include<functional>
-
-#define DEBUG_TYPE "MemRegion"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <cstdint>
+#include <functional>
+#include <iterator>
+#include <string>
+#include <tuple>
+#include <utility>
 
 using namespace clang;
 using namespace ento;
 
+#define DEBUG_TYPE "MemRegion"
+
 //===----------------------------------------------------------------------===//
 // MemRegion Construction.
 //===----------------------------------------------------------------------===//
@@ -42,8 +68,7 @@ RegionTy* MemRegionManager::getSubRegion
   llvm::FoldingSetNodeID ID;
   RegionTy::ProfileRegion(ID, arg1, superRegion);
   void *InsertPos;
-  RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID,
-                                                                   InsertPos));
+  auto *R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
     R = A.Allocate<RegionTy>();
@@ -60,8 +85,7 @@ RegionTy* MemRegionManager::getSubRegion
   llvm::FoldingSetNodeID ID;
   RegionTy::ProfileRegion(ID, arg1, arg2, superRegion);
   void *InsertPos;
-  RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID,
-                                                                   InsertPos));
+  auto *R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
     R = A.Allocate<RegionTy>();
@@ -80,8 +104,7 @@ RegionTy* MemRegionManager::getSubRegion
   llvm::FoldingSetNodeID ID;
   RegionTy::ProfileRegion(ID, arg1, arg2, arg3, superRegion);
   void *InsertPos;
-  RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID,
-                                                                   InsertPos));
+  auto *R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
     R = A.Allocate<RegionTy>();
@@ -96,12 +119,11 @@ RegionTy* MemRegionManager::getSubRegion
 // Object destruction.
 //===----------------------------------------------------------------------===//
 
-MemRegion::~MemRegion() {}
+MemRegion::~MemRegion() = default;
 
-MemRegionManager::~MemRegionManager() {
-  // All regions and their data are BumpPtrAllocated.  No need to call
-  // their destructors.
-}
+// All regions and their data are BumpPtrAllocated.  No need to call their
+// destructors.
+MemRegionManager::~MemRegionManager() = default;
 
 //===----------------------------------------------------------------------===//
 // Basic methods.
@@ -112,7 +134,7 @@ bool SubRegion::isSubRegionOf(const MemR
   do {
     if (r == R)
       return true;
-    if (const SubRegion* sr = dyn_cast<SubRegion>(r))
+    if (const auto *sr = dyn_cast<SubRegion>(r))
       r = sr->getSuperRegion();
     else
       break;
@@ -124,16 +146,16 @@ MemRegionManager* SubRegion::getMemRegio
   const SubRegion* r = this;
   do {
     const MemRegion *superRegion = r->getSuperRegion();
-    if (const SubRegion *sr = dyn_cast<SubRegion>(superRegion)) {
+    if (const auto *sr = dyn_cast<SubRegion>(superRegion)) {
       r = sr;
       continue;
     }
     return superRegion->getMemRegionManager();
-  } while (1);
+  } while (true);
 }
 
 const StackFrameContext *VarRegion::getStackFrame() const {
-  const StackSpaceRegion *SSR = dyn_cast<StackSpaceRegion>(getMemorySpace());
+  const auto *SSR = dyn_cast<StackSpaceRegion>(getMemorySpace());
   return SSR ? SSR->getStackFrame() : nullptr;
 }
 
@@ -220,17 +242,17 @@ void StaticGlobalSpaceRegion::Profile(ll
   ID.AddPointer(getCodeRegion());
 }
 
-void StringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
-                                 const StringLiteral* Str,
-                                 const MemRegion* superRegion) {
+void StringRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
+                                 const StringLiteral *Str,
+                                 const MemRegion *superRegion) {
   ID.AddInteger(static_cast<unsigned>(StringRegionKind));
   ID.AddPointer(Str);
   ID.AddPointer(superRegion);
 }
 
-void ObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
-                                     const ObjCStringLiteral* Str,
-                                     const MemRegion* superRegion) {
+void ObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
+                                     const ObjCStringLiteral *Str,
+                                     const MemRegion *superRegion) {
   ID.AddInteger(static_cast<unsigned>(ObjCStringRegionKind));
   ID.AddPointer(Str);
   ID.AddPointer(superRegion);
@@ -385,13 +407,19 @@ void CXXBaseObjectRegion::Profile(llvm::
 // Region anchors.
 //===----------------------------------------------------------------------===//
 
-void GlobalsSpaceRegion::anchor() { }
-void NonStaticGlobalSpaceRegion::anchor() { }
-void StackSpaceRegion::anchor() { }
-void TypedRegion::anchor() { }
-void TypedValueRegion::anchor() { }
-void CodeTextRegion::anchor() { }
-void SubRegion::anchor() { }
+void GlobalsSpaceRegion::anchor() {}
+
+void NonStaticGlobalSpaceRegion::anchor() {}
+
+void StackSpaceRegion::anchor() {}
+
+void TypedRegion::anchor() {}
+
+void TypedValueRegion::anchor() {}
+
+void CodeTextRegion::anchor() {}
+
+void SubRegion::anchor() {}
 
 //===----------------------------------------------------------------------===//
 // Region pretty-printing.
@@ -413,7 +441,7 @@ void MemRegion::dumpToStream(raw_ostream
 }
 
 void AllocaRegion::dumpToStream(raw_ostream &os) const {
-  os << "alloca{" << static_cast<const void*>(Ex) << ',' << Cnt << '}';
+  os << "alloca{" << static_cast<const void *>(Ex) << ',' << Cnt << '}';
 }
 
 void FunctionCodeRegion::dumpToStream(raw_ostream &os) const {
@@ -421,7 +449,7 @@ void FunctionCodeRegion::dumpToStream(ra
 }
 
 void BlockCodeRegion::dumpToStream(raw_ostream &os) const {
-  os << "block_code{" << static_cast<const void*>(this) << '}';
+  os << "block_code{" << static_cast<const void *>(this) << '}';
 }
 
 void BlockDataRegion::dumpToStream(raw_ostream &os) const {
@@ -437,12 +465,12 @@ void BlockDataRegion::dumpToStream(raw_o
 
 void CompoundLiteralRegion::dumpToStream(raw_ostream &os) const {
   // FIXME: More elaborate pretty-printing.
-  os << "{ " << static_cast<const void*>(CL) <<  " }";
+  os << "{ " << static_cast<const void *>(CL) <<  " }";
 }
 
 void CXXTempObjectRegion::dumpToStream(raw_ostream &os) const {
   os << "temp_object{" << getValueType().getAsString() << ','
-     << static_cast<const void*>(Ex) << '}';
+     << static_cast<const void *>(Ex) << '}';
 }
 
 void CXXBaseObjectRegion::dumpToStream(raw_ostream &os) const {
@@ -484,11 +512,10 @@ void SymbolicRegion::dumpToStream(raw_os
 
 void VarRegion::dumpToStream(raw_ostream &os) const {
   const auto *VD = cast<VarDecl>(D);
-  if (const auto *ID = VD->getIdentifier()) {
+  if (const IdentifierInfo *ID = VD->getIdentifier())
     os << ID->getName();
-  } else {
-    os << "VarRegion{" << static_cast<const void*>(this) << '}';
-  }
+  else
+    os << "VarRegion{" << static_cast<const void *>(this) << '}';
 }
 
 LLVM_DUMP_METHOD void RegionRawOffset::dump() const {
@@ -632,19 +659,18 @@ std::string MemRegion::getDescriptiveNam
   // Get variable name.
   if (R && R->canPrintPrettyAsExpr()) {
     R->printPrettyAsExpr(os);
-    if (UseQuotes) {
+    if (UseQuotes)
       return (llvm::Twine("'") + os.str() + ArrayIndices + "'").str();
-    } else {
+    else
       return (llvm::Twine(os.str()) + ArrayIndices).str();
-    }
   }
 
   return VariableName;
 }
 
 SourceRange MemRegion::sourceRange() const {
-  const VarRegion *const VR = dyn_cast<VarRegion>(this->getBaseRegion());
-  const FieldRegion *const FR = dyn_cast<FieldRegion>(this);
+  const auto *const VR = dyn_cast<VarRegion>(this->getBaseRegion());
+  const auto *const FR = dyn_cast<FieldRegion>(this);
 
   // Check for more specific regions first.
   // FieldRegion
@@ -656,9 +682,8 @@ SourceRange MemRegion::sourceRange() con
     return VR->getDecl()->getSourceRange();
   }
   // Return invalid source range (can be checked by client).
-  else {
-    return SourceRange{};
-  }
+  else
+    return {};
 }
 
 //===----------------------------------------------------------------------===//
@@ -748,13 +773,14 @@ const CodeSpaceRegion *MemRegionManager:
 //===----------------------------------------------------------------------===//
 // Constructing regions.
 //===----------------------------------------------------------------------===//
-const StringRegion* MemRegionManager::getStringRegion(const StringLiteral* Str){
+
+const StringRegion *MemRegionManager::getStringRegion(const StringLiteral *Str){
   return getSubRegion<StringRegion>(
       Str, cast<GlobalInternalSpaceRegion>(getGlobalsRegion()));
 }
 
 const ObjCStringRegion *
-MemRegionManager::getObjCStringRegion(const ObjCStringLiteral* Str){
+MemRegionManager::getObjCStringRegion(const ObjCStringLiteral *Str){
   return getSubRegion<ObjCStringRegion>(
       Str, cast<GlobalInternalSpaceRegion>(getGlobalsRegion()));
 }
@@ -767,14 +793,13 @@ getStackOrCaptureRegionForDeclContext(co
                                       const DeclContext *DC,
                                       const VarDecl *VD) {
   while (LC) {
-    if (const StackFrameContext *SFC = dyn_cast<StackFrameContext>(LC)) {
+    if (const auto *SFC = dyn_cast<StackFrameContext>(LC)) {
       if (cast<DeclContext>(SFC->getDecl()) == DC)
         return SFC;
     }
-    if (const BlockInvocationContext *BC =
-        dyn_cast<BlockInvocationContext>(LC)) {
-      const BlockDataRegion *BR =
-        static_cast<const BlockDataRegion*>(BC->getContextData());
+    if (const auto *BC = dyn_cast<BlockInvocationContext>(LC)) {
+      const auto *BR =
+          static_cast<const BlockDataRegion *>(BC->getContextData());
       // FIXME: This can be made more efficient.
       for (BlockDataRegion::referenced_vars_iterator
            I = BR->referenced_vars_begin(),
@@ -828,7 +853,7 @@ const VarRegion* MemRegionManager::getVa
     if (V.is<const VarRegion*>())
       return V.get<const VarRegion*>();
 
-    const StackFrameContext *STC = V.get<const StackFrameContext*>();
+    const auto *STC = V.get<const StackFrameContext *>();
 
     if (!STC) {
       // FIXME: Assign a more sensible memory space to static locals
@@ -846,7 +871,7 @@ const VarRegion* MemRegionManager::getVa
         if (isa<FunctionDecl>(STCD) || isa<ObjCMethodDecl>(STCD))
           sReg = getGlobalsRegion(MemRegion::StaticGlobalSpaceRegionKind,
                                   getFunctionCodeRegion(cast<NamedDecl>(STCD)));
-        else if (const BlockDecl *BD = dyn_cast<BlockDecl>(STCD)) {
+        else if (const auto *BD = dyn_cast<BlockDecl>(STCD)) {
           // FIXME: The fallback type here is totally bogus -- though it should
           // never be queried, it will prevent uniquing with the real
           // BlockCodeRegion. Ideally we'd fix the AST so that we always had a
@@ -942,7 +967,7 @@ MemRegionManager::getElementRegion(QualT
 
   void *InsertPos;
   MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
-  ElementRegion* R = cast_or_null<ElementRegion>(data);
+  auto *R = cast_or_null<ElementRegion>(data);
 
   if (!R) {
     R = A.Allocate<ElementRegion>();
@@ -964,7 +989,6 @@ MemRegionManager::getBlockCodeRegion(con
   return getSubRegion<BlockCodeRegion>(BD, locTy, AC, getCodeRegion());
 }
 
-
 /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
 const SymbolicRegion *MemRegionManager::getSymbolicRegion(SymbolRef sym) {
   return getSubRegion<SymbolicRegion>(sym, getUnknownRegion());
@@ -1027,10 +1051,8 @@ MemRegionManager::getCXXBaseObjectRegion
     if (IsVirtual) {
       // Virtual base regions should not be layered, since the layout rules
       // are different.
-      while (const CXXBaseObjectRegion *Base =
-               dyn_cast<CXXBaseObjectRegion>(Super)) {
+      while (const auto *Base = dyn_cast<CXXBaseObjectRegion>(Super))
         Super = cast<SubRegion>(Base->getSuperRegion());
-      }
       assert(Super && !isa<MemSpaceRegion>(Super));
     }
   }
@@ -1041,7 +1063,7 @@ MemRegionManager::getCXXBaseObjectRegion
 const CXXThisRegion*
 MemRegionManager::getCXXThisRegion(QualType thisPointerTy,
                                    const LocationContext *LC) {
-  const PointerType *PT = thisPointerTy->getAs<PointerType>();
+  const auto *PT = thisPointerTy->getAs<PointerType>();
   assert(PT);
   // Inside the body of the operator() of a lambda a this expr might refer to an
   // object in one of the parent location contexts.
@@ -1070,7 +1092,7 @@ MemRegionManager::getAllocaRegion(const
 
 const MemSpaceRegion *MemRegion::getMemorySpace() const {
   const MemRegion *R = this;
-  const SubRegion* SR = dyn_cast<SubRegion>(this);
+  const auto *SR = dyn_cast<SubRegion>(this);
 
   while (SR) {
     R = SR->getSuperRegion();
@@ -1131,7 +1153,7 @@ const MemRegion *MemRegion::StripCasts(b
   while (true) {
     switch (R->getKind()) {
     case ElementRegionKind: {
-      const ElementRegion *ER = cast<ElementRegion>(R);
+      const auto *ER = cast<ElementRegion>(R);
       if (!ER->getIndex().isZeroConstant())
         return R;
       R = ER->getSuperRegion();
@@ -1149,10 +1171,10 @@ const MemRegion *MemRegion::StripCasts(b
 }
 
 const SymbolicRegion *MemRegion::getSymbolicBase() const {
-  const SubRegion *SubR = dyn_cast<SubRegion>(this);
+  const auto *SubR = dyn_cast<SubRegion>(this);
 
   while (SubR) {
-    if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(SubR))
+    if (const auto *SymR = dyn_cast<SymbolicRegion>(SubR))
       return SymR;
     SubR = dyn_cast<SubRegion>(SubR->getSuperRegion());
   }
@@ -1243,7 +1265,6 @@ RegionRawOffset ElementRegion::getAsArra
   return RegionRawOffset(superR, offset);
 }
 
-
 /// Returns true if \p Base is an immediate base class of \p Child
 static bool isImmediateBase(const CXXRecordDecl *Child,
                             const CXXRecordDecl *Base) {
@@ -1263,7 +1284,7 @@ static RegionOffset calculateOffset(cons
   const MemRegion *SymbolicOffsetBase = nullptr;
   int64_t Offset = 0;
 
-  while (1) {
+  while (true) {
     switch (R->getKind()) {
     case MemRegion::CodeSpaceRegionKind:
     case MemRegion::StackLocalsSpaceRegionKind:
@@ -1307,14 +1328,14 @@ static RegionOffset calculateOffset(cons
       goto Finish;
 
     case MemRegion::CXXBaseObjectRegionKind: {
-      const CXXBaseObjectRegion *BOR = cast<CXXBaseObjectRegion>(R);
+      const auto *BOR = cast<CXXBaseObjectRegion>(R);
       R = BOR->getSuperRegion();
 
       QualType Ty;
       bool RootIsSymbolic = false;
-      if (const TypedValueRegion *TVR = dyn_cast<TypedValueRegion>(R)) {
+      if (const auto *TVR = dyn_cast<TypedValueRegion>(R)) {
         Ty = TVR->getDesugaredValueType(R->getContext());
-      } else if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R)) {
+      } else if (const auto *SR = dyn_cast<SymbolicRegion>(R)) {
         // If our base region is symbolic, we don't know what type it really is.
         // Pretend the type of the symbol is the true dynamic type.
         // (This will at least be self-consistent for the life of the symbol.)
@@ -1358,7 +1379,7 @@ static RegionOffset calculateOffset(cons
       break;
     }
     case MemRegion::ElementRegionKind: {
-      const ElementRegion *ER = cast<ElementRegion>(R);
+      const auto *ER = cast<ElementRegion>(R);
       R = ER->getSuperRegion();
 
       QualType EleTy = ER->getValueType();
@@ -1386,7 +1407,7 @@ static RegionOffset calculateOffset(cons
       break;
     }
     case MemRegion::FieldRegionKind: {
-      const FieldRegion *FR = cast<FieldRegion>(R);
+      const auto *FR = cast<FieldRegion>(R);
       R = FR->getSuperRegion();
 
       const RecordDecl *RD = FR->getDecl()->getParent();
@@ -1476,13 +1497,14 @@ void BlockDataRegion::LazyInitializeRefe
   llvm::BumpPtrAllocator &A = MemMgr.getAllocator();
   BumpVectorContext BC(A);
 
-  typedef BumpVector<const MemRegion*> VarVec;
-  VarVec *BV = A.Allocate<VarVec>();
+  using VarVec = BumpVector<const MemRegion *>;
+
+  auto *BV = A.Allocate<VarVec>();
   new (BV) VarVec(BC, NumBlockVars);
-  VarVec *BVOriginal = A.Allocate<VarVec>();
+  auto *BVOriginal = A.Allocate<VarVec>();
   new (BVOriginal) VarVec(BC, NumBlockVars);
 
-  for (const VarDecl *VD : ReferencedBlockVars) {
+  for (const auto *VD : ReferencedBlockVars) {
     const VarRegion *VR = nullptr;
     const VarRegion *OriginalVR = nullptr;
     std::tie(VR, OriginalVR) = getCaptureRegions(VD);
@@ -1500,14 +1522,13 @@ BlockDataRegion::referenced_vars_iterato
 BlockDataRegion::referenced_vars_begin() const {
   const_cast<BlockDataRegion*>(this)->LazyInitializeReferencedVars();
 
-  BumpVector<const MemRegion*> *Vec =
-    static_cast<BumpVector<const MemRegion*>*>(ReferencedVars);
+  auto *Vec = static_cast<BumpVector<const MemRegion *> *>(ReferencedVars);
 
   if (Vec == (void*) 0x1)
     return BlockDataRegion::referenced_vars_iterator(nullptr, nullptr);
 
-  BumpVector<const MemRegion*> *VecOriginal =
-    static_cast<BumpVector<const MemRegion*>*>(OriginalVars);
+  auto *VecOriginal =
+      static_cast<BumpVector<const MemRegion *> *>(OriginalVars);
 
   return BlockDataRegion::referenced_vars_iterator(Vec->begin(),
                                                    VecOriginal->begin());
@@ -1517,14 +1538,13 @@ BlockDataRegion::referenced_vars_iterato
 BlockDataRegion::referenced_vars_end() const {
   const_cast<BlockDataRegion*>(this)->LazyInitializeReferencedVars();
 
-  BumpVector<const MemRegion*> *Vec =
-    static_cast<BumpVector<const MemRegion*>*>(ReferencedVars);
+  auto *Vec = static_cast<BumpVector<const MemRegion *> *>(ReferencedVars);
 
   if (Vec == (void*) 0x1)
     return BlockDataRegion::referenced_vars_iterator(nullptr, nullptr);
 
-  BumpVector<const MemRegion*> *VecOriginal =
-    static_cast<BumpVector<const MemRegion*>*>(OriginalVars);
+  auto *VecOriginal =
+      static_cast<BumpVector<const MemRegion *> *>(OriginalVars);
 
   return BlockDataRegion::referenced_vars_iterator(Vec->end(),
                                                    VecOriginal->end());
@@ -1552,7 +1572,7 @@ void RegionAndSymbolInvalidationTraits::
 void RegionAndSymbolInvalidationTraits::setTrait(const MemRegion *MR,
                                                  InvalidationKinds IK) {
   assert(MR);
-  if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR))
+  if (const auto *SR = dyn_cast<SymbolicRegion>(MR))
     setTrait(SR->getSymbol(), IK);
   else
     MRTraitsMap[MR] |= IK;
@@ -1572,7 +1592,7 @@ bool RegionAndSymbolInvalidationTraits::
   if (!MR)
     return false;
 
-  if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(MR))
+  if (const auto *SR = dyn_cast<SymbolicRegion>(MR))
     return hasTrait(SR->getSymbol(), IK);
 
   const_region_iterator I = MRTraitsMap.find(MR);




More information about the cfe-commits mailing list