ilya-biryukov updated this revision to Diff 241706.
ilya-biryukov added a comment.
Herald added a subscriber: bmahjour.
Rebase on top of refactored dependence propagation
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65591/new/
https://reviews.llvm.org/D65591
Files:
clang/include/clang/AST/ASTDumperUtils.h
clang/include/clang/AST/DependencyFlags.h
clang/include/clang/AST/Expr.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===================================================================
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -462,6 +462,7 @@
Record.push_back(E->isValueDependent());
Record.push_back(E->isInstantiationDependent());
Record.push_back(E->containsUnexpandedParameterPack());
+ Record.push_back(E->containsErrors());
Record.push_back(E->getValueKind());
Record.push_back(E->getObjectKind());
}
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2258,6 +2258,7 @@
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
//DeclRefExpr
@@ -2282,6 +2283,7 @@
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
//Integer Literal
@@ -2301,6 +2303,7 @@
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
//Character Literal
@@ -2320,6 +2323,7 @@
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
// CastExpr
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===================================================================
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -106,7 +106,7 @@
/// The number of record fields required for the Expr class
/// itself.
- static const unsigned NumExprFields = NumStmtFields + 7;
+ static const unsigned NumExprFields = NumStmtFields + 8;
/// Read and initialize a ExplicitTemplateArgumentList structure.
void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
@@ -518,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;
@@ -527,6 +528,8 @@
Deps |= ExprDependence::Instantiation;
if (ContainsUnexpandedTemplateParameters)
Deps |= ExprDependence::UnexpandedPack;
+ if (ContainsErrors)
+ Deps |= ExprDependence::Error;
E->setDependencies(Deps);
E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
Index: clang/lib/AST/TextNodeDumper.cpp
===================================================================
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -127,6 +127,11 @@
if (const auto *E = dyn_cast<Expr>(Node)) {
dumpType(E->getType());
+ if (E->containsErrors()) {
+ ColorScope Color(OS, ShowColors, ErrorsColor);
+ OS << " contains-errors";
+ }
+
{
ColorScope Color(OS, ShowColors, ValueKindColor);
switch (E->getValueKind()) {
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -538,7 +538,8 @@
if (!(D & ExprDependence::Type) && E->getType()->getContainedDeducedType())
D |= ExprDependence::Type;
for (auto *A : E->arguments())
- D |= A->getDependence() & ExprDependence::UnexpandedPack;
+ D |= A->getDependence() &
+ (ExprDependence::UnexpandedPack | ExprDependence::Error);
return D;
}
Index: clang/include/clang/AST/Expr.h
===================================================================
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -224,6 +224,12 @@
return static_cast<bool>(getDependence() & ExprDependence::UnexpandedPack);
}
+ /// Whether this expression contains subexpressions which had errors, e.g. a
+ /// TypoExpr.
+ bool containsErrors() const {
+ return static_cast<bool>(getDependence() & ExprDependence::Error);
+ }
+
/// getExprLoc - Return the preferred location for the arrow when diagnosing
/// a problem with a generic expression.
SourceLocation getExprLoc() const LLVM_READONLY;
@@ -5871,7 +5877,8 @@
public:
TypoExpr(QualType T) : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary) {
assert(T->isDependentType() && "TypoExpr given a non-dependent type");
- setDependencies(ExprDependence::TypeValueInstantiation);
+ setDependencies(ExprDependence::TypeValueInstantiation |
+ ExprDependence::Error);
}
child_range children() {
Index: clang/include/clang/AST/DependencyFlags.h
===================================================================
--- clang/include/clang/AST/DependencyFlags.h
+++ clang/include/clang/AST/DependencyFlags.h
@@ -17,11 +17,12 @@
enum ExprDependence : uint8_t {
UnexpandedPack = 1,
Instantiation = 2,
- Type = 4,
- Value = 8,
+ Error = 4,
+ Type = 8,
+ Value = 16,
None = 0,
- All = 15,
+ All = 31,
TypeValue = Type | Value,
TypeInstantiation = Type | Instantiation,
@@ -32,24 +33,25 @@
};
};
using ExprDependence = ExprDependenceScope::ExprDependence;
-static constexpr unsigned ExprDependenceBits = 4;
+static constexpr unsigned ExprDependenceBits = 5;
#define LLVM_COMMON_DEPENDENCE(NAME) \
struct NAME##Scope { \
enum NAME { \
UnexpandedPack = 1, \
Instantiation = 2, \
- Dependent = 4, \
+ Error = 4, \
+ Dependent = 8, \
\
None = 0, \
DependentInstantiation = Dependent | Instantiation, \
- All = 7, \
+ All = 15, \
\
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Dependent) \
}; \
}; \
using NAME = NAME##Scope::NAME; \
- static constexpr unsigned NAME##Bits = 3;
+ static constexpr unsigned NAME##Bits = 4;
LLVM_COMMON_DEPENDENCE(TypeDependence)
LLVM_COMMON_DEPENDENCE(NestedNameSpecifierDependence)
Index: clang/include/clang/AST/ASTDumperUtils.h
===================================================================
--- clang/include/clang/AST/ASTDumperUtils.h
+++ clang/include/clang/AST/ASTDumperUtils.h
@@ -62,6 +62,8 @@
static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false};
// bitfield/objcproperty/objcsubscript/vectorcomponent
static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false};
+// contains-errors
+static const TerminalColor ErrorsColor = {llvm::raw_ostream::RED, true};
// Null statements
static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false};
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits