Skip to content

Commit 764c3af

Browse files
authored
[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>) | ^~~~~~ ```
1 parent 33e41c4 commit 764c3af

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ static int initialize(Lang Language) {
141141
unsigned NSLen;
142142
const char *HeaderName;
143143
};
144-
#define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size(), #Header},
144+
#define SYMBOL(Name, NS, Header) \
145+
{#NS #Name, static_cast<decltype(Symbol::NSLen)>(StringRef(#NS).size()), \
146+
#Header},
145147
switch (Language) {
146148
case Lang::C: {
147149
static constexpr Symbol CSymbols[] = {

0 commit comments

Comments
 (0)