r274930 - Teach -ast-print to print constexpr variables.
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 8 14:09:08 PDT 2016
Author: vvassilev
Date: Fri Jul 8 16:09:08 2016
New Revision: 274930
URL: http://llvm.org/viewvc/llvm-project?rev=274930&view=rev
Log:
Teach -ast-print to print constexpr variables.
Patch reviewed by Richard Smith (D22168).
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/SemaCXX/ast-print.cpp
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=274930&r1=274929&r2=274930&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jul 8 16:09:08 2016
@@ -715,6 +715,11 @@ void DeclPrinter::VisitLabelDecl(LabelDe
void DeclPrinter::VisitVarDecl(VarDecl *D) {
prettyPrintPragmas(D);
+
+ QualType T = D->getTypeSourceInfo()
+ ? D->getTypeSourceInfo()->getType()
+ : D->getASTContext().getUnqualifiedObjCPointerType(D->getType());
+
if (!Policy.SuppressSpecifiers) {
StorageClass SC = D->getStorageClass();
if (SC != SC_None)
@@ -736,11 +741,13 @@ void DeclPrinter::VisitVarDecl(VarDecl *
if (D->isModulePrivate())
Out << "__module_private__ ";
+
+ if (D->isConstexpr()) {
+ Out << "constexpr ";
+ T.removeLocalConst();
+ }
}
- QualType T = D->getTypeSourceInfo()
- ? D->getTypeSourceInfo()->getType()
- : D->getASTContext().getUnqualifiedObjCPointerType(D->getType());
printDeclType(T, D->getName());
Expr *Init = D->getInit();
if (!Policy.SuppressInitializers && Init) {
Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=274930&r1=274929&r2=274930&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Fri Jul 8 16:09:08 2016
@@ -228,11 +228,13 @@ template <typename T> struct Foo : T {
};
}
-namespace dont_crash {
+namespace dont_crash_on_auto_vars {
struct T { enum E {X = 12ll }; };
struct S {
struct { int I; } ADecl;
static const auto Y = T::X;
};
//CHECK: static const auto Y = T::X;
+constexpr auto var = T::X;
+//CHECK: constexpr auto var = T::X;
}
More information about the cfe-commits
mailing list