diff options
author | Brad King <brad.king@kitware.com> | 2022-11-29 15:35:59 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-11-29 15:36:10 (GMT) |
commit | 79721c19f1bc8f04dc3c019ad7feb61ae040e4ee (patch) | |
tree | 02e3e8b02a3fe6b261007b06a8aa8dfa844f8d8d /Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx | |
parent | f6b4923e95b875d441564d5b3d85286d802ba09f (diff) | |
parent | 5ad111e595c2e1642fdebd3f7048a5aca664035f (diff) | |
download | CMake-79721c19f1bc8f04dc3c019ad7feb61ae040e4ee.zip CMake-79721c19f1bc8f04dc3c019ad7feb61ae040e4ee.tar.gz CMake-79721c19f1bc8f04dc3c019ad7feb61ae040e4ee.tar.bz2 |
Merge topic 'clang-tidy-module-string-concatenation-cmstrcat-check'
5ad111e595 clang-tidy: disable string concatenation check
c6c8616468 clang-tidy module: add tests for string concatenation check
e1ec052d53 clang-tidy module: add check for string concatenation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !7961
Diffstat (limited to 'Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx')
-rw-r--r-- | Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx new file mode 100644 index 0000000..79aecd4 --- /dev/null +++ b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx @@ -0,0 +1,36 @@ +#include <string> + +template <typename... Args> +std::string cmStrCat(Args&&... args) +{ + return ""; +} + +std::string a = "This is a string variable"; +std::string b = " and this is a string variable"; +std::string concat; + +// Correction needed +void test1() +{ + concat = cmStrCat(a, b); + concat = cmStrCat(a, " and this is a string literal"); + concat = cmStrCat(a, 'O'); + concat = cmStrCat("This is a string literal", b); + concat = cmStrCat('O', a); + concat = cmStrCat(a, " and this is a string literal", 'O', b); + + concat = cmStrCat(concat, b); + concat = cmStrCat(concat, " and this is a string literal"); + concat = cmStrCat(concat, 'o'); + concat = cmStrCat(concat, b, " and this is a string literal ", 'o', b); +} + +// No correction needed +void test2() +{ + a = b; + a = "This is a string literal"; + a = 'X'; + cmStrCat(a, b); +} |