[PATCH] D143971: [clang-tidy] Flag code with both string constructor arguments implicitly casted
Chris Cotter via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 13 18:29:45 PST 2023
ccotter added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp:58
+ // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
+ std::string s7(kText[1], 10);
+ // CHECK-MESSAGES: [[@LINE-1]]:15: warning: string constructor arguments might be incorrect;
----------------
This is specifically a bug I wrote recently where I meant to write `&kText[1]`. This doesn't fall under the "arguments swapped" case since indeed I merely forgot a '&'. At most, the tool can flag this potentially buggy code and suggest casts if the author determines the code is correct as is. However, the tool does not actually provide replacements as such code is more likely to be incorrect and require the author to determine the fix and apply it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143971/new/
https://reviews.llvm.org/D143971
More information about the cfe-commits
mailing list