hokein updated this revision to Diff 249039.
hokein added a comment.
- rebase to master
- fix the crash
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/include/clang/AST/Type.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
@@ -540,6 +540,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
@@ -2281,6 +2281,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
@@ -2305,6 +2306,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
@@ -2324,6 +2326,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
@@ -2343,6 +2346,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 + ExprDependenceBits + 3;
/// 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->setDependence(Deps);
E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
Index: clang/lib/AST/TextNodeDumper.cpp
===================================================================
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -128,6 +128,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
@@ -625,7 +625,8 @@
if (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/Type.h
===================================================================
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1496,7 +1496,7 @@
return CachedLocalOrUnnamed;
}
};
- enum { NumTypeBits = 18 };
+ enum { NumTypeBits = 8 + TypeDependenceBits + 6 };
protected:
// These classes allow subclasses to somewhat cleanly pack bitfields
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;
@@ -5874,7 +5880,8 @@
public:
TypoExpr(QualType T) : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary) {
assert(T->isDependentType() && "TypoExpr given a non-dependent type");
- setDependence(ExprDependence::TypeValueInstantiation);
+ setDependence(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,7 +33,7 @@
};
};
using ExprDependence = ExprDependenceScope::ExprDependence;
-static constexpr unsigned ExprDependenceBits = 4;
+static constexpr unsigned ExprDependenceBits = 5;
struct TypeDependenceScope {
enum TypeDependence : uint8_t {
@@ -42,13 +43,15 @@
/// Whether this type somehow involves a template parameter, even
/// if the resolution of the type does not depend on a template parameter.
Instantiation = 2,
+ ///
+ Error = 4,
/// Whether this type is a dependent type (C++ [temp.dep.type]).
- Dependent = 4,
+ Dependent = 8,
/// Whether this type is a variably-modified type (C99 6.7.5).
- VariablyModified = 8,
+ VariablyModified = 16,
None = 0,
- All = 15,
+ All = 31,
DependentInstantiation = Dependent | Instantiation,
@@ -56,24 +59,25 @@
};
};
using TypeDependence = TypeDependenceScope::TypeDependence;
-static constexpr unsigned TypeDependenceBits = 4;
+static constexpr unsigned TypeDependenceBits = 5;
#define LLVM_COMMON_DEPENDENCE(NAME) \
struct NAME##Scope { \
enum NAME : uint8_t { \
UnexpandedPack = 1, \
- Instantiation = 2, \
- Dependent = 4, \
+ Instantiation = 2, \
+ 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(NestedNameSpecifierDependence)
LLVM_COMMON_DEPENDENCE(TemplateNameDependence)
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