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

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 09:53:35 PDT 2026


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

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

>From 6665d0d5325c333e61696ad725a440c942e31160 Mon Sep 17 00:00:00 2001
From: Hans Wennborg <hans at chromium.org>
Date: Tue, 28 Apr 2026 18:50:42 +0200
Subject: [PATCH] [Support] Mark string-returning sys::path::native nodiscard

To make it clear that it doesn't modify the path in place like the other
overloads. Follow-up to #193228
---
 llvm/include/llvm/Support/Path.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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,



More information about the llvm-commits mailing list