[clang] [StaticAnalyzer] Fix tryExpandAsInteger's failures on PCH macros (PR #142722)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 3 23:13:55 PDT 2025
================
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.15.0 -emit-pch -o %t %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-macosx10.15.0 -include-pch %t \
+// RUN: -analyzer-checker=core,apiModeling,unix.StdCLibraryFunctions -verify %s
+//
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_analyze_cc1 -include-pch %t \
+// RUN: -analyzer-checker=core,apiModeling,unix.StdCLibraryFunctions -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+// Pre-compiled header
+
+int foo();
+
+// Literal data for macro values will be null as they are defined in a PCH
+#define EOF -1
+#define AT_FDCWD -2
+
+#else
+// Source file
----------------
steakhal wrote:
I'd suggest using the llvm `split-file` utility instead of macro hacks. You will find a couple of examples in different tests to get inspired.
https://github.com/llvm/llvm-project/pull/142722
More information about the cfe-commits
mailing list