[PATCH] D123783: [clang] Eliminate TypeProcessingState::trivial.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 04:52:55 PDT 2022


mboehme created this revision.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This flag is redundant -- it's true iff `savedAttrs` is empty.

Querying `savedAttrs.empty()` should not take any more time than querying the
`trivial` flag, so this should not have a performance impact either.

I noticed this while working on https://reviews.llvm.org/D111548.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123783

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===================================================================
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -166,9 +166,6 @@
     /// DeclSpec.
     unsigned chunkIndex;
 
-    /// Whether there are non-trivial modifications to the decl spec.
-    bool trivial;
-
     /// Whether we saved the attributes in the decl spec.
     bool hasSavedAttrs;
 
@@ -200,8 +197,8 @@
   public:
     TypeProcessingState(Sema &sema, Declarator &declarator)
         : sema(sema), declarator(declarator),
-          chunkIndex(declarator.getNumTypeObjects()), trivial(true),
-          hasSavedAttrs(false), parsedNoDeref(false) {}
+          chunkIndex(declarator.getNumTypeObjects()), hasSavedAttrs(false),
+          parsedNoDeref(false) {}
 
     Sema &getSema() const {
       return sema;
@@ -238,7 +235,6 @@
       DeclSpec &spec = getMutableDeclSpec();
       llvm::append_range(savedAttrs,
                          llvm::make_pointer_range(spec.getAttributes()));
-      trivial &= savedAttrs.empty();
       hasSavedAttrs = true;
     }
 
@@ -330,7 +326,8 @@
     bool didParseNoDeref() const { return parsedNoDeref; }
 
     ~TypeProcessingState() {
-      if (trivial) return;
+      if (savedAttrs.empty())
+        return;
 
       restoreDeclSpecAttrs();
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123783.422817.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220414/9d12e9f0/attachment.bin>


More information about the cfe-commits mailing list