[clang] 764c3af - [Tooling/Inclusion] Avoid narrowing conversions in macro expansion (#72664)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 17 08:53:48 PST 2023
Author: Krzysztof Parzyszek
Date: 2023-11-17T10:53:43-06:00
New Revision: 764c3afd43128f7ccddb070953c330b340ebe811
URL: https://github.com/llvm/llvm-project/commit/764c3afd43128f7ccddb070953c330b340ebe811
DIFF: https://github.com/llvm/llvm-project/commit/764c3afd43128f7ccddb070953c330b340ebe811.diff
LOG: [Tooling/Inclusion] Avoid narrowing conversions in macro expansion (#72664)
```
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:144:65: warning:
narrowing conversion of ‘llvm::StringRef(((const char*)"std::experiment
al::filesystem::")).llvm::StringRef::size()’ from ‘size_t’ {aka ‘long un
signed int’} to ‘unsigned int’ [-Wnarrowing]
144 | #define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size
(), #Header},
| ~~~~~~~~~~~~~~~~~~~
^~
clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc:51:1: note: in ex
pansion of macro ‘SYMBOL’
51 | SYMBOL(temp_directory_path, std::experimental::filesystem::, <ex
perimental/filesystem>)
| ^~~~~~
```
Added:
Modified:
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 03f61d33e1f26e7..adf1b230ff03181 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -141,7 +141,9 @@ static int initialize(Lang Language) {
unsigned NSLen;
const char *HeaderName;
};
-#define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size(), #Header},
+#define SYMBOL(Name, NS, Header) \
+ {#NS #Name, static_cast<decltype(Symbol::NSLen)>(StringRef(#NS).size()), \
+ #Header},
switch (Language) {
case Lang::C: {
static constexpr Symbol CSymbols[] = {
More information about the cfe-commits
mailing list