https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/209024

PPMemoryAllocationsTest.PPMacroDefinesAllocations measures the memory
footprint of the preprocessor allocator and asserts a strict threshold
of 130.0 bytes per define.

When built with ASan, the allocator adds redzones to allocations,
which increases the total memory reported by `getTotalMemory()` and
causes the test to fail (reporting ~136.8 bytes per define).

Adjust the threshold to 145.0 bytes per define when built with ASan
(detected via `LLVM_ADDRESS_SANITIZER_BUILD`) to account for this
overhead while maintaining the strict limit for standard builds.

Assisted-by: Gemini


>From d377eaf61d0edb04ba6647515498059a54d125bd Mon Sep 17 00:00:00 2001
From: Vitaly Buka <[email protected]>
Date: Sun, 12 Jul 2026 07:42:05 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 clang/unittests/Lex/PPMemoryAllocationsTest.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/unittests/Lex/PPMemoryAllocationsTest.cpp 
b/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
index ebdb0346b3bed..e06ec5a98495d 100644
--- a/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
+++ b/clang/unittests/Lex/PPMemoryAllocationsTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "gtest/gtest.h"
+#include "llvm/Support/Compiler.h"
 
 using namespace clang;
 
@@ -89,7 +90,11 @@ TEST_F(PPMemoryAllocationsTest, PPMacroDefinesAllocations) {
   // Assume a reasonable upper bound based on that number that we don't want
   // to exceed when storing information about a macro #define with 1 or 3
   // tokens.
+#if LLVM_ADDRESS_SANITIZER_BUILD
+  EXPECT_LT(BytesPerDefine, 145.0f);
+#else
   EXPECT_LT(BytesPerDefine, 130.0f);
+#endif
 }
 
 } // anonymous namespace

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to