aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-07-11 17:49:21 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-07-11 17:49:21 +0000
commit0673cb30340aadaede7b795c763b00f6b64e611c (patch)
tree57d43b23d2e6ab0dc4b7d0c1737fd0028ce81261 /lib/Basic
parenta5ca112ced1c0856187fe6717d36ce614f20d4a6 (diff)
Apply patch from Richard Trieu to fix PR9548:
When two different types has the same text representation in the same diagnostic message, print an a.k.a. after the type if the a.k.a. gives extra information about the type. class versa_string; typedef versa_string string; namespace std {template <typename T> class vector;} using std::vector; void f(vector<string> v); namespace std { class basic_string; typedef basic_string string; template <typename T> class vector {}; void g() { vector<string> v; f(v); } } Old message: ---------------- test.cc:15:3: error: no matching function for call to 'f' f(&v); ^ test.cc:7:6: note: candidate function not viable: no known conversion from 'vector<string>' to 'vector<string>' for 1st argument void f(vector<string> v); ^ 1 error generated. New message: --------------- test.cc:15:3: error: no matching function for call to 'f' f(v); ^ test.cc:7:6: note: candidate function not viable: no known conversion from 'vector<string>' (aka 'std::vector<std::basic_string>') to 'vector<string>' (aka 'std::vector<versa_string>') for 1st argument void f(vector<string> v); ^ 1 error generated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic')
-rw-r--r--lib/Basic/Diagnostic.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index e0ef53d00d..ae363a0df0 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -26,7 +26,8 @@ static void DummyArgToStringFn(Diagnostic::ArgumentKind AK, intptr_t QT,
const Diagnostic::ArgumentValue *PrevArgs,
unsigned NumPrevArgs,
llvm::SmallVectorImpl<char> &Output,
- void *Cookie) {
+ void *Cookie,
+ llvm::SmallVectorImpl<intptr_t> &QualTypeVals) {
const char *Str = "<can't format argument>";
Output.append(Str, Str+strlen(Str));
}
@@ -544,7 +545,14 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
/// ConvertArgToString, allowing the implementation to avoid redundancies in
/// obvious cases.
llvm::SmallVector<Diagnostic::ArgumentValue, 8> FormattedArgs;
-
+
+ /// QualTypeVals - Pass a vector of arrays so that QualType names can be
+ /// compared to see if more information is needed to be printed.
+ llvm::SmallVector<intptr_t, 2> QualTypeVals;
+ for (unsigned i = 0, e = getNumArgs(); i < e; ++i)
+ if (getArgKind(i) == Diagnostic::ak_qualtype)
+ QualTypeVals.push_back(getRawArg(i));
+
while (DiagStr != DiagEnd) {
if (DiagStr[0] != '%') {
// Append non-%0 substrings to Str if we have one.
@@ -675,7 +683,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
Modifier, ModifierLen,
Argument, ArgumentLen,
FormattedArgs.data(), FormattedArgs.size(),
- OutStr);
+ OutStr, QualTypeVals);
break;
}