r225180 - Fix dangling pointer in isDerivedFrom.
Samuel Benzaquen
sbenza at google.com
Mon Jan 5 07:26:42 PST 2015
Author: sbenza
Date: Mon Jan 5 09:26:42 2015
New Revision: 225180
URL: http://llvm.org/viewvc/llvm-project?rev=225180&view=rev
Log:
Fix dangling pointer in isDerivedFrom.
Summary:
Replace usage of StringRef with std::string in AST_MATCHER* generated
matchers to make sure they keep their own copy of the string.
The value could be a temporary and it causes the pointer to be dangling
by the time the matcher is executed.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6843
Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=225180&r1=225179&r2=225180&view=diff
==============================================================================
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jan 5 09:26:42 2015
@@ -1774,7 +1774,7 @@ AST_MATCHER_P(CXXRecordDecl, isDerivedFr
}
/// \brief Overloaded method as shortcut for \c isDerivedFrom(hasName(...)).
-AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isDerivedFrom, StringRef, BaseName, 1) {
+AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isDerivedFrom, std::string, BaseName, 1) {
assert(!BaseName.empty());
return isDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
}
@@ -1789,8 +1789,8 @@ AST_MATCHER_P_OVERLOAD(CXXRecordDecl, is
/// \brief Overloaded method as shortcut for
/// \c isSameOrDerivedFrom(hasName(...)).
-AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isSameOrDerivedFrom, StringRef, BaseName,
- 1) {
+AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isSameOrDerivedFrom, std::string,
+ BaseName, 1) {
assert(!BaseName.empty());
return isSameOrDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
}
More information about the cfe-commits
mailing list