@@ -66,6 +66,44 @@ namespace dwarf {
66
66
enum Tag : uint16_t ;
67
67
}
68
68
69
+ // / Wrapper structure that holds a language name and its version.
70
+ // /
71
+ // / Some debug-info formats, particularly DWARF, distniguish between
72
+ // / language codes that include the version name and codes that don't.
73
+ // / DISourceLanguageName may hold either of these.
74
+ // /
75
+ class DISourceLanguageName {
76
+ // / Language name.
77
+ // / If \ref Version is not std::nullopt, then this name
78
+ // / is version independent (i.e., doesn't include the language
79
+ // / version in its name).
80
+ uint16_t Name;
81
+
82
+ // / Language version. The version scheme is language
83
+ // / dependent.
84
+ std::optional<uint32_t > Version;
85
+
86
+ public:
87
+ bool hasVersionedName () const { return Version.has_value (); }
88
+
89
+ // / Returns a versioned or unversioned language name.
90
+ uint16_t getName () const { return Name; }
91
+
92
+ // Transitional API for cases where we do not yet support
93
+ // versioned source language names. Use \ref getName instead.
94
+ //
95
+ // FIXME: remove once all callers of this API account for versioned
96
+ // names.
97
+ uint16_t getUnversionedName () const {
98
+ assert (!hasVersionedName ());
99
+ return Name;
100
+ }
101
+
102
+ DISourceLanguageName (uint16_t Lang, uint32_t Version)
103
+ : Name(Lang), Version(Version) {};
104
+ DISourceLanguageName (uint16_t Lang) : Name(Lang), Version(std::nullopt ) {};
105
+ };
106
+
69
107
class DbgVariableRecord ;
70
108
71
109
LLVM_ABI extern cl::opt<bool > EnableFSDiscriminator;
@@ -2003,7 +2041,7 @@ class DICompileUnit : public DIScope {
2003
2041
LLVM_ABI static const char *nameTableKindString (DebugNameTableKind PK);
2004
2042
2005
2043
private:
2006
- unsigned SourceLanguage;
2044
+ DISourceLanguageName SourceLanguage;
2007
2045
unsigned RuntimeVersion;
2008
2046
uint64_t DWOId;
2009
2047
unsigned EmissionKind;
@@ -2013,16 +2051,17 @@ class DICompileUnit : public DIScope {
2013
2051
bool DebugInfoForProfiling;
2014
2052
bool RangesBaseAddress;
2015
2053
2016
- DICompileUnit (LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
2017
- bool IsOptimized, unsigned RuntimeVersion,
2018
- unsigned EmissionKind, uint64_t DWOId, bool SplitDebugInlining,
2019
- bool DebugInfoForProfiling, unsigned NameTableKind,
2020
- bool RangesBaseAddress, ArrayRef<Metadata *> Ops);
2054
+ DICompileUnit (LLVMContext &C, StorageType Storage,
2055
+ DISourceLanguageName SourceLanguage, bool IsOptimized,
2056
+ unsigned RuntimeVersion, unsigned EmissionKind, uint64_t DWOId,
2057
+ bool SplitDebugInlining, bool DebugInfoForProfiling,
2058
+ unsigned NameTableKind, bool RangesBaseAddress,
2059
+ ArrayRef<Metadata *> Ops);
2021
2060
~DICompileUnit () = default ;
2022
2061
2023
2062
static DICompileUnit *
2024
- getImpl (LLVMContext &Context, unsigned SourceLanguage, DIFile *File ,
2025
- StringRef Producer, bool IsOptimized, StringRef Flags,
2063
+ getImpl (LLVMContext &Context, DISourceLanguageName SourceLanguage,
2064
+ DIFile *File, StringRef Producer, bool IsOptimized, StringRef Flags,
2026
2065
unsigned RuntimeVersion, StringRef SplitDebugFilename,
2027
2066
unsigned EmissionKind, DICompositeTypeArray EnumTypes,
2028
2067
DIScopeArray RetainedTypes,
@@ -2042,8 +2081,8 @@ class DICompileUnit : public DIScope {
2042
2081
getCanonicalMDString (Context, SDK), Storage, ShouldCreate);
2043
2082
}
2044
2083
LLVM_ABI static DICompileUnit *
2045
- getImpl (LLVMContext &Context, unsigned SourceLanguage, Metadata *File ,
2046
- MDString *Producer, bool IsOptimized, MDString *Flags,
2084
+ getImpl (LLVMContext &Context, DISourceLanguageName SourceLanguage,
2085
+ Metadata *File, MDString *Producer, bool IsOptimized, MDString *Flags,
2047
2086
unsigned RuntimeVersion, MDString *SplitDebugFilename,
2048
2087
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
2049
2088
Metadata *GlobalVariables, Metadata *ImportedEntities,
@@ -2068,7 +2107,7 @@ class DICompileUnit : public DIScope {
2068
2107
2069
2108
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY (
2070
2109
DICompileUnit,
2071
- (unsigned SourceLanguage, DIFile *File, StringRef Producer,
2110
+ (DISourceLanguageName SourceLanguage, DIFile *File, StringRef Producer,
2072
2111
bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
2073
2112
StringRef SplitDebugFilename, DebugEmissionKind EmissionKind,
2074
2113
DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,
@@ -2084,7 +2123,7 @@ class DICompileUnit : public DIScope {
2084
2123
SysRoot, SDK))
2085
2124
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY (
2086
2125
DICompileUnit,
2087
- (unsigned SourceLanguage, Metadata *File, MDString *Producer,
2126
+ (DISourceLanguageName SourceLanguage, Metadata *File, MDString *Producer,
2088
2127
bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
2089
2128
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes,
2090
2129
Metadata *RetainedTypes, Metadata *GlobalVariables,
@@ -2099,7 +2138,7 @@ class DICompileUnit : public DIScope {
2099
2138
2100
2139
TempDICompileUnit clone () const { return cloneImpl (); }
2101
2140
2102
- unsigned getSourceLanguage () const { return SourceLanguage; }
2141
+ DISourceLanguageName getSourceLanguage () const { return SourceLanguage; }
2103
2142
bool isOptimized () const { return IsOptimized; }
2104
2143
unsigned getRuntimeVersion () const { return RuntimeVersion; }
2105
2144
DebugEmissionKind getEmissionKind () const {
0 commit comments