[AST] Add a flag indicating if any subexpression had errors
The only subexpression that is considered an error now is TypoExpr, but
we plan to add expressions with errors to improve editor tooling on broken
code. We intend to use the same mechanism to guard against spurious
diagnostics on those as well.
See the follow-up revision for an actual usage of the flag.
Original patch from Ilya.
Reviewers: sammccall
Reviewed By: sammccall
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65591
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index d74b0d5..1fbcab2 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -106,7 +106,8 @@
/// The number of record fields required for the Expr class
/// itself.
- static const unsigned NumExprFields = NumStmtFields + 7;
+ static const unsigned NumExprFields =
+ NumStmtFields + ExprDependenceBits + 3;
/// Read and initialize a ExplicitTemplateArgumentList structure.
void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
@@ -517,6 +518,7 @@
bool ValueDependent = Record.readInt();
bool InstantiationDependent = Record.readInt();
bool ContainsUnexpandedTemplateParameters = Record.readInt();
+ bool ContainsErrors = Record.readInt();
auto Deps = ExprDependence::None;
if (TypeDependent)
Deps |= ExprDependence::Type;
@@ -526,6 +528,8 @@
Deps |= ExprDependence::Instantiation;
if (ContainsUnexpandedTemplateParameters)
Deps |= ExprDependence::UnexpandedPack;
+ if (ContainsErrors)
+ Deps |= ExprDependence::Error;
E->setDependence(Deps);
E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));