llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Piotr Zegar (PiotrZSL)

<details>
<summary>Changes</summary>

Resolved the crash that occurred during the use of a user-defined C-style 
string literal. The fix entails checking whether the identifier is non-empty 
before attempting to read its name.

---
Full diff: https://github.com/llvm/llvm-project/pull/70709.diff


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-trailing-return-type-cxx20.cpp
 (+18) 


``````````diff
diff --git 
a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index b81cfbcbfd16ccc..5a456c58fb5cc53 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -103,7 +103,7 @@ struct UnqualNameVisitor : public 
RecursiveASTVisitor<UnqualNameVisitor> {
 
   bool VisitDeclRefExpr(DeclRefExpr *S) {
     DeclarationName Name = S->getNameInfo().getName();
-    return S->getQualifierLoc() || !Name.isIdentifier() ||
+    return S->getQualifierLoc() || Name.isEmpty() || !Name.isIdentifier() ||
            !visitUnqualName(Name.getAsIdentifierInfo()->getName());
   }
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-trailing-return-type-cxx20.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-trailing-return-type-cxx20.cpp
index 63fe7a95fdc94ac..72fdcc01779650e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-trailing-return-type-cxx20.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-trailing-return-type-cxx20.cpp
@@ -98,3 +98,21 @@ struct TestDefaultOperatorB {
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use a trailing return type for 
this function [modernize-use-trailing-return-type]
   // CHECK-FIXES: {{^}}  friend auto operator<(const TestDefaultOperatorB &, 
const TestDefaultOperatorB &) noexcept -> bool = default;{{$}}
 };
+
+namespace PR69863 {
+
+template <unsigned Len>
+struct CustomCompileTimeString {
+  constexpr CustomCompileTimeString(const char (&)[Len]) noexcept {}
+};
+
+template <CustomCompileTimeString Str>
+constexpr decltype(Str) operator""__csz() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use a trailing return type for 
this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}constexpr auto operator""__csz() noexcept -> 
decltype(Str) {
+  return Str;
+}
+
+inline constexpr CustomCompileTimeString SomeString = "This line will cause a 
crash"__csz;
+
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/70709
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to