Skip to content

[clang] Refactor LangOptions to specify AST effect as X macro arg #146766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jansvoboda11
Copy link
Contributor

This removes the {BENIGN,COMPATIBLE}{,_ENUM,_VALUE}_LANGOPT X macros controlling LangOptions. These are permutations of the base LANGOPT, ENUM_LANGOPT and VALUE_LANGOPT X macros that also carry the information of their effect on AST (and therefore module compatibility). Their functionality is now implemented by passing Benign, Compatible or NotCompatible argument to the base X macros and using C++17 if constexpr in the clients to achieve the same codegen.

This PR solves this FIXME:

// FIXME: Clients should be able to more easily select whether they want
// different levels of compatibility versus how to handle different kinds
// of option.

The base X macros are preserved, since they are used in LangOptions.h to generate different kinds of field and function declarations for flags, values and enums, which can't be achieved with if constexpr.

The new syntax also forces developers to think about compatibility when adding new language option, hopefully reducing the number of new options that are affecting by default even though they are benign or compatible.

Note that the BENIGN_ macros used to forward to their COMPATIBLE_ counterparts. I don't think this ever kicked in, since there are no clients of the .def file that define COMPATIBLE_ without also defining BENIGN_. However, this might be something downstream forks need to take care of by doing if constexpr (CK::Compatibility == CK::Benign || CK::Compatibility == CK::Compatible) in place of #define COMPATIBLE_.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules labels Jul 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2025

@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

This removes the {BENIGN,COMPATIBLE}{,_ENUM,_VALUE}_LANGOPT X macros controlling LangOptions. These are permutations of the base LANGOPT, ENUM_LANGOPT and VALUE_LANGOPT X macros that also carry the information of their effect on AST (and therefore module compatibility). Their functionality is now implemented by passing Benign, Compatible or NotCompatible argument to the base X macros and using C++17 if constexpr in the clients to achieve the same codegen.

This PR solves this FIXME:

// FIXME: Clients should be able to more easily select whether they want
// different levels of compatibility versus how to handle different kinds
// of option.

The base X macros are preserved, since they are used in LangOptions.h to generate different kinds of field and function declarations for flags, values and enums, which can't be achieved with if constexpr.

The new syntax also forces developers to think about compatibility when adding new language option, hopefully reducing the number of new options that are affecting by default even though they are benign or compatible.

Note that the BENIGN_ macros used to forward to their COMPATIBLE_ counterparts. I don't think this ever kicked in, since there are no clients of the .def file that define COMPATIBLE_ without also defining BENIGN_. However, this might be something downstream forks need to take care of by doing if constexpr (CK::Compatibility == CK::Benign || CK::Compatibility == CK::Compatible) in place of #define COMPATIBLE_.


Patch is 79.01 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/146766.diff

7 Files Affected:

  • (modified) clang/include/clang/Basic/LangOptions.def (+368-419)
  • (modified) clang/include/clang/Basic/LangOptions.h (+24-7)
  • (modified) clang/lib/Basic/LangOptions.cpp (+9-6)
  • (modified) clang/lib/Frontend/CompilerInvocation.cpp (+8-5)
  • (modified) clang/lib/Frontend/FrontendActions.cpp (+10-6)
  • (modified) clang/lib/Serialization/ASTReader.cpp (+46-40)
  • (modified) clang/lib/Serialization/ASTWriter.cpp (+2-2)
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index 789761c1f3647..5b20c19087c79 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -9,31 +9,16 @@
 // This file defines the language options. Users of this file must
 // define the LANGOPT macro to make use of this information. The arguments to
 // the macro are:
-//   LANGOPT(Name, Bits, DefaultValue, Description)
+//   LANGOPT(Name, Bits, DefaultValue, Compatibility, Description)
 // Note that the DefaultValue must be a constant value (literal or enumeration);
 // it cannot depend on the value of another language option.
 //
 // Optionally, the user may also define:
 //
-// BENIGN_LANGOPT: for options that don't affect the construction of the AST in
-//     any way (that is, the value can be different between an implicit module
-//     and the user of that module).
-//
-// COMPATIBLE_LANGOPT: for options that affect the construction of the AST in
-//     a way that doesn't prevent interoperability (that is, the value can be
-//     different between an explicit module and the user of that module).
-//
 // ENUM_LANGOPT: for options that have enumeration, rather than unsigned, type.
 //
 // VALUE_LANGOPT: for options that describe a value rather than a flag.
 //
-// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
-// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the above.
-//
-// FIXME: Clients should be able to more easily select whether they want
-// different levels of compatibility versus how to handle different kinds
-// of option.
-//
 // The Description field should be a noun phrase, for instance "frobbing all
 // widgets" or "C's implicit blintz feature".
 //===----------------------------------------------------------------------===//
@@ -42,504 +27,468 @@
 #  error Define the LANGOPT macro to handle language options
 #endif
 
-#ifndef COMPATIBLE_LANGOPT
-#  define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
-     LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_LANGOPT
-#  define BENIGN_LANGOPT(Name, Bits, Default, Description) \
-     COMPATIBLE_LANGOPT(Name, Bits, Default, Description)
-#endif
-
 #ifndef ENUM_LANGOPT
-#  define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
-     LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef COMPATIBLE_ENUM_LANGOPT
-#  define COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
-     ENUM_LANGOPT(Name, Type, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_ENUM_LANGOPT
-#  define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
-     COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
+#  define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
+     LANGOPT(Name, Bits, Default, Compatibility, Description)
 #endif
 
 #ifndef VALUE_LANGOPT
-#  define VALUE_LANGOPT(Name, Bits, Default, Description) \
-     LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef COMPATIBLE_VALUE_LANGOPT
-#  define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
-     VALUE_LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_VALUE_LANGOPT
-#  define BENIGN_VALUE_LANGOPT(Name, Bits, Default, Description) \
-     COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description)
+#  define VALUE_LANGOPT(Name, Bits, Default, Compatibility, Description) \
+     LANGOPT(Name, Bits, Default, Compatibility, Description)
 #endif
 
-// FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead.
-LANGOPT(C99               , 1, 0, "C99")
-LANGOPT(C11               , 1, 0, "C11")
-LANGOPT(C17               , 1, 0, "C17")
-LANGOPT(C23               , 1, 0, "C23")
-LANGOPT(C2y               , 1, 0, "C2y")
-LANGOPT(MSVCCompat        , 1, 0, "Microsoft Visual C++ full compatibility mode")
-LANGOPT(Kernel            , 1, 0, "Kernel mode")
-LANGOPT(MicrosoftExt      , 1, 0, "Microsoft C++ extensions")
-LANGOPT(ZOSExt            , 1, 0, "z/OS extensions")
-LANGOPT(AsmBlocks         , 1, 0, "Microsoft inline asm blocks")
-LANGOPT(Borland           , 1, 0, "Borland extensions")
-LANGOPT(CPlusPlus         , 1, 0, "C++")
-LANGOPT(CPlusPlus11       , 1, 0, "C++11")
-LANGOPT(CPlusPlus14       , 1, 0, "C++14")
-LANGOPT(CPlusPlus17       , 1, 0, "C++17")
-LANGOPT(CPlusPlus20       , 1, 0, "C++20")
-LANGOPT(CPlusPlus23       , 1, 0, "C++23")
-LANGOPT(CPlusPlus26       , 1, 0, "C++26")
-LANGOPT(ObjC              , 1, 0, "Objective-C")
-BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0,
-               "Objective-C auto-synthesized properties")
-BENIGN_LANGOPT(EncodeExtendedBlockSig , 1, 0,
-               "Encoding extended block type signature")
-BENIGN_LANGOPT(EncodeCXXClassTemplateSpec , 1, 0,
-               "Fully encode c++ class template specialization")
-BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1,
-               "Objective-C related result type inference")
-LANGOPT(AppExt , 1, 0, "Objective-C App Extension")
-LANGOPT(Trigraphs         , 1, 0,"trigraphs")
-LANGOPT(LineComment       , 1, 0, "'//' comments")
-LANGOPT(Bool              , 1, 0, "bool, true, and false keywords")
-LANGOPT(Half              , 1, 0, "half keyword")
-LANGOPT(WChar             , 1, 0, "wchar_t keyword")
-LANGOPT(Char8             , 1, 0, "char8_t keyword")
-LANGOPT(IEEE128           , 1, 0, "__ieee128 keyword")
-LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
-BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
-BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
-LANGOPT(GNUMode           , 1, 1, "GNU extensions")
-LANGOPT(GNUKeywords       , 1, 1, "GNU keywords")
-VALUE_LANGOPT(GNUCVersion , 32, 0, "GNU C compatibility version")
-LANGOPT(DisableKNRFunctions, 1, 0, "require function types to have a prototype")
-LANGOPT(Digraphs          , 1, 0, "digraphs")
-BENIGN_LANGOPT(HexFloats  , 1, 0, "C99 hexadecimal float constants")
-LANGOPT(CXXOperatorNames  , 1, 0, "C++ operator name keywords")
-LANGOPT(AppleKext         , 1, 0, "Apple kext support")
-BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
-LANGOPT(WritableStrings   , 1, 0, "writable string support")
-LANGOPT(ConstStrings      , 1, 0, "const-qualified string support")
+// FIXME: A lot of the Benign options should be Compatible instead.
+LANGOPT(C99               , 1, 0, NotCompatible, "C99")
+LANGOPT(C11               , 1, 0, NotCompatible, "C11")
+LANGOPT(C17               , 1, 0, NotCompatible, "C17")
+LANGOPT(C23               , 1, 0, NotCompatible, "C23")
+LANGOPT(C2y               , 1, 0, NotCompatible, "C2y")
+LANGOPT(MSVCCompat        , 1, 0, NotCompatible, "Microsoft Visual C++ full compatibility mode")
+LANGOPT(Kernel            , 1, 0, NotCompatible, "Kernel mode")
+LANGOPT(MicrosoftExt      , 1, 0, NotCompatible, "Microsoft C++ extensions")
+LANGOPT(ZOSExt            , 1, 0, NotCompatible, "z/OS extensions")
+LANGOPT(AsmBlocks         , 1, 0, NotCompatible, "Microsoft inline asm blocks")
+LANGOPT(Borland           , 1, 0, NotCompatible, "Borland extensions")
+LANGOPT(CPlusPlus         , 1, 0, NotCompatible, "C++")
+LANGOPT(CPlusPlus11       , 1, 0, NotCompatible, "C++11")
+LANGOPT(CPlusPlus14       , 1, 0, NotCompatible, "C++14")
+LANGOPT(CPlusPlus17       , 1, 0, NotCompatible, "C++17")
+LANGOPT(CPlusPlus20       , 1, 0, NotCompatible, "C++20")
+LANGOPT(CPlusPlus23       , 1, 0, NotCompatible, "C++23")
+LANGOPT(CPlusPlus26       , 1, 0, NotCompatible, "C++26")
+LANGOPT(ObjC              , 1, 0, NotCompatible, "Objective-C")
+LANGOPT(ObjCDefaultSynthProperties , 1, 0, Benign,
+        "Objective-C auto-synthesized properties")
+LANGOPT(EncodeExtendedBlockSig , 1, 0, Benign,
+        "Encoding extended block type signature")
+LANGOPT(EncodeCXXClassTemplateSpec , 1, 0, Benign,
+        "Fully encode c++ class template specialization")
+LANGOPT(ObjCInferRelatedResultType , 1, 1, Benign,
+        "Objective-C related result type inference")
+LANGOPT(AppExt            , 1, 0, NotCompatible, "Objective-C App Extension")
+LANGOPT(Trigraphs         , 1, 0, NotCompatible, "trigraphs")
+LANGOPT(LineComment       , 1, 0, NotCompatible, "'//' comments")
+LANGOPT(Bool              , 1, 0, NotCompatible, "bool, true, and false keywords")
+LANGOPT(Half              , 1, 0, NotCompatible, "half keyword")
+LANGOPT(WChar             , 1, 0, NotCompatible, "wchar_t keyword")
+LANGOPT(Char8             , 1, 0, NotCompatible, "char8_t keyword")
+LANGOPT(IEEE128           , 1, 0, NotCompatible, "__ieee128 keyword")
+LANGOPT(DeclSpecKeyword   , 1, 0, NotCompatible, "__declspec keyword")
+LANGOPT(DollarIdents      , 1, 1, Benign, "'$' in identifiers")
+LANGOPT(AsmPreprocessor   , 1, 0, Benign, "preprocessor in asm mode")
+LANGOPT(GNUMode           , 1, 1, NotCompatible, "GNU extensions")
+LANGOPT(GNUKeywords       , 1, 1, NotCompatible, "GNU keywords")
+VALUE_LANGOPT(GNUCVersion , 32, 0, NotCompatible, "GNU C compatibility version")
+LANGOPT(DisableKNRFunctions, 1, 0, NotCompatible, "require function types to have a prototype")
+LANGOPT(Digraphs          , 1, 0, NotCompatible, "digraphs")
+LANGOPT(HexFloats         , 1, 0, Benign, "C99 hexadecimal float constants")
+LANGOPT(CXXOperatorNames  , 1, 0, NotCompatible, "C++ operator name keywords")
+LANGOPT(AppleKext         , 1, 0, NotCompatible, "Apple kext support")
+LANGOPT(PascalStrings     , 1, 0, Benign, "Pascal string support")
+LANGOPT(WritableStrings   , 1, 0, NotCompatible, "writable string support")
+LANGOPT(ConstStrings      , 1, 0, NotCompatible, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
-             LaxVectorConversionKind::All, "lax vector conversions")
+             LaxVectorConversionKind::All, NotCompatible, "lax vector conversions")
 ENUM_LANGOPT(AltivecSrcCompat, AltivecSrcCompatKind, 2,
-             AltivecSrcCompatKind::Default, "Altivec source compatibility")
-LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
-LANGOPT(AltiVec           , 1, 0, "AltiVec-style vector initializers")
-LANGOPT(ZVector           , 1, 0, "System z vector extensions")
-LANGOPT(Exceptions        , 1, 0, "exception handling")
-LANGOPT(ObjCExceptions    , 1, 0, "Objective-C exceptions")
-LANGOPT(CXXExceptions     , 1, 0, "C++ exceptions")
-LANGOPT(EHAsynch          , 1, 0, "C/C++ EH Asynch exceptions")
+             AltivecSrcCompatKind::Default, NotCompatible, "Altivec source compatibility")
+LANGOPT(ConvergentFunctions, 1, 1, NotCompatible, "Assume convergent functions")
+LANGOPT(AltiVec           , 1, 0, NotCompatible, "AltiVec-style vector initializers")
+LANGOPT(ZVector           , 1, 0, NotCompatible, "System z vector extensions")
+LANGOPT(Exceptions        , 1, 0, NotCompatible, "exception handling")
+LANGOPT(ObjCExceptions    , 1, 0, NotCompatible, "Objective-C exceptions")
+LANGOPT(CXXExceptions     , 1, 0, NotCompatible, "C++ exceptions")
+LANGOPT(EHAsynch          , 1, 0, NotCompatible, "C/C++ EH Asynch exceptions")
 ENUM_LANGOPT(ExceptionHandling, ExceptionHandlingKind, 3,
-             ExceptionHandlingKind::None, "exception handling")
-LANGOPT(IgnoreExceptions  , 1, 0, "ignore exceptions")
-LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
-LANGOPT(AssumeNothrowExceptionDtor , 1, 0, "Assume exception object's destructor is nothrow")
-LANGOPT(TraditionalCPP    , 1, 0, "traditional CPP emulation")
-LANGOPT(RTTI              , 1, 1, "run-time type information")
-LANGOPT(RTTIData          , 1, 1, "emit run-time type information data")
-LANGOPT(MSBitfields       , 1, 0, "Microsoft-compatible structure layout")
-LANGOPT(MSVolatile        , 1, 0, "Microsoft-compatible volatile loads and stores")
-LANGOPT(Freestanding, 1, 0, "freestanding implementation")
-LANGOPT(NoBuiltin         , 1, 0, "disable builtin functions")
-LANGOPT(NoMathBuiltin     , 1, 0, "disable math builtin functions")
-LANGOPT(GNUAsm            , 1, 1, "GNU-style inline assembly")
-LANGOPT(Coroutines        , 1, 0, "C++20 coroutines")
-LANGOPT(CoroAlignedAllocation, 1, 0, "prefer Aligned Allocation according to P2014 Option 2")
-LANGOPT(DllExportInlines  , 1, 1, "dllexported classes dllexport inline methods")
-LANGOPT(ExperimentalLibrary, 1, 0, "enable unstable and experimental library features")
-
-LANGOPT(PointerAuthIntrinsics, 1, 0, "pointer authentication intrinsics")
-LANGOPT(PointerAuthCalls  , 1, 0, "function pointer authentication")
-LANGOPT(PointerAuthReturns, 1, 0, "return pointer authentication")
-LANGOPT(PointerAuthIndirectGotos, 1, 0, "indirect gotos pointer authentication")
-LANGOPT(PointerAuthAuthTraps, 1, 0, "pointer authentication failure traps")
-LANGOPT(PointerAuthVTPtrAddressDiscrimination, 1, 0, "incorporate address discrimination in authenticated vtable pointers")
-LANGOPT(PointerAuthVTPtrTypeDiscrimination, 1, 0, "incorporate type discrimination in authenticated vtable pointers")
-LANGOPT(PointerAuthTypeInfoVTPtrDiscrimination, 1, 0, "incorporate type and address discrimination in authenticated vtable pointers for std::type_info")
-BENIGN_LANGOPT(PointerAuthFunctionTypeDiscrimination, 1, 0,
-               "Use type discrimination when signing function pointers")
-LANGOPT(PointerAuthInitFini, 1, 0, "sign function pointers in init/fini arrays")
-LANGOPT(PointerAuthInitFiniAddressDiscrimination, 1, 0,
+             ExceptionHandlingKind::None,  NotCompatible, "exception handling")
+LANGOPT(IgnoreExceptions  , 1, 0, NotCompatible, "ignore exceptions")
+LANGOPT(ExternCNoUnwind   , 1, 0, NotCompatible, "Assume extern C functions don't unwind")
+LANGOPT(AssumeNothrowExceptionDtor , 1, 0, NotCompatible, "Assume exception object's destructor is nothrow")
+LANGOPT(TraditionalCPP    , 1, 0, NotCompatible, "traditional CPP emulation")
+LANGOPT(RTTI              , 1, 1, NotCompatible, "run-time type information")
+LANGOPT(RTTIData          , 1, 1, NotCompatible, "emit run-time type information data")
+LANGOPT(MSBitfields       , 1, 0, NotCompatible, "Microsoft-compatible structure layout")
+LANGOPT(MSVolatile        , 1, 0, NotCompatible, "Microsoft-compatible volatile loads and stores")
+LANGOPT(Freestanding      , 1, 0, NotCompatible, "freestanding implementation")
+LANGOPT(NoBuiltin         , 1, 0, NotCompatible, "disable builtin functions")
+LANGOPT(NoMathBuiltin     , 1, 0, NotCompatible, "disable math builtin functions")
+LANGOPT(GNUAsm            , 1, 1, NotCompatible, "GNU-style inline assembly")
+LANGOPT(Coroutines        , 1, 0, NotCompatible, "C++20 coroutines")
+LANGOPT(CoroAlignedAllocation, 1, 0, NotCompatible, "prefer Aligned Allocation according to P2014 Option 2")
+LANGOPT(DllExportInlines  , 1, 1, NotCompatible, "dllexported classes dllexport inline methods")
+LANGOPT(ExperimentalLibrary, 1, 0, NotCompatible, "enable unstable and experimental library features")
+
+LANGOPT(PointerAuthIntrinsics, 1, 0, NotCompatible, "pointer authentication intrinsics")
+LANGOPT(PointerAuthCalls  , 1, 0, NotCompatible, "function pointer authentication")
+LANGOPT(PointerAuthReturns, 1, 0, NotCompatible, "return pointer authentication")
+LANGOPT(PointerAuthIndirectGotos, 1, 0, NotCompatible, "indirect gotos pointer authentication")
+LANGOPT(PointerAuthAuthTraps, 1, 0, NotCompatible, "pointer authentication failure traps")
+LANGOPT(PointerAuthVTPtrAddressDiscrimination, 1, 0, NotCompatible, "incorporate address discrimination in authenticated vtable pointers")
+LANGOPT(PointerAuthVTPtrTypeDiscrimination, 1, 0, NotCompatible, "incorporate type discrimination in authenticated vtable pointers")
+LANGOPT(PointerAuthTypeInfoVTPtrDiscrimination, 1, 0, NotCompatible, "incorporate type and address discrimination in authenticated vtable pointers for std::type_info")
+LANGOPT(PointerAuthFunctionTypeDiscrimination, 1, 0, Benign,
+        "Use type discrimination when signing function pointers")
+LANGOPT(PointerAuthInitFini, 1, 0, NotCompatible, "sign function pointers in init/fini arrays")
+LANGOPT(PointerAuthInitFiniAddressDiscrimination, 1, 0, NotCompatible,
         "incorporate address discrimination in authenticated function pointers in init/fini arrays")
-LANGOPT(PointerAuthELFGOT, 1, 0, "authenticate pointers from GOT")
-LANGOPT(AArch64JumpTableHardening, 1, 0, "use hardened lowering for jump-table dispatch")
-
-LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for all language standard modes")
-LANGOPT(ExperimentalLateParseAttributes, 1, 0, "experimental late parsing of attributes")
-
-COMPATIBLE_LANGOPT(RecoveryAST, 1, 1, "Preserve expressions in AST when encountering errors")
-COMPATIBLE_LANGOPT(RecoveryASTType, 1, 1, "Preserve the type in recovery expressions")
-
-BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
-LANGOPT(POSIXThreads      , 1, 0, "POSIX thread support")
-LANGOPT(Blocks            , 1, 0, "blocks extension to C")
-BENIGN_LANGOPT(EmitAllDecls      , 1, 0, "emitting all declarations")
-LANGOPT(MathErrno         , 1, 1, "errno in math functions")
-LANGOPT(Modules           , 1, 0, "modules semantics")
-COMPATIBLE_LANGOPT(CPlusPlusModules, 1, 0, "C++ modules syntax")
-LANGOPT(SkipODRCheckInGMF, 1, 0, "Skip ODR checks for decls in the global module fragment")
-LANGOPT(BuiltinHeadersInSystemModules, 1, 0, "builtin headers belong to system modules, and _Builtin_ modules are ignored for cstdlib headers")
-BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 3, CMK_None,
-                    "compiling a module interface")
-BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
-BENIGN_LANGOPT(BuildingPCHWithObjectFile, 1, 0, "building a pch which has a corresponding object file")
-BENIGN_LANGOPT(CacheGeneratedPCH, 1, 0, "cache generated PCH files in memory")
-BENIGN_LANGOPT(PCHInstantiateTemplates, 1, 0, "instantiate templates while building a PCH")
-COMPATIBLE_LANGOPT(ModulesDeclUse    , 1, 0, "require declaration of module uses")
-BENIGN_LANGOPT(ModulesSearchAll  , 1, 1, "searching even non-imported modules to find unresolved references")
-COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of module uses and all headers to be in modules")
-COMPATIBLE_LANGOPT(ModulesValidateTextualHeaderIncludes, 1, 1, "validation of textual header includes")
-BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically importing modules as needed when performing error recovery")
-BENIGN_LANGOPT(ImplicitModules, 1, 1, "building modules that are not specified via -fmodule-file")
-COMPATIBLE_LANGOPT(ModulesLocalVisibility, 1, 0, "local submodule visibility")
-COMPATIBLE_LANGOPT(Optimize          , 1, 0, "__OPTIMIZE__ predefined macro")
-COMPATIBLE_LANGOPT(OptimizeSize      , 1, 0, "__OPTIMIZE_SIZE__ predefined macro")
-COMPATIBLE_LANGOPT(Static            , 1, 0, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)")
-VALUE_LANGOPT(PackStruct  , 32, 0,
+LANGOPT(PointerAuthELFGOT, 1, 0, NotCompatible, "authenticate pointers from GOT")
+LANGOPT(AArch64JumpTableHardening, 1, 0, NotCompatible, "use hardened lowering for jump-table dispatch")
+
+LANGOPT(DoubleSquareBracketAttributes, 1, 0, NotCompatible, "'[[]]' attributes extension for all language standard modes")
+LANGOPT(ExperimentalLateParseAttributes, 1, 0, NotCompatible, "experimental late parsing of attributes")
+
+LANGOPT(RecoveryAST, 1, 1, Compatible, "Preserve expressions in AST when encountering errors")
+LANGOPT(RecoveryASTType, 1, 1, Compatible, "Preserve the type in recovery expressions")
+
+LANGOPT(ThreadsafeStatics , 1, 1, Benign, "thread-safe static initializers")
+LANGOPT(POSIXThreads      , 1, 0, NotCompatible, "POSIX thread support")
+LANGOPT(Blocks            , 1, 0, NotCompatible, "blocks extension to C")
+LANGOPT(EmitAllDecls      , 1, 0, Benign, "emitting all declarations")
+LANGOPT(MathErrno         , 1, 1, NotCompatible, "errno in math functions")
+LANGOPT(Modules           , 1, 0, NotCompatible, "modules semantics")
+LANGOPT(CPlusPlusModules  , 1, 0, Compatible, "C++ modules syntax")
+LANGOPT(SkipODRCheckInGMF , 1, 0, NotCompatible, "Skip ODR checks for decls in the global module fragment")
+LANGOPT(BuiltinHeadersInSystemModules, 1, 0, NotCompatible, "builtin headers belong to system modules, and _Builtin_ modules are ignored for cstdlib headers")
+ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 3, CMK_None, Benign,
+             "compiling a module interface")
+LANGOPT(CompilingPCH, 1, 0, Benign, "building a pch")
+LANGOPT(BuildingPCHWithObje...
[truncated]

Copy link

github-actions bot commented Jul 2, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/Basic/LangOptions.h clang/lib/Basic/LangOptions.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/FrontendActions.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp
View the diff from clang-format here.
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 89eb0b689..960c9fd7f 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -647,14 +647,14 @@ namespace {
       using CK = LangOptions::CompatibilityKind;
 
       Out.indent(2) << "Language options:\n";
-#define LANGOPT(Name, Bits, Default, Compatibility, Description)               \
+#define LANGOPT(Name, Bits, Default, Compatibility, Description)             \
     if constexpr (CK::Compatibility != CK::Benign)                             \
       DUMP_BOOLEAN(LangOpts.Name, Description);
-#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description)    \
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description)  \
     if constexpr (CK::Compatibility != CK::Benign)                             \
       Out.indent(4) << Description << ": "                                     \
                     << static_cast<unsigned>(LangOpts.get##Name()) << "\n";
-#define VALUE_LANGOPT(Name, Bits, Default, Compatibility, Description)         \
+#define VALUE_LANGOPT(Name, Bits, Default, Compatibility, Description)       \
     if constexpr (CK::Compatibility != CK::Benign)                             \
       Out.indent(4) << Description << ": " << LangOpts.Name << "\n";
 #include "clang/Basic/LangOptions.def"

Copy link
Contributor

@Bigcheese Bigcheese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants