forked from OSchip/llvm-project
Teach -ast-print to print constexpr variables.
Patch reviewed by Richard Smith (D22168). llvm-svn: 274930
This commit is contained in:
parent
5246482c7a
commit
1002373946
|
@ -715,6 +715,11 @@ void DeclPrinter::VisitLabelDecl(LabelDecl *D) {
|
|||
|
||||
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 *D) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue