[clang-tools-extra] [clang-tidy] Add readability-use-builtin-literals check (PR #76065)

via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 20 07:34:42 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 7767c5856d85cd1acf2efc32f77fdf07f00f9ff4 b4d7dbcf67117471a2d7025013fb1fcd188b33b6 -- clang-tools-extra/clang-tidy/readability/UseBuiltinLiteralsCheck.cpp clang-tools-extra/clang-tidy/readability/UseBuiltinLiteralsCheck.h clang-tools-extra/test/clang-tidy/checkers/readability/use-builtin-literals-cpp17.cpp clang-tools-extra/test/clang-tidy/checkers/readability/use-builtin-literals-cpp23.cpp clang-tools-extra/test/clang-tidy/checkers/readability/use-builtin-literals.cpp clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/UseBuiltinLiteralsCheck.cpp b/clang-tools-extra/clang-tidy/readability/UseBuiltinLiteralsCheck.cpp
index ede4651789..6a10fbd51c 100644
--- a/clang-tools-extra/clang-tidy/readability/UseBuiltinLiteralsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UseBuiltinLiteralsCheck.cpp
@@ -104,7 +104,7 @@ void UseBuiltinLiteralsCheck::check(const MatchFinder::MatchResult &Result) {
 
   StringRef LitText = getRawStringRef(Lit->getExprLoc(), SM, getLangOpts());
   std::string CastType = MatchedCast->getTypeAsWritten().getAsString();
-  std::string Fix; // Replacement string for the fix-it hint.
+  std::string Fix;              // Replacement string for the fix-it hint.
   std::optional<StringRef> Seq; // Literal sequence, prefix or suffix.
 
   if (const auto *CharLit = Nodes.getNodeAs<CharacterLiteral>("char");
@@ -153,8 +153,8 @@ void UseBuiltinLiteralsCheck::check(const MatchFinder::MatchResult &Result) {
     diag(MatchedCast->getExprLoc(),
          "use built-in '%0' %1 instead of explicit cast to '%2'")
         << *Seq
-		<< (Nodes.getNodeAs<CharacterLiteral>("char") ? "prefix" : "suffix")
-		<< CastType;
+        << (Nodes.getNodeAs<CharacterLiteral>("char") ? "prefix" : "suffix")
+        << CastType;
   }
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/76065


More information about the cfe-commits mailing list