summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-03-31 01:28:22 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-03-31 01:28:22 +0000
commit94d58f88801833c1d8d1bbc3d3f4244be9e2348d (patch)
tree7814a3433ac2be78578fca9689edb08a470a9906 /llvm/lib/AsmParser
parent3744fd09d8f453d7442f61f872e333918b3069a1 (diff)
downloadbcm5719-llvm-94d58f88801833c1d8d1bbc3d3f4244be9e2348d.tar.gz
bcm5719-llvm-94d58f88801833c1d8d1bbc3d3f4244be9e2348d.zip
Verifier: Move more debug info checks away from Verify()
Most of these checks were already in the `Verifier` so this is more of a cleanup. Now almost everything is over there. Now that require a `name:` for `MDGlobalVariable`, add a check in `LLParser` for it. llvm-svn: 233657
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 6e79960e3db..ed1d0ff9ee6 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3041,7 +3041,9 @@ struct MDConstant : public MDFieldImpl<ConstantAsMetadata *> {
MDConstant() : ImplTy(nullptr) {}
};
struct MDStringField : public MDFieldImpl<MDString *> {
- MDStringField() : ImplTy(nullptr) {}
+ bool AllowEmpty;
+ MDStringField(bool AllowEmpty = true)
+ : ImplTy(nullptr), AllowEmpty(AllowEmpty) {}
};
struct MDFieldList : public MDFieldImpl<SmallVector<Metadata *, 4>> {
MDFieldList() : ImplTy(SmallVector<Metadata *, 4>()) {}
@@ -3253,10 +3255,14 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDConstant &Result) {
template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result) {
+ LocTy ValueLoc = Lex.getLoc();
std::string S;
if (ParseStringConstant(S))
return true;
+ if (!Result.AllowEmpty && S.empty())
+ return Error(ValueLoc, "'" + Name + "' cannot be empty");
+
Result.assign(S.empty() ? nullptr : MDString::get(Context, S));
return false;
}
@@ -3655,8 +3661,8 @@ bool LLParser::ParseMDTemplateValueParameter(MDNode *&Result, bool IsDistinct) {
/// declaration: !3)
bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ REQUIRED(name, MDStringField, (/* AllowEmpty */ false)); \
OPTIONAL(scope, MDField, ); \
- OPTIONAL(name, MDStringField, ); \
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
OpenPOWER on IntegriCloud