Profiling the pointer of a canonical type is sufficient to uniquely identify the...
authorDouglas Gregor <dgregor@apple.com>
Tue, 28 Jul 2009 15:32:17 +0000 (15:32 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 28 Jul 2009 15:32:17 +0000 (15:32 +0000)
llvm-svn: 77321

clang/lib/AST/StmtProfile.cpp

index fe8d1b7..af2b934 100644 (file)
@@ -272,21 +272,6 @@ void StmtProfiler::VisitCompoundLiteralExpr(CompoundLiteralExpr *S) {
   ID.AddBoolean(S->isFileScope());
 }
 
-void StmtProfiler::VisitDecl(Decl *D) {
-  if (Canonical) {
-    if (NonTypeTemplateParmDecl *NTTP 
-          = dyn_cast_or_null<NonTypeTemplateParmDecl>(D)) {
-      ID.AddInteger(NTTP->getDepth());
-      ID.AddInteger(NTTP->getIndex());
-      return;
-    }
-
-    // FIXME: Other template template parameters?
-  }
-  
-  ID.AddPointer(D? D->getCanonicalDecl() : 0);
-}
-
 void StmtProfiler::VisitCastExpr(CastExpr *S) {
   VisitExpr(S);
 }
@@ -604,17 +589,25 @@ void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
   ID.AddBoolean(S->isArrow());
 }
 
-void StmtProfiler::VisitType(QualType T) {
+void StmtProfiler::VisitDecl(Decl *D) {
   if (Canonical) {
-    if (const TemplateTypeParmType *TTP = T->getAs<TemplateTypeParmType>()) {
-      ID.AddInteger(TTP->getDepth());
-      ID.AddInteger(TTP->getIndex());
+    if (NonTypeTemplateParmDecl *NTTP 
+        = dyn_cast_or_null<NonTypeTemplateParmDecl>(D)) {
+      ID.AddInteger(NTTP->getDepth());
+      ID.AddInteger(NTTP->getIndex());
       return;
     }
     
-    T = Context.getCanonicalType(T);
+    // FIXME: Template template parameters?
   }
   
+  ID.AddPointer(D? D->getCanonicalDecl() : 0);
+}
+
+void StmtProfiler::VisitType(QualType T) {
+  if (Canonical)
+    T = Context.getCanonicalType(T);
+  
   ID.AddPointer(T.getAsOpaquePtr());
 }