[llvm] r249767 - Support: Stop relying on iterator auto-conversion, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 15:47:55 PDT 2015
Author: dexonsmith
Date: Thu Oct 8 17:47:55 2015
New Revision: 249767
URL: http://llvm.org/viewvc/llvm-project?rev=249767&view=rev
Log:
Support: Stop relying on iterator auto-conversion, NFC
Stop relying on ilist implicit conversions from `value_type&` to
`iterator` in YAMLParser.cpp.
I eventually want to outlaw this entirely. It encourages
`getNextNode()` and `getPrevNode()` in iterator logic, which is
extremely fragile (and relies on them never returning `nullptr`).
FTR, there's nothing nefarious going on in this case, it was just easy
to clean up since the callers really wanted iterators to begin with.
Modified:
llvm/trunk/lib/Support/YAMLParser.cpp
Modified: llvm/trunk/lib/Support/YAMLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?rev=249767&r1=249766&r2=249767&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLParser.cpp (original)
+++ llvm/trunk/lib/Support/YAMLParser.cpp Thu Oct 8 17:47:55 2015
@@ -801,7 +801,7 @@ Token &Scanner::peekNext() {
removeStaleSimpleKeyCandidates();
SimpleKey SK;
- SK.Tok = TokenQueue.front();
+ SK.Tok = TokenQueue.begin();
if (std::find(SimpleKeys.begin(), SimpleKeys.end(), SK)
== SimpleKeys.end())
break;
@@ -1163,7 +1163,7 @@ bool Scanner::scanFlowCollectionStart(bo
TokenQueue.push_back(T);
// [ and { may begin a simple key.
- saveSimpleKeyCandidate(TokenQueue.back(), Column - 1, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), Column - 1, false);
// And may also be followed by a simple key.
IsSimpleKeyAllowed = true;
@@ -1326,7 +1326,7 @@ bool Scanner::scanFlowScalar(bool IsDoub
T.Range = StringRef(Start, Current - Start);
TokenQueue.push_back(T);
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
@@ -1404,7 +1404,7 @@ bool Scanner::scanPlainScalar() {
TokenQueue.push_back(T);
// Plain scalars can be simple keys.
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
@@ -1439,7 +1439,7 @@ bool Scanner::scanAliasOrAnchor(bool IsA
TokenQueue.push_back(T);
// Alias and anchors can be simple keys.
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
@@ -1669,7 +1669,7 @@ bool Scanner::scanTag() {
TokenQueue.push_back(T);
// Tags can be simple keys.
- saveSimpleKeyCandidate(TokenQueue.back(), ColStart, false);
+ saveSimpleKeyCandidate(--TokenQueue.end(), ColStart, false);
IsSimpleKeyAllowed = false;
More information about the llvm-commits
mailing list