[llvm] r195285 - revert r194655

Nick Kledzik kledzik at apple.com
Wed Nov 20 16:20:10 PST 2013


Author: kledzik
Date: Wed Nov 20 18:20:10 2013
New Revision: 195285

URL: http://llvm.org/viewvc/llvm-project?rev=195285&view=rev
Log:
revert r194655

Modified:
    llvm/trunk/include/llvm/Support/YAMLTraits.h
    llvm/trunk/lib/Support/YAMLTraits.cpp
    llvm/trunk/unittests/Support/YAMLIOTest.cpp

Modified: llvm/trunk/include/llvm/Support/YAMLTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLTraits.h?rev=195285&r1=195284&r2=195285&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLTraits.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLTraits.h Wed Nov 20 18:20:10 2013
@@ -18,7 +18,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/YAMLParser.h"
@@ -318,7 +317,7 @@ public:
   IO(void *Ctxt=NULL);
   virtual ~IO();
 
-  virtual bool outputting() const = 0;
+  virtual bool outputting() = 0;
 
   virtual unsigned beginSequence() = 0;
   virtual bool preflightElement(unsigned, void *&) = 0;
@@ -703,10 +702,8 @@ public:
   // Check if there was an syntax or semantic error during parsing.
   llvm::error_code error();
 
-  static bool classof(const IO *io) { return !io->outputting(); }
-
 private:
-  virtual bool outputting() const;
+  virtual bool outputting();
   virtual bool mapTag(StringRef, bool);
   virtual void beginMapping();
   virtual void endMapping();
@@ -831,9 +828,7 @@ public:
   Output(llvm::raw_ostream &, void *Ctxt=NULL);
   virtual ~Output();
 
-  static bool classof(const IO *io) { return io->outputting(); }
-  
-  virtual bool outputting() const;
+  virtual bool outputting();
   virtual bool mapTag(StringRef, bool);
   virtual void beginMapping();
   virtual void endMapping();

Modified: llvm/trunk/lib/Support/YAMLTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLTraits.cpp?rev=195285&r1=195284&r2=195285&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLTraits.cpp (original)
+++ llvm/trunk/lib/Support/YAMLTraits.cpp Wed Nov 20 18:20:10 2013
@@ -65,7 +65,7 @@ void Input::HNode::anchor() {}
 void Input::EmptyHNode::anchor() {}
 void Input::ScalarHNode::anchor() {}
 
-bool Input::outputting() const {
+bool Input::outputting() {
   return false;
 }
 
@@ -406,7 +406,7 @@ Output::Output(raw_ostream &yout, void *
 Output::~Output() {
 }
 
-bool Output::outputting() const {
+bool Output::outputting() {
   return true;
 }
 

Modified: llvm/trunk/unittests/Support/YAMLIOTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/YAMLIOTest.cpp?rev=195285&r1=195284&r2=195285&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/YAMLIOTest.cpp (original)
+++ llvm/trunk/unittests/Support/YAMLIOTest.cpp Wed Nov 20 18:20:10 2013
@@ -1115,76 +1115,6 @@ TEST(YAMLIO, TestTaggedDocumentsWriteAnd
 }
 
 
-//===----------------------------------------------------------------------===//
-//  Test dyn_cast<> on IO object 
-//===----------------------------------------------------------------------===//
-
-struct DynCast {
-  int value;
-};
-typedef std::vector<DynCast> DynCastSequence;
-
-LLVM_YAML_IS_SEQUENCE_VECTOR(DynCast)
-
-namespace llvm {
-namespace yaml {
-  template <>
-  struct MappingTraits<DynCast> {
-    static void mapping(IO &io, DynCast& info) {
-      // Change 10 to 13 when writing yaml.
-      if (Output *output = dyn_cast<Output>(&io)) {
-        (void)output;
-        if (info.value == 10)
-          info.value = 13;
-      }
-      io.mapRequired("value", info.value);
-      // Change 20 to 23 when parsing yaml.
-      if (Input *input = dyn_cast<Input>(&io)) {
-        (void)input;
-        if (info.value == 20)
-          info.value = 23;
-      }
-    }
-  };
-}
-}
-
-//
-// Test writing then reading back a sequence of mappings
-//
-TEST(YAMLIO, TestDynCast) {
-  std::string intermediate;
-  {
-    DynCast entry1;
-    entry1.value = 10;
-    DynCast entry2;
-    entry2.value = 20;
-    DynCast entry3;
-    entry3.value = 30;
-    DynCastSequence seq;
-    seq.push_back(entry1);
-    seq.push_back(entry2);
-    seq.push_back(entry3);
-
-    llvm::raw_string_ostream ostr(intermediate);
-    Output yout(ostr);
-    yout << seq;
-  }
-
-  {
-    Input yin(intermediate);
-    DynCastSequence seq2;
-    yin >> seq2;
-
-    EXPECT_FALSE(yin.error());
-    EXPECT_EQ(seq2.size(), 3UL);
-    EXPECT_EQ(seq2[0].value, 13);   // Verify changed to 13.
-    EXPECT_EQ(seq2[1].value, 23);   // Verify changed to 23.
-    EXPECT_EQ(seq2[2].value, 30);   // Verify stays same.
-  }
-}
-
-
 
 //===----------------------------------------------------------------------===//
 //  Test error handling





More information about the llvm-commits mailing list