Szelethus created this revision.
Szelethus added reviewers: xazax.hun, george.karpenkov, NoQ, rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, 
whisperity.
Szelethus added a dependency: D50504: [analyzer][UninitializedObjectChecker] 
Refactoring p2.: Moving pointer chasing to a separate file.

This is a standalone part of the effort to reduce `FieldChainInfo`s inteerface.


Repository:
  rC Clang

https://reviews.llvm.org/D50505

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject.h
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp

Index: lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp
@@ -18,8 +18,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "UninitializedObject.h"
 #include "ClangSACheckers.h"
+#include "UninitializedObject.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
@@ -40,8 +40,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "UninitializedObject.h"
 #include "ClangSACheckers.h"
+#include "UninitializedObject.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
@@ -81,7 +81,7 @@
 /// (e.g. if the object is a field of another object, in which case we'd check
 /// it multiple times).
 static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
-                               CheckerContext &Context);
+                                      CheckerContext &Context);
 
 /// Constructs a note message for a given FieldChainInfo object.
 static void printNoteMessage(llvm::raw_ostream &Out,
@@ -305,7 +305,6 @@
   return false;
 }
 
-
 bool FindUninitializedFields::isPrimitiveUninit(const SVal &V) {
   if (V.isUndef())
     return true;
@@ -341,6 +340,13 @@
   return (*Chain.begin())->getDecl();
 }
 
+/// Prints every element except the last to `Out`. Since ImmutableLists store
+/// elements in reverse order, and have no reverse iterators, we use a
+/// recursive function to print the fieldchain correctly. The last element in
+/// the chain is to be printed by `print`.
+static void printTail(llvm::raw_ostream &Out,
+                      const FieldChainInfo::FieldChainImpl *L);
+
 // TODO: This function constructs an incorrect string if a void pointer is a
 // part of the chain:
 //
@@ -378,15 +384,13 @@
   if (Chain.isEmpty())
     return;
 
-  const llvm::ImmutableListImpl<const FieldRegion *> *L =
-      Chain.getInternalPointer();
+  const FieldChainImpl *L = Chain.getInternalPointer();
   printTail(Out, L->getTail());
   Out << getVariableName(L->getHead()->getDecl());
 }
 
-void FieldChainInfo::printTail(
-    llvm::raw_ostream &Out,
-    const llvm::ImmutableListImpl<const FieldRegion *> *L) {
+static void printTail(llvm::raw_ostream &Out,
+                      const FieldChainInfo::FieldChainImpl *L) {
   if (!L)
     return;
 
@@ -415,7 +419,7 @@
 }
 
 static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
-                               CheckerContext &Context) {
+                                      CheckerContext &Context) {
 
   Optional<nonloc::LazyCompoundVal> CurrentObject = getObjectVal(Ctor, Context);
   if (!CurrentObject)
Index: lib/StaticAnalyzer/Checkers/UninitializedObject.h
===================================================================
--- lib/StaticAnalyzer/Checkers/UninitializedObject.h
+++ lib/StaticAnalyzer/Checkers/UninitializedObject.h
@@ -35,6 +35,7 @@
 /// constructor calls.
 class FieldChainInfo {
 public:
+  using FieldChainImpl = llvm::ImmutableListImpl<const FieldRegion *>;
   using FieldChain = llvm::ImmutableList<const FieldRegion *>;
 
 private:
@@ -48,7 +49,8 @@
   FieldChainInfo(FieldChain::Factory &F) : Factory(F) {}
 
   FieldChainInfo(const FieldChainInfo &Other, const bool IsDereferenced)
-      : Factory(Other.Factory), Chain(Other.Chain), IsDereferenced(IsDereferenced) {}
+      : Factory(Other.Factory), Chain(Other.Chain),
+        IsDereferenced(IsDereferenced) {}
 
   FieldChainInfo(const FieldChainInfo &Other, const FieldRegion *FR,
                  const bool IsDereferenced = false);
@@ -64,12 +66,6 @@
   void print(llvm::raw_ostream &Out) const;
 
 private:
-  /// Prints every element except the last to `Out`. Since ImmutableLists store
-  /// elements in reverse order, and have no reverse iterators, we use a
-  /// recursive function to print the fieldchain correctly. The last element in
-  /// the chain is to be printed by `print`.
-  static void printTail(llvm::raw_ostream &Out,
-                        const llvm::ImmutableListImpl<const FieldRegion *> *L);
   friend struct FieldChainInfoComparator;
 };
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D50505: [analyzer][... Umann Kristóf via Phabricator via cfe-commits

Reply via email to