[PATCH] D15861: Support fully-qualified names for all QualTypes

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 8 15:50:57 PST 2016


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

OK, let's go ahead with this approach for now; we can investigate replacing the implementation with a `PrintingPolicy` flag later.


================
Comment at: lib/Tooling/Core/QualTypeNames.cpp:308-312
@@ +307,7 @@
+  Decl *Decl = nullptr;
+  if (const TypedefType *TDT = llvm::dyn_cast<TypedefType>(TypePtr)) {
+    Decl = TDT->getDecl();
+  } else {
+    // There are probably other cases ...
+    if (const TagType *TagDeclType = llvm::dyn_cast<TagType>(TypePtr))
+      Decl = TagDeclType->getDecl();
----------------
You don't need `llvm::` on `dyn_cast`. It's more idiomatic to use `const auto *TDT = dyn_cast<TypedefType>(TypePtr)` rather than repeating the type on both sides of the `=`.

================
Comment at: lib/Tooling/Core/QualTypeNames.cpp:310-316
@@ +309,9 @@
+    Decl = TDT->getDecl();
+  } else {
+    // There are probably other cases ...
+    if (const TagType *TagDeclType = llvm::dyn_cast<TagType>(TypePtr))
+      Decl = TagDeclType->getDecl();
+    else
+      Decl = TypePtr->getAsCXXRecordDecl();
+  }
+
----------------
Maybe drop the braces around this to form an `if`/`else if` chain.


http://reviews.llvm.org/D15861





More information about the cfe-commits mailing list