mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
LLParser: Require non-null scope for MDLocation and MDLocalVariable
Change `LLParser` to require a non-null `scope:` field for both `MDLocation` and `MDLocalVariable`. There's no need to wait for the verifier for this check. This also allows their `::getImpl()` methods to assert that the incoming scope is non-null. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233394 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -3030,7 +3030,9 @@ struct MDBoolField : public MDFieldImpl<bool> {
|
||||
MDBoolField(bool Default = false) : ImplTy(Default) {}
|
||||
};
|
||||
struct MDField : public MDFieldImpl<Metadata *> {
|
||||
MDField() : ImplTy(nullptr) {}
|
||||
bool AllowNull;
|
||||
|
||||
MDField(bool AllowNull = true) : ImplTy(nullptr), AllowNull(AllowNull) {}
|
||||
};
|
||||
struct MDConstant : public MDFieldImpl<ConstantAsMetadata *> {
|
||||
MDConstant() : ImplTy(nullptr) {}
|
||||
@ -3221,6 +3223,8 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDBoolField &Result) {
|
||||
template <>
|
||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
|
||||
if (Lex.getKind() == lltok::kw_null) {
|
||||
if (!Result.AllowNull)
|
||||
return TokError("'" + Name + "' cannot be null");
|
||||
Lex.Lex();
|
||||
Result.assign(nullptr);
|
||||
return false;
|
||||
@ -3343,7 +3347,7 @@ bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
|
||||
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
||||
OPTIONAL(line, LineField, ); \
|
||||
OPTIONAL(column, ColumnField, ); \
|
||||
REQUIRED(scope, MDField, ); \
|
||||
REQUIRED(scope, MDField, (/* AllowNull */ false)); \
|
||||
OPTIONAL(inlinedAt, MDField, );
|
||||
PARSE_MD_FIELDS();
|
||||
#undef VISIT_MD_FIELDS
|
||||
@ -3675,7 +3679,7 @@ bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) {
|
||||
bool LLParser::ParseMDLocalVariable(MDNode *&Result, bool IsDistinct) {
|
||||
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
||||
REQUIRED(tag, DwarfTagField, ); \
|
||||
REQUIRED(scope, MDField, ); \
|
||||
REQUIRED(scope, MDField, (/* AllowNull */ false)); \
|
||||
OPTIONAL(name, MDStringField, ); \
|
||||
OPTIONAL(file, MDField, ); \
|
||||
OPTIONAL(line, LineField, ); \
|
||||
|
Reference in New Issue
Block a user