diff options
| author | Artem Belevich <tra@google.com> | 2018-01-17 19:29:39 +0000 |
|---|---|---|
| committer | Artem Belevich <tra@google.com> | 2018-01-17 19:29:39 +0000 |
| commit | 224879ea4757bf758c0e0bcd2a2e5a6ec71be0f3 (patch) | |
| tree | 00dfdfaafb3de018939dec6e5af8c78d0b07c2aa /clang/lib | |
| parent | 9f3fe42e19e693c59295abeb5a1d9463140ccaae (diff) | |
| download | bcm5719-llvm-224879ea4757bf758c0e0bcd2a2e5a6ec71be0f3.tar.gz bcm5719-llvm-224879ea4757bf758c0e0bcd2a2e5a6ec71be0f3.zip | |
[DeclPrinter] Fix two cases that crash clang -ast-print.
Both are related to handling anonymous structures.
* clang didn't handle () around an anonymous struct variable.
* clang also crashed on syntax errors that could lead to other
syntactic constructs following the declaration of an
anonymous struct. While the code is invalid, that's not
a good reason to panic compiler.
Differential Revision: https://reviews.llvm.org/D41788
llvm-svn: 322742
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index b792c5920a5..e82144b0ae9 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -128,9 +128,7 @@ static QualType GetBaseType(QualType T) { // FIXME: This should be on the Type class! QualType BaseType = T; while (!BaseType->isSpecifierType()) { - if (isa<TypedefType>(BaseType)) - break; - else if (const PointerType* PTy = BaseType->getAs<PointerType>()) + if (const PointerType *PTy = BaseType->getAs<PointerType>()) BaseType = PTy->getPointeeType(); else if (const BlockPointerType *BPy = BaseType->getAs<BlockPointerType>()) BaseType = BPy->getPointeeType(); @@ -144,8 +142,11 @@ static QualType GetBaseType(QualType T) { BaseType = RTy->getPointeeType(); else if (const AutoType *ATy = BaseType->getAs<AutoType>()) BaseType = ATy->getDeducedType(); + else if (const ParenType *PTy = BaseType->getAs<ParenType>()) + BaseType = PTy->desugar(); else - llvm_unreachable("Unknown declarator!"); + // This must be a syntax error. + break; } return BaseType; } |

