diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-03-25 22:17:48 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-03-25 22:17:48 +0000 |
| commit | 210b590562e1baa8a72ff1ce682290e9cbe98062 (patch) | |
| tree | 4fbcbcfb6c06cc7274b29497521484fa90c3b84b /clang/lib/Sema | |
| parent | e99d5f30446bc6dd0c2832758860250cd8ba53e5 (diff) | |
| download | bcm5719-llvm-210b590562e1baa8a72ff1ce682290e9cbe98062.tar.gz bcm5719-llvm-210b590562e1baa8a72ff1ce682290e9cbe98062.zip | |
Teach the diagnostic engine to provide more detailed information about
how to handle a diagnostic during template argument deduction, which
may be "substitution failure", "suppress", or "report". This keeps us
from, e.g., emitting warnings while performing template argument
deduction.
llvm-svn: 99560
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 24 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.h | 14 |
2 files changed, 25 insertions, 13 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 7190cf0f1ff..ccfbe1e00a7 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -348,6 +348,30 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() { } } +Sema::SemaDiagnosticBuilder Sema::Diag(SourceLocation Loc, unsigned DiagID) { + if (isSFINAEContext()) { + switch (Diagnostic::getDiagnosticSFINAEResponse(DiagID)) { + case Diagnostic::SFINAE_Report: + // Fall through; we'll report the diagnostic below. + break; + + case Diagnostic::SFINAE_SubstitutionFailure: + // Count this failure so that we know that template argument deduction + // has failed. + ++NumSFINAEErrors; + // Fall through + + case Diagnostic::SFINAE_Suppress: + // Suppress this diagnostic. + Diags.setLastDiagnosticIgnored(); + return SemaDiagnosticBuilder(*this); + } + } + + DiagnosticBuilder DB = Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID); + return SemaDiagnosticBuilder(DB, *this, DiagID); +} + Sema::SemaDiagnosticBuilder Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) { SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID())); diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index 7e2e6143965..5986b479cdd 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -610,19 +610,7 @@ public: }; /// \brief Emit a diagnostic. - SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) { - if (isSFINAEContext() && Diagnostic::isBuiltinSFINAEDiag(DiagID)) { - // If we encountered an error during template argument - // deduction, and that error is one of the SFINAE errors, - // suppress the diagnostic. - ++NumSFINAEErrors; - Diags.setLastDiagnosticIgnored(); - return SemaDiagnosticBuilder(*this); - } - - DiagnosticBuilder DB = Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID); - return SemaDiagnosticBuilder(DB, *this, DiagID); - } + SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); /// \brief Emit a partial diagnostic. SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD); |

