This patch moves the Debug Options to llvm/Frontend so that it can be shared by Flang as well.
Reviewed By: kiranchandramohan, awarzynski
Differential Revision: https://reviews.llvm.org/D142347
///< template parameter descriptions in
///< forward declarations (versus just
///< including them in the name).
-ENUM_CODEGENOPT(DebugSimpleTemplateNames, codegenoptions::DebugTemplateNamesKind, 2, codegenoptions::DebugTemplateNamesKind::Full) ///< Whether to emit template parameters
+ENUM_CODEGENOPT(DebugSimpleTemplateNames, llvm::codegenoptions::DebugTemplateNamesKind, 2, llvm::codegenoptions::DebugTemplateNamesKind::Full) ///< Whether to emit template parameters
///< in the textual names of template
///< specializations.
///< Implies DebugFwdTemplateNames to
VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
/// The kind of generated debug info.
-ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, codegenoptions::NoDebugInfo)
+ENUM_CODEGENOPT(DebugInfo, llvm::codegenoptions::DebugInfoKind, 4, llvm::codegenoptions::NoDebugInfo)
/// Whether to generate macro debug info.
CODEGENOPT(MacroDebugInfo, 1, 0)
#ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H
#define LLVM_CLANG_BASIC_CODEGENOPTIONS_H
-#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/XRayInstr.h"
#include "llvm/ADT/FloatingPointMode.h"
+#include "llvm/Frontend/Debug/Options.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Regex.h"
#include "llvm/Target/TargetOptions.h"
/// Check if type and variable info should be emitted.
bool hasReducedDebugInfo() const {
- return getDebugInfo() >= codegenoptions::DebugInfoConstructor;
+ return getDebugInfo() >= llvm::codegenoptions::DebugInfoConstructor;
}
/// Check if maybe unused type info should be emitted.
bool hasMaybeUnusedDebugInfo() const {
- return getDebugInfo() >= codegenoptions::UnusedTypeInfo;
+ return getDebugInfo() >= llvm::codegenoptions::UnusedTypeInfo;
}
// Check if any one of SanitizeCoverage* is enabled.
#ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
#define LLVM_CLANG_DRIVER_TOOLCHAIN_H
-#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Sanitizers.h"
#include "llvm/ADT/FloatingPointMode.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Frontend/Debug/Options.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/VersionTuple.h"
virtual void CheckObjCARC() const {}
/// Get the default debug info format. Typically, this is DWARF.
- virtual codegenoptions::DebugInfoFormat getDefaultDebugFormat() const {
- return codegenoptions::DIF_DWARF;
+ virtual llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const {
+ return llvm::codegenoptions::DIF_DWARF;
}
/// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
}
/// Adjust debug information kind considering all passed options.
- virtual void adjustDebugInfoKind(codegenoptions::DebugInfoKind &DebugInfoKind,
- const llvm::opt::ArgList &Args) const {}
+ virtual void
+ adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
+ const llvm::opt::ArgList &Args) const {}
/// GetExceptionModel - Return the tool chain exception model.
virtual llvm::ExceptionHandling
llvm::DICompileUnit::DebugEmissionKind EmissionKind;
switch (DebugKind) {
- case codegenoptions::NoDebugInfo:
- case codegenoptions::LocTrackingOnly:
+ case llvm::codegenoptions::NoDebugInfo:
+ case llvm::codegenoptions::LocTrackingOnly:
EmissionKind = llvm::DICompileUnit::NoDebug;
break;
- case codegenoptions::DebugLineTablesOnly:
+ case llvm::codegenoptions::DebugLineTablesOnly:
EmissionKind = llvm::DICompileUnit::LineTablesOnly;
break;
- case codegenoptions::DebugDirectivesOnly:
+ case llvm::codegenoptions::DebugDirectivesOnly:
EmissionKind = llvm::DICompileUnit::DebugDirectivesOnly;
break;
- case codegenoptions::DebugInfoConstructor:
- case codegenoptions::LimitedDebugInfo:
- case codegenoptions::FullDebugInfo:
- case codegenoptions::UnusedTypeInfo:
+ case llvm::codegenoptions::DebugInfoConstructor:
+ case llvm::codegenoptions::LimitedDebugInfo:
+ case llvm::codegenoptions::FullDebugInfo:
+ case llvm::codegenoptions::UnusedTypeInfo:
EmissionKind = llvm::DICompileUnit::FullDebug;
break;
}
// In this debug mode, emit type info for a class when its constructor type
// info is emitted.
- if (DebugKind == codegenoptions::DebugInfoConstructor)
+ if (DebugKind == llvm::codegenoptions::DebugInfoConstructor)
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
completeUnusedClass(*CD->getParent());
QualType AllocatedTy,
SourceLocation Loc) {
if (CGM.getCodeGenOpts().getDebugInfo() <=
- codegenoptions::DebugLineTablesOnly)
+ llvm::codegenoptions::DebugLineTablesOnly)
return;
llvm::MDNode *node;
if (AllocatedTy->isVoidType())
}
void CGDebugInfo::completeType(const EnumDecl *ED) {
- if (DebugKind <= codegenoptions::DebugLineTablesOnly)
+ if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return;
QualType Ty = CGM.getContext().getEnumType(ED);
void *TyPtr = Ty.getAsOpaquePtr();
}
void CGDebugInfo::completeType(const RecordDecl *RD) {
- if (DebugKind > codegenoptions::LimitedDebugInfo ||
+ if (DebugKind > llvm::codegenoptions::LimitedDebugInfo ||
!CGM.getLangOpts().CPlusPlus)
completeRequiredType(RD);
}
}
void CGDebugInfo::completeClass(const RecordDecl *RD) {
- if (DebugKind <= codegenoptions::DebugLineTablesOnly)
+ if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return;
QualType Ty = CGM.getContext().getRecordType(RD);
void *TyPtr = Ty.getAsOpaquePtr();
return false;
}
-static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
+static bool shouldOmitDefinition(llvm::codegenoptions::DebugInfoKind DebugKind,
bool DebugTypeExtRefs, const RecordDecl *RD,
const LangOptions &LangOpts) {
if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
// Only emit forward declarations in line tables only to keep debug info size
// small. This only applies to CodeView, since we don't emit types in DWARF
// line tables only.
- if (DebugKind == codegenoptions::DebugLineTablesOnly)
+ if (DebugKind == llvm::codegenoptions::DebugLineTablesOnly)
return true;
- if (DebugKind > codegenoptions::LimitedDebugInfo ||
+ if (DebugKind > llvm::codegenoptions::LimitedDebugInfo ||
RD->hasAttr<StandaloneDebugAttr>())
return false;
// In constructor homing mode, only emit complete debug info for a class
// when its constructor is emitted.
- if ((DebugKind == codegenoptions::DebugInfoConstructor) &&
+ if ((DebugKind == llvm::codegenoptions::DebugInfoConstructor) &&
canUseCtorHoming(CXXDecl))
return true;
}
void CGDebugInfo::completeUnusedClass(const CXXRecordDecl &D) {
- if (DebugKind <= codegenoptions::DebugLineTablesOnly || D.isDynamicClass())
+ if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly ||
+ D.isDynamicClass())
return;
completeClassData(&D);
// No need to replicate the linkage name if it isn't different from the
// subprogram name, no need to have it at all unless coverage is enabled or
// debug is set to more than just line tables or extra debug info is needed.
- if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
- !CGM.getCodeGenOpts().EmitGcovNotes &&
- !CGM.getCodeGenOpts().DebugInfoForProfiling &&
- !CGM.getCodeGenOpts().PseudoProbeForProfiling &&
- DebugKind <= codegenoptions::DebugLineTablesOnly))
+ if (LinkageName == Name ||
+ (!CGM.getCodeGenOpts().EmitGcovArcs &&
+ !CGM.getCodeGenOpts().EmitGcovNotes &&
+ !CGM.getCodeGenOpts().DebugInfoForProfiling &&
+ !CGM.getCodeGenOpts().PseudoProbeForProfiling &&
+ DebugKind <= llvm::codegenoptions::DebugLineTablesOnly))
LinkageName = StringRef();
// Emit the function scope in line tables only mode (if CodeView) to
// differentiate between function names.
if (CGM.getCodeGenOpts().hasReducedDebugInfo() ||
- (DebugKind == codegenoptions::DebugLineTablesOnly &&
+ (DebugKind == llvm::codegenoptions::DebugLineTablesOnly &&
CGM.getCodeGenOpts().EmitCodeView)) {
if (const NamespaceDecl *NSDecl =
dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext()))
}
llvm::DISubprogram *CGDebugInfo::getFunctionDeclaration(const Decl *D) {
- if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+ if (!D || DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return nullptr;
const auto *FD = dyn_cast<FunctionDecl>(D);
llvm::DISubprogram *CGDebugInfo::getObjCMethodDeclaration(
const Decl *D, llvm::DISubroutineType *FnType, unsigned LineNo,
llvm::DINode::DIFlags Flags, llvm::DISubprogram::DISPFlags SPFlags) {
- if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+ if (!D || DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return nullptr;
const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
llvm::DIFile *F) {
// In CodeView, we emit the function types in line tables only because the
// only way to distinguish between functions is by display name and type.
- if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
+ if (!D || (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly &&
!CGM.getCodeGenOpts().EmitCodeView))
// Create fake but valid subroutine type. Otherwise -verify would fail, and
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
CGM.getLLVMContext(), getLineNumber(Loc), getColumnNumber(Loc),
LexicalBlockStack.back(), CurInlinedAt));
- if (DebugKind <= codegenoptions::DebugLineTablesOnly)
+ if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return;
// Create a new lexical block and push it on the stack.
// Provide an entry in the line table for the end of the block.
EmitLocation(Builder, Loc);
- if (DebugKind <= codegenoptions::DebugLineTablesOnly)
+ if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly)
return;
LexicalBlockStack.pop_back();
const NamedDecl *ND = dyn_cast<NamedDecl>(D);
if (!ND)
return Name;
- codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
+ llvm::codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
CGM.getCodeGenOpts().getDebugSimpleTemplateNames();
if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
- TemplateNamesKind = codegenoptions::DebugTemplateNamesKind::Full;
+ TemplateNamesKind = llvm::codegenoptions::DebugTemplateNamesKind::Full;
std::optional<TemplateArgs> Args;
PrintingPolicy PP = getPrintingPolicy();
- if (TemplateNamesKind == codegenoptions::DebugTemplateNamesKind::Full ||
+ if (TemplateNamesKind == llvm::codegenoptions::DebugTemplateNamesKind::Full ||
!Reconstitutable) {
ND->getNameForDiagnostic(OS, PP, Qualified);
} else {
- bool Mangled =
- TemplateNamesKind == codegenoptions::DebugTemplateNamesKind::Mangled;
+ bool Mangled = TemplateNamesKind ==
+ llvm::codegenoptions::DebugTemplateNamesKind::Mangled;
// check if it's a template
if (Mangled)
OS << "_STN|";
llvm::DINode::DIFlags CGDebugInfo::getCallSiteRelatedAttrs() const {
// Call site-related attributes are only useful in optimized programs, and
// when there's a possibility of debugging backtraces.
- if (!CGM.getLangOpts().Optimize || DebugKind == codegenoptions::NoDebugInfo ||
- DebugKind == codegenoptions::LocTrackingOnly)
+ if (!CGM.getLangOpts().Optimize ||
+ DebugKind == llvm::codegenoptions::NoDebugInfo ||
+ DebugKind == llvm::codegenoptions::LocTrackingOnly)
return llvm::DINode::FlagZero;
// Call site-related attributes are available in DWARF v5. Some debuggers,
friend class ApplyDebugLocation;
friend class SaveAndRestoreLocation;
CodeGenModule &CGM;
- const codegenoptions::DebugInfoKind DebugKind;
+ const llvm::codegenoptions::DebugInfoKind DebugKind;
bool DebugTypeExtRefs;
llvm::DIBuilder DBuilder;
llvm::DICompileUnit *TheCU = nullptr;
unsigned Flags, bool EmitLoc) {
uint32_t SrcLocStrSize;
llvm::Constant *SrcLocStr;
- if ((!EmitLoc &&
- CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo) ||
+ if ((!EmitLoc && CGM.getCodeGenOpts().getDebugInfo() ==
+ llvm::codegenoptions::NoDebugInfo) ||
Loc.isInvalid()) {
SrcLocStr = OMPBuilder.getOrCreateDefaultSrcLocStr(SrcLocStrSize);
} else {
// The information types are only built if there is debug information
// requested.
- if (CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo) {
+ if (CGM.getCodeGenOpts().getDebugInfo() ==
+ llvm::codegenoptions::NoDebugInfo) {
Info.RTArgs.MapNamesArray = llvm::Constant::getNullValue(
llvm::Type::getInt8Ty(CGF.Builder.getContext())->getPointerTo());
} else {
Info.Pointers[I], CGM.getTypes().ConvertTypeForMem(C.VoidPtrTy));
llvm::Value *CurSizeArg = Info.Sizes[I];
llvm::Value *CurNameArg =
- (CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo)
+ (CGM.getCodeGenOpts().getDebugInfo() ==
+ llvm::codegenoptions::NoDebugInfo)
? llvm::ConstantPointerNull::get(CGM.VoidPtrTy)
: emitMappingInformation(MapperCGF, OMPBuilder, Info.Exprs[I]);
CGOpenMPRuntime::TargetDataInfo Info;
// Fill up the arrays and create the arguments.
emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder);
- bool EmitDebug =
- CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
+ bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
+ llvm::codegenoptions::NoDebugInfo;
OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, Info.RTArgs, Info,
EmitDebug,
/*ForEndCall=*/false);
/*IsNonContiguous=*/true);
llvm::OpenMPIRBuilder::TargetDataRTArgs RTArgs;
- bool EmitDebug =
- CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
+ bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
+ llvm::codegenoptions::NoDebugInfo;
OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, RTArgs, Info,
EmitDebug);
assert(Info.isValid() && "Invalid data environment closing arguments.");
llvm::OpenMPIRBuilder::TargetDataRTArgs RTArgs;
- bool EmitDebug =
- CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
+ bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
+ llvm::codegenoptions::NoDebugInfo;
OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, RTArgs, Info,
EmitDebug,
/*ForEndCall=*/true);
/*IsNonContiguous=*/true);
bool RequiresOuterTask = D.hasClausesOfKind<OMPDependClause>() ||
D.hasClausesOfKind<OMPNowaitClause>();
- bool EmitDebug =
- CGF.CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo;
+ bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
+ llvm::codegenoptions::NoDebugInfo;
OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, Info.RTArgs, Info,
EmitDebug,
/*ForEndCall=*/false);
switch (keyFunction->getTemplateSpecializationKind()) {
case TSK_Undeclared:
case TSK_ExplicitSpecialization:
- assert((def || CodeGenOpts.OptimizationLevel > 0 ||
- CodeGenOpts.getDebugInfo() != codegenoptions::NoDebugInfo) &&
- "Shouldn't query vtable linkage without key function, "
- "optimizations, or debug info");
- if (!def && CodeGenOpts.OptimizationLevel > 0)
- return llvm::GlobalVariable::AvailableExternallyLinkage;
-
- if (keyFunction->isInlined())
- return !Context.getLangOpts().AppleKext ?
- llvm::GlobalVariable::LinkOnceODRLinkage :
- llvm::Function::InternalLinkage;
-
- return llvm::GlobalVariable::ExternalLinkage;
+ assert(
+ (def || CodeGenOpts.OptimizationLevel > 0 ||
+ CodeGenOpts.getDebugInfo() != llvm::codegenoptions::NoDebugInfo) &&
+ "Shouldn't query vtable linkage without key function, "
+ "optimizations, or debug info");
+ if (!def && CodeGenOpts.OptimizationLevel > 0)
+ return llvm::GlobalVariable::AvailableExternallyLinkage;
+
+ if (keyFunction->isInlined())
+ return !Context.getLangOpts().AppleKext
+ ? llvm::GlobalVariable::LinkOnceODRLinkage
+ : llvm::Function::InternalLinkage;
+
+ return llvm::GlobalVariable::ExternalLinkage;
case TSK_ImplicitInstantiation:
return !Context.getLangOpts().AppleKext ?
// If debug info or coverage generation is enabled, create the CGDebugInfo
// object.
- if (CodeGenOpts.getDebugInfo() != codegenoptions::NoDebugInfo ||
+ if (CodeGenOpts.getDebugInfo() != llvm::codegenoptions::NoDebugInfo ||
CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes)
DebugInfo.reset(new CGDebugInfo(*this));
// When building a module MainFileName is the name of the modulemap file.
CodeGenOpts.MainFileName =
LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
- CodeGenOpts.setDebugInfo(codegenoptions::FullDebugInfo);
+ CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
CodeGenOpts.DebugPrefixMap =
CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
// Convert an arg of the form "-gN" or "-ggdbN" or one of their aliases
// to the corresponding DebugInfoKind.
-static codegenoptions::DebugInfoKind DebugLevelToInfoKind(const Arg &A) {
+static llvm::codegenoptions::DebugInfoKind DebugLevelToInfoKind(const Arg &A) {
assert(A.getOption().matches(options::OPT_gN_Group) &&
"Not a -g option that specifies a debug-info level");
if (A.getOption().matches(options::OPT_g0) ||
A.getOption().matches(options::OPT_ggdb0))
- return codegenoptions::NoDebugInfo;
+ return llvm::codegenoptions::NoDebugInfo;
if (A.getOption().matches(options::OPT_gline_tables_only) ||
A.getOption().matches(options::OPT_ggdb1))
- return codegenoptions::DebugLineTablesOnly;
+ return llvm::codegenoptions::DebugLineTablesOnly;
if (A.getOption().matches(options::OPT_gline_directives_only))
- return codegenoptions::DebugDirectivesOnly;
- return codegenoptions::DebugInfoConstructor;
+ return llvm::codegenoptions::DebugDirectivesOnly;
+ return llvm::codegenoptions::DebugInfoConstructor;
}
static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) {
RelaxDefault);
}
-static void RenderDebugEnablingArgs(const ArgList &Args, ArgStringList &CmdArgs,
- codegenoptions::DebugInfoKind DebugInfoKind,
- unsigned DwarfVersion,
- llvm::DebuggerKind DebuggerTuning) {
+static void
+RenderDebugEnablingArgs(const ArgList &Args, ArgStringList &CmdArgs,
+ llvm::codegenoptions::DebugInfoKind DebugInfoKind,
+ unsigned DwarfVersion,
+ llvm::DebuggerKind DebuggerTuning) {
switch (DebugInfoKind) {
- case codegenoptions::DebugDirectivesOnly:
+ case llvm::codegenoptions::DebugDirectivesOnly:
CmdArgs.push_back("-debug-info-kind=line-directives-only");
break;
- case codegenoptions::DebugLineTablesOnly:
+ case llvm::codegenoptions::DebugLineTablesOnly:
CmdArgs.push_back("-debug-info-kind=line-tables-only");
break;
- case codegenoptions::DebugInfoConstructor:
+ case llvm::codegenoptions::DebugInfoConstructor:
CmdArgs.push_back("-debug-info-kind=constructor");
break;
- case codegenoptions::LimitedDebugInfo:
+ case llvm::codegenoptions::LimitedDebugInfo:
CmdArgs.push_back("-debug-info-kind=limited");
break;
- case codegenoptions::FullDebugInfo:
+ case llvm::codegenoptions::FullDebugInfo:
CmdArgs.push_back("-debug-info-kind=standalone");
break;
- case codegenoptions::UnusedTypeInfo:
+ case llvm::codegenoptions::UnusedTypeInfo:
CmdArgs.push_back("-debug-info-kind=unused-types");
break;
default:
CmdArgs.push_back(Value.data());
} else {
RenderDebugEnablingArgs(Args, CmdArgs,
- codegenoptions::DebugInfoConstructor,
+ llvm::codegenoptions::DebugInfoConstructor,
DwarfVersion, llvm::DebuggerKind::Default);
}
} else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") ||
DwarfFormatArg->render(Args, CmdArgs);
}
-static void renderDebugOptions(const ToolChain &TC, const Driver &D,
- const llvm::Triple &T, const ArgList &Args,
- bool EmitCodeView, bool IRInput,
- ArgStringList &CmdArgs,
- codegenoptions::DebugInfoKind &DebugInfoKind,
- DwarfFissionKind &DwarfFission) {
+static void
+renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
+ const ArgList &Args, bool EmitCodeView, bool IRInput,
+ ArgStringList &CmdArgs,
+ llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
+ DwarfFissionKind &DwarfFission) {
if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
options::OPT_fno_debug_info_for_profiling, false) &&
checkDebugInfoOption(
}
}
if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) {
- DebugInfoKind = codegenoptions::DebugInfoConstructor;
+ DebugInfoKind = llvm::codegenoptions::DebugInfoConstructor;
// If the last option explicitly specified a debug-info level, use it.
if (checkDebugInfoOption(A, Args, D, TC) &&
// complicated if you've disabled inline info in the skeleton CUs
// (SplitDWARFInlining) - then there's value in composing split-dwarf and
// line-tables-only, so let those compose naturally in that case.
- if (DebugInfoKind == codegenoptions::NoDebugInfo ||
- DebugInfoKind == codegenoptions::DebugDirectivesOnly ||
- (DebugInfoKind == codegenoptions::DebugLineTablesOnly &&
+ if (DebugInfoKind == llvm::codegenoptions::NoDebugInfo ||
+ DebugInfoKind == llvm::codegenoptions::DebugDirectivesOnly ||
+ (DebugInfoKind == llvm::codegenoptions::DebugLineTablesOnly &&
SplitDWARFInlining))
DwarfFission = DwarfFissionKind::None;
}
// If the user asked for debug info but did not explicitly specify -gcodeview
// or -gdwarf, ask the toolchain for the default format.
if (!EmitCodeView && !EmitDwarf &&
- DebugInfoKind != codegenoptions::NoDebugInfo) {
+ DebugInfoKind != llvm::codegenoptions::NoDebugInfo) {
switch (TC.getDefaultDebugFormat()) {
- case codegenoptions::DIF_CodeView:
+ case llvm::codegenoptions::DIF_CodeView:
EmitCodeView = true;
break;
- case codegenoptions::DIF_DWARF:
+ case llvm::codegenoptions::DIF_DWARF:
EmitDwarf = true;
break;
}
// -gline-directives-only supported only for the DWARF debug info.
if (RequestedDWARFVersion == 0 &&
- DebugInfoKind == codegenoptions::DebugDirectivesOnly)
- DebugInfoKind = codegenoptions::NoDebugInfo;
+ DebugInfoKind == llvm::codegenoptions::DebugDirectivesOnly)
+ DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
// strict DWARF is set to false by default. But for DBX, we need it to be set
// as true by default.
// wins.
if (checkDebugInfoOption(Args.getLastArg(options::OPT_gmodules), Args, D,
TC)) {
- if (DebugInfoKind != codegenoptions::DebugLineTablesOnly &&
- DebugInfoKind != codegenoptions::DebugDirectivesOnly) {
- DebugInfoKind = codegenoptions::DebugInfoConstructor;
+ if (DebugInfoKind != llvm::codegenoptions::DebugLineTablesOnly &&
+ DebugInfoKind != llvm::codegenoptions::DebugDirectivesOnly) {
+ DebugInfoKind = llvm::codegenoptions::DebugInfoConstructor;
CmdArgs.push_back("-dwarf-ext-refs");
CmdArgs.push_back("-fmodule-format=obj");
}
if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug))
(void)checkDebugInfoOption(A, Args, D, TC);
- if (DebugInfoKind == codegenoptions::LimitedDebugInfo ||
- DebugInfoKind == codegenoptions::DebugInfoConstructor) {
+ if (DebugInfoKind == llvm::codegenoptions::LimitedDebugInfo ||
+ DebugInfoKind == llvm::codegenoptions::DebugInfoConstructor) {
if (Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types,
options::OPT_feliminate_unused_debug_types, false))
- DebugInfoKind = codegenoptions::UnusedTypeInfo;
+ DebugInfoKind = llvm::codegenoptions::UnusedTypeInfo;
else if (NeedFullDebug)
- DebugInfoKind = codegenoptions::FullDebugInfo;
+ DebugInfoKind = llvm::codegenoptions::FullDebugInfo;
}
if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source,
// When emitting remarks, we need at least debug lines in the output.
if (willEmitRemarks(Args) &&
- DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
- DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+ DebugInfoKind <= llvm::codegenoptions::DebugDirectivesOnly)
+ DebugInfoKind = llvm::codegenoptions::DebugLineTablesOnly;
// Adjust the debug info kind for the given toolchain.
TC.adjustDebugInfoKind(DebugInfoKind, Args);
RenderTargetOptions(Triple, Args, KernelOrKext, CmdArgs);
// These two are potentially updated by AddClangCLArgs.
- codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
+ llvm::codegenoptions::DebugInfoKind DebugInfoKind =
+ llvm::codegenoptions::NoDebugInfo;
bool EmitCodeView = false;
// Add clang-cl arguments.
// This controls whether or not we perform JustMyCode instrumentation.
if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
if (TC.getTriple().isOSBinFormatELF()) {
- if (DebugInfoKind >= codegenoptions::DebugInfoConstructor)
+ if (DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
CmdArgs.push_back("-fjmc");
else
D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "-fjmc"
if ((Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
(EH || UnwindTables || AsyncUnwindTables ||
- DebugInfoKind != codegenoptions::NoDebugInfo))
+ DebugInfoKind != llvm::codegenoptions::NoDebugInfo))
CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1");
if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {
void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
ArgStringList &CmdArgs,
- codegenoptions::DebugInfoKind *DebugInfoKind,
+ llvm::codegenoptions::DebugInfoKind *DebugInfoKind,
bool *EmitCodeView) const {
bool isNVPTX = getToolChain().getTriple().isNVPTX();
options::OPT_gline_tables_only)) {
*EmitCodeView = true;
if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
- *DebugInfoKind = codegenoptions::DebugInfoConstructor;
+ *DebugInfoKind = llvm::codegenoptions::DebugInfoConstructor;
else
- *DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+ *DebugInfoKind = llvm::codegenoptions::DebugLineTablesOnly;
} else {
*EmitCodeView = false;
}
// This controls whether or not we perform JustMyCode instrumentation.
if (Args.hasFlag(options::OPT__SLASH_JMC, options::OPT__SLASH_JMC_,
/*Default=*/false)) {
- if (*EmitCodeView && *DebugInfoKind >= codegenoptions::DebugInfoConstructor)
+ if (*EmitCodeView &&
+ *DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
CmdArgs.push_back("-fjmc");
else
D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "/JMC"
WantDebug = !A->getOption().matches(options::OPT_g0) &&
!A->getOption().matches(options::OPT_ggdb0);
- codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
+ llvm::codegenoptions::DebugInfoKind DebugInfoKind =
+ llvm::codegenoptions::NoDebugInfo;
// Add the -fdebug-compilation-dir flag if needed.
const char *DebugCompilationDir =
// the guard for source type, however there is a test which asserts
// that some assembler invocation receives no -debug-info-kind,
// and it's not clear whether that test is just overly restrictive.
- DebugInfoKind = (WantDebug ? codegenoptions::DebugInfoConstructor
- : codegenoptions::NoDebugInfo);
+ DebugInfoKind = (WantDebug ? llvm::codegenoptions::DebugInfoConstructor
+ : llvm::codegenoptions::NoDebugInfo);
addDebugPrefixMapArg(getToolChain().getDriver(), getToolChain(), Args,
CmdArgs);
Args.AddAllArgs(CmdArgs, options::OPT_mllvm);
- if (DebugInfoKind > codegenoptions::NoDebugInfo && Output.isFilename())
+ if (DebugInfoKind > llvm::codegenoptions::NoDebugInfo && Output.isFilename())
addDebugObjectName(Args, CmdArgs, DebugCompilationDir,
Output.getFilename());
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_CLANG_H
#include "MSVC.h"
-#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/Types.h"
+#include "llvm/Frontend/Debug/Options.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
void AddClangCLArgs(const llvm::opt::ArgList &Args, types::ID InputType,
llvm::opt::ArgStringList &CmdArgs,
- codegenoptions::DebugInfoKind *DebugInfoKind,
+ llvm::codegenoptions::DebugInfoKind *DebugInfoKind,
bool *EmitCodeView) const;
mutable std::unique_ptr<llvm::raw_fd_ostream> CompilationDatabase = nullptr;
}
void NVPTXToolChain::adjustDebugInfoKind(
- codegenoptions::DebugInfoKind &DebugInfoKind, const ArgList &Args) const {
+ llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
+ const ArgList &Args) const {
switch (mustEmitDebugInfo(Args)) {
case DisableDebugInfo:
- DebugInfoKind = codegenoptions::NoDebugInfo;
+ DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
break;
case DebugDirectivesOnly:
- DebugInfoKind = codegenoptions::DebugDirectivesOnly;
+ DebugInfoKind = llvm::codegenoptions::DebugDirectivesOnly;
break;
case EmitSameDebugInfoAsHost:
// Use same debug info level as the host.
bool IsMathErrnoDefault() const override { return false; }
bool supportsDebugInfoOption(const llvm::opt::Arg *A) const override;
- void adjustDebugInfoKind(codegenoptions::DebugInfoKind &DebugInfoKind,
+ void adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
const llvm::opt::ArgList &Args) const override;
// NVPTX supports only DWARF2.
}
void HIPSPVToolChain::adjustDebugInfoKind(
- codegenoptions::DebugInfoKind &DebugInfoKind,
+ llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
const llvm::opt::ArgList &Args) const {
// Debug info generation is disabled for SPIRV-LLVM-Translator
// which currently aborts on the presence of DW_OP_LLVM_convert.
// TODO: Enable debug info when the SPIR-V backend arrives.
- DebugInfoKind = codegenoptions::NoDebugInfo;
+ DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
}
computeMSVCVersion(const Driver *D,
const llvm::opt::ArgList &Args) const override;
- void adjustDebugInfoKind(codegenoptions::DebugInfoKind &DebugInfoKind,
+ void adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
const llvm::opt::ArgList &Args) const override;
bool IsIntegratedAssemblerDefault() const override { return true; }
bool IsMathErrnoDefault() const override { return false; }
#include "AMDGPU.h"
#include "Cuda.h"
-#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
+#include "llvm/Frontend/Debug/Options.h"
#include "llvm/WindowsDriver/MSVCPaths.h"
namespace clang {
/// Set CodeView as the default debug info format for non-MachO binary
/// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to
/// override the default.
- codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
- return getTriple().isOSBinFormatMachO() ? codegenoptions::DIF_DWARF
- : codegenoptions::DIF_CodeView;
+ llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
+ return getTriple().isOSBinFormatMachO()
+ ? llvm::codegenoptions::DIF_DWARF
+ : llvm::codegenoptions::DIF_CodeView;
}
/// Set the debugger tuning to "default", since we're definitely not tuning
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/CommentOptions.h"
-#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/Frontend/Debug/Options.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/Linker/Linker.h"
#include "llvm/MC/MCTargetOptions.h"
std::optional<StringRef> DebugInfoVal;
switch (Opts.DebugInfo) {
- case codegenoptions::DebugLineTablesOnly:
+ case llvm::codegenoptions::DebugLineTablesOnly:
DebugInfoVal = "line-tables-only";
break;
- case codegenoptions::DebugDirectivesOnly:
+ case llvm::codegenoptions::DebugDirectivesOnly:
DebugInfoVal = "line-directives-only";
break;
- case codegenoptions::DebugInfoConstructor:
+ case llvm::codegenoptions::DebugInfoConstructor:
DebugInfoVal = "constructor";
break;
- case codegenoptions::LimitedDebugInfo:
+ case llvm::codegenoptions::LimitedDebugInfo:
DebugInfoVal = "limited";
break;
- case codegenoptions::FullDebugInfo:
+ case llvm::codegenoptions::FullDebugInfo:
DebugInfoVal = "standalone";
break;
- case codegenoptions::UnusedTypeInfo:
+ case llvm::codegenoptions::UnusedTypeInfo:
DebugInfoVal = "unused-types";
break;
- case codegenoptions::NoDebugInfo: // default value
+ case llvm::codegenoptions::NoDebugInfo: // default value
DebugInfoVal = std::nullopt;
break;
- case codegenoptions::LocTrackingOnly: // implied value
+ case llvm::codegenoptions::LocTrackingOnly: // implied value
DebugInfoVal = std::nullopt;
break;
}
GenerateArg(Args, OPT_gpubnames, SA);
auto TNK = Opts.getDebugSimpleTemplateNames();
- if (TNK != codegenoptions::DebugTemplateNamesKind::Full) {
- if (TNK == codegenoptions::DebugTemplateNamesKind::Simple)
+ if (TNK != llvm::codegenoptions::DebugTemplateNamesKind::Full) {
+ if (TNK == llvm::codegenoptions::DebugTemplateNamesKind::Simple)
GenerateArg(Args, OPT_gsimple_template_names_EQ, "simple", SA);
- else if (TNK == codegenoptions::DebugTemplateNamesKind::Mangled)
+ else if (TNK == llvm::codegenoptions::DebugTemplateNamesKind::Mangled)
GenerateArg(Args, OPT_gsimple_template_names_EQ, "mangled", SA);
}
// ProfileInstrumentUsePath is marshalled automatically, no need to generate
if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
unsigned Val =
llvm::StringSwitch<unsigned>(A->getValue())
- .Case("line-tables-only", codegenoptions::DebugLineTablesOnly)
- .Case("line-directives-only", codegenoptions::DebugDirectivesOnly)
- .Case("constructor", codegenoptions::DebugInfoConstructor)
- .Case("limited", codegenoptions::LimitedDebugInfo)
- .Case("standalone", codegenoptions::FullDebugInfo)
- .Case("unused-types", codegenoptions::UnusedTypeInfo)
+ .Case("line-tables-only", llvm::codegenoptions::DebugLineTablesOnly)
+ .Case("line-directives-only",
+ llvm::codegenoptions::DebugDirectivesOnly)
+ .Case("constructor", llvm::codegenoptions::DebugInfoConstructor)
+ .Case("limited", llvm::codegenoptions::LimitedDebugInfo)
+ .Case("standalone", llvm::codegenoptions::FullDebugInfo)
+ .Case("unused-types", llvm::codegenoptions::UnusedTypeInfo)
.Default(~0U);
if (Val == ~0U)
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
<< A->getValue();
else
- Opts.setDebugInfo(static_cast<codegenoptions::DebugInfoKind>(Val));
+ Opts.setDebugInfo(static_cast<llvm::codegenoptions::DebugInfoKind>(Val));
}
// If -fuse-ctor-homing is set and limited debug info is already on, then use
if (const Arg *A =
Args.getLastArg(OPT_fuse_ctor_homing, OPT_fno_use_ctor_homing)) {
if (A->getOption().matches(OPT_fuse_ctor_homing) &&
- Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
- Opts.setDebugInfo(codegenoptions::DebugInfoConstructor);
+ Opts.getDebugInfo() == llvm::codegenoptions::LimitedDebugInfo)
+ Opts.setDebugInfo(llvm::codegenoptions::DebugInfoConstructor);
if (A->getOption().matches(OPT_fno_use_ctor_homing) &&
- Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
- Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
+ Opts.getDebugInfo() == llvm::codegenoptions::DebugInfoConstructor)
+ Opts.setDebugInfo(llvm::codegenoptions::LimitedDebugInfo);
}
for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
<< A->getSpelling() << A->getValue();
Opts.setDebugSimpleTemplateNames(
StringRef(A->getValue()) == "simple"
- ? codegenoptions::DebugTemplateNamesKind::Simple
- : codegenoptions::DebugTemplateNamesKind::Mangled);
+ ? llvm::codegenoptions::DebugTemplateNamesKind::Simple
+ : llvm::codegenoptions::DebugTemplateNamesKind::Mangled);
}
if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
// If the user requested a flag that requires source locations available in
// the backend, make sure that the backend tracks source location information.
- if (NeedLocTracking && Opts.getDebugInfo() == codegenoptions::NoDebugInfo)
- Opts.setDebugInfo(codegenoptions::LocTrackingOnly);
+ if (NeedLocTracking &&
+ Opts.getDebugInfo() == llvm::codegenoptions::NoDebugInfo)
+ Opts.setDebugInfo(llvm::codegenoptions::LocTrackingOnly);
// Parse -fsanitize-recover= arguments.
// FIXME: Report unrecoverable sanitizers incorrectly specified here.
if (std::unique_ptr<raw_ostream> OS =
CI.createDefaultOutputFile(false, InFile, "cpp")) {
if (CI.getLangOpts().ObjCRuntime.isNonFragile())
- return CreateModernObjCRewriter(
- std::string(InFile), std::move(OS), CI.getDiagnostics(),
- CI.getLangOpts(), CI.getDiagnosticOpts().NoRewriteMacros,
- (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo));
+ return CreateModernObjCRewriter(std::string(InFile), std::move(OS),
+ CI.getDiagnostics(), CI.getLangOpts(),
+ CI.getDiagnosticOpts().NoRewriteMacros,
+ (CI.getCodeGenOpts().getDebugInfo() !=
+ llvm::codegenoptions::NoDebugInfo));
return CreateObjCRewriter(std::string(InFile), std::move(OS),
CI.getDiagnostics(), CI.getLangOpts(),
CI.getDiagnosticOpts().NoRewriteMacros);
Inv->getLangOpts()->CXXExceptions = true;
// Needed for testing dynamic_cast.
Inv->getLangOpts()->RTTI = true;
- Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
+ Inv->getCodeGenOpts().setDebugInfo(llvm::codegenoptions::FullDebugInfo);
Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
Ins->setInvocation(std::move(Inv));
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
-#define LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
+#ifndef LLVM_FRONTEND_DEBUG_OPTIONS_H
+#define LLVM_FRONTEND_DEBUG_OPTIONS_H
-namespace clang {
+namespace llvm {
namespace codegenoptions {
enum DebugInfoFormat {
UnusedTypeInfo,
};
-enum class DebugTemplateNamesKind {
- Full,
- Simple,
- Mangled
-};
+enum class DebugTemplateNamesKind { Full, Simple, Mangled };
} // end namespace codegenoptions
-} // end namespace clang
+} // end namespace llvm
#endif