mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
[YAMLIO] Correctly diagnose empty alias/anchor
The `Range` of an alias/anchor token includes the leading `&` or `*`, but it is skipped while parsing the name. The check for an empty name fails to account for the skipped leading character and so the error is never hit. Fix the off-by-one and add a couple regression tests. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D91462
This commit is contained in:
parent
1ea2aab479
commit
f01afcb594
@ -1423,7 +1423,7 @@ bool Scanner::scanAliasOrAnchor(bool IsAlias) {
|
||||
++Column;
|
||||
}
|
||||
|
||||
if (Start == Current) {
|
||||
if (Start + 1 == Current) {
|
||||
setError("Got empty alias or anchor", Start);
|
||||
return false;
|
||||
}
|
||||
|
@ -3101,3 +3101,15 @@ TEST(YAMLIO, TestUnknownDirective) {
|
||||
EXPECT_FALSE(yin2.setCurrentDocument());
|
||||
EXPECT_TRUE(yin2.error());
|
||||
}
|
||||
|
||||
TEST(YAMLIO, TestEmptyAlias) {
|
||||
Input yin("&");
|
||||
EXPECT_FALSE(yin.setCurrentDocument());
|
||||
EXPECT_TRUE(yin.error());
|
||||
}
|
||||
|
||||
TEST(YAMLIO, TestEmptyAnchor) {
|
||||
Input yin("*");
|
||||
EXPECT_FALSE(yin.setCurrentDocument());
|
||||
EXPECT_TRUE(yin.error());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user