summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2019-10-11 14:02:03 +0000
committerYitzhak Mandelbaum <yitzhakm@google.com>2019-10-11 14:02:03 +0000
commit30c29388e105e7c1acc791c5f2470a3bd3900139 (patch)
tree3ee9cc36461b030c4123cd4e82faf4e7b1794a22 /include
parent3868de80cb9d69ee7bb3291d588ebb5ed4ba43e3 (diff)
downloadclang-30c29388e105e7c1acc791c5f2470a3bd3900139.tar.gz
[libTooling] Change Stencil equality to use `toString()`
Summary: Removes the `isEqual` method from StencilPartInterface and modifies equality to use the string representation returned by the `toString` method for comparison. This means the `run` and `selection` stencils return true by default, and clients should be cautious in relying on equality operator for comparison of stencils containing parts generated by these functions. It also means we no longer need the custom RTTI support (typeId() and down_cast()), so it has been removed. Patch by Harshal T. Lehri. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68825 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374552 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Tooling/Transformer/Stencil.h25
1 files changed, 1 insertions, 24 deletions
diff --git a/include/clang/Tooling/Transformer/Stencil.h b/include/clang/Tooling/Transformer/Stencil.h
index 617585cacd..eeb5902444 100644
--- a/include/clang/Tooling/Transformer/Stencil.h
+++ b/include/clang/Tooling/Transformer/Stencil.h
@@ -48,26 +48,18 @@ public:
virtual llvm::Error eval(const ast_matchers::MatchFinder::MatchResult &Match,
std::string *Result) const = 0;
- virtual bool isEqual(const StencilPartInterface &other) const = 0;
-
/// Constructs a string representation of the StencilPart. StencilParts
/// generated by the `selection` and `run` functions do not have a unique
/// string representation.
virtual std::string toString() const = 0;
- const void *typeId() const { return TypeId; }
-
protected:
- StencilPartInterface(const void *DerivedId) : TypeId(DerivedId) {}
+ StencilPartInterface() = default;
// Since this is an abstract class, copying/assigning only make sense for
// derived classes implementing `clone()`.
StencilPartInterface(const StencilPartInterface &) = default;
StencilPartInterface &operator=(const StencilPartInterface &) = default;
-
- /// Unique identifier of the concrete type of this instance. Supports safe
- /// downcasting.
- const void *TypeId;
};
/// A copyable facade for a std::unique_ptr<StencilPartInterface>. Copies result
@@ -83,14 +75,6 @@ public:
return Impl->eval(Match, Result);
}
- bool operator==(const StencilPart &Other) const {
- if (Impl == Other.Impl)
- return true;
- if (Impl == nullptr || Other.Impl == nullptr)
- return false;
- return Impl->isEqual(*Other.Impl);
- }
-
std::string toString() const {
if (Impl == nullptr)
return "";
@@ -142,7 +126,6 @@ public:
}
private:
- friend bool operator==(const Stencil &A, const Stencil &B);
static StencilPart wrap(llvm::StringRef Text);
static StencilPart wrap(RangeSelector Selector);
static StencilPart wrap(StencilPart Part) { return Part; }
@@ -150,12 +133,6 @@ private:
std::vector<StencilPart> Parts;
};
-inline bool operator==(const Stencil &A, const Stencil &B) {
- return A.Parts == B.Parts;
-}
-
-inline bool operator!=(const Stencil &A, const Stencil &B) { return !(A == B); }
-
// Functions for conveniently building stencils.
namespace stencil {
/// Convenience wrapper for Stencil::cat that can be imported with a using decl.