Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang-tools-extra/clangd/ModulesBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,

IntrusiveRefCntPtr<ModuleCache> ModCache = createCrossProcessModuleCache();
PCHContainerOperations PCHOperations;
CodeGenOptions CodeGenOpts;
ASTReader Reader(PP, *ModCache, /*ASTContext=*/nullptr,
PCHOperations.getRawReader(), {});
PCHOperations.getRawReader(), CodeGenOpts, {});

// We don't need any listener here. By default it will use a validator
// listener.
Expand Down
30 changes: 15 additions & 15 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,17 @@ CODEGENOPT(ObjCAvoidHeapifyLocalBlocks, 1, 0, Benign)


// The optimization options affect frontend options, which in turn do affect the AST.
VALUE_CODEGENOPT(OptimizationLevel, 2, 0, Affecting) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0, Affecting) ///< If -Os (==1, Benign) or -Oz (==2, Benign) is specified.
VALUE_CODEGENOPT(OptimizationLevel, 2, 0, Compatible) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0, Compatible) ///< If -Os (==1, Benign) or -Oz (==2, Benign) is specified.

CODEGENOPT(AtomicProfileUpdate , 1, 0, Benign) ///< Set -fprofile-update=atomic
CODEGENOPT(ContinuousProfileSync, 1, 0, Benign) ///< Enable continuous instrumentation profiling
/// Choose profile instrumenation kind or no instrumentation.

ENUM_CODEGENOPT(ProfileInstr, llvm::driver::ProfileInstrKind, 4, llvm::driver::ProfileInstrKind::ProfileNone, Benign)
ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 4, ProfileInstrKind::ProfileNone, Benign)

/// Choose profile kind for PGO use compilation.
ENUM_CODEGENOPT(ProfileUse, llvm::driver::ProfileInstrKind, 2, llvm::driver::ProfileInstrKind::ProfileNone, Benign)
ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileInstrKind::ProfileNone, Benign)
/// Partition functions into N groups and select only functions in group i to be
/// instrumented. Selected group numbers can be 0 to N-1 inclusive.
VALUE_CODEGENOPT(ProfileTotalFunctionGroups, 32, 1, Benign)
Expand All @@ -244,8 +244,8 @@ CODEGENOPT(SaveTempLabels , 1, 0, Benign) ///< Save temporary labels.
CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0, Benign) ///< Enable use-after-scope detection
///< in AddressSanitizer
ENUM_CODEGENOPT(SanitizeAddressUseAfterReturn,
llvm::AsanDetectStackUseAfterReturnMode, 2,
llvm::AsanDetectStackUseAfterReturnMode::Runtime,
AsanDetectStackUseAfterReturnMode, 2,
AsanDetectStackUseAfterReturnMode::Runtime,
Benign
) ///< Set detection mode for stack-use-after-return.
CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1, 0, Benign) ///< Enable poisoning operator new[] which is not a replaceable
Expand All @@ -255,9 +255,9 @@ CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0, Benign) ///< Enable linker
CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0, Benign) ///< Enable ODR indicator globals
CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0, Benign) ///< Enable tracking origins in
///< MemorySanitizer
ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
llvm::AsanDtorKind::Global, Benign) ///< Set how ASan global
///< destructors are emitted.
ENUM_CODEGENOPT(SanitizeAddressDtor, AsanDtorKind, 2,
AsanDtorKind::Global, Benign) ///< Set how ASan global
///< destructors are emitted.
CODEGENOPT(SanitizeMemoryParamRetval, 1, 0, Benign) ///< Enable detection of uninitialized
///< parameters and return values
///< in MemorySanitizer
Expand Down Expand Up @@ -375,13 +375,13 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0, Benign)
VALUE_CODEGENOPT(SSPBufferSize, 32, 0, Benign)

/// The kind of inlining to perform.
ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining, Benign)
ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining, Compatible)

/// The maximum stack size a function can have to be considered for inlining.
VALUE_CODEGENOPT(InlineMaxStackSize, 32, UINT_MAX, Benign)

// Vector functions library to use.
ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, llvm::driver::VectorLibrary::NoLibrary, Benign)
ENUM_CODEGENOPT(VecLib, VectorLibrary, 4, VectorLibrary::NoLibrary, Benign)

/// The default TLS model to use.
ENUM_CODEGENOPT(DefaultTLSModel, TLSModel, 2, GeneralDynamicTLSModel, Benign)
Expand Down Expand Up @@ -457,8 +457,8 @@ ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2,
CODEGENOPT(SkipRaxSetup, 1, 0, Benign)

/// Whether to zero out caller-used registers before returning.
ENUM_CODEGENOPT(ZeroCallUsedRegs, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
5, llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip, Benign)
ENUM_CODEGENOPT(ZeroCallUsedRegs, ZeroCallUsedRegsKind,
5, ZeroCallUsedRegsKind::Skip, Benign)

/// Modify C++ ABI to returning `this` pointer from constructors and
/// non-deleting destructors. (No effect on Microsoft ABI.)
Expand All @@ -477,8 +477,8 @@ CODEGENOPT(ResMayAlias, 1, 0, Benign)

/// Controls how unwind v2 (epilog) information should be generated for x64
/// Windows.
ENUM_CODEGENOPT(WinX64EHUnwindV2, llvm::WinX64EHUnwindV2Mode,
2, llvm::WinX64EHUnwindV2Mode::Disabled, Benign)
ENUM_CODEGENOPT(WinX64EHUnwindV2, WinX64EHUnwindV2Mode,
2, WinX64EHUnwindV2Mode::Disabled, Benign)

/// FIXME: Make DebugOptions its own top-level .def file.
#include "DebugOptions.def"
Expand Down
21 changes: 20 additions & 1 deletion clang/include/clang/Basic/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,32 @@ class CodeGenOptionsBase {
enum class CompatibilityKind {
/// Does affect the construction of the AST in a way that does prevent
/// module interoperability.
Affecting,
NotCompatible,
/// Does 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).
Compatible,
/// Does not 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).
Benign,
};

using CFBranchLabelSchemeKind = CFBranchLabelSchemeKind;
using ProfileInstrKind = llvm::driver::ProfileInstrKind;
using AsanDetectStackUseAfterReturnMode =
llvm::AsanDetectStackUseAfterReturnMode;
using AsanDtorKind = llvm::AsanDtorKind;
using VectorLibrary = llvm::driver::VectorLibrary;
using ZeroCallUsedRegsKind = llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind;
using WinX64EHUnwindV2Mode = llvm::WinX64EHUnwindV2Mode;

using DebugCompressionType = llvm::DebugCompressionType;
using EmitDwarfUnwindType = llvm::EmitDwarfUnwindType;
using DebugTemplateNamesKind = llvm::codegenoptions::DebugTemplateNamesKind;
using DebugInfoKind = llvm::codegenoptions::DebugInfoKind;
using DebuggerKind = llvm::DebuggerKind;

#define CODEGENOPT(Name, Bits, Default, Compatibility) unsigned Name : Bits;
#define ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)
#include "clang/Basic/CodeGenOptions.def"
Expand Down
58 changes: 29 additions & 29 deletions clang/include/clang/Basic/DebugOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ VALUE_CODEGENOPT(Name, Bits, Default, Compatibility)
ENUM_CODEGENOPT(Name, Type, Bits, Default, Compatibility)
#endif

ENUM_DEBUGOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
llvm::DebugCompressionType::None, Benign)
DEBUGOPT(Dwarf64, 1, 0, Affecting) ///< -gdwarf64.
ENUM_DEBUGOPT(CompressDebugSections, DebugCompressionType, 2,
DebugCompressionType::None, Benign)
DEBUGOPT(Dwarf64, 1, 0, Compatible) ///< -gdwarf64.
DEBUGOPT(EnableDIPreservationVerify, 1, 0, Benign) ///< Enable di preservation
///< verify each (it means
///< check the original debug
Expand All @@ -40,17 +40,17 @@ DEBUGOPT(ForceDwarfFrameSection , 1, 0, Benign) ///< Set when -fforce-dwarf-fram
///< is enabled.

///< Set when -femit-dwarf-unwind is passed.
ENUM_DEBUGOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
llvm::EmitDwarfUnwindType::Default, Benign)
ENUM_DEBUGOPT(EmitDwarfUnwind, EmitDwarfUnwindType, 2,
EmitDwarfUnwindType::Default, Benign)

DEBUGOPT(NoDwarfDirectoryAsm , 1, 0, Benign) ///< Set when -fno-dwarf-directory-asm
///< is enabled.

DEBUGOPT(NoInlineLineTables, 1, 0, Benign) ///< Whether debug info should contain
///< inline line tables.

DEBUGOPT(DebugStrictDwarf, 1, 1, Affecting) ///< Whether or not to use strict DWARF info.
DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0, Affecting) ///< Omit unreferenced member
DEBUGOPT(DebugStrictDwarf, 1, 1, Compatible) ///< Whether or not to use strict DWARF info.
DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0, Compatible) ///< Omit unreferenced member
///< functions in type debug info.

/// Control the Assignment Tracking debug info feature.
Expand All @@ -60,73 +60,73 @@ ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,
/// Whether or not to use Key Instructions to determine breakpoint locations.
DEBUGOPT(DebugKeyInstructions, 1, 0, Benign)

DEBUGOPT(DebugColumnInfo, 1, 0, Affecting) ///< Whether or not to use column information
DEBUGOPT(DebugColumnInfo, 1, 0, Compatible) ///< Whether or not to use column information
///< in debug info.

DEBUGOPT(DebugTypeExtRefs, 1, 0, Affecting) ///< Whether or not debug info should contain
DEBUGOPT(DebugTypeExtRefs, 1, 0, Compatible) ///< Whether or not debug info should contain
///< external references to a PCH or module.

DEBUGOPT(DebugExplicitImport, 1, 0, Affecting) ///< Whether or not debug info should
DEBUGOPT(DebugExplicitImport, 1, 0, Compatible) ///< Whether or not debug info should
///< contain explicit imports for
///< anonymous namespaces

/// Set debug info source file hashing algorithm.
ENUM_DEBUGOPT(DebugSrcHash, DebugSrcHashKind, 2, DSH_MD5, Affecting)
ENUM_DEBUGOPT(DebugSrcHash, DebugSrcHashKind, 2, DSH_MD5, Compatible)

DEBUGOPT(SplitDwarfInlining, 1, 1, Affecting) ///< Whether to include inlining info in the
DEBUGOPT(SplitDwarfInlining, 1, 1, Compatible) ///< Whether to include inlining info in the
///< skeleton CU to allow for symbolication
///< of inline stack frames without .dwo files.
DEBUGOPT(DebugFwdTemplateParams, 1, 0, Affecting) ///< Whether to emit complete
DEBUGOPT(DebugFwdTemplateParams, 1, 0, Compatible) ///< Whether to emit complete
///< template parameter descriptions in
///< forward declarations (versus just
///< including them in the name).
ENUM_DEBUGOPT(DebugSimpleTemplateNames,
llvm::codegenoptions::DebugTemplateNamesKind, 2,
llvm::codegenoptions::DebugTemplateNamesKind::Full, Affecting)
DebugTemplateNamesKind, 2,
DebugTemplateNamesKind::Full, Compatible)
///< Whether to emit template parameters in the textual names of
///< template specializations.
///< Implies DebugFwdTemplateNames to allow decorated names to be
///< reconstructed when needed.

/// The kind of generated debug info.
ENUM_DEBUGOPT(DebugInfo, llvm::codegenoptions::DebugInfoKind, 4,
llvm::codegenoptions::NoDebugInfo, Affecting)
ENUM_DEBUGOPT(DebugInfo, DebugInfoKind, 4,
DebugInfoKind::NoDebugInfo, Compatible)

/// Whether to generate macro debug info.
DEBUGOPT(MacroDebugInfo, 1, 0, Affecting)
DEBUGOPT(MacroDebugInfo, 1, 0, Compatible)

/// Tune the debug info for this debugger.
ENUM_DEBUGOPT(DebuggerTuning, llvm::DebuggerKind, 3,
llvm::DebuggerKind::Default, Affecting)
ENUM_DEBUGOPT(DebuggerTuning, DebuggerKind, 3,
DebuggerKind::Default, Compatible)

/// Dwarf version. Version zero indicates to LLVM that no DWARF should be
/// emitted.
VALUE_DEBUGOPT(DwarfVersion, 3, 0, Affecting)
VALUE_DEBUGOPT(DwarfVersion, 3, 0, Compatible)

/// Whether we should emit CodeView debug information. It's possible to emit
/// CodeView and DWARF into the same object.
DEBUGOPT(EmitCodeView, 1, 0, Affecting)
DEBUGOPT(EmitCodeView, 1, 0, Compatible)

/// Whether to emit the .debug$H section containing hashes of CodeView types.
DEBUGOPT(CodeViewGHash, 1, 0, Affecting)
DEBUGOPT(CodeViewGHash, 1, 0, Compatible)

/// Whether to emit the compiler path and command line into the CodeView debug information.
DEBUGOPT(CodeViewCommandLine, 1, 0, Affecting)
DEBUGOPT(CodeViewCommandLine, 1, 0, Compatible)

/// Whether emit extra debug info for sample pgo profile collection.
DEBUGOPT(DebugInfoForProfiling, 1, 0, Affecting)
DEBUGOPT(DebugInfoForProfiling, 1, 0, Compatible)

/// Whether to emit DW_TAG_template_alias for template aliases.
DEBUGOPT(DebugTemplateAlias, 1, 0, Affecting)
DEBUGOPT(DebugTemplateAlias, 1, 0, Compatible)

/// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
DEBUGOPT(DebugNameTable, 2, 0, Affecting)
DEBUGOPT(DebugNameTable, 2, 0, Compatible)

/// Whether to use DWARF base address specifiers in .debug_ranges.
DEBUGOPT(DebugRangesBaseAddress, 1, 0, Affecting)
DEBUGOPT(DebugRangesBaseAddress, 1, 0, Compatible)

/// Whether to embed source in DWARF debug line section.
DEBUGOPT(EmbedSource, 1, 0, Affecting)
DEBUGOPT(EmbedSource, 1, 0, Compatible)

#undef DEBUGOPT
#undef ENUM_DEBUGOPT
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/DiagnosticSerializationKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def err_ast_file_langopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in
"precompiled file '%3' but is currently %select{disabled|enabled}2">;
def err_ast_file_langopt_value_mismatch : Error<
"%0 differs in precompiled file '%1' vs. current file">;
def err_ast_file_codegenopt_mismatch : Error<"%0 was %select{disabled|enabled}1 in "
"precompiled file '%3' but is currently %select{disabled|enabled}2">;
def err_ast_file_codegenopt_value_mismatch
: Error<"%0 differs in precompiled file '%1' vs. current file">;
def err_ast_file_diagopt_mismatch : Error<"%0 is currently enabled, but was not in "
"the precompiled file '%1'">;
def err_ast_file_modulecache_mismatch : Error<"precompiled file '%2' was compiled with module cache "
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ LANGOPT(ModulesValidateTextualHeaderIncludes, 1, 1, Compatible, "validation of t
LANGOPT(ModulesErrorRecovery, 1, 1, Benign, "automatically importing modules as needed when performing error recovery")
LANGOPT(ImplicitModules, 1, 1, Benign, "building modules that are not specified via -fmodule-file")
LANGOPT(ModulesLocalVisibility, 1, 0, Compatible, "local submodule visibility")
LANGOPT(Optimize , 1, 0, Compatible, "__OPTIMIZE__ predefined macro")
LANGOPT(OptimizeSize , 1, 0, Compatible, "__OPTIMIZE_SIZE__ predefined macro")
LANGOPT(Static , 1, 0, Compatible, "__STATIC__ predefined macro (as opposed to __DYNAMIC__)")
VALUE_LANGOPT(PackStruct , 32, 0, NotCompatible,
"default struct packing maximum alignment")
Expand All @@ -179,7 +177,6 @@ VALUE_LANGOPT(PIE , 1, 0, Compatible, "is pie")
LANGOPT(ROPI , 1, 0, NotCompatible, "Read-only position independence")
LANGOPT(RWPI , 1, 0, NotCompatible, "Read-write position independence")
LANGOPT(GNUInline , 1, 0, Compatible, "GNU inline semantics")
LANGOPT(NoInlineDefine , 1, 0, Compatible, "__NO_INLINE__ predefined macro")
LANGOPT(Deprecated , 1, 0, Compatible, "__DEPRECATED predefined macro")
LANGOPT(FastMath , 1, 0, Compatible, "fast FP math optimizations, and __FAST_MATH__ predefined macro")
LANGOPT(UnsafeFPMath , 1, 0, Compatible, "Unsafe Floating Point Math")
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ASTContext;
class ASTDeserializationListener;
class ASTMutationListener;
class ASTReader;
class CodeGenOptions;
class CompilerInstance;
class CompilerInvocation;
class Decl;
Expand Down Expand Up @@ -107,6 +108,7 @@ class ASTUnit {

private:
std::unique_ptr<LangOptions> LangOpts;
std::unique_ptr<CodeGenOptions> CodeGenOpts;
// FIXME: The documentation on \c LoadFrom* member functions states that the
// DiagnosticsEngine (and therefore DiagnosticOptions) must outlive the
// returned ASTUnit. This is not the case. Enfore it by storing non-owning
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ class CompilerInstance : public ModuleLoader {
DisableValidationForModuleKind DisableValidation,
bool AllowPCHWithCompilerErrors, Preprocessor &PP, ModuleCache &ModCache,
ASTContext &Context, const PCHContainerReader &PCHContainerRdr,
const CodeGenOptions &CodeGenOpts,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
ArrayRef<std::shared_ptr<DependencyCollector>> DependencyCollectors,
void *DeserializationListener, bool OwnDeserializationListener,
Expand Down
5 changes: 4 additions & 1 deletion clang/include/clang/Serialization/ASTBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace serialization {
/// Version 4 of AST files also requires that the version control branch and
/// revision match exactly, since there is no backward compatibility of
/// AST files at this time.
const unsigned VERSION_MAJOR = 34;
const unsigned VERSION_MAJOR = 35;

/// AST file minor version number supported by this version of
/// Clang.
Expand Down Expand Up @@ -399,6 +399,9 @@ enum OptionsRecordTypes {

/// Record code for the preprocessor options table.
PREPROCESSOR_OPTIONS,

/// Record code for the codegen options table.
CODEGEN_OPTIONS,
};

/// Record codes for the unhashed control block.
Expand Down
Loading
Loading