llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: UebelAndre

<details>
<summary>Changes</summary>

`CXUnsavedFile::Length` is `unsigned long`, which is 32 bits on 64-bit Windows. 
Initializing it from `std::string::size()` inside the braced initializer is a 
narrowing conversion there: MSVC reports `C4838` and clang-cl 
`-Wc++11-narrowing`, both fatal under `/WX`. Cast explicitly.

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


1 Files Affected:

- (modified) clang/unittests/libclang/TestUtils.h (+5-3) 


``````````diff
diff --git a/clang/unittests/libclang/TestUtils.h 
b/clang/unittests/libclang/TestUtils.h
index 013aad17358211..27543d0a63d28b 100644
--- a/clang/unittests/libclang/TestUtils.h
+++ b/clang/unittests/libclang/TestUtils.h
@@ -82,9 +82,11 @@ class LibclangParseTest : public ::testing::Test {
         fixed_addr_string(new std::string(Filename)),
         fixed_addr_string(new std::string(Contents))));
     UnsavedFiles.push_back({
-        it.first->first->c_str(),   // filename
-        it.first->second->c_str(),  // contents
-        it.first->second->size()    // length
+        it.first->first->c_str(),  // filename
+        it.first->second->c_str(), // contents
+        // CXUnsavedFile::Length is `unsigned long`, which is 32 bits on
+        // 64-bit Windows, so converting from size_t here narrows.
+        static_cast<unsigned long>(it.first->second->size()) // length
     });
   }
   template <typename F>

``````````

</details>


https://github.com/llvm/llvm-project/pull/228405
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to