diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-03-03 04:09:56 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-03-03 04:09:56 +0000 |
commit | 16412ef25a2203b7066d0db2b41f944631e5cf79 (patch) | |
tree | 8f32e2a14e146b2d8a0d03c7b1cdec5c6540b35a /lib/AST/ASTContext.cpp | |
parent | 7e8678314cf19f28cfddb2d9d0567d993073ec7e (diff) |
Avoid an unnecessary recursive loop between type canonicalization and NNS canonicalization which would (rarely) lead to memory corruption. While I'm here, simplify. Fixes PR12166. Not committing a testcase because it's impossible to reduce it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index e0056da60b..9424bc3006 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3376,26 +3376,13 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const { // types, e.g., // typedef typename T::type T1; // typedef typename T1::type T2; - if (const DependentNameType *DNT = T->getAs<DependentNameType>()) { - NestedNameSpecifier *Prefix - = getCanonicalNestedNameSpecifier(DNT->getQualifier()); - return NestedNameSpecifier::Create(*this, Prefix, + if (const DependentNameType *DNT = T->getAs<DependentNameType>()) + return NestedNameSpecifier::Create(*this, DNT->getQualifier(), const_cast<IdentifierInfo *>(DNT->getIdentifier())); - } - // Do the same thing as above, but with dependent-named specializations. - if (const DependentTemplateSpecializationType *DTST - = T->getAs<DependentTemplateSpecializationType>()) { - NestedNameSpecifier *Prefix - = getCanonicalNestedNameSpecifier(DTST->getQualifier()); - - T = getDependentTemplateSpecializationType(DTST->getKeyword(), - Prefix, DTST->getIdentifier(), - DTST->getNumArgs(), - DTST->getArgs()); - T = getCanonicalType(T); - } - + // Otherwise, just canonicalize the type, and force it to be a TypeSpec. + // FIXME: Why are TypeSpec and TypeSpecWithTemplate distinct in the + // first place? return NestedNameSpecifier::Create(*this, 0, false, const_cast<Type*>(T.getTypePtr())); } |