[PATCH] D56657: [clang-tidy] bugprone-string-constructor: Catch string from nullptr.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 15 12:33:45 PST 2019
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM aside from a nit and a test case request.
================
Comment at: clang-tidy/bugprone/StringConstructorCheck.cpp:141
}
+ } else if (const Expr* Ptr = Result.Nodes.getNodeAs<Expr>("from-ptr")) {
+ Expr::EvalResult ConstPtr;
----------------
Formatting is wrong here, and you can use `const auto *` as the type is spelled out in the initialization.
================
Comment at: test/clang-tidy/bugprone-string-constructor.cpp:49-50
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
+ std::string q6(nullptr);
+ // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructing string from nullptr is undefined behaviour
+}
----------------
Can you also add: `std::string q7 = 0;` as a test case?
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56657/new/
https://reviews.llvm.org/D56657
More information about the cfe-commits
mailing list