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 | eab5d1eaaa662c849f1f9920dc8c6a31d7c32d47 (patch) | |
tree | 1313bf5996ce3065393646b179b9e8f2b5408c31 /lib/Sema/Sema.cpp | |
parent | 90f97892eb8b2ecfcf633c9df01e2504686d4d96 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 7190cf0f1f..ccfbe1e00a 100644 --- a/lib/Sema/Sema.cpp +++ b/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())); |