[llvm] [Support] Mark string-returning sys::path::native nodiscard (PR #194675)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 09:54:19 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Hans Wennborg (zmodem)

<details>
<summary>Changes</summary>

To make it clear that it doesn't modify the path in place like the other overloads. Follow-up to #<!-- -->193228

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


1 Files Affected:

- (modified) llvm/include/llvm/Support/Path.h (+2-1) 


``````````diff
diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h
index 4fa9585ec2b8c..28e1e8ba3ae36 100644
--- a/llvm/include/llvm/Support/Path.h
+++ b/llvm/include/llvm/Support/Path.h
@@ -270,7 +270,8 @@ LLVM_ABI void native(const Twine &path, SmallVectorImpl<char> &result,
 /// converts all '\' to '/'.
 ///
 /// @param path A path that is transformed to native format.
-LLVM_ABI std::string native(const Twine &path, Style style = Style::native);
+[[nodiscard]] LLVM_ABI std::string native(const Twine &path,
+                                          Style style = Style::native);
 
 /// Convert path to the native form in place. This is used to give paths to
 /// users and operating system calls in the platform's normal way. For example,

``````````

</details>


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


More information about the llvm-commits mailing list