Skip to content

Commit aac0406

Browse files
committed
[Traversal] Walk into macro initializers more carefully
These expressions are a little tricky, because we don't always type-check them in the way that clients would expect. We might want to change the representation here, but until then... don't walk the untypechecked ones.
1 parent 40b3321 commit aac0406

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/AST/ASTWalker.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,15 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
423423
}
424424

425425
if (auto def = MD->definition) {
426-
if (auto newDef = doIt(def))
427-
MD->definition = newDef;
428-
else
429-
return true;
426+
// Don't walk into unchecked definitions.
427+
if (auto expansion = dyn_cast<MacroExpansionExpr>(def)) {
428+
if (!expansion->getType().isNull()) {
429+
if (auto newDef = doIt(def))
430+
MD->definition = newDef;
431+
else
432+
return true;
433+
}
434+
}
430435
}
431436

432437
// Visit trailing requirements

0 commit comments

Comments
 (0)