From 3d2afaa29ea78b6170da9852ce5d57480720d1e0 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 27 Mar 2015 17:29:58 +0000 Subject: Verifier: Check fields of MDVariable subclasses Check fields from `MDLocalVariable` and `MDGlobalVariable` and change the accessors to downcast to the right types. `getType()` still returns `Metadata*` since it could be an `MDString`-based reference. Since local variables require non-null scopes, I also updated `LLParser` to require a `scope:` field. A number of testcases had grown bitrot and started failing with this patch; I committed them separately in r233349. If I just broke your out-of-tree testcases, you're probably hitting similar problems (so have a look there). llvm-svn: 233389 --- llvm/lib/AsmParser/LLParser.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/AsmParser/LLParser.cpp') diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 103c8c48a5e..484a7250e2e 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3035,8 +3035,8 @@ struct MDField : public MDFieldImpl { struct MDConstant : public MDFieldImpl { MDConstant() : ImplTy(nullptr) {} }; -struct MDStringField : public MDFieldImpl { - MDStringField() : ImplTy(std::string()) {} +struct MDStringField : public MDFieldImpl { + MDStringField() : ImplTy(nullptr) {} }; struct MDFieldList : public MDFieldImpl> { MDFieldList() : ImplTy(SmallVector()) {} @@ -3250,7 +3250,7 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result) { if (ParseStringConstant(S)) return true; - Result.assign(std::move(S)); + Result.assign(S.empty() ? nullptr : MDString::get(Context, S)); return false; } @@ -3675,7 +3675,7 @@ bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) { bool LLParser::ParseMDLocalVariable(MDNode *&Result, bool IsDistinct) { #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ REQUIRED(tag, DwarfTagField, ); \ - OPTIONAL(scope, MDField, ); \ + REQUIRED(scope, MDField, ); \ OPTIONAL(name, MDStringField, ); \ OPTIONAL(file, MDField, ); \ OPTIONAL(line, LineField, ); \ -- cgit v1.2.3