[clang] [clang][Modules] Complete the implementation of P2615: Meaningful exports (PR #194201)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 19:05:01 PDT 2026


================
@@ -3,9 +3,135 @@
 
 
 // RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only %t/A.cpp
+// RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only %t/B.cpp
+// RUN: not %clang_cc1 -std=c++20 -fsyntax-only -fdiagnostics-parseable-fixits %t/B.cpp 2>&1 | FileCheck %t/B.cpp
+// RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only %t/msvc-stl-exception-1.cpp
----------------
zwuis wrote:

> Hmm, looking up a macro in the preprocessor's macro table on every check isn't free — it's noticeably more expensive than a single bit test.

Not on every check. Macro lookup result is cached at the first time calling `NeedsCXXStandardLibraryWorkaroundBefore`.

> Doing it unconditionally means libc++ and libstdc++ users pay that cost on every relevant code path, even though the check is only meaningful for the MSVC STL.

So we check the grammar first, then check the standard library version. AFAICT libc++ and libstdc++ users don't pay that cost.

> So we get the same behavior for the cases we care about without imposing overhead on the majority of users who aren't on MSVC.

The behaviour is slightly different. We suppress diagnostics when the value of the macro is within specific range.

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


More information about the cfe-commits mailing list