[clang] 834a84d - [clang][dataflow] Output debug info if `getChild()` doesn't find field.
Martin Braenne via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 28 02:12:18 PDT 2023
Author: Martin Braenne
Date: 2023-06-28T09:12:08Z
New Revision: 834a84d091ab7d196e966d8f08101136eb1c1e06
URL: https://github.com/llvm/llvm-project/commit/834a84d091ab7d196e966d8f08101136eb1c1e06
DIFF: https://github.com/llvm/llvm-project/commit/834a84d091ab7d196e966d8f08101136eb1c1e06.diff
LOG: [clang][dataflow] Output debug info if `getChild()` doesn't find field.
Depends On D153409
Reviewed By: xazax.hun
Differential Revision: https://reviews.llvm.org/D153851
Added:
Modified:
clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h b/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
index 58ebb9bf52586..453f1e13362b7 100644
--- a/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
+++ b/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 @@ class AggregateStorageLocation final : public StorageLocation {
/// 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 @@ class AggregateStorageLocation final : public StorageLocation {
} // namespace dataflow
} // namespace clang
+#undef DEBUG_TYPE
+
#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H
More information about the cfe-commits
mailing list