diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2021-03-16 10:19:52 +0000 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2021-03-24 18:49:58 +0000 |
commit | 058455ffbec13bd1bc468a0206b9e3a95dc4b8c8 (patch) | |
tree | 475c2ce66bd88b45eae38dbc282c4287ab43365a /llvm/lib/FileCheck/FileCheck.cpp | |
parent | 63f73c3eb9716256ab8dbb868e16d08a88636cba (diff) | |
download | llvm-058455ffbec13bd1bc468a0206b9e3a95dc4b8c8.zip llvm-058455ffbec13bd1bc468a0206b9e3a95dc4b8c8.tar.gz llvm-058455ffbec13bd1bc468a0206b9e3a95dc4b8c8.tar.bz2 |
[FileCheck] Fix PR49531: invalid use of string var
FileCheck string substitution block parsing code only report an invalid
variable name in a string variable use if it starts with a forbidden
character. It does not report anything if there are unparsed characters
after the variable name, i.e. [[X-Y]] is parsed as [[X]] and no error is
returned. This commit fixes that.
Reviewed By: jdenny, jhenderson
Differential Revision: https://reviews.llvm.org/D98691
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/lib/FileCheck/FileCheck.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index bcf828d..12a0ae6 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -1083,8 +1083,15 @@ bool Pattern::parsePattern(StringRef PatternStr, StringRef Prefix, if (IsPseudo) { MatchStr = OrigMatchStr; IsLegacyLineExpr = IsNumBlock = true; - } else + } else { + if (!MatchStr.empty()) { + SM.PrintMessage(SMLoc::getFromPointer(Name.data()), + SourceMgr::DK_Error, + "invalid name in string variable use"); + return true; + } SubstStr = Name; + } } } |