[clang] [include-cleaner] Support multi-header symbols in mapping generator (PR #147720)

via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 3 13:27:58 PDT 2025


=?utf-8?q?Ildikó?= Cseri <cseriildiko at icloud.com>,
=?utf-8?q?Ildikó?= Cseri <cseriildiko at icloud.com>,
=?utf-8?q?Ildikó?= Cseri <cseriildiko at icloud.com>,
=?utf-8?q?Ildikó?= Cseri <cseriildiko at icloud.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/147720 at github.com>


================
@@ -497,354 +78,3 @@ SYMBOL(_26, std::placeholders::, <functional>)
 SYMBOL(_27, std::placeholders::, <functional>)
 SYMBOL(_28, std::placeholders::, <functional>)
 SYMBOL(_29, std::placeholders::, <functional>)
-
-// Macros
-SYMBOL(NULL, None, <cstddef>)
-SYMBOL(NULL, None, <stddef.h>)
-SYMBOL(NULL, None, <cstdlib>)
-SYMBOL(NULL, None, <stdlib.h>)
-SYMBOL(NULL, None, <cstring>)
-SYMBOL(NULL, None, <string.h>)
-SYMBOL(NULL, None, <cwchar>)
-SYMBOL(NULL, None, <wchar.h>)
-SYMBOL(NULL, None, <ctime>)
-SYMBOL(NULL, None, <time.h>)
-SYMBOL(NULL, None, <clocale>)
-SYMBOL(NULL, None, <locale.h>)
-SYMBOL(NULL, None, <cstdio>)
-SYMBOL(NULL, None, <stdio.h>)
----------------
itislu wrote:

I'd like to note a change in behavior with `NULL`: Previously, when autocompleting `NULL`, `cstddef` was included automatically by clangd, now `clocale` gets included.

While this is technically fine, as per the standard `NULL` is defined in 7 different headers, I would say most common (and most idiomatic) is `cstddef`. This might also be reflected in the [C standard](https://open-std.org/JTC1/SC22/WG14/www/docs/n3550.pdf) with footnote 57 in § 6.3.3.3:
> The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see 7.22.

I think the ordering should be changed at the source on [cppreference](https://en.cppreference.com/w/cpp/types/NULL.html), but they are on maintenance for many months now and changes cannot be suggested atm.
I just wanted to record this change of behavior, as it's probably an unwanted side effect of this PR.

https://github.com/llvm/llvm-project/pull/147720


More information about the cfe-commits mailing list