r274859 - Don't crash when printing auto variables.
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 8 09:04:22 PDT 2016
Author: vvassilev
Date: Fri Jul 8 11:04:22 2016
New Revision: 274859
URL: http://llvm.org/viewvc/llvm-project?rev=274859&view=rev
Log:
Don't crash when printing auto variables.
Patch by Axel Naumann!
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=274859&r1=274858&r2=274859&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jul 8 11:04:22 2016
@@ -132,6 +132,8 @@ static QualType GetBaseType(QualType T)
BaseType = VTy->getElementType();
else if (const ReferenceType *RTy = BaseType->getAs<ReferenceType>())
BaseType = RTy->getPointeeType();
+ else if (const AutoType *ATy = BaseType->getAs<AutoType>())
+ BaseType = ATy->getDeducedType();
else
llvm_unreachable("Unknown declarator!");
}
Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=274859&r1=274858&r2=274859&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Fri Jul 8 11:04:22 2016
@@ -227,3 +227,12 @@ template <typename T> struct Foo : T {
using T::operator-;
};
}
+
+namespace dont_crash {
+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;
+}
More information about the cfe-commits
mailing list