[PATCH] D153851: [clang][dataflow] Output debug info if `getChild()` doesn't find field.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 28 02:12:27 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG834a84d091ab: [clang][dataflow] Output debug info if `getChild()` doesn't find field. (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153851/new/

https://reviews.llvm.org/D153851

Files:
  clang/include/clang/Analysis/FlowSensitive/StorageLocation.h


Index: clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
===================================================================
--- clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
+++ clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
@@ -17,6 +17,9 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/Debug.h"
+
+#define DEBUG_TYPE "dataflow"
 
 namespace clang {
 namespace dataflow {
@@ -85,6 +88,17 @@
   /// Returns the child storage location for `D`.
   StorageLocation &getChild(const ValueDecl &D) const {
     auto It = Children.find(&D);
+    LLVM_DEBUG({
+      if (It == Children.end()) {
+        llvm::dbgs() << "Couldn't find child " << D.getNameAsString()
+                     << " on StorageLocation " << this << " of type "
+                     << getType() << "\n";
+        llvm::dbgs() << "Existing children:\n";
+        for ([[maybe_unused]] auto [Field, Loc] : Children) {
+          llvm::dbgs() << Field->getNameAsString() << "\n";
+        }
+      }
+    });
     assert(It != Children.end());
     return *It->second;
   }
@@ -100,4 +114,6 @@
 } // namespace dataflow
 } // namespace clang
 
+#undef DEBUG_TYPE
+
 #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153851.535292.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230628/31506b02/attachment.bin>


More information about the cfe-commits mailing list