[llvm-branch-commits] [cfe-branch] r159773 - in /cfe/branches/tooling: include/clang/ASTMatchers/ASTMatchers.h include/clang/ASTMatchers/ASTMatchersInternal.h lib/ASTMatchers/ASTMatchFinder.cpp
Manuel Klimek
klimek at google.com
Thu Jul 5 12:54:13 PDT 2012
Author: klimek
Date: Thu Jul 5 14:54:13 2012
New Revision: 159773
URL: http://llvm.org/viewvc/llvm-project?rev=159773&view=rev
Log:
Changes std::string to StringRef where possible. Changing it in
all the matchers would require significantly more effort - we can
do that later if there is a need.
Modified:
cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h
cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp
Modified: cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h?rev=159773&r1=159772&r2=159773&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchers.h Thu Jul 5 14:54:13 2012
@@ -67,11 +67,11 @@
/// FIXME: We'll need one of those for every base type.
/// @{
template <typename T>
- const T *getDeclAs(const std::string &ID) const {
+ const T *getDeclAs(StringRef ID) const {
return getNodeAs<T>(DeclBindings, ID);
}
template <typename T>
- const T *getStmtAs(const std::string &ID) const {
+ const T *getStmtAs(StringRef ID) const {
return getNodeAs<T>(StmtBindings, ID);
}
/// @}
@@ -83,7 +83,7 @@
: DeclBindings(DeclBindings), StmtBindings(StmtBindings) {}
template <typename T, typename MapT>
- const T *getNodeAs(const MapT &Bindings, const std::string &ID) const {
+ const T *getNodeAs(const MapT &Bindings, StringRef ID) const {
typename MapT::const_iterator It = Bindings.find(ID);
if (It == Bindings.end()) {
return NULL;
Modified: cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=159773&r1=159772&r2=159773&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchersInternal.h Thu Jul 5 14:54:13 2012
@@ -415,7 +415,7 @@
///
/// A class is considered to be also derived from itself.
virtual bool classIsDerivedFrom(const clang::CXXRecordDecl *Declaration,
- const std::string &BaseName) const = 0;
+ StringRef BaseName) const = 0;
// FIXME: Implement for other base nodes.
virtual bool matchesChildOf(const clang::Decl &DeclNode,
@@ -586,7 +586,7 @@
public:
/// \brief Creates an IdMatcher that binds to 'ID' if 'InnerMatcher' matches
/// the node.
- IdMatcher(const std::string &ID, const Matcher<T> &InnerMatcher)
+ IdMatcher(StringRef ID, const Matcher<T> &InnerMatcher)
: ID(ID), InnerMatcher(InnerMatcher) {}
virtual bool matches(const T &Node,
Modified: cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp?rev=159773&r1=159772&r2=159773&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp Thu Jul 5 14:54:13 2012
@@ -289,7 +289,7 @@
}
virtual bool classIsDerivedFrom(const clang::CXXRecordDecl *Declaration,
- const std::string &BaseName) const;
+ StringRef BaseName) const;
// Implements ASTMatchFinder::MatchesChildOf.
virtual bool matchesChildOf(const clang::Decl &DeclNode,
@@ -351,7 +351,7 @@
// words, there is a type (including typedef) with the name 'Name'
// that is equal to 'TypeNode'.
bool typeHasAlias(const clang::Type *TypeNode,
- const std::string &Name) const {
+ StringRef Name) const {
const clang::Type *const CanonicalType =
ActiveASTContext->getCanonicalType(TypeNode);
const std::set<std::string> *UnqualifiedAlias =
@@ -394,8 +394,8 @@
// also derived from itself.
bool
MatchASTVisitor::classIsDerivedFrom(const clang::CXXRecordDecl *Declaration,
- const std::string &BaseName) const {
- if (std::string(Declaration->getName()) == BaseName) {
+ StringRef BaseName) const {
+ if (Declaration->getName() == BaseName) {
return true;
}
if (!Declaration->hasDefinition()) {
More information about the llvm-branch-commits
mailing list