[PATCH] D22565: YAMLParser: report errors according to provided position

Paweł Bylica via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 03:58:45 PDT 2016


chfast created this revision.
chfast added reviewers: arphaman, rafael, Bigcheese.
chfast added a subscriber: llvm-commits.

Function yaml::Scanner::setError() has a Position argument that is never used
and is supposed to provide better information about position of an error.
The change uses Position instead of Current source location.

Alternatively, the Position argument can be removed and the code would be
simplified. Unit tests don't care.

Is there any case where Position is not Current and that information is useful?

https://reviews.llvm.org/D22565

Files:
  lib/Support/YAMLParser.cpp

Index: lib/Support/YAMLParser.cpp
===================================================================
--- lib/Support/YAMLParser.cpp
+++ lib/Support/YAMLParser.cpp
@@ -280,13 +280,13 @@
   }
 
   void setError(const Twine &Message, StringRef::iterator Position) {
-    if (Current >= End)
-      Current = End - 1;
+    if (Position >= End)
+      Position = End - 1;
 
     // Don't print out more errors after the first one we encounter. The rest
     // are just the result of the first, and have no meaning.
     if (!Failed)
-      printError(SMLoc::getFromPointer(Current), SourceMgr::DK_Error, Message);
+      printError(SMLoc::getFromPointer(Position), SourceMgr::DK_Error, Message);
     Failed = true;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22565.64657.patch
Type: text/x-patch
Size: 720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160720/6d51ee1c/attachment.bin>


More information about the llvm-commits mailing list