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(); }
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(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits