diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-04-25 20:41:38 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-04-25 20:41:38 +0000 |
commit | 1adc8c339184d09a40d770524a19734a213807ba (patch) | |
tree | b6ea76ccbb85e82dc7d07797781dc9c3fe2e9f0e /clang/lib/AST/ASTDiagnostic.cpp | |
parent | 0651d7650afe49e73d4533064aa5b6d2a85041c9 (diff) | |
download | bcm5719-llvm-1adc8c339184d09a40d770524a19734a213807ba.tar.gz bcm5719-llvm-1adc8c339184d09a40d770524a19734a213807ba.zip |
Print detailed vector type information on diagnostics.
We never aka vector types because our attributed syntax for it is less
comprehensible than the typedefs. This leaves the user in the dark when
the typedef isn't named that well.
Example:
v2s v; v4f w;
w = v;
The naming in this cases isn't even that bad, but the error we give is
useless without looking up the actual typedefs.
t.c:6:5: error: assigning to 'v4f' from incompatible type 'v2s'
Now:
t.c:6:5: error: assigning to 'v4f' (vector of 4 'float' values) from
incompatible type 'v2s' (vector of 2 'int' values)
We do this for all diagnostics that print a vector type.
llvm-svn: 207267
Diffstat (limited to 'clang/lib/AST/ASTDiagnostic.cpp')
-rw-r--r-- | clang/lib/AST/ASTDiagnostic.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 7c6bec4503f..539e666a486 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -228,6 +228,20 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, return S; } } + + // Give some additional info on vector types. These are either not desugared + // or displaying complex __attribute__ expressions so add details of the + // type and element count. + if (Ty->isVectorType()) { + const VectorType *VTy = Ty->getAs<VectorType>(); + std::string DecoratedString; + llvm::raw_string_ostream OS(DecoratedString); + const char *Values = VTy->getNumElements() > 1 ? "values" : "value"; + OS << "'" << S << "' (vector of " << VTy->getNumElements() << " '" + << VTy->getElementType().getAsString(Context.getPrintingPolicy()) + << "' " << Values << ")"; + return OS.str(); + } } S = "'" + S + "'"; |