diff options
author | Leny Kholodov <lkholodov@accesssoftek.com> | 2016-09-06 10:46:28 +0000 |
---|---|---|
committer | Leny Kholodov <lkholodov@accesssoftek.com> | 2016-09-06 10:46:28 +0000 |
commit | 5fcc4185f5f1b489abd6c5ff62537cd5969c1250 (patch) | |
tree | ff5f18c41a84090a4e1c8f439bd88056b53ad8e0 /llvm/lib/AsmParser | |
parent | 3e0b817b91f247c0d4855a79a6fb534c6a115a38 (diff) | |
download | bcm5719-llvm-5fcc4185f5f1b489abd6c5ff62537cd5969c1250.tar.gz bcm5719-llvm-5fcc4185f5f1b489abd6c5ff62537cd5969c1250.zip |
DebugInfo: use strongly typed enum for debug info flags
Use ADT/BitmaskEnum for DINode::DIFlags for the following purposes:
Get rid of unsigned int for flags to avoid problems on platforms with sizeof(int) < 4
Flags are now strongly typed
Patch by: Victor Leschuk <vleschuk@gmail.com>
Differential Revision: https://reviews.llvm.org/D23766
llvm-svn: 280700
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index a39cbfd22f8..5120b949e84 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1271,7 +1271,7 @@ bool LLParser::ParseStringConstant(std::string &Result) { /// ParseUInt32 /// ::= uint32 -bool LLParser::ParseUInt32(unsigned &Val) { +bool LLParser::ParseUInt32(uint32_t &Val) { if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned()) return TokError("expected integer"); uint64_t Val64 = Lex.getAPSIntVal().getLimitedValue(0xFFFFFFFFULL+1); @@ -3407,8 +3407,8 @@ struct EmissionKindField : public MDUnsignedField { EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {} }; -struct DIFlagField : public MDUnsignedField { - DIFlagField() : MDUnsignedField(0, UINT32_MAX) {} +struct DIFlagField : public MDFieldImpl<DINode::DIFlags> { + DIFlagField() : MDFieldImpl(DINode::FlagZero) {} }; struct MDSignedField : public MDFieldImpl<int64_t> { @@ -3610,12 +3610,15 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, /// ::= DIFlagVector '|' DIFlagFwdDecl '|' uint32 '|' DIFlagPublic template <> bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DIFlagField &Result) { - assert(Result.Max == UINT32_MAX && "Expected only 32-bits"); // Parser for a single flag. - auto parseFlag = [&](unsigned &Val) { - if (Lex.getKind() == lltok::APSInt && !Lex.getAPSIntVal().isSigned()) - return ParseUInt32(Val); + auto parseFlag = [&](DINode::DIFlags &Val) { + if (Lex.getKind() == lltok::APSInt && !Lex.getAPSIntVal().isSigned()) { + uint32_t TempVal = static_cast<uint32_t>(Val); + bool Res = ParseUInt32(TempVal); + Val = static_cast<DINode::DIFlags>(TempVal); + return Res; + } if (Lex.getKind() != lltok::DIFlag) return TokError("expected debug info flag"); @@ -3629,9 +3632,9 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DIFlagField &Result) { }; // Parse the flags and combine them together. - unsigned Combined = 0; + DINode::DIFlags Combined = DINode::FlagZero; do { - unsigned Val; + DINode::DIFlags Val; if (parseFlag(Val)) return true; Combined |= Val; |