[clang-tools-extra] r322002 - [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation between basic_string and basic_string_view.
Samuel Benzaquen via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 07:59:08 PST 2018
Author: sbenza
Date: Mon Jan 8 07:59:08 2018
New Revision: 322002
URL: http://llvm.org/viewvc/llvm-project?rev=322002&view=rev
Log:
[clang-tidy] Fix DanglingHandleCheck for the correct conversion operation between basic_string and basic_string_view.
Summary:
Fix DanglingHandleCheck to handle the final implementation of std::string and std::string_view.
These use a conversion operator instead of a conversion constructor.
Reviewers: hokein
Subscribers: klimek, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D41779
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
Modified: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp?rev=322002&r1=322001&r2=322002&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp Mon Jan 8 07:59:08 2018
@@ -25,8 +25,12 @@ namespace {
ast_matchers::internal::BindableMatcher<Stmt>
handleFrom(const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle,
const ast_matchers::internal::Matcher<Expr> &Arg) {
- return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
- hasArgument(0, Arg));
+ return expr(
+ anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
+ hasArgument(0, Arg)),
+ cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)),
+ callee(memberExpr(member(cxxConversionDecl()))),
+ on(Arg))));
}
ast_matchers::internal::Matcher<Stmt> handleFromTemporaryValue(
Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp?rev=322002&r1=322001&r2=322002&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp Mon Jan 8 07:59:08 2018
@@ -45,10 +45,15 @@ class map {
value_type& operator[](Key&& key);
};
+class basic_string_view;
+
class basic_string {
public:
basic_string();
basic_string(const char*);
+
+ operator basic_string_view() const noexcept;
+
~basic_string();
};
@@ -57,7 +62,6 @@ typedef basic_string string;
class basic_string_view {
public:
basic_string_view(const char*);
- basic_string_view(const basic_string&);
};
typedef basic_string_view string_view;
More information about the cfe-commits
mailing list