diff options
author | Krzysztof Parzyszek <Krzysztof.Parzyszek@amd.com> | 2023-11-17 10:53:43 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 10:53:43 -0600 |
commit | 764c3afd43128f7ccddb070953c330b340ebe811 (patch) | |
tree | 769a3b851176f43002b9a8c89d5130e3fba296f0 /clang | |
parent | 33e41c457a20e5872a20ad40ed28a7ed78693217 (diff) | |
download | llvm-764c3afd43128f7ccddb070953c330b340ebe811.zip llvm-764c3afd43128f7ccddb070953c330b340ebe811.tar.gz llvm-764c3afd43128f7ccddb070953c330b340ebe811.tar.bz2 |
[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>)
| ^~~~~~
```
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp index 03f61d3..adf1b230 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[] = { |