diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-17 00:46:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-17 00:46:16 +0000 |
commit | 2d67097ad41f4c2fe82ebce3f587e06498f1bd71 (patch) | |
tree | dd6cae767852e74d46c2fd18b46e5630c73c96f8 /include/clang/Basic/PartialDiagnostic.h | |
parent | 2845a6746f6320994675a9a413ecbe5252d4dc02 (diff) |
Refactor all diagnosing of TypoCorrections through a common function, in
preparation for teaching this function how to diagnose a correction that
includes importing a module.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r-- | include/clang/Basic/PartialDiagnostic.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h index 3f68160f69..dd29926fce 100644 --- a/include/clang/Basic/PartialDiagnostic.h +++ b/include/clang/Basic/PartialDiagnostic.h @@ -368,6 +368,27 @@ public: } friend inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const IdentifierInfo *II) { + PD.AddTaggedVal(reinterpret_cast<intptr_t>(II), + DiagnosticsEngine::ak_identifierinfo); + return PD; + } + + // Adds a DeclContext to the diagnostic. The enable_if template magic is here + // so that we only match those arguments that are (statically) DeclContexts; + // other arguments that derive from DeclContext (e.g., RecordDecls) will not + // match. + template<typename T> + friend inline + typename llvm::enable_if<llvm::is_same<T, DeclContext>, + const PartialDiagnostic &>::type + operator<<(const PartialDiagnostic &PD, T *DC) { + PD.AddTaggedVal(reinterpret_cast<intptr_t>(DC), + DiagnosticsEngine::ak_declcontext); + return PD; + } + + friend inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, const SourceRange &R) { PD.AddSourceRange(CharSourceRange::getTokenRange(R)); return PD; |