X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FYAMLTraits.h;h=78829f862123b43ab4eb8202ec009761eb11dcc9;hb=ebe69fe11e48d322045d5949c83283927a0d790b;hp=023dcee7d54c69d247e8b5599e36c44185b66a2f;hpb=b7d2e72b02a4cb8034f32f8247a2558d2434e121;p=android-x86%2Fexternal-llvm.git diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 023dcee7d54..78829f86212 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -447,6 +447,7 @@ public: virtual void beginEnumScalar() = 0; virtual bool matchEnumScalar(const char*, bool) = 0; + virtual bool matchEnumFallback() = 0; virtual void endEnumScalar() = 0; virtual bool beginBitSetScalar(bool &) = 0; @@ -472,6 +473,16 @@ public: } } + template + void enumFallback(T &Val) { + if ( matchEnumFallback() ) { + // FIXME: Force integral conversion to allow strong typedefs to convert. + FBT Res = (uint64_t)Val; + yamlize(*this, Res, true); + Val = (uint64_t)Res; + } + } + template void bitSetCase(T &Val, const char* Str, const T ConstVal) { if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) { @@ -532,7 +543,7 @@ public: void mapOptional(const char* Key, T& Val, const T& Default) { this->processKeyWithDefault(Key, Val, Default, false); } - + private: template void processKeyWithDefault(const char *Key, Optional &Val, @@ -706,7 +717,7 @@ struct ScalarTraits { static StringRef input(StringRef, void*, StringRef &); static bool mustQuote(StringRef S) { return needsQuotes(S); } }; - + template<> struct ScalarTraits { static void output(const std::string &, void*, llvm::raw_ostream &); @@ -899,6 +910,7 @@ private: void endFlowSequence() override; void beginEnumScalar() override; bool matchEnumScalar(const char*, bool) override; + bool matchEnumFallback() override; void endEnumScalar() override; bool beginBitSetScalar(bool &) override; bool bitSetMatch(const char *, bool ) override; @@ -1026,6 +1038,7 @@ public: void endFlowSequence() override; void beginEnumScalar() override; bool matchEnumScalar(const char*, bool) override; + bool matchEnumFallback() override; void endEnumScalar() override; bool beginBitSetScalar(bool &) override; bool bitSetMatch(const char *, bool ) override;