summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2013-12-19 02:05:20 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2013-12-19 02:05:20 +0000
commitb353ee18086227b3a4192a970cdbced5358003f5 (patch)
tree64ae9508ca7ea628d2b65cd55305b8158d2a4022 /clang/lib/Serialization/ASTReaderDecl.cpp
parent092ab4a9fe43493b3d884baee34b9c0373f22c3b (diff)
downloadbcm5719-llvm-b353ee18086227b3a4192a970cdbced5358003f5.tar.gz
bcm5719-llvm-b353ee18086227b3a4192a970cdbced5358003f5.zip
PCH: fix a crash caused by a circular deserialization dependency
We started by trying to deserialize decltype(func-param) in a trailing return type, which causes the function parameter decl to be deserialized, which pulls in the function decl, which pulls the function type, which pulls the same decltype() in the return type, and then we crashed. llvm-svn: 197644
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 70fb062b2c5..c2e286814bc 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -356,11 +356,14 @@ void ASTDeclReader::Visit(Decl *D) {
}
void ASTDeclReader::VisitDecl(Decl *D) {
- if (D->isTemplateParameter()) {
+ if (D->isTemplateParameter() || D->isTemplateParameterPack() ||
+ isa<ParmVarDecl>(D)) {
// We don't want to deserialize the DeclContext of a template
- // parameter immediately, because the template parameter might be
- // used in the formulation of its DeclContext. Use the translation
- // unit DeclContext as a placeholder.
+ // parameter or of a parameter of a function template immediately. These
+ // entities might be used in the formulation of its DeclContext (for
+ // example, a function parameter can be used in decltype() in trailing
+ // return type of the function). Use the translation unit DeclContext as a
+ // placeholder.
GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
Reader.addPendingDeclContextInfo(D,
OpenPOWER on IntegriCloud