Use canonical Decls as key for "do not desugar"; may have dupe Type*s.

This commit is contained in:
Axel Naumann 2014-10-07 16:06:28 +02:00 committed by sftnight
parent a83d3bafe3
commit 556ac8c3dc
2 changed files with 13 additions and 11 deletions

View File

@ -17,6 +17,7 @@
namespace clang {
class ASTContext;
class Expr;
class Decl;
class DeclContext;
class DeclarationName;
class GlobalDecl;
@ -140,8 +141,8 @@ namespace utils {
/// transformation
///
struct Config {
typedef llvm::SmallSet<const clang::Decl*, 4> SkipCollection;
typedef const clang::Type cType;
typedef llvm::SmallSet<cType*, 4> SkipCollection;
typedef llvm::DenseMap<cType*, cType*> ReplaceCollection;
SkipCollection m_toSkip;

View File

@ -689,12 +689,12 @@ namespace utils {
return 0;
}
static bool ShouldKeepTypedef(QualType QT,
const llvm::SmallSet<const Type*, 4>& TypesToSkip)
static bool ShouldKeepTypedef(const TypedefType* TT,
const llvm::SmallSet<const Decl*, 4>& ToSkip)
{
// Return true, if we should keep this typedef rather than desugaring it.
return 0 != TypesToSkip.count(QT.getTypePtr());
return 0 != ToSkip.count(TT->getDecl()->getCanonicalDecl());
}
static bool SingleStepPartiallyDesugarTypeImpl(QualType& QT)
@ -974,14 +974,15 @@ namespace utils {
// Desugar QT until we cannot desugar any more, or
// we hit one of the special typedefs.
while (1) {
if (llvm::isa<TypedefType>(QT.getTypePtr()) &&
ShouldKeepTypedef(QT, TypeConfig.m_toSkip)) {
if (!fullyQualifyType && !fullyQualifyTmpltArg) {
return QT;
if (const TypedefType* TT = llvm::dyn_cast<TypedefType>(QT.getTypePtr())){
if (ShouldKeepTypedef(TT, TypeConfig.m_toSkip)) {
if (!fullyQualifyType && !fullyQualifyTmpltArg) {
return QT;
}
// We might have stripped the namespace/scope part,
// so we must go on to add it back.
break;
}
// We might have stripped the namespace/scope part,
// so we must go on to add it back.
break;
}
bool wasDesugared = Transform::SingleStepPartiallyDesugarType(QT,Ctx);