File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ static void walkSubElementsImpl(InterfaceT interface,
27
27
DenseSet<Type> &visitedTypes) {
28
28
interface.walkImmediateSubElements (
29
29
[&](Attribute attr) {
30
+ // Guard against potentially null inputs. This removes the need for the
31
+ // derived attribute/type to do it.
32
+ if (!attr)
33
+ return ;
34
+
30
35
// Avoid infinite recursion when visiting sub attributes later, if this
31
36
// is a mutable attribute.
32
37
if (LLVM_UNLIKELY (attr.hasTrait <AttributeTrait::IsMutable>())) {
@@ -43,6 +48,11 @@ static void walkSubElementsImpl(InterfaceT interface,
43
48
walkAttrsFn (attr);
44
49
},
45
50
[&](Type type) {
51
+ // Guard against potentially null inputs. This removes the need for the
52
+ // derived attribute/type to do it.
53
+ if (!type)
54
+ return ;
55
+
46
56
// Avoid infinite recursion when visiting sub types later, if this
47
57
// is a mutable type.
48
58
if (LLVM_UNLIKELY (type.hasTrait <TypeTrait::IsMutable>())) {
@@ -93,6 +103,10 @@ static void updateSubElementImpl(
93
103
return ;
94
104
newElements.push_back (element);
95
105
106
+ // Guard against potentially null inputs. We always map null to null.
107
+ if (!element)
108
+ return ;
109
+
96
110
// Check for an existing mapping for this element, and walk it if we haven't
97
111
// yet.
98
112
T *mappedElement = &visited[element];
You can’t perform that action at this time.
0 commit comments