22 unsigned ExtraNotes) {
23 return diag(Loc, DiagId, ExtraNotes,
false);
27 unsigned ExtraNotes) {
29 return diag(E->
getExprLoc(), DiagId, ExtraNotes,
false);
35 unsigned ExtraNotes) {
37 return diag(SI.
getLoc(), DiagId, ExtraNotes,
false);
43 unsigned ExtraNotes) {
50 return diag(Loc, DiagId, ExtraNotes,
true);
54 unsigned ExtraNotes) {
59 unsigned ExtraNotes) {
81 getEvalStatus().Diag->push_back(std::make_pair(Loc, PD));
82 return getEvalStatus().Diag->back().second;
86 unsigned ExtraNotes,
bool IsCCEDiag) {
88 if (EvalStatus.
Diag) {
89 if (hasPriorDiagnostic()) {
93 unsigned CallStackNotes = getCallStackDepth() - 1;
95 getASTContext().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()) {
109 return OptionalDiagnostic(&(*EvalStatus.
Diag)[0].second);
111 setActiveDiagnostic(
false);
112 return OptionalDiagnostic();
115void State::addCallStack(
unsigned Limit) {
117 unsigned ActiveCalls = getCallStackDepth() - 1;
118 unsigned SkipStart = ActiveCalls, SkipEnd = SkipStart;
119 if (Limit && Limit < ActiveCalls) {
120 SkipStart = Limit / 2 + Limit % 2;
121 SkipEnd = ActiveCalls - Limit / 2;
125 unsigned CallIdx = 0;
126 const Frame *Top = getCurrentFrame();
127 const Frame *Bottom = getBottomFrame();
128 for (
const Frame *F = Top; F != Bottom; F = F->
getCaller(), ++CallIdx) {
129 SourceRange CallRange = F->getCallRange();
133 if (CallIdx >= SkipStart && CallIdx < SkipEnd) {
134 if (CallIdx == SkipStart) {
136 addDiag(CallRange.
getBegin(), diag::note_constexpr_calls_suppressed)
137 << unsigned(ActiveCalls - Limit);
145 dyn_cast_if_present<CXXConstructorDecl>(F->getCallee());
146 CD && CD->isInheritingConstructor()) {
148 diag::note_constexpr_inherited_ctor_call_here)
153 SmallString<128> Buffer;
154 llvm::raw_svector_ostream
Out(Buffer);
157 addDiag(CallRange.
getBegin(), diag::note_constexpr_call_here)
158 <<
Out.str() << CallRange;
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.
Implements a partial diagnostic which may not be emitted.
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...
A partial diagnostic which we might know in advance that we are not going to emit.
Encodes a location in the source.
SourceLocation getBegin() const
virtual Frame * getCaller() const =0
Returns a pointer to the caller frame.
Describes the statement/declaration an opcode was generated from.
SourceLocation getLoc() const
virtual bool hasActiveDiagnostic()=0
virtual void setActiveDiagnostic(bool Flag)=0
OptionalDiagnostic Note(SourceLocation Loc, diag::kind DiagId)
Add a note to a prior diagnostic.
DiagnosticBuilder report(SourceLocation Loc, diag::kind DiagId)
Directly reports a diagnostic message.
OptionalDiagnostic FFDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
Diagnose that the evaluation could not be folded (FF => FoldFailure)
virtual Expr::EvalStatus & getEvalStatus() const =0
void addNotes(ArrayRef< PartialDiagnosticAt > Diags)
Add a stack of notes to a prior diagnostic.
OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
Diagnose that the evaluation does not produce a C++11 core constant expression.
virtual ASTContext & getASTContext() const =0
unsigned kind
All of the diagnostics that can be emitted by the frontend.
The JSON file list parser is used to communicate input to InstallAPI.
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...