[clang] [clang] On Windows, silence warning when building with MSVC (PR #187937)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 22 08:53:08 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Alexandre Ganea (aganea)
<details>
<summary>Changes</summary>
This fixes:
```
[2124/7029] Building CXX object tools\clang\lib\AST\CMakeFiles\obj.clangAST.dir\TemplateBase.cpp.obj
C:\git\llvm-project\clang\lib\AST\TemplateBase.cpp(753): warning C4312: 'reinterpret_cast': conversion from 'clang::SourceLocation::UIntTy' to 'clang::TemplateArgumentLocInfo::LocOrPointer' of greater size
```
---
Full diff: https://github.com/llvm/llvm-project/pull/187937.diff
1 Files Affected:
- (modified) clang/lib/AST/TemplateBase.cpp (+2-2)
``````````diff
diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index f76c2e336dc86..a5e0dde45364c 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -750,8 +750,8 @@ clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo(
clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo(
ASTContext &Ctx, SourceLocation TrivialLoc) {
if constexpr (EmbedLocInPointer)
- Pointer = reinterpret_cast<LocOrPointer>((TrivialLoc.getRawEncoding() + 1u)
- << LowBitsRequired);
+ Pointer = reinterpret_cast<LocOrPointer>(static_cast<uintptr_t>(
+ (TrivialLoc.getRawEncoding() + 1u) << LowBitsRequired));
else
Pointer = new (Ctx) SourceLocation(TrivialLoc);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/187937
More information about the cfe-commits
mailing list