From ec07a0772409e48e0abde8ded16aaa2bb3b4660d Mon Sep 17 00:00:00 2001 From: qining Date: Fri, 26 Aug 2016 11:54:36 -0400 Subject: [PATCH] Add a method in the types to check whether there is no decoration on a type. --- source/opt/types.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/opt/types.h b/source/opt/types.h index c085b1e..0286d8d 100644 --- a/source/opt/types.h +++ b/source/opt/types.h @@ -84,6 +84,11 @@ class Type { // Returns a human-readable string to represent this type. virtual std::string str() const = 0; + // Returns true if there is no decoration on this type. For struct types, + // returns true only when there is no decoration for both the struct type + // and the struct members. + virtual bool decoration_empty() const { return decorations_.empty(); } + // A bunch of methods for casting this type to a given type. Returns this if the // cast can be done, nullptr otherwise. #define DeclareCastMethod(target) \ @@ -271,6 +276,9 @@ class Struct : public Type { bool IsSame(Type* that) const override; std::string str() const override; + bool decoration_empty() const override { + return decorations_.empty() && element_decorations_.empty(); + } Struct* AsStruct() override { return this; } const Struct* AsStruct() const override { return this; } -- 2.7.4