[Mlir-commits] [mlir] [MLIR] Make More Specific Function Header For StringLiteral Optimization in `Diagnostic` (PR #112154)
    llvmlistbot at llvm.org 
    llvmlistbot at llvm.org
       
    Mon Oct 14 00:18:26 PDT 2024
    
    
  
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 b2c615fc792c3f75af66aac99c05ffa85ef50354 dd4bc6aba00f5bc823c6382e2947fc46aeab6eb9 --extensions cpp,h -- mlir/unittests/IR/Diagnostic.cpp mlir/include/mlir/IR/Diagnostics.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/unittests/IR/Diagnostic.cpp b/mlir/unittests/IR/Diagnostic.cpp
index dfc83001f1..96e09d3330 100644
--- a/mlir/unittests/IR/Diagnostic.cpp
+++ b/mlir/unittests/IR/Diagnostic.cpp
@@ -22,7 +22,8 @@ TEST(DiagnosticLifetime, TestCopiesConstCharStar) {
   std::string myStr(expectedMessage);
 
   mlir::MLIRContext context;
-  Diagnostic diagnostic(mlir::UnknownLoc::get(&context), DiagnosticSeverity::Note);
+  Diagnostic diagnostic(mlir::UnknownLoc::get(&context),
+                        DiagnosticSeverity::Note);
   diagnostic << myStr.c_str();
 
   // Mutate underlying pointer, but ensure diagnostic still has orig. message
@@ -37,14 +38,15 @@ TEST(DiagnosticLifetime, TestCopiesConstCharStar) {
 TEST(DiagnosticLifetime, TestLazyCopyStringLiteral) {
   char charArr[21] = "Error 1, mutate this";
   mlir::MLIRContext context;
-  Diagnostic diagnostic(mlir::UnknownLoc::get(&context), DiagnosticSeverity::Note);
+  Diagnostic diagnostic(mlir::UnknownLoc::get(&context),
+                        DiagnosticSeverity::Note);
 
   // Diagnostic contains optimization which assumes string literals are
   // represented by `const char[]` type. This is imperfect as we can sometimes
   // trick the type system as seen below.
   //
   // Still we use this to check the diagnostic is lazily storing the pointer.
-  auto addToDiagnosticAsConst = [&diagnostic](const char (&charArr)[21]) {
+  auto addToDiagnosticAsConst = [&diagnostic](const char(&charArr)[21]) {
     diagnostic << charArr;
   };
   addToDiagnosticAsConst(charArr);
``````````
</details>
https://github.com/llvm/llvm-project/pull/112154
    
    
More information about the Mlir-commits
mailing list