summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/TemplateBase.cpp
diff options
context:
space:
mode:
authorWill Wilson <will@indefiant.com>2014-12-13 04:31:07 +0000
committerWill Wilson <will@indefiant.com>2014-12-13 04:31:07 +0000
commit67c41ba0dd7c2d6aeb5c74b232d0ec813d0bb13e (patch)
treed7292fd34e738729f541a18260ed6c67709674da /clang/lib/AST/TemplateBase.cpp
parent01ad4ae72b375ffd6ee1a44240c7a55498ccef8b (diff)
downloadbcm5719-llvm-67c41ba0dd7c2d6aeb5c74b232d0ec813d0bb13e.tar.gz
bcm5719-llvm-67c41ba0dd7c2d6aeb5c74b232d0ec813d0bb13e.zip
Pretty print support for template arg enum constants
llvm-svn: 224184
Diffstat (limited to 'clang/lib/AST/TemplateBase.cpp')
-rw-r--r--clang/lib/AST/TemplateBase.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index f07b18e7c12..4250c813a28 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -33,11 +33,22 @@ using namespace clang;
/// \param TemplArg the TemplateArgument instance to print.
///
/// \param Out the raw_ostream instance to use for printing.
+///
+/// \param Policy the printing policy for EnumConstantDecl printing.
static void printIntegral(const TemplateArgument &TemplArg,
- raw_ostream &Out) {
+ raw_ostream &Out, const PrintingPolicy& Policy) {
const ::clang::Type *T = TemplArg.getIntegralType().getTypePtr();
const llvm::APSInt &Val = TemplArg.getAsIntegral();
+ if (const EnumType* ET = T->getAs<EnumType>()) {
+ for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
+ if (ECD->getInitVal() == Val) {
+ ECD->printQualifiedName(Out, Policy);
+ return;
+ }
+ }
+ }
+
if (T->isBooleanType()) {
Out << (Val.getBoolValue() ? "true" : "false");
} else if (T->isCharType()) {
@@ -378,7 +389,7 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
break;
case Integral: {
- printIntegral(*this, Out);
+ printIntegral(*this, Out, Policy);
break;
}
OpenPOWER on IntegriCloud