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

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 25 09:54:32 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() + "()";
----------------
steakhal wrote:

I think it's not worse than it was before.
If you object, I could as well just directly compare against `type == "Expr *"`, similarly to how it was done before.
Or I'm not sure how to resolve this comment.
Did you think of dropping suffixes like `const`, `volatile`, etc? If so, why?
Out of curiosity, I put there these asserts `assert(!T.ends_with_insensitive("const"))`, `assert(!T.ends_with_insensitive("volatile"))` and they didn't fire when I ran `check-clang`, thus I think we probably keep the logic simple unless we have a use-case to solve.
WDYT?

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


More information about the cfe-commits mailing list