21 unsigned ExtraNotes) {
22 return diag(Loc, DiagId, ExtraNotes,
false);
26 unsigned ExtraNotes) {
27 if (getEvalStatus().
Diag)
28 return diag(E->
getExprLoc(), DiagId, ExtraNotes,
false);
29 setActiveDiagnostic(
false);
34 unsigned ExtraNotes) {
35 if (getEvalStatus().
Diag)
36 return diag(SI.
getLoc(), DiagId, ExtraNotes,
false);
37 setActiveDiagnostic(
false);
42 unsigned ExtraNotes) {
45 if (!getEvalStatus().
Diag || !getEvalStatus().
Diag->empty()) {
46 setActiveDiagnostic(
false);
49 return diag(Loc, DiagId, ExtraNotes,
true);
53 unsigned ExtraNotes) {
54 return CCEDiag(E->
getExprLoc(), DiagId, ExtraNotes);
58 unsigned ExtraNotes) {
59 return CCEDiag(SI.
getLoc(), DiagId, ExtraNotes);
63 if (!hasActiveDiagnostic())
69 if (hasActiveDiagnostic()) {
70 getEvalStatus().Diag->insert(getEvalStatus().
Diag->end(), Diags.begin(),
76 return getCtx().getDiagnostics().Report(Loc, DiagId);
82 getEvalStatus().Diag->push_back(std::make_pair(Loc, PD));
83 return getEvalStatus().Diag->back().second;
87 unsigned ExtraNotes,
bool IsCCEDiag) {
89 if (EvalStatus.
Diag) {
90 if (hasPriorDiagnostic()) {
94 unsigned CallStackNotes = getCallStackDepth() - 1;
95 unsigned Limit = getCtx().getDiagnostics().getConstexprBacktraceLimit();
97 CallStackNotes = std::min(CallStackNotes, Limit + 1);
98 if (checkingPotentialConstantExpression())
101 setActiveDiagnostic(
true);
102 setFoldFailureDiagnostic(!IsCCEDiag);
103 EvalStatus.
Diag->clear();
104 EvalStatus.
Diag->reserve(1 + ExtraNotes + CallStackNotes);
105 addDiag(Loc, DiagId);
106 if (!checkingPotentialConstantExpression()) {
111 setActiveDiagnostic(
false);
115const LangOptions &State::getLangOpts()
const {
return getCtx().getLangOpts(); }
117void State::addCallStack(
unsigned Limit) {
119 unsigned ActiveCalls = getCallStackDepth() - 1;
120 unsigned SkipStart = ActiveCalls, SkipEnd = SkipStart;
121 if (Limit && Limit < ActiveCalls) {
122 SkipStart = Limit / 2 + Limit % 2;
123 SkipEnd = ActiveCalls - Limit / 2;
127 unsigned CallIdx = 0;
128 Frame *Top = getCurrentFrame();
129 const Frame *Bottom = getBottomFrame();
130 for (
Frame *F = Top; F != Bottom; F = F->
getCaller(), ++CallIdx) {
134 if (CallIdx >= SkipStart && CallIdx < SkipEnd) {
135 if (CallIdx == SkipStart) {
137 addDiag(CallLocation, diag::note_constexpr_calls_suppressed)
145 if (
auto *CD = dyn_cast_if_present<CXXConstructorDecl>(F->getCallee())) {
146 if (CD->isInheritingConstructor()) {
147 addDiag(CallLocation, diag::note_constexpr_inherited_ctor_call_here)
154 llvm::raw_svector_ostream Out(Buffer);
156 addDiag(CallLocation, diag::note_constexpr_call_here) << Out.str();
Defines the clang::ASTContext interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
A little helper class used to produce diagnostics.
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A partial diagnostic which we might know in advance that we are not going to emit.
Encodes a location in the source.
Base class for stack frames, shared between VM and walker.
virtual Frame * getCaller() const =0
Returns a pointer to the caller frame.
Describes the statement/declaration an opcode was generated from.
SourceLocation getLoc() const
EvalStatus is a struct with detailed info about an evaluation in progress.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...