[clang] [clang] Fix pretty-printing assume_aligned attributes (PR #67331)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 09:59:46 PDT 2023


================
@@ -320,10 +320,11 @@ namespace {
     }
 
     std::string getIsOmitted() const override {
-      if (type == "IdentifierInfo *")
-        return "!get" + getUpperName().str() + "()";
-      if (type == "TypeSourceInfo *")
+      StringRef T = type;
+      if (T == "TypeSourceInfo *")
         return "!get" + getUpperName().str() + "Loc()";
+      if (T.ends_with(" *"))
+        return "!get" + getUpperName().str() + "()";
----------------
erichkeane wrote:

Ah, you're not wrong about this not being worse... I guess the list of things handled in here are finite, since this is a list from a generated .td file.  

I think handling `Expr *` separately (as a separate condition of the `IdentifierInfo *` line) is probably the 'right' way to go, but I think we should have an 'assert' above the return-false to ensure that anyone who adds a new type makes sure it gets handled here.

https://github.com/llvm/llvm-project/pull/67331


More information about the cfe-commits mailing list