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 | |
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')
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 13 | ||||
-rw-r--r-- | include/clang/Basic/PartialDiagnostic.h | 21 |
2 files changed, 29 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index d50b7fca1b..e954eb6bc3 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -895,7 +895,7 @@ def err_tagless_friend_type_template : Error< def err_no_matching_local_friend : Error< "no matching function found in local scope">; def err_no_matching_local_friend_suggest : Error< - "no matching function %0 found in local scope; did you mean %2?">; + "no matching function %0 found in local scope; did you mean %3?">; def err_partial_specialization_friend : Error< "partial specialization cannot be declared as a friend">; def err_qualified_friend_def : Error< @@ -4345,8 +4345,8 @@ def err_friend_decl_with_def_arg_redeclared : Error< def err_friend_decl_does_not_match : Error< "friend declaration of %0 does not match any declaration in %1">; def err_member_decl_does_not_match_suggest : Error< - "out-of-line %select{declaration|definition}3 of %0 " - "does not match any declaration in %1; did you mean %2?">; + "out-of-line %select{declaration|definition}2 of %0 " + "does not match any declaration in %1; did you mean %3?">; def err_member_def_does_not_match_ret_type : Error< "out-of-line definition of %q0 differs from the declaration in the return type">; def err_nonstatic_member_out_of_line : Error< @@ -6464,7 +6464,7 @@ def warn_direct_ivar_access : Warning<"instance variable %0 is being " // Spell-checking diagnostics def err_unknown_type_or_class_name_suggest : Error< - "unknown %select{type|class}2 name %0; did you mean %1?">; + "unknown %select{type|class}1 name %0; did you mean %2?">; def err_unknown_typename_suggest : Error< "unknown type name %0; did you mean %1?">; def err_unknown_nested_typename_suggest : Error< @@ -6576,8 +6576,11 @@ def err_opencl_global_invalid_addr_space : Error< let CategoryName = "OpenMP Issue" in { // OpenMP support. +def err_omp_expected_var_arg : Error< + "%0 is not a global variable, static local variable or static data member">; def err_omp_expected_var_arg_suggest : Error< - "%0 is not a global variable, static local variable or static data member%select{|; did you mean %2?}1">; + "%0 is not a global variable, static local variable or static data member; " + "did you mean %1">; def err_omp_global_var_arg : Error< "arguments of '#pragma omp %0' must have %select{global storage|static storage duration}1">; def err_omp_ref_type_arg : Error< 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; |