diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -7381,11 +7381,11 @@ -
Causes all nested matchers to be matched with the specified traversal kind.
Given
@@ -7394,7 +7394,7 @@
int i = 3.0;
}
The matcher
- traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
+ traverse(TK_IgnoreImplicitCastsAndParentheses,
varDecl(hasInitializer(floatLiteral().bind("init")))
)
matches the variable declaration with "init" bound to the "3.0".
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -94,6 +94,7 @@
class CXXRecordDecl;
class DiagnosticsEngine;
class ParentMapContext;
+class DynTypedNode;
class DynTypedNodeList;
class Expr;
class FixedPointSemantics;
@@ -130,9 +131,6 @@
class VTableContextBase;
struct BlockVarCopyInit;
-namespace ast_type_traits {
-class DynTypedNode;
-}
namespace Builtin {
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -66,8 +66,7 @@
/// not already been loaded.
bool Deserialize = false;
- ast_type_traits::TraversalKind Traversal =
- ast_type_traits::TraversalKind::TK_AsIs;
+ TraversalKind Traversal = TraversalKind::TK_AsIs;
NodeDelegateType &getNodeDelegate() {
return getDerived().doGetNodeDelegate();
@@ -78,7 +77,7 @@
void setDeserialize(bool D) { Deserialize = D; }
bool getDeserialize() const { return Deserialize; }
- void SetTraversalKind(ast_type_traits::TraversalKind TK) { Traversal = TK; }
+ void SetTraversalKind(TraversalKind TK) { Traversal = TK; }
void Visit(const Decl *D) {
getNodeDelegate().AddChild([=] {
@@ -109,12 +108,12 @@
if (auto *E = dyn_cast_or_null(S)) {
switch (Traversal) {
- case ast_type_traits::TK_AsIs:
+ case TK_AsIs:
break;
- case ast_type_traits::TK_IgnoreImplicitCastsAndParentheses:
+ case TK_IgnoreImplicitCastsAndParentheses:
S = E->IgnoreParenImpCasts();
break;
- case ast_type_traits::TK_IgnoreUnlessSpelledInSource:
+ case TK_IgnoreUnlessSpelledInSource:
S = E->IgnoreUnlessSpelledInSource();
break;
}
@@ -132,8 +131,7 @@
if (isa(S) || isa(S))
return;
- if (isa(S) &&
- Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+ if (isa(S) && Traversal == TK_IgnoreUnlessSpelledInSource)
return;
for (const Stmt *SubStmt : S->children())
@@ -229,7 +227,7 @@
});
}
- void Visit(const ast_type_traits::DynTypedNode &N) {
+ void Visit(const DynTypedNode &N) {
// FIXME: Improve this with a switch or a visitor pattern.
if (const auto *D = N.get())
Visit(D);
@@ -659,7 +657,7 @@
}
void VisitLambdaExpr(const LambdaExpr *Node) {
- if (Traversal == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
+ if (Traversal == TK_IgnoreUnlessSpelledInSource) {
for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
const auto *C = Node->capture_begin() + I;
if (!C->isExplicit())
diff --git a/clang/include/clang/AST/ASTTypeTraits.h b/clang/include/clang/AST/ASTTypeTraits.h
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -33,8 +33,6 @@
struct PrintingPolicy;
-namespace ast_type_traits {
-
/// Defines how we descend a level in the AST when we pass
/// through expressions.
enum TraversalKind {
@@ -522,18 +520,29 @@
}
};
-} // end namespace ast_type_traits
+// Previously these types were defined in the clang::ast_type_traits namespace.
+// Provide typedefs so that legacy code can be fixed asynchronously.
+namespace ast_type_traits {
+using DynTypedNode = ::clang::DynTypedNode;
+using ASTNodeKind = ::clang::ASTNodeKind;
+using TraversalKind = ::clang::TraversalKind;
+
+constexpr TraversalKind TK_AsIs = ::clang::TK_AsIs;
+constexpr TraversalKind TK_IgnoreImplicitCastsAndParentheses =
+ ::clang::TK_IgnoreImplicitCastsAndParentheses;
+constexpr TraversalKind TK_IgnoreUnlessSpelledInSource =
+ ::clang::TK_IgnoreUnlessSpelledInSource;
+} // namespace ast_type_traits
+
} // end namespace clang
namespace llvm {
template <>
-struct DenseMapInfo
- : clang::ast_type_traits::ASTNodeKind::DenseMapInfo {};
+struct DenseMapInfo : clang::ASTNodeKind::DenseMapInfo {};
template <>
-struct DenseMapInfo
- : clang::ast_type_traits::DynTypedNode::DenseMapInfo {};
+struct DenseMapInfo : clang::DynTypedNode::DenseMapInfo {};
} // end namespace llvm
diff --git a/clang/include/clang/AST/ParentMapContext.h b/clang/include/clang/AST/ParentMapContext.h
--- a/clang/include/clang/AST/ParentMapContext.h
+++ b/clang/include/clang/AST/ParentMapContext.h
@@ -52,33 +52,31 @@
/// NestedNameSpecifier or NestedNameSpecifierLoc.
template DynTypedNodeList getParents(const NodeT &Node);
- DynTypedNodeList getParents(const ast_type_traits::DynTypedNode &Node);
+ DynTypedNodeList getParents(const DynTypedNode &Node);
/// Clear parent maps.
void clear();
- ast_type_traits::TraversalKind getTraversalKind() const { return Traversal; }
- void setTraversalKind(ast_type_traits::TraversalKind TK) { Traversal = TK; }
+ TraversalKind getTraversalKind() const { return Traversal; }
+ void setTraversalKind(TraversalKind TK) { Traversal = TK; }
const Expr *traverseIgnored(const Expr *E) const;
Expr *traverseIgnored(Expr *E) const;
- ast_type_traits::DynTypedNode
- traverseIgnored(const ast_type_traits::DynTypedNode &N) const;
+ DynTypedNode traverseIgnored(const DynTypedNode &N) const;
private:
ASTContext &ASTCtx;
class ParentMap;
- ast_type_traits::TraversalKind Traversal = ast_type_traits::TK_AsIs;
+ TraversalKind Traversal = TK_AsIs;
std::unique_ptr Parents;
};
class TraversalKindScope {
ParentMapContext &Ctx;
- ast_type_traits::TraversalKind TK = ast_type_traits::TK_AsIs;
+ TraversalKind TK = TK_AsIs;
public:
- TraversalKindScope(ASTContext &ASTCtx,
- llvm::Optional ScopeTK)
+ TraversalKindScope(ASTContext &ASTCtx, llvm::Optional ScopeTK)
: Ctx(ASTCtx.getParentMapContext()) {
TK = Ctx.getTraversalKind();
if (ScopeTK)
@@ -91,10 +89,9 @@
/// Container for either a single DynTypedNode or for an ArrayRef to
/// DynTypedNode. For use with ParentMap.
class DynTypedNodeList {
- using DynTypedNode = ast_type_traits::DynTypedNode;
+ using DynTypedNode = DynTypedNode;
- llvm::AlignedCharArrayUnion> Storage;
+ llvm::AlignedCharArrayUnion> Storage;
bool IsSingleNode;
public:
@@ -106,14 +103,14 @@
new (Storage.buffer) ArrayRef(A);
}
- const ast_type_traits::DynTypedNode *begin() const {
+ const DynTypedNode *begin() const {
if (!IsSingleNode)
return reinterpret_cast *>(Storage.buffer)
->begin();
return reinterpret_cast(Storage.buffer);
}
- const ast_type_traits::DynTypedNode *end() const {
+ const DynTypedNode *end() const {
if (!IsSingleNode)
return reinterpret_cast *>(Storage.buffer)
->end();
@@ -131,7 +128,7 @@
template
inline DynTypedNodeList ParentMapContext::getParents(const NodeT &Node) {
- return getParents(ast_type_traits::DynTypedNode::create(Node));
+ return getParents(DynTypedNode::create(Node));
}
template
@@ -140,8 +137,7 @@
}
template <>
-inline DynTypedNodeList
-ASTContext::getParents(const ast_type_traits::DynTypedNode &Node) {
+inline DynTypedNodeList ASTContext::getParents(const DynTypedNode &Node) {
return getParentMapContext().getParents(Node);
}
diff --git a/clang/include/clang/ASTMatchers/ASTMatchFinder.h b/clang/include/clang/ASTMatchers/ASTMatchFinder.h
--- a/clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -182,10 +182,9 @@
///
/// @{
template void match(const T &Node, ASTContext &Context) {
- match(clang::ast_type_traits::DynTypedNode::create(Node), Context);
+ match(clang::DynTypedNode::create(Node), Context);
}
- void match(const clang::ast_type_traits::DynTypedNode &Node,
- ASTContext &Context);
+ void match(const clang::DynTypedNode &Node, ASTContext &Context);
/// @}
/// Finds all matches in the given AST.
@@ -242,9 +241,8 @@
match(MatcherT Matcher, const NodeT &Node, ASTContext &Context);
template
-SmallVector
-match(MatcherT Matcher, const ast_type_traits::DynTypedNode &Node,
- ASTContext &Context);
+SmallVector match(MatcherT Matcher, const DynTypedNode &Node,
+ ASTContext &Context);
/// @}
/// Returns the results of matching \p Matcher on the translation unit of
@@ -283,9 +281,8 @@
}
template
-SmallVector
-match(MatcherT Matcher, const ast_type_traits::DynTypedNode &Node,
- ASTContext &Context) {
+SmallVector match(MatcherT Matcher, const DynTypedNode &Node,
+ ASTContext &Context) {
internal::CollectMatchesCallback Callback;
MatchFinder Finder;
Finder.addMatcher(Matcher, &Callback);
@@ -296,7 +293,7 @@
template
SmallVector
match(MatcherT Matcher, const NodeT &Node, ASTContext &Context) {
- return match(Matcher, ast_type_traits::DynTypedNode::create(Node), Context);
+ return match(Matcher, DynTypedNode::create(Node), Context);
}
template
@@ -310,8 +307,8 @@
}
inline SmallVector
-matchDynamic(internal::DynTypedMatcher Matcher,
- const ast_type_traits::DynTypedNode &Node, ASTContext &Context) {
+matchDynamic(internal::DynTypedMatcher Matcher, const DynTypedNode &Node,
+ ASTContext &Context) {
internal::CollectMatchesCallback Callback;
MatchFinder Finder;
Finder.addDynamicMatcher(Matcher, &Callback);
@@ -323,8 +320,7 @@
SmallVector matchDynamic(internal::DynTypedMatcher Matcher,
const NodeT &Node,
ASTContext &Context) {
- return matchDynamic(Matcher, ast_type_traits::DynTypedNode::create(Node),
- Context);
+ return matchDynamic(Matcher, DynTypedNode::create(Node), Context);
}
inline SmallVector
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -115,7 +115,7 @@
/// Type of mapping from binding identifiers to bound nodes. This type
/// is an associative container with a key type of \c std::string and a value
- /// type of \c clang::ast_type_traits::DynTypedNode
+ /// type of \c clang::DynTypedNode
using IDToNodeMap = internal::BoundNodesMap::IDToNodeMap;
/// Retrieve mapping from binding identifiers to bound nodes.
@@ -722,13 +722,13 @@
/// \endcode
/// The matcher
/// \code
-/// traverse(ast_type_traits::TK_IgnoreImplicitCastsAndParentheses,
+/// traverse(TK_IgnoreImplicitCastsAndParentheses,
/// varDecl(hasInitializer(floatLiteral().bind("init")))
/// )
/// \endcode
/// matches the variable declaration with "init" bound to the "3.0".
template
-internal::Matcher traverse(ast_type_traits::TraversalKind TK,
+internal::Matcher traverse(TraversalKind TK,
const internal::Matcher &InnerMatcher) {
return internal::DynTypedMatcher::constructRestrictedWrapper(
new internal::TraversalMatcher(TK, InnerMatcher),
@@ -738,8 +738,7 @@
template
internal::BindableMatcher
-traverse(ast_type_traits::TraversalKind TK,
- const internal::BindableMatcher &InnerMatcher) {
+traverse(TraversalKind TK, const internal::BindableMatcher &InnerMatcher) {
return internal::BindableMatcher(
internal::DynTypedMatcher::constructRestrictedWrapper(
new internal::TraversalMatcher(TK, InnerMatcher),
@@ -749,7 +748,7 @@
template
internal::TraversalWrapper>
-traverse(ast_type_traits::TraversalKind TK,
+traverse(TraversalKind TK,
const internal::VariadicOperatorMatcher &InnerMatcher) {
return internal::TraversalWrapper>(
TK, InnerMatcher);
@@ -759,9 +758,8 @@
typename T, typename ToTypes>
internal::TraversalWrapper<
internal::ArgumentAdaptingMatcherFuncAdaptor>
-traverse(ast_type_traits::TraversalKind TK,
- const internal::ArgumentAdaptingMatcherFuncAdaptor<
- ArgumentAdapterT, T, ToTypes> &InnerMatcher) {
+traverse(TraversalKind TK, const internal::ArgumentAdaptingMatcherFuncAdaptor<
+ ArgumentAdapterT, T, ToTypes> &InnerMatcher) {
return internal::TraversalWrapper<
internal::ArgumentAdaptingMatcherFuncAdaptor>(TK, InnerMatcher);
@@ -771,10 +769,8 @@
typename ReturnTypesF>
internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam1>
-traverse(
- ast_type_traits::TraversalKind TK,
- const internal::PolymorphicMatcherWithParam1
- &InnerMatcher) {
+traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam1<
+ MatcherT, P1, ReturnTypesF> &InnerMatcher) {
return internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam1>(
TK, InnerMatcher);
@@ -784,10 +780,8 @@
typename P1, typename P2, typename ReturnTypesF>
internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam2>
-traverse(
- ast_type_traits::TraversalKind TK,
- const internal::PolymorphicMatcherWithParam2
- &InnerMatcher) {
+traverse(TraversalKind TK, const internal::PolymorphicMatcherWithParam2<
+ MatcherT, P1, P2, ReturnTypesF> &InnerMatcher) {
return internal::TraversalWrapper<
internal::PolymorphicMatcherWithParam2>(
TK, InnerMatcher);
@@ -4584,7 +4578,7 @@
// they're ever reused.
internal::NotEqualsBoundNodePredicate Predicate;
Predicate.ID = ID;
- Predicate.Node = ast_type_traits::DynTypedNode::create(Node);
+ Predicate.Node = DynTypedNode::create(Node);
return Builder->removeBindings(Predicate);
}
@@ -6735,8 +6729,7 @@
InnerMatcher) {
const auto &Parents = Finder->getASTContext().getParents(Node);
- llvm::SmallVector Stack(Parents.begin(),
- Parents.end());
+ llvm::SmallVector Stack(Parents.begin(), Parents.end());
while(!Stack.empty()) {
const auto &CurNode = Stack.back();
Stack.pop_back();
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -148,7 +148,7 @@
/// Adds \c Node to the map with key \c ID.
///
/// The node's base type should be in NodeBaseType or it will be unaccessible.
- void addNode(StringRef ID, const ast_type_traits::DynTypedNode& DynNode) {
+ void addNode(StringRef ID, const DynTypedNode &DynNode) {
NodeMap[std::string(ID)] = DynNode;
}
@@ -165,10 +165,10 @@
return It->second.get();
}
- ast_type_traits::DynTypedNode getNode(StringRef ID) const {
+ DynTypedNode getNode(StringRef ID) const {
IDToNodeMap::const_iterator It = NodeMap.find(ID);
if (It == NodeMap.end()) {
- return ast_type_traits::DynTypedNode();
+ return DynTypedNode();
}
return It->second;
}
@@ -183,8 +183,7 @@
/// Note that we're using std::map here, as for memoization:
/// - we need a comparison operator
/// - we need an assignment operator
- using IDToNodeMap =
- std::map>;
+ using IDToNodeMap = std::map>;
const IDToNodeMap &getMap() const {
return NodeMap;
@@ -223,7 +222,7 @@
};
/// Add a binding from an id to a node.
- void setBinding(StringRef Id, const ast_type_traits::DynTypedNode &DynNode) {
+ void setBinding(StringRef Id, const DynTypedNode &DynNode) {
if (Bindings.empty())
Bindings.emplace_back();
for (BoundNodesMap &Binding : Bindings)
@@ -280,11 +279,10 @@
///
/// May bind \p DynNode to an ID via \p Builder, or recurse into
/// the AST via \p Finder.
- virtual bool dynMatches(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+ virtual bool dynMatches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const = 0;
- virtual llvm::Optional TraversalKind() const {
+ virtual llvm::Optional TraversalKind() const {
return llvm::None;
}
};
@@ -307,8 +305,7 @@
ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const = 0;
- bool dynMatches(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+ bool dynMatches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const override {
return matches(DynNode.getUnchecked(), Finder, Builder);
}
@@ -347,7 +344,7 @@
/// Takes ownership of the provided implementation pointer.
template
DynTypedMatcher(MatcherInterface *Implementation)
- : SupportedKind(ast_type_traits::ASTNodeKind::getFromNodeKind()),
+ : SupportedKind(ASTNodeKind::getFromNodeKind()),
RestrictKind(SupportedKind), Implementation(Implementation) {}
/// Construct from a variadic function.
@@ -375,40 +372,38 @@
};
static DynTypedMatcher
- constructVariadic(VariadicOperator Op,
- ast_type_traits::ASTNodeKind SupportedKind,
+ constructVariadic(VariadicOperator Op, ASTNodeKind SupportedKind,
std::vector InnerMatchers);
static DynTypedMatcher
constructRestrictedWrapper(const DynTypedMatcher &InnerMatcher,
- ast_type_traits::ASTNodeKind RestrictKind);
+ ASTNodeKind RestrictKind);
/// Get a "true" matcher for \p NodeKind.
///
/// It only checks that the node is of the right kind.
- static DynTypedMatcher trueMatcher(ast_type_traits::ASTNodeKind NodeKind);
+ static DynTypedMatcher trueMatcher(ASTNodeKind NodeKind);
void setAllowBind(bool AB) { AllowBind = AB; }
/// Check whether this matcher could ever match a node of kind \p Kind.
/// \return \c false if this matcher will never match such a node. Otherwise,
/// return \c true.
- bool canMatchNodesOfKind(ast_type_traits::ASTNodeKind Kind) const;
+ bool canMatchNodesOfKind(ASTNodeKind Kind) const;
/// Return a matcher that points to the same implementation, but
/// restricts the node types for \p Kind.
- DynTypedMatcher dynCastTo(const ast_type_traits::ASTNodeKind Kind) const;
+ DynTypedMatcher dynCastTo(const ASTNodeKind Kind) const;
/// Returns true if the matcher matches the given \c DynNode.
- bool matches(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder) const;
+ bool matches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder) const;
/// Same as matches(), but skips the kind check.
///
/// It is faster, but the caller must ensure the node is valid for the
/// kind of this matcher.
- bool matchesNoKindCheck(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+ bool matchesNoKindCheck(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const;
/// Bind the specified \p ID to the matcher.
@@ -423,7 +418,7 @@
/// include both in the ID to make it unique.
///
/// \c MatcherIDType supports operator< and provides strict weak ordering.
- using MatcherIDType = std::pair;
+ using MatcherIDType = std::pair;
MatcherIDType getID() const {
/// FIXME: Document the requirements this imposes on matcher
/// implementations (no new() implementation_ during a Matches()).
@@ -435,9 +430,7 @@
///
/// \c matches() will always return false unless the node passed is of this
/// or a derived type.
- ast_type_traits::ASTNodeKind getSupportedKind() const {
- return SupportedKind;
- }
+ ASTNodeKind getSupportedKind() const { return SupportedKind; }
/// Returns \c true if the passed \c DynTypedMatcher can be converted
/// to a \c Matcher.
@@ -445,9 +438,9 @@
/// This method verifies that the underlying matcher in \c Other can process
/// nodes of types T.
template bool canConvertTo() const {
- return canConvertTo(ast_type_traits::ASTNodeKind::getFromNodeKind());
+ return canConvertTo(ASTNodeKind::getFromNodeKind());
}
- bool canConvertTo(ast_type_traits::ASTNodeKind To) const;
+ bool canConvertTo(ASTNodeKind To) const;
/// Construct a \c Matcher interface around the dynamic matcher.
///
@@ -466,20 +459,19 @@
template Matcher unconditionalConvertTo() const;
private:
- DynTypedMatcher(ast_type_traits::ASTNodeKind SupportedKind,
- ast_type_traits::ASTNodeKind RestrictKind,
- IntrusiveRefCntPtr Implementation)
- : SupportedKind(SupportedKind), RestrictKind(RestrictKind),
- Implementation(std::move(Implementation)) {}
+ DynTypedMatcher(ASTNodeKind SupportedKind, ASTNodeKind RestrictKind,
+ IntrusiveRefCntPtr Implementation)
+ : SupportedKind(SupportedKind), RestrictKind(RestrictKind),
+ Implementation(std::move(Implementation)) {}
bool AllowBind = false;
- ast_type_traits::ASTNodeKind SupportedKind;
+ ASTNodeKind SupportedKind;
/// A potentially stricter node kind.
///
/// It allows to perform implicit and dynamic cast of matchers without
/// needing to change \c Implementation.
- ast_type_traits::ASTNodeKind RestrictKind;
+ ASTNodeKind RestrictKind;
IntrusiveRefCntPtr Implementation;
};
@@ -520,7 +512,7 @@
!std::is_same::value> * = nullptr)
: Implementation(restrictMatcher(Other.Implementation)) {
assert(Implementation.getSupportedKind().isSame(
- ast_type_traits::ASTNodeKind::getFromNodeKind()));
+ ASTNodeKind::getFromNodeKind()));
}
/// Implicitly converts \c Matcher to \c Matcher.
@@ -545,8 +537,7 @@
bool matches(const T &Node,
ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const {
- return Implementation.matches(ast_type_traits::DynTypedNode::create(Node),
- Finder, Builder);
+ return Implementation.matches(DynTypedNode::create(Node), Finder, Builder);
}
/// Returns an ID that uniquely identifies the matcher.
@@ -576,8 +567,8 @@
BoundNodesTreeBuilder *Builder) const override {
if (Node.isNull())
return false;
- return this->InnerMatcher.matches(
- ast_type_traits::DynTypedNode::create(*Node), Finder, Builder);
+ return this->InnerMatcher.matches(DynTypedNode::create(*Node), Finder,
+ Builder);
}
};
@@ -589,13 +580,13 @@
friend class DynTypedMatcher;
static DynTypedMatcher restrictMatcher(const DynTypedMatcher &Other) {
- return Other.dynCastTo(ast_type_traits::ASTNodeKind::getFromNodeKind());
+ return Other.dynCastTo(ASTNodeKind::getFromNodeKind());
}
explicit Matcher(const DynTypedMatcher &Implementation)
: Implementation(restrictMatcher(Implementation)) {
- assert(this->Implementation.getSupportedKind()
- .isSame(ast_type_traits::ASTNodeKind::getFromNodeKind()));
+ assert(this->Implementation.getSupportedKind().isSame(
+ ASTNodeKind::getFromNodeKind()));
}
DynTypedMatcher Implementation;
@@ -615,9 +606,8 @@
template <>
inline Matcher DynTypedMatcher::convertTo() const {
assert(canConvertTo());
- const ast_type_traits::ASTNodeKind SourceKind = getSupportedKind();
- if (SourceKind.isSame(
- ast_type_traits::ASTNodeKind::getFromNodeKind())) {
+ const ASTNodeKind SourceKind = getSupportedKind();
+ if (SourceKind.isSame(ASTNodeKind::getFromNodeKind())) {
// We support implicit conversion from Matcher to Matcher
return unconditionalConvertTo();
}
@@ -919,9 +909,8 @@
/// is \c NULL.
bool matchesDecl(const Decl *Node, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const {
- return Node != nullptr &&
- this->InnerMatcher.matches(
- ast_type_traits::DynTypedNode::create(*Node), Finder, Builder);
+ return Node != nullptr && this->InnerMatcher.matches(
+ DynTypedNode::create(*Node), Finder, Builder);
}
};
@@ -1003,8 +992,8 @@
template
bool matchesChildOf(const T &Node, const DynTypedMatcher &Matcher,
- BoundNodesTreeBuilder *Builder,
- ast_type_traits::TraversalKind Traverse, BindKind Bind) {
+ BoundNodesTreeBuilder *Builder, TraversalKind Traverse,
+ BindKind Bind) {
static_assert(std::is_base_of::value ||
std::is_base_of::value ||
std::is_base_of::value ||
@@ -1012,8 +1001,8 @@
std::is_base_of::value ||
std::is_base_of::value,
"unsupported type for recursive matching");
- return matchesChildOf(ast_type_traits::DynTypedNode::create(Node),
- getASTContext(), Matcher, Builder, Traverse, Bind);
+ return matchesChildOf(DynTypedNode::create(Node), getASTContext(), Matcher,
+ Builder, Traverse, Bind);
}
template
@@ -1028,8 +1017,8 @@
std::is_base_of::value ||
std::is_base_of::value,
"unsupported type for recursive matching");
- return matchesDescendantOf(ast_type_traits::DynTypedNode::create(Node),
- getASTContext(), Matcher, Builder, Bind);
+ return matchesDescendantOf(DynTypedNode::create(Node), getASTContext(),
+ Matcher, Builder, Bind);
}
// FIXME: Implement support for BindKind.
@@ -1043,27 +1032,24 @@
std::is_base_of::value ||
std::is_base_of::value,
"type not allowed for recursive matching");
- return matchesAncestorOf(ast_type_traits::DynTypedNode::create(Node),
- getASTContext(), Matcher, Builder, MatchMode);
+ return matchesAncestorOf(DynTypedNode::create(Node), getASTContext(),
+ Matcher, Builder, MatchMode);
}
virtual ASTContext &getASTContext() const = 0;
protected:
- virtual bool matchesChildOf(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx, const DynTypedMatcher &Matcher,
+ virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx,
+ const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
- ast_type_traits::TraversalKind Traverse,
- BindKind Bind) = 0;
+ TraversalKind Traverse, BindKind Bind) = 0;
- virtual bool matchesDescendantOf(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx,
+ virtual bool matchesDescendantOf(const DynTypedNode &Node, ASTContext &Ctx,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
BindKind Bind) = 0;
- virtual bool matchesAncestorOf(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx,
+ virtual bool matchesAncestorOf(const DynTypedNode &Node, ASTContext &Ctx,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
AncestorMatchMode MatchMode) = 0;
@@ -1182,41 +1168,38 @@
template
class TraversalMatcher : public WrapperMatcherInterface {
- ast_type_traits::TraversalKind Traversal;
+ TraversalKind Traversal;
public:
- explicit TraversalMatcher(ast_type_traits::TraversalKind TK,
- const Matcher &ChildMatcher)
+ explicit TraversalMatcher(TraversalKind TK, const Matcher &ChildMatcher)
: TraversalMatcher::WrapperMatcherInterface(ChildMatcher), Traversal(TK) {
}
bool matches(const T &Node, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const override {
- return this->InnerMatcher.matches(
- ast_type_traits::DynTypedNode::create(Node), Finder, Builder);
+ return this->InnerMatcher.matches(DynTypedNode::create(Node), Finder,
+ Builder);
}
- llvm::Optional
- TraversalKind() const override {
+ llvm::Optional TraversalKind() const override {
return Traversal;
}
};
template class TraversalWrapper {
public:
- TraversalWrapper(ast_type_traits::TraversalKind TK,
- const MatcherType &InnerMatcher)
+ TraversalWrapper(TraversalKind TK, const MatcherType &InnerMatcher)
: TK(TK), InnerMatcher(InnerMatcher) {}
template operator Matcher() const {
return internal::DynTypedMatcher::constructRestrictedWrapper(
new internal::TraversalMatcher(TK, InnerMatcher),
- ast_type_traits::ASTNodeKind::getFromNodeKind())
+ ASTNodeKind::getFromNodeKind())
.template unconditionalConvertTo();
}
private:
- ast_type_traits::TraversalKind TK;
+ TraversalKind TK;
MatcherType InnerMatcher;
};
@@ -1299,8 +1282,7 @@
template
operator Matcher() const {
- return DynTypedMatcher::trueMatcher(
- ast_type_traits::ASTNodeKind::getFromNodeKind())
+ return DynTypedMatcher::trueMatcher(ASTNodeKind::getFromNodeKind())
.template unconditionalConvertTo();
}
};
@@ -1348,7 +1330,7 @@
bool matches(const T &Node, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const override {
return Finder->matchesChildOf(Node, this->InnerMatcher, Builder,
- ast_type_traits::TraversalKind::TK_AsIs,
+ TraversalKind::TK_AsIs,
ASTMatchFinder::BK_First);
}
};
@@ -1371,7 +1353,7 @@
BoundNodesTreeBuilder* Builder) const override {
return Finder->matchesChildOf(
Node, this->InnerMatcher, Builder,
- ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses,
+ TraversalKind::TK_IgnoreImplicitCastsAndParentheses,
ASTMatchFinder::BK_All);
}
};
@@ -1392,7 +1374,7 @@
template operator Matcher() const {
return DynTypedMatcher::constructVariadic(
- Op, ast_type_traits::ASTNodeKind::getFromNodeKind(),
+ Op, ASTNodeKind::getFromNodeKind(),
getMatchers(std::index_sequence_for()))
.template unconditionalConvertTo();
}
@@ -1448,10 +1430,9 @@
std::vector DynMatchers(PI(InnerMatchers.begin()),
PI(InnerMatchers.end()));
return BindableMatcher(
- DynTypedMatcher::constructVariadic(
- DynTypedMatcher::VO_AllOf,
- ast_type_traits::ASTNodeKind::getFromNodeKind(),
- std::move(DynMatchers))
+ DynTypedMatcher::constructVariadic(DynTypedMatcher::VO_AllOf,
+ ASTNodeKind::getFromNodeKind(),
+ std::move(DynMatchers))
.template unconditionalConvertTo());
}
@@ -1652,9 +1633,8 @@
}
private:
- static ast_type_traits::DynTypedNode
- extract(const NestedNameSpecifierLoc &Loc) {
- return ast_type_traits::DynTypedNode::create(*Loc.getNestedNameSpecifier());
+ static DynTypedNode extract(const NestedNameSpecifierLoc &Loc) {
+ return DynTypedNode::create(*Loc.getNestedNameSpecifier());
}
};
@@ -1671,8 +1651,8 @@
BoundNodesTreeBuilder *Builder) const override {
if (!Node)
return false;
- return this->InnerMatcher.matches(
- ast_type_traits::DynTypedNode::create(Node.getType()), Finder, Builder);
+ return this->InnerMatcher.matches(DynTypedNode::create(Node.getType()),
+ Finder, Builder);
}
};
@@ -1692,8 +1672,8 @@
QualType NextNode = (Node.*TraverseFunction)();
if (NextNode.isNull())
return false;
- return this->InnerMatcher.matches(
- ast_type_traits::DynTypedNode::create(NextNode), Finder, Builder);
+ return this->InnerMatcher.matches(DynTypedNode::create(NextNode), Finder,
+ Builder);
}
private:
@@ -1716,8 +1696,8 @@
TypeLoc NextNode = (Node.*TraverseFunction)();
if (!NextNode)
return false;
- return this->InnerMatcher.matches(
- ast_type_traits::DynTypedNode::create(NextNode), Finder, Builder);
+ return this->InnerMatcher.matches(DynTypedNode::create(NextNode), Finder,
+ Builder);
}
private:
@@ -1817,7 +1797,7 @@
}
std::string ID;
- ast_type_traits::DynTypedNode Node;
+ DynTypedNode Node;
};
template
diff --git a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
--- a/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
@@ -43,11 +43,10 @@
ArgKind(Kind K) : K(K) { assert(K != AK_Matcher); }
/// Constructor for matcher types.
- ArgKind(ast_type_traits::ASTNodeKind MatcherKind)
- : K(AK_Matcher), MatcherKind(MatcherKind) {}
+ ArgKind(ASTNodeKind MatcherKind) : K(AK_Matcher), MatcherKind(MatcherKind) {}
Kind getArgKind() const { return K; }
- ast_type_traits::ASTNodeKind getMatcherKind() const {
+ ASTNodeKind getMatcherKind() const {
assert(K == AK_Matcher);
return MatcherKind;
}
@@ -71,7 +70,7 @@
private:
Kind K;
- ast_type_traits::ASTNodeKind MatcherKind;
+ ASTNodeKind MatcherKind;
};
using ast_matchers::internal::DynTypedMatcher;
@@ -93,7 +92,7 @@
/// Methods that depend on T from hasTypedMatcher/getTypedMatcher.
class MatcherOps {
public:
- MatcherOps(ast_type_traits::ASTNodeKind NodeKind) : NodeKind(NodeKind) {}
+ MatcherOps(ASTNodeKind NodeKind) : NodeKind(NodeKind) {}
bool canConstructFrom(const DynTypedMatcher &Matcher,
bool &IsExactMatch) const;
@@ -114,7 +113,7 @@
~MatcherOps() = default;
private:
- ast_type_traits::ASTNodeKind NodeKind;
+ ASTNodeKind NodeKind;
};
/// Payload interface to be specialized by each matcher type.
@@ -127,7 +126,7 @@
virtual std::string getTypeAsString() const = 0;
virtual llvm::Optional
getTypedMatcher(const MatcherOps &Ops) const = 0;
- virtual bool isConvertibleTo(ast_type_traits::ASTNodeKind Kind,
+ virtual bool isConvertibleTo(ASTNodeKind Kind,
unsigned *Specificity) const = 0;
};
@@ -184,8 +183,7 @@
///
/// \param Specificity value corresponding to the "specificity" of the
/// conversion.
- bool isConvertibleTo(ast_type_traits::ASTNodeKind Kind,
- unsigned *Specificity) const {
+ bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity) const {
if (Value)
return Value->isConvertibleTo(Kind, Specificity);
return false;
@@ -223,8 +221,7 @@
template
struct VariantMatcher::TypedMatcherOps final : VariantMatcher::MatcherOps {
- TypedMatcherOps()
- : MatcherOps(ast_type_traits::ASTNodeKind::getFromNodeKind()) {}
+ TypedMatcherOps() : MatcherOps(ASTNodeKind::getFromNodeKind()) {}
typedef ast_matchers::internal::Matcher MatcherT;
DynTypedMatcher
diff --git a/clang/include/clang/Tooling/ASTDiff/ASTDiff.h b/clang/include/clang/Tooling/ASTDiff/ASTDiff.h
--- a/clang/include/clang/Tooling/ASTDiff/ASTDiff.h
+++ b/clang/include/clang/Tooling/ASTDiff/ASTDiff.h
@@ -37,11 +37,11 @@
struct Node {
NodeId Parent, LeftMostDescendant, RightMostDescendant;
int Depth, Height, Shift = 0;
- ast_type_traits::DynTypedNode ASTNode;
+ DynTypedNode ASTNode;
SmallVector Children;
ChangeKind Change = None;
- ast_type_traits::ASTNodeKind getType() const;
+ ASTNodeKind getType() const;
StringRef getTypeLabel() const;
bool isLeaf() const { return Children.empty(); }
llvm::Optional getIdentifier() const;
diff --git a/clang/include/clang/Tooling/ASTDiff/ASTDiffInternal.h b/clang/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
--- a/clang/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
+++ b/clang/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
@@ -15,7 +15,7 @@
namespace clang {
namespace diff {
-using DynTypedNode = ast_type_traits::DynTypedNode;
+using DynTypedNode = DynTypedNode;
class SyntaxTree;
class SyntaxTreeImpl;
diff --git a/clang/include/clang/Tooling/Refactoring/ASTSelection.h b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
--- a/clang/include/clang/Tooling/Refactoring/ASTSelection.h
+++ b/clang/include/clang/Tooling/Refactoring/ASTSelection.h
@@ -48,12 +48,11 @@
/// actually be selected, e.g. a statement in macro whose child is in a macro
/// argument.
struct SelectedASTNode {
- ast_type_traits::DynTypedNode Node;
+ DynTypedNode Node;
SourceSelectionKind SelectionKind;
std::vector Children;
- SelectedASTNode(const ast_type_traits::DynTypedNode &Node,
- SourceSelectionKind SelectionKind)
+ SelectedASTNode(const DynTypedNode &Node, SourceSelectionKind SelectionKind)
: Node(Node), SelectionKind(SelectionKind) {}
SelectedASTNode(SelectedASTNode &&) = default;
SelectedASTNode &operator=(SelectedASTNode &&) = default;
diff --git a/clang/lib/AST/ASTTypeTraits.cpp b/clang/lib/AST/ASTTypeTraits.cpp
--- a/clang/lib/AST/ASTTypeTraits.cpp
+++ b/clang/lib/AST/ASTTypeTraits.cpp
@@ -18,8 +18,7 @@
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/OpenMPClause.h"
-namespace clang {
-namespace ast_type_traits {
+using namespace clang;
const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
{ NKI_None, "" },
@@ -178,6 +177,3 @@
return SourceRange(C->getBeginLoc(), C->getEndLoc());
return SourceRange();
}
-
-} // end namespace ast_type_traits
-} // end namespace clang
diff --git a/clang/lib/AST/ParentMapContext.cpp b/clang/lib/AST/ParentMapContext.cpp
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -34,54 +34,53 @@
return nullptr;
switch (Traversal) {
- case ast_type_traits::TK_AsIs:
+ case TK_AsIs:
return E;
- case ast_type_traits::TK_IgnoreImplicitCastsAndParentheses:
+ case TK_IgnoreImplicitCastsAndParentheses:
return E->IgnoreParenImpCasts();
- case ast_type_traits::TK_IgnoreUnlessSpelledInSource:
+ case TK_IgnoreUnlessSpelledInSource:
return E->IgnoreUnlessSpelledInSource();
}
llvm_unreachable("Invalid Traversal type!");
}
-ast_type_traits::DynTypedNode
-ParentMapContext::traverseIgnored(const ast_type_traits::DynTypedNode &N) const {
+DynTypedNode ParentMapContext::traverseIgnored(const DynTypedNode &N) const {
if (const auto *E = N.get()) {
- return ast_type_traits::DynTypedNode::create(*traverseIgnored(E));
+ return DynTypedNode::create(*traverseIgnored(E));
}
return N;
}
class ParentMapContext::ParentMap {
/// Contains parents of a node.
- using ParentVector = llvm::SmallVector;
+ using ParentVector = llvm::SmallVector;
/// Maps from a node to its parents. This is used for nodes that have
/// pointer identity only, which are more common and we can save space by
/// only storing a unique pointer to them.
- using ParentMapPointers = llvm::DenseMap<
- const void *,
- llvm::PointerUnion>;
+ using ParentMapPointers =
+ llvm::DenseMap>;
/// Parent map for nodes without pointer identity. We store a full
/// DynTypedNode for all keys.
- using ParentMapOtherNodes = llvm::DenseMap<
- ast_type_traits::DynTypedNode,
- llvm::PointerUnion>;
+ using ParentMapOtherNodes =
+ llvm::DenseMap>;
ParentMapPointers PointerParents;
ParentMapOtherNodes OtherParents;
class ASTVisitor;
- static ast_type_traits::DynTypedNode
+ static DynTypedNode
getSingleDynTypedNodeFromParentMap(ParentMapPointers::mapped_type U) {
if (const auto *D = U.dyn_cast())
- return ast_type_traits::DynTypedNode::create(*D);
+ return DynTypedNode::create(*D);
if (const auto *S = U.dyn_cast())
- return ast_type_traits::DynTypedNode::create(*S);
- return *U.get();
+ return DynTypedNode::create(*S);
+ return *U.get();
}
template
@@ -89,7 +88,7 @@
const MapTy &Map) {
auto I = Map.find(Node);
if (I == Map.end()) {
- return llvm::ArrayRef();
+ return llvm::ArrayRef();
}
if (const auto *V = I->second.template dyn_cast()) {
return llvm::makeArrayRef(*V);
@@ -101,28 +100,26 @@
ParentMap(ASTContext &Ctx);
~ParentMap() {
for (const auto &Entry : PointerParents) {
- if (Entry.second.is()) {
- delete Entry.second.get();
+ if (Entry.second.is()) {
+ delete Entry.second.get();
} else if (Entry.second.is()) {
delete Entry.second.get();
}
}
for (const auto &Entry : OtherParents) {
- if (Entry.second.is()) {
- delete Entry.second.get();
+ if (Entry.second.is()) {
+ delete Entry.second.get();
} else if (Entry.second.is()) {
delete Entry.second.get();
}
}
}
- DynTypedNodeList getParents(ast_type_traits::TraversalKind TK,
- const ast_type_traits::DynTypedNode &Node) {
+ DynTypedNodeList getParents(TraversalKind TK, const DynTypedNode &Node) {
if (Node.getNodeKind().hasPointerIdentity()) {
auto ParentList =
getDynNodeFromMap(Node.getMemoizationData(), PointerParents);
- if (ParentList.size() == 1 &&
- TK == ast_type_traits::TK_IgnoreUnlessSpelledInSource) {
+ if (ParentList.size() == 1 && TK == TK_IgnoreUnlessSpelledInSource) {
const auto *E = ParentList[0].get();
const auto *Child = Node.get();
if (E && Child)
@@ -186,28 +183,25 @@
}
const auto *P = dyn_cast(S);
if (!P)
- return ast_type_traits::DynTypedNode::create(*S);
+ return DynTypedNode::create(*S);
Child = E;
E = P;
}
- return ast_type_traits::DynTypedNode::create(*E);
+ return DynTypedNode::create(*E);
}
};
/// Template specializations to abstract away from pointers and TypeLocs.
/// @{
-template
-static ast_type_traits::DynTypedNode createDynTypedNode(const T &Node) {
- return ast_type_traits::DynTypedNode::create(*Node);
+template static DynTypedNode createDynTypedNode(const T &Node) {
+ return DynTypedNode::create(*Node);
}
-template <>
-ast_type_traits::DynTypedNode createDynTypedNode(const TypeLoc &Node) {
- return ast_type_traits::DynTypedNode::create(Node);
+template <> DynTypedNode createDynTypedNode(const TypeLoc &Node) {
+ return DynTypedNode::create(Node);
}
template <>
-ast_type_traits::DynTypedNode
-createDynTypedNode(const NestedNameSpecifierLoc &Node) {
- return ast_type_traits::DynTypedNode::create(Node);
+DynTypedNode createDynTypedNode(const NestedNameSpecifierLoc &Node) {
+ return DynTypedNode::create(Node);
}
/// @}
@@ -257,13 +251,12 @@
else if (const auto *S = ParentStack.back().get())
NodeOrVector = S;
else
- NodeOrVector = new ast_type_traits::DynTypedNode(ParentStack.back());
+ NodeOrVector = new DynTypedNode(ParentStack.back());
} else {
if (!NodeOrVector.template is()) {
auto *Vector = new ParentVector(
1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
- delete NodeOrVector
- .template dyn_cast();
+ delete NodeOrVector.template dyn_cast();
NodeOrVector = Vector;
}
@@ -299,28 +292,27 @@
bool TraverseTypeLoc(TypeLoc TypeLocNode) {
return TraverseNode(
- TypeLocNode, ast_type_traits::DynTypedNode::create(TypeLocNode),
+ TypeLocNode, DynTypedNode::create(TypeLocNode),
[&] { return VisitorBase::TraverseTypeLoc(TypeLocNode); },
&Map.OtherParents);
}
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNSLocNode) {
return TraverseNode(
- NNSLocNode, ast_type_traits::DynTypedNode::create(NNSLocNode),
+ NNSLocNode, DynTypedNode::create(NNSLocNode),
[&] { return VisitorBase::TraverseNestedNameSpecifierLoc(NNSLocNode); },
&Map.OtherParents);
}
ParentMap ⤅
- llvm::SmallVector ParentStack;
+ llvm::SmallVector ParentStack;
};
ParentMapContext::ParentMap::ParentMap(ASTContext &Ctx) {
ASTVisitor(*this).TraverseAST(Ctx);
}
-DynTypedNodeList
-ParentMapContext::getParents(const ast_type_traits::DynTypedNode &Node) {
+DynTypedNodeList ParentMapContext::getParents(const DynTypedNode &Node) {
if (!Parents)
// We build the parent map for the traversal scope (usually whole TU), as
// hasAncestor can escape any subtree.
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -57,9 +57,9 @@
// provides enough benefit for the additional amount of code.
struct MatchKey {
DynTypedMatcher::MatcherIDType MatcherID;
- ast_type_traits::DynTypedNode Node;
+ DynTypedNode Node;
BoundNodesTreeBuilder BoundNodes;
- ast_type_traits::TraversalKind Traversal = ast_type_traits::TK_AsIs;
+ TraversalKind Traversal = TK_AsIs;
bool operator<(const MatchKey &Other) const {
return std::tie(Traversal, MatcherID, Node, BoundNodes) <
@@ -87,8 +87,7 @@
// matching the descendants.
MatchChildASTVisitor(const DynTypedMatcher *Matcher, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder, int MaxDepth,
- ast_type_traits::TraversalKind Traversal,
- ASTMatchFinder::BindKind Bind)
+ TraversalKind Traversal, ASTMatchFinder::BindKind Bind)
: Matcher(Matcher), Finder(Finder), Builder(Builder), CurrentDepth(0),
MaxDepth(MaxDepth), Traversal(Traversal), Bind(Bind), Matches(false) {}
@@ -103,7 +102,7 @@
// Traverse*(c) for each child c of 'node'.
// - Traverse*(c) in turn calls Traverse(c), completing the
// recursion.
- bool findMatch(const ast_type_traits::DynTypedNode &DynNode) {
+ bool findMatch(const DynTypedNode &DynNode) {
reset();
if (const Decl *D = DynNode.get())
traverse(*D);
@@ -145,15 +144,14 @@
auto *LambdaNode = dyn_cast_or_null(StmtNode);
if (LambdaNode &&
Finder->getASTContext().getParentMapContext().getTraversalKind() ==
- ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+ TK_IgnoreUnlessSpelledInSource)
StmtToTraverse = LambdaNode;
else
StmtToTraverse =
Finder->getASTContext().getParentMapContext().traverseIgnored(
ExprNode);
}
- if (Traversal ==
- ast_type_traits::TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
+ if (Traversal == TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
if (Expr *ExprNode = dyn_cast_or_null(StmtNode))
StmtToTraverse = ExprNode->IgnoreParenImpCasts();
}
@@ -220,7 +218,7 @@
}
bool TraverseLambdaExpr(LambdaExpr *Node) {
if (Finder->getASTContext().getParentMapContext().getTraversalKind() !=
- ast_type_traits::TK_IgnoreUnlessSpelledInSource)
+ TK_IgnoreUnlessSpelledInSource)
return VisitorBase::TraverseLambdaExpr(Node);
if (!Node)
return true;
@@ -311,7 +309,7 @@
}
if (Bind != ASTMatchFinder::BK_All) {
BoundNodesTreeBuilder RecursiveBuilder(*Builder);
- if (Matcher->matches(ast_type_traits::DynTypedNode::create(Node), Finder,
+ if (Matcher->matches(DynTypedNode::create(Node), Finder,
&RecursiveBuilder)) {
Matches = true;
ResultBindings.addMatch(RecursiveBuilder);
@@ -319,7 +317,7 @@
}
} else {
BoundNodesTreeBuilder RecursiveBuilder(*Builder);
- if (Matcher->matches(ast_type_traits::DynTypedNode::create(Node), Finder,
+ if (Matcher->matches(DynTypedNode::create(Node), Finder,
&RecursiveBuilder)) {
// After the first match the matcher succeeds.
Matches = true;
@@ -346,7 +344,7 @@
BoundNodesTreeBuilder ResultBindings;
int CurrentDepth;
const int MaxDepth;
- const ast_type_traits::TraversalKind Traversal;
+ const TraversalKind Traversal;
const ASTMatchFinder::BindKind Bind;
bool Matches;
};
@@ -443,12 +441,10 @@
bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit);
// Matches children or descendants of 'Node' with 'BaseMatcher'.
- bool memoizedMatchesRecursively(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx,
+ bool memoizedMatchesRecursively(const DynTypedNode &Node, ASTContext &Ctx,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder, int MaxDepth,
- ast_type_traits::TraversalKind Traversal,
- BindKind Bind) {
+ TraversalKind Traversal, BindKind Bind) {
// For AST-nodes that don't have an identity, we can't memoize.
if (!Node.getMemoizationData() || !Builder->isComparable())
return matchesRecursively(Node, Matcher, Builder, MaxDepth, Traversal,
@@ -480,11 +476,10 @@
}
// Matches children or descendants of 'Node' with 'BaseMatcher'.
- bool matchesRecursively(const ast_type_traits::DynTypedNode &Node,
+ bool matchesRecursively(const DynTypedNode &Node,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder, int MaxDepth,
- ast_type_traits::TraversalKind Traversal,
- BindKind Bind) {
+ TraversalKind Traversal, BindKind Bind) {
MatchChildASTVisitor Visitor(
&Matcher, this, Builder, MaxDepth, Traversal, Bind);
return Visitor.findMatch(Node);
@@ -501,10 +496,9 @@
bool Directly) override;
// Implements ASTMatchFinder::matchesChildOf.
- bool matchesChildOf(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx, const DynTypedMatcher &Matcher,
- BoundNodesTreeBuilder *Builder,
- ast_type_traits::TraversalKind Traversal,
+ bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx,
+ const DynTypedMatcher &Matcher,
+ BoundNodesTreeBuilder *Builder, TraversalKind Traversal,
BindKind Bind) override {
if (ResultCache.size() > MaxMemoizationEntries)
ResultCache.clear();
@@ -512,19 +506,18 @@
Bind);
}
// Implements ASTMatchFinder::matchesDescendantOf.
- bool matchesDescendantOf(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx, const DynTypedMatcher &Matcher,
+ bool matchesDescendantOf(const DynTypedNode &Node, ASTContext &Ctx,
+ const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
BindKind Bind) override {
if (ResultCache.size() > MaxMemoizationEntries)
ResultCache.clear();
return memoizedMatchesRecursively(Node, Ctx, Matcher, Builder, INT_MAX,
- ast_type_traits::TraversalKind::TK_AsIs,
- Bind);
+ TraversalKind::TK_AsIs, Bind);
}
// Implements ASTMatchFinder::matchesAncestorOf.
- bool matchesAncestorOf(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx, const DynTypedMatcher &Matcher,
+ bool matchesAncestorOf(const DynTypedNode &Node, ASTContext &Ctx,
+ const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
AncestorMatchMode MatchMode) override {
// Reset the cache outside of the recursive call to make sure we
@@ -537,7 +530,7 @@
// Matches all registered matchers on the given node and calls the
// result callback for every node that matches.
- void match(const ast_type_traits::DynTypedNode &Node) {
+ void match(const DynTypedNode &Node) {
// FIXME: Improve this with a switch or a visitor pattern.
if (auto *N = Node.get()) {
match(*N);
@@ -615,7 +608,7 @@
}
}
- void matchWithFilter(const ast_type_traits::DynTypedNode &DynNode) {
+ void matchWithFilter(const DynTypedNode &DynNode) {
auto Kind = DynNode.getNodeKind();
auto it = MatcherFiltersMap.find(Kind);
const auto &Filter =
@@ -639,8 +632,7 @@
}
}
- const std::vector &
- getFilterForKind(ast_type_traits::ASTNodeKind Kind) {
+ const std::vector &getFilterForKind(ASTNodeKind Kind) {
auto &Filter = MatcherFiltersMap[Kind];
auto &Matchers = this->Matchers->DeclOrStmt;
assert((Matchers.size() < USHRT_MAX) && "Too many matchers.");
@@ -655,10 +647,10 @@
/// @{
/// Overloads to pair the different node types to their matchers.
void matchDispatch(const Decl *Node) {
- return matchWithFilter(ast_type_traits::DynTypedNode::create(*Node));
+ return matchWithFilter(DynTypedNode::create(*Node));
}
void matchDispatch(const Stmt *Node) {
- return matchWithFilter(ast_type_traits::DynTypedNode::create(*Node));
+ return matchWithFilter(DynTypedNode::create(*Node));
}
void matchDispatch(const Type *Node) {
@@ -695,10 +687,11 @@
// Once there are multiple parents, the breadth first search order does not
// allow simple memoization on the ancestors. Thus, we only memoize as long
// as there is a single parent.
- bool memoizedMatchesAncestorOfRecursively(
- const ast_type_traits::DynTypedNode &Node, ASTContext &Ctx,
- const DynTypedMatcher &Matcher, BoundNodesTreeBuilder *Builder,
- AncestorMatchMode MatchMode) {
+ bool memoizedMatchesAncestorOfRecursively(const DynTypedNode &Node,
+ ASTContext &Ctx,
+ const DynTypedMatcher &Matcher,
+ BoundNodesTreeBuilder *Builder,
+ AncestorMatchMode MatchMode) {
// For AST-nodes that don't have an identity, we can't memoize.
if (!Builder->isComparable())
return matchesAncestorOfRecursively(Node, Ctx, Matcher, Builder,
@@ -730,8 +723,7 @@
return CachedResult.ResultOfMatch;
}
- bool matchesAncestorOfRecursively(const ast_type_traits::DynTypedNode &Node,
- ASTContext &Ctx,
+ bool matchesAncestorOfRecursively(const DynTypedNode &Node, ASTContext &Ctx,
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
AncestorMatchMode MatchMode) {
@@ -758,7 +750,7 @@
}
if (Parents.size() == 1) {
// Only one parent - do recursive memoization.
- const ast_type_traits::DynTypedNode Parent = Parents[0];
+ const DynTypedNode Parent = Parents[0];
BoundNodesTreeBuilder BuilderCopy = *Builder;
if (Matcher.matches(Parent, this, &BuilderCopy)) {
*Builder = std::move(BuilderCopy);
@@ -773,8 +765,7 @@
} else {
// Multiple parents - BFS over the rest of the nodes.
llvm::DenseSet Visited;
- std::deque Queue(Parents.begin(),
- Parents.end());
+ std::deque Queue(Parents.begin(), Parents.end());
while (!Queue.empty()) {
BoundNodesTreeBuilder BuilderCopy = *Builder;
if (Matcher.matches(Queue.front(), this, &BuilderCopy)) {
@@ -864,8 +855,7 @@
/// kind (and derived kinds) so it is a waste to try every matcher on every
/// node.
/// We precalculate a list of matchers that pass the toplevel restrict check.
- llvm::DenseMap>
- MatcherFiltersMap;
+ llvm::DenseMap> MatcherFiltersMap;
const MatchFinder::MatchFinderOptions &Options;
ASTContext *ActiveASTContext;
@@ -1140,8 +1130,7 @@
return std::make_unique(this, ParsingDone);
}
-void MatchFinder::match(const clang::ast_type_traits::DynTypedNode &Node,
- ASTContext &Context) {
+void MatchFinder::match(const clang::DynTypedNode &Node, ASTContext &Context) {
internal::MatchASTVisitor Visitor(&Matchers, Options);
Visitor.set_active_ast_context(&Context);
Visitor.match(Node);
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -51,26 +51,23 @@
namespace internal {
-bool NotUnaryOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder,
+bool NotUnaryOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers);
-bool AllOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+bool AllOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers);
-bool EachOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+bool EachOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers);
-bool AnyOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+bool AnyOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers);
-bool OptionallyVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
+bool OptionallyVariadicOperator(const DynTypedNode &DynNode,
ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers);
@@ -86,7 +83,7 @@
namespace {
using VariadicOperatorFunction = bool (*)(
- const ast_type_traits::DynTypedNode &DynNode, ASTMatchFinder *Finder,
+ const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder, ArrayRef InnerMatchers);
template
@@ -95,8 +92,7 @@
VariadicMatcher(std::vector InnerMatchers)
: InnerMatchers(std::move(InnerMatchers)) {}
- bool dynMatches(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+ bool dynMatches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const override {
return Func(DynNode, Finder, Builder, InnerMatchers);
}
@@ -111,16 +107,14 @@
IntrusiveRefCntPtr InnerMatcher)
: ID(ID), InnerMatcher(std::move(InnerMatcher)) {}
- bool dynMatches(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+ bool dynMatches(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const override {
bool Result = InnerMatcher->dynMatches(DynNode, Finder, Builder);
if (Result) Builder->setBinding(ID, DynNode);
return Result;
}
- llvm::Optional
- TraversalKind() const override {
+ llvm::Optional TraversalKind() const override {
return InnerMatcher->TraversalKind();
}
@@ -140,7 +134,7 @@
Retain(); // Reference count will never become zero.
}
- bool dynMatches(const ast_type_traits::DynTypedNode &, ASTMatchFinder *,
+ bool dynMatches(const DynTypedNode &, ASTMatchFinder *,
BoundNodesTreeBuilder *) const override {
return true;
}
@@ -150,10 +144,10 @@
static llvm::ManagedStatic TrueMatcherInstance;
-DynTypedMatcher DynTypedMatcher::constructVariadic(
- DynTypedMatcher::VariadicOperator Op,
- ast_type_traits::ASTNodeKind SupportedKind,
- std::vector InnerMatchers) {
+DynTypedMatcher
+DynTypedMatcher::constructVariadic(DynTypedMatcher::VariadicOperator Op,
+ ASTNodeKind SupportedKind,
+ std::vector InnerMatchers) {
assert(!InnerMatchers.empty() && "Array must not be empty.");
assert(llvm::all_of(InnerMatchers,
[SupportedKind](const DynTypedMatcher &M) {
@@ -174,8 +168,8 @@
// invalid types earlier and we can elide the kind checks inside the
// matcher.
for (auto &IM : InnerMatchers) {
- RestrictKind = ast_type_traits::ASTNodeKind::getMostDerivedType(
- RestrictKind, IM.RestrictKind);
+ RestrictKind =
+ ASTNodeKind::getMostDerivedType(RestrictKind, IM.RestrictKind);
}
return DynTypedMatcher(
SupportedKind, RestrictKind,
@@ -206,34 +200,30 @@
llvm_unreachable("Invalid Op value.");
}
-DynTypedMatcher DynTypedMatcher::constructRestrictedWrapper(
- const DynTypedMatcher &InnerMatcher,
- ast_type_traits::ASTNodeKind RestrictKind) {
+DynTypedMatcher
+DynTypedMatcher::constructRestrictedWrapper(const DynTypedMatcher &InnerMatcher,
+ ASTNodeKind RestrictKind) {
DynTypedMatcher Copy = InnerMatcher;
Copy.RestrictKind = RestrictKind;
return Copy;
}
-DynTypedMatcher DynTypedMatcher::trueMatcher(
- ast_type_traits::ASTNodeKind NodeKind) {
+DynTypedMatcher DynTypedMatcher::trueMatcher(ASTNodeKind NodeKind) {
return DynTypedMatcher(NodeKind, NodeKind, &*TrueMatcherInstance);
}
-bool DynTypedMatcher::canMatchNodesOfKind(
- ast_type_traits::ASTNodeKind Kind) const {
+bool DynTypedMatcher::canMatchNodesOfKind(ASTNodeKind Kind) const {
return RestrictKind.isBaseOf(Kind);
}
-DynTypedMatcher DynTypedMatcher::dynCastTo(
- const ast_type_traits::ASTNodeKind Kind) const {
+DynTypedMatcher DynTypedMatcher::dynCastTo(const ASTNodeKind Kind) const {
auto Copy = *this;
Copy.SupportedKind = Kind;
- Copy.RestrictKind =
- ast_type_traits::ASTNodeKind::getMostDerivedType(Kind, RestrictKind);
+ Copy.RestrictKind = ASTNodeKind::getMostDerivedType(Kind, RestrictKind);
return Copy;
}
-bool DynTypedMatcher::matches(const ast_type_traits::DynTypedNode &DynNode,
+bool DynTypedMatcher::matches(const DynTypedNode &DynNode,
ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const {
TraversalKindScope RAII(Finder->getASTContext(),
@@ -253,9 +243,9 @@
return false;
}
-bool DynTypedMatcher::matchesNoKindCheck(
- const ast_type_traits::DynTypedNode &DynNode, ASTMatchFinder *Finder,
- BoundNodesTreeBuilder *Builder) const {
+bool DynTypedMatcher::matchesNoKindCheck(const DynTypedNode &DynNode,
+ ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder) const {
TraversalKindScope raii(Finder->getASTContext(),
Implementation->TraversalKind());
@@ -281,10 +271,10 @@
return std::move(Result);
}
-bool DynTypedMatcher::canConvertTo(ast_type_traits::ASTNodeKind To) const {
+bool DynTypedMatcher::canConvertTo(ASTNodeKind To) const {
const auto From = getSupportedKind();
- auto QualKind = ast_type_traits::ASTNodeKind::getFromNodeKind();
- auto TypeKind = ast_type_traits::ASTNodeKind::getFromNodeKind();
+ auto QualKind = ASTNodeKind::getFromNodeKind();
+ auto TypeKind = ASTNodeKind::getFromNodeKind();
/// Mimic the implicit conversions of Matcher<>.
/// - From Matcher to Matcher
if (From.isSame(TypeKind) && To.isSame(QualKind)) return true;
@@ -296,8 +286,8 @@
Bindings.append(Other.Bindings.begin(), Other.Bindings.end());
}
-bool NotUnaryOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder,
+bool NotUnaryOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers) {
if (InnerMatchers.size() != 1)
return false;
@@ -316,8 +306,7 @@
return !InnerMatchers[0].matches(DynNode, Finder, &Discard);
}
-bool AllOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+bool AllOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers) {
// allOf leads to one matcher for each alternative in the first
@@ -330,8 +319,7 @@
return true;
}
-bool EachOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+bool EachOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers) {
BoundNodesTreeBuilder Result;
@@ -347,8 +335,7 @@
return Matched;
}
-bool AnyOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
- ASTMatchFinder *Finder,
+bool AnyOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers) {
for (const DynTypedMatcher &InnerMatcher : InnerMatchers) {
@@ -361,7 +348,7 @@
return false;
}
-bool OptionallyVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
+bool OptionallyVariadicOperator(const DynTypedNode &DynNode,
ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder,
ArrayRef InnerMatchers) {
diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -80,7 +80,7 @@
}
static ArgKind getKind() {
- return ArgKind(ast_type_traits::ASTNodeKind::getFromNodeKind());
+ return ArgKind(ASTNodeKind::getFromNodeKind());
}
};
@@ -211,7 +211,7 @@
/// set of argument types accepted for argument \p ArgNo to \p ArgKinds.
// FIXME: We should provide the ability to constrain the output of this
// function based on the types of other matcher arguments.
- virtual void getArgKinds(ast_type_traits::ASTNodeKind ThisKind, unsigned ArgNo,
+ virtual void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
std::vector &ArgKinds) const = 0;
/// Returns whether this matcher is convertible to the given type. If it is
@@ -221,20 +221,19 @@
/// same matcher overload. Zero specificity indicates that this conversion
/// would produce a trivial matcher that will either always or never match.
/// Such matchers are excluded from code completion results.
- virtual bool isConvertibleTo(
- ast_type_traits::ASTNodeKind Kind, unsigned *Specificity = nullptr,
- ast_type_traits::ASTNodeKind *LeastDerivedKind = nullptr) const = 0;
+ virtual bool
+ isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity = nullptr,
+ ASTNodeKind *LeastDerivedKind = nullptr) const = 0;
/// Returns whether the matcher will, given a matcher of any type T, yield a
/// matcher of type T.
virtual bool isPolymorphic() const { return false; }
};
-inline bool isRetKindConvertibleTo(
- ArrayRef RetKinds,
- ast_type_traits::ASTNodeKind Kind, unsigned *Specificity,
- ast_type_traits::ASTNodeKind *LeastDerivedKind) {
- for (const ast_type_traits::ASTNodeKind &NodeKind : RetKinds) {
+inline bool isRetKindConvertibleTo(ArrayRef RetKinds,
+ ASTNodeKind Kind, unsigned *Specificity,
+ ASTNodeKind *LeastDerivedKind) {
+ for (const ASTNodeKind &NodeKind : RetKinds) {
if (ArgKind(NodeKind).isConvertibleTo(Kind, Specificity)) {
if (LeastDerivedKind)
*LeastDerivedKind = NodeKind;
@@ -264,10 +263,10 @@
/// \param RetKinds The list of matcher types to which the matcher is
/// convertible.
/// \param ArgKinds The types of the arguments this matcher takes.
- FixedArgCountMatcherDescriptor(
- MarshallerType Marshaller, void (*Func)(), StringRef MatcherName,
- ArrayRef RetKinds,
- ArrayRef ArgKinds)
+ FixedArgCountMatcherDescriptor(MarshallerType Marshaller, void (*Func)(),
+ StringRef MatcherName,
+ ArrayRef RetKinds,
+ ArrayRef ArgKinds)
: Marshaller(Marshaller), Func(Func), MatcherName(MatcherName),
RetKinds(RetKinds.begin(), RetKinds.end()),
ArgKinds(ArgKinds.begin(), ArgKinds.end()) {}
@@ -281,14 +280,13 @@
bool isVariadic() const override { return false; }
unsigned getNumArgs() const override { return ArgKinds.size(); }
- void getArgKinds(ast_type_traits::ASTNodeKind ThisKind, unsigned ArgNo,
+ void getArgKinds(ASTNodeKind ThisKind, unsigned ArgNo,
std::vector &Kinds) const override {
Kinds.push_back(ArgKinds[ArgNo]);
}
- bool isConvertibleTo(
- ast_type_traits::ASTNodeKind Kind, unsigned *Specificity,
- ast_type_traits::ASTNodeKind *LeastDerivedKind) const override {
+ bool isConvertibleTo(ASTNodeKind Kind, unsigned *Specificity,
+ ASTNodeKind *LeastDerivedKind) const override {
return isRetKindConvertibleTo(RetKinds, Kind, Specificity,
LeastDerivedKind);
}
@@ -297,7 +295,7 @@
const MarshallerType Marshaller;
void (* const Func)();
const std::string MatcherName;
- const std::vector RetKinds;
+ const std::vector RetKinds;
const std::vector ArgKinds;
};
@@ -336,36 +334,35 @@
}
template
-inline void buildReturnTypeVectorFromTypeList(
- std::vector &RetTypes) {
- RetTypes.push_back(
- ast_type_traits::ASTNodeKind::getFromNodeKind());
+inline void
+buildReturnTypeVectorFromTypeList(std::vector &RetTypes) {
+ RetTypes.push_back(ASTNodeKind::getFromNodeKind());
buildReturnTypeVectorFromTypeList(RetTypes);
}
template <>
inline void
buildReturnTypeVectorFromTypeList(
- std::vector &RetTypes) {}
+ std::vector &RetTypes) {}
template
struct BuildReturnTypeVector {
- static void build(std::vector &RetTypes) {
+ static void build(std::vector &RetTypes) {
buildReturnTypeVectorFromTypeList(RetTypes);
}
};
template