simideveloper created this revision.
Herald added a project: All.
simideveloper requested review of this revision.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146867
Files:
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Interp/Interp.cpp
Index: clang/lib/AST/Interp/Interp.cpp
===================================================================
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -369,9 +369,9 @@
}
static void DiagnoseUninitializedSubobject(InterpState &S, const SourceInfo &SI,
- QualType SubObjType,
+ StringRef SubObjName,
SourceLocation SubObjLoc) {
- S.FFDiag(SI, diag::note_constexpr_uninitialized) << true << SubObjType;
+ S.FFDiag(SI, diag::note_constexpr_uninitialized) << true << SubObjName;
if (SubObjLoc.isValid())
S.Note(SubObjLoc, diag::note_constexpr_subobject_declared_here);
}
@@ -400,7 +400,7 @@
} else {
for (size_t I = 0; I != NumElems; ++I) {
if (!BasePtr.atIndex(I).isInitialized()) {
- DiagnoseUninitializedSubobject(S, S.Current->getSource(OpPC), ElemType,
+ DiagnoseUninitializedSubobject(S, S.Current->getSource(OpPC), BasePtr.getElemRecord()->getName(),
BasePtr.getFieldDesc()->getLocation());
Result = false;
}
@@ -427,7 +427,7 @@
Result &= CheckArrayInitialized(S, OpPC, FieldPtr, CAT);
} else if (!FieldPtr.isInitialized()) {
DiagnoseUninitializedSubobject(S, S.Current->getSource(OpPC),
- F.Decl->getType(), F.Decl->getLocation());
+ F.Decl->getName(), F.Decl->getLocation());
Result = false;
}
}
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2119,7 +2119,7 @@
EvalInfo &Info, SourceLocation DiagLoc,
QualType Type, const APValue &Value,
ConstantExprKind Kind,
- SourceLocation SubobjectLoc,
+ const FieldDecl* SubobjectDecl,
CheckedTemporaries &CheckedTemps);
/// Check that this reference or pointer core constant expression is a valid
@@ -2267,7 +2267,7 @@
assert(V && "evasluation result refers to uninitialised temporary");
if (!CheckEvaluationResult(CheckEvaluationResultKind::ConstantExpression,
Info, MTE->getExprLoc(), TempType, *V,
- Kind, SourceLocation(), CheckedTemps))
+ Kind, /*SubobjectDecl=*/nullptr, CheckedTemps))
return false;
}
}
@@ -2350,13 +2350,13 @@
EvalInfo &Info, SourceLocation DiagLoc,
QualType Type, const APValue &Value,
ConstantExprKind Kind,
- SourceLocation SubobjectLoc,
+ const FieldDecl* SubobjectDecl,
CheckedTemporaries &CheckedTemps) {
- if (!Value.hasValue()) {
+ if ((!Value.hasValue())&& SubobjectDecl!=nullptr) {
Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
- << true << Type;
- if (SubobjectLoc.isValid())
- Info.Note(SubobjectLoc, diag::note_constexpr_subobject_declared_here);
+ << true << SubobjectDecl->getName();
+ if (SubobjectDecl->getLocation().isValid())
+ Info.Note(SubobjectDecl->getLocation(), diag::note_constexpr_subobject_declared_here);
return false;
}
@@ -2372,20 +2372,20 @@
QualType EltTy = Type->castAsArrayTypeUnsafe()->getElementType();
for (unsigned I = 0, N = Value.getArrayInitializedElts(); I != N; ++I) {
if (!CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
- Value.getArrayInitializedElt(I), Kind,
- SubobjectLoc, CheckedTemps))
+ Value.getArrayInitializedElt(I), Kind,SubobjectDecl
+ , CheckedTemps))
return false;
}
if (!Value.hasArrayFiller())
return true;
return CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
- Value.getArrayFiller(), Kind, SubobjectLoc,
+ Value.getArrayFiller(), Kind, SubobjectDecl,
CheckedTemps);
}
if (Value.isUnion() && Value.getUnionField()) {
return CheckEvaluationResult(
CERK, Info, DiagLoc, Value.getUnionField()->getType(),
- Value.getUnionValue(), Kind, Value.getUnionField()->getLocation(),
+ Value.getUnionValue(), Kind, Value.getUnionField(),
CheckedTemps);
}
if (Value.isStruct()) {
@@ -2395,7 +2395,7 @@
for (const CXXBaseSpecifier &BS : CD->bases()) {
if (!CheckEvaluationResult(CERK, Info, DiagLoc, BS.getType(),
Value.getStructBase(BaseIndex), Kind,
- BS.getBeginLoc(), CheckedTemps))
+ /*SubobjectDecl=*/nullptr, CheckedTemps))
return false;
++BaseIndex;
}
@@ -2406,7 +2406,7 @@
if (!CheckEvaluationResult(CERK, Info, DiagLoc, I->getType(),
Value.getStructField(I->getFieldIndex()),
- Kind, I->getLocation(), CheckedTemps))
+ Kind, I, CheckedTemps))
return false;
}
}
@@ -2440,7 +2440,7 @@
CheckedTemporaries CheckedTemps;
return CheckEvaluationResult(CheckEvaluationResultKind::ConstantExpression,
Info, DiagLoc, Type, Value, Kind,
- SourceLocation(), CheckedTemps);
+ nullptr, CheckedTemps);
}
/// Check that this evaluated value is fully-initialized and can be loaded by
@@ -2450,7 +2450,7 @@
CheckedTemporaries CheckedTemps;
return CheckEvaluationResult(
CheckEvaluationResultKind::FullyInitialized, Info, DiagLoc, Type, Value,
- ConstantExprKind::Normal, SourceLocation(), CheckedTemps);
+ ConstantExprKind::Normal,nullptr, CheckedTemps);
}
/// Enforce C++2a [expr.const]/4.17, which disallows new-expressions unless
Index: clang/include/clang/Basic/DiagnosticASTKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticASTKinds.td
+++ clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -6,12 +6,6 @@
//
//===----------------------------------------------------------------------===//
-//----------------understanding syntax of diagnostics messages--------===//
-//keyword after def represents symbolic constant for that diagnostics
-//for %select{}num The select operator uses num to select one of the alternatives inside the braces, which are separated by |.
-//If you pass 0 as parameter , it will substitute the 0th alternative, which is the empty string; if you pass I, it will substitute the Ith alternative
-//%num is a placeholder for a parameter passed to the diagnostic engine where num can be 0 for first argument 1 for second argument and so on
-//===--------------------------------------------------------------------===//
let Component = "AST" in {
// Constant expression diagnostics. These (and their users) belong in Sema.
@@ -71,7 +65,7 @@
"%select{pointer|reference}0 to a consteval declaration "
"is not a constant expression">;
def note_constexpr_uninitialized : Note<
- "%select{|sub}0object of type %1 is not initialized">;
+ "%select{|sub}0object %1 is not initialized">;
def note_constexpr_static_local : Note<
"control flows through the definition of a %select{static|thread_local}0 variable">;
def note_constexpr_subobject_declared_here : Note<
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits