mboehme updated this revision to Diff 425145. mboehme marked an inline comment as done. mboehme added a comment.
Eliminate hasSavedAttrs as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123783/new/ 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,12 +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; - /// The original set of attributes on the DeclSpec. SmallVector<ParsedAttr *, 2> savedAttrs; @@ -200,8 +194,7 @@ public: TypeProcessingState(Sema &sema, Declarator &declarator) : sema(sema), declarator(declarator), - chunkIndex(declarator.getNumTypeObjects()), trivial(true), - hasSavedAttrs(false), parsedNoDeref(false) {} + chunkIndex(declarator.getNumTypeObjects()), parsedNoDeref(false) {} Sema &getSema() const { return sema; @@ -233,13 +226,12 @@ /// Save the current set of attributes on the DeclSpec. void saveDeclSpecAttrs() { // Don't try to save them multiple times. - if (hasSavedAttrs) return; + if (!savedAttrs.empty()) + return; DeclSpec &spec = getMutableDeclSpec(); llvm::append_range(savedAttrs, llvm::make_pointer_range(spec.getAttributes())); - trivial &= savedAttrs.empty(); - hasSavedAttrs = true; } /// Record that we had nowhere to put the given type attribute. @@ -330,23 +322,18 @@ bool didParseNoDeref() const { return parsedNoDeref; } ~TypeProcessingState() { - if (trivial) return; + if (savedAttrs.empty()) + return; - restoreDeclSpecAttrs(); + getMutableDeclSpec().getAttributes().clearListOnly(); + for (ParsedAttr *AL : savedAttrs) + getMutableDeclSpec().getAttributes().addAtEnd(AL); } private: DeclSpec &getMutableDeclSpec() const { return const_cast<DeclSpec&>(declarator.getDeclSpec()); } - - void restoreDeclSpecAttrs() { - assert(hasSavedAttrs); - - getMutableDeclSpec().getAttributes().clearListOnly(); - for (ParsedAttr *AL : savedAttrs) - getMutableDeclSpec().getAttributes().addAtEnd(AL); - } }; } // end anonymous namespace
Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -166,12 +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; - /// The original set of attributes on the DeclSpec. SmallVector<ParsedAttr *, 2> savedAttrs; @@ -200,8 +194,7 @@ public: TypeProcessingState(Sema &sema, Declarator &declarator) : sema(sema), declarator(declarator), - chunkIndex(declarator.getNumTypeObjects()), trivial(true), - hasSavedAttrs(false), parsedNoDeref(false) {} + chunkIndex(declarator.getNumTypeObjects()), parsedNoDeref(false) {} Sema &getSema() const { return sema; @@ -233,13 +226,12 @@ /// Save the current set of attributes on the DeclSpec. void saveDeclSpecAttrs() { // Don't try to save them multiple times. - if (hasSavedAttrs) return; + if (!savedAttrs.empty()) + return; DeclSpec &spec = getMutableDeclSpec(); llvm::append_range(savedAttrs, llvm::make_pointer_range(spec.getAttributes())); - trivial &= savedAttrs.empty(); - hasSavedAttrs = true; } /// Record that we had nowhere to put the given type attribute. @@ -330,23 +322,18 @@ bool didParseNoDeref() const { return parsedNoDeref; } ~TypeProcessingState() { - if (trivial) return; + if (savedAttrs.empty()) + return; - restoreDeclSpecAttrs(); + getMutableDeclSpec().getAttributes().clearListOnly(); + for (ParsedAttr *AL : savedAttrs) + getMutableDeclSpec().getAttributes().addAtEnd(AL); } private: DeclSpec &getMutableDeclSpec() const { return const_cast<DeclSpec&>(declarator.getDeclSpec()); } - - void restoreDeclSpecAttrs() { - assert(hasSavedAttrs); - - getMutableDeclSpec().getAttributes().clearListOnly(); - for (ParsedAttr *AL : savedAttrs) - getMutableDeclSpec().getAttributes().addAtEnd(AL); - } }; } // end anonymous namespace
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits