[clang] [analyzer] Fix a test issue in mingw configurations (PR #92737)
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Mon May 20 03:51:06 PDT 2024
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/92737
On Windows, long is always 32 bit, thus one can't use long for casting pointers to integers, on 64 bit architectures.
Instead use long long, which should be large enough.
This avoids errors like "error: cast from pointer to smaller type 'long' loses information" in this testcase.
This condition only seems to be an error in mingw mode; in MSVC mode (clang-cl), this is only a warning.
>From 392c23804e3531be2786b5ec9712409e222c3dba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Sun, 19 May 2024 00:33:47 +0300
Subject: [PATCH] [analyzer] Fix a test issue in mingw configurations
On Windows, long is always 32 bit, thus one can't use long for
casting pointers to integers, on 64 bit architectures.
Instead use long long, which should be large enough.
This avoids errors like "error: cast from pointer to smaller type
'long' loses information" in this testcase.
This condition only seems to be an error in mingw mode; in MSVC
mode (clang-cl), this is only a warning.
---
clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp b/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp
index 03aee56a200f6..b13e7123ee524 100644
--- a/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp
+++ b/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp
@@ -90,7 +90,7 @@ void reportDescriptiveName(int *p);
extern int* ptr;
extern int array[3];
void top() {
- reportDescriptiveName(&array[(long)ptr]);
+ reportDescriptiveName(&array[(long long)ptr]);
})cpp";
std::string Output;
More information about the cfe-commits
mailing list