2020-09-01 19:21:18 +08:00
|
|
|
//===- llvm/unittest/FileCheck/FileCheckTest.cpp - FileCheck tests --------===//
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-09-01 19:21:18 +08:00
|
|
|
#include "llvm/FileCheck/FileCheck.h"
|
|
|
|
#include "../lib/FileCheck/FileCheckImpl.h"
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
#include "llvm/Support/Regex.h"
|
2020-01-16 20:14:13 +08:00
|
|
|
#include "llvm/Testing/Support/Error.h"
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
#include "gtest/gtest.h"
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
#include <tuple>
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
#include <unordered_set>
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
[FileCheck] Move private interface to its own header
Summary:
Most of the class definition in llvm/include/llvm/Support/FileCheck.h
are actually implementation details that should not be relied upon. This
commit moves all of it in a new header file under
llvm/lib/Support/FileCheck. It also takes advantage of the code movement
to put the code into a new llvm::filecheck namespace.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67649
llvm-svn: 373395
2019-10-02 05:37:55 +08:00
|
|
|
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class FileCheckTest : public ::testing::Test {};
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
static StringRef bufferize(SourceMgr &SM, StringRef Str) {
|
|
|
|
std::unique_ptr<MemoryBuffer> Buffer =
|
|
|
|
MemoryBuffer::getMemBufferCopy(Str, "TestBuffer");
|
|
|
|
StringRef StrBufferRef = Buffer->getBuffer();
|
|
|
|
SM.AddNewSourceBuffer(std::move(Buffer), SMLoc());
|
|
|
|
return StrBufferRef;
|
|
|
|
}
|
|
|
|
|
2020-04-04 08:02:45 +08:00
|
|
|
static std::string toString(const std::unordered_set<std::string> &Set) {
|
|
|
|
bool First = true;
|
|
|
|
std::string Str;
|
|
|
|
for (StringRef S : Set) {
|
|
|
|
Str += Twine(First ? "{" + S : ", " + S).str();
|
|
|
|
First = false;
|
|
|
|
}
|
|
|
|
Str += '}';
|
|
|
|
return Str;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ErrorT>
|
|
|
|
static void expectSameErrors(std::unordered_set<std::string> ExpectedMsgs,
|
|
|
|
Error Err) {
|
|
|
|
auto AnyErrorMsgMatch = [&ExpectedMsgs](std::string &&ErrorMsg) -> bool {
|
|
|
|
for (auto ExpectedMsgItr = ExpectedMsgs.begin(),
|
|
|
|
ExpectedMsgEnd = ExpectedMsgs.end();
|
|
|
|
ExpectedMsgItr != ExpectedMsgEnd; ++ExpectedMsgItr) {
|
|
|
|
if (ErrorMsg.find(*ExpectedMsgItr) != std::string::npos) {
|
|
|
|
ExpectedMsgs.erase(ExpectedMsgItr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
Error RemainingErrors = std::move(Err);
|
|
|
|
do {
|
|
|
|
RemainingErrors =
|
|
|
|
handleErrors(std::move(RemainingErrors), [&](const ErrorT &E) {
|
|
|
|
EXPECT_TRUE(AnyErrorMsgMatch(E.message()))
|
|
|
|
<< "Unexpected error message:" << std::endl
|
|
|
|
<< E.message();
|
|
|
|
});
|
|
|
|
} while (RemainingErrors && !ExpectedMsgs.empty());
|
|
|
|
EXPECT_THAT_ERROR(std::move(RemainingErrors), Succeeded());
|
|
|
|
EXPECT_TRUE(ExpectedMsgs.empty())
|
|
|
|
<< "Error message(s) not found:" << std::endl
|
|
|
|
<< toString(ExpectedMsgs);
|
|
|
|
}
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
template <typename ErrorT>
|
|
|
|
static void expectError(StringRef ExpectedMsg, Error Err) {
|
2020-04-04 08:02:45 +08:00
|
|
|
expectSameErrors<ErrorT>({ExpectedMsg.str()}, std::move(Err));
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void expectDiagnosticError(StringRef ExpectedMsg, Error Err) {
|
|
|
|
expectError<ErrorDiagnostic>(ExpectedMsg, std::move(Err));
|
|
|
|
}
|
|
|
|
|
2020-06-19 02:48:55 +08:00
|
|
|
constexpr uint64_t MaxUint64 = std::numeric_limits<uint64_t>::max();
|
|
|
|
constexpr int64_t MaxInt64 = std::numeric_limits<int64_t>::max();
|
|
|
|
constexpr int64_t MinInt64 = std::numeric_limits<int64_t>::min();
|
|
|
|
constexpr uint64_t AbsoluteMinInt64 =
|
|
|
|
static_cast<uint64_t>(-(MinInt64 + 1)) + 1;
|
|
|
|
constexpr uint64_t AbsoluteMaxInt64 = static_cast<uint64_t>(MaxInt64);
|
2020-06-19 22:52:07 +08:00
|
|
|
|
2020-06-19 02:48:55 +08:00
|
|
|
struct ExpressionFormatParameterisedFixture
|
2020-06-11 23:14:24 +08:00
|
|
|
: public ::testing::TestWithParam<
|
|
|
|
std::pair<ExpressionFormat::Kind, unsigned>> {
|
|
|
|
unsigned Precision;
|
2020-06-19 02:48:55 +08:00
|
|
|
bool Signed;
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
bool AllowHex;
|
|
|
|
bool AllowUpperHex;
|
2020-06-19 02:48:55 +08:00
|
|
|
ExpressionFormat Format;
|
|
|
|
Regex WildcardRegex;
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
2020-06-19 02:48:55 +08:00
|
|
|
StringRef TenStr;
|
|
|
|
StringRef FifteenStr;
|
|
|
|
std::string MaxUint64Str;
|
|
|
|
std::string MaxInt64Str;
|
|
|
|
std::string MinInt64Str;
|
|
|
|
StringRef FirstInvalidCharDigits;
|
|
|
|
StringRef AcceptedHexOnlyDigits;
|
|
|
|
StringRef RefusedHexOnlyDigits;
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
|
2020-07-17 11:36:46 +08:00
|
|
|
void SetUp() override {
|
2020-06-11 23:14:24 +08:00
|
|
|
ExpressionFormat::Kind Kind;
|
|
|
|
std::tie(Kind, Precision) = GetParam();
|
2020-06-19 02:48:55 +08:00
|
|
|
AllowHex = Kind == ExpressionFormat::Kind::HexLower ||
|
|
|
|
Kind == ExpressionFormat::Kind::HexUpper;
|
|
|
|
AllowUpperHex = Kind == ExpressionFormat::Kind::HexUpper;
|
|
|
|
Signed = Kind == ExpressionFormat::Kind::Signed;
|
2020-06-11 23:14:24 +08:00
|
|
|
Format = ExpressionFormat(Kind, Precision);
|
2020-06-19 02:48:55 +08:00
|
|
|
|
|
|
|
if (!AllowHex) {
|
|
|
|
MaxUint64Str = std::to_string(MaxUint64);
|
|
|
|
MaxInt64Str = std::to_string(MaxInt64);
|
|
|
|
MinInt64Str = std::to_string(MinInt64);
|
|
|
|
TenStr = "10";
|
|
|
|
FifteenStr = "15";
|
|
|
|
FirstInvalidCharDigits = "aA";
|
|
|
|
AcceptedHexOnlyDigits = RefusedHexOnlyDigits = "N/A";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MaxUint64Str = AllowUpperHex ? "FFFFFFFFFFFFFFFF" : "ffffffffffffffff";
|
|
|
|
MaxInt64Str = AllowUpperHex ? "7FFFFFFFFFFFFFFF" : "7fffffffffffffff";
|
|
|
|
TenStr = AllowUpperHex ? "A" : "a";
|
|
|
|
FifteenStr = AllowUpperHex ? "F" : "f";
|
|
|
|
AcceptedHexOnlyDigits = AllowUpperHex ? "ABCDEF" : "abcdef";
|
|
|
|
RefusedHexOnlyDigits = AllowUpperHex ? "abcdef" : "ABCDEF";
|
|
|
|
MinInt64Str = "N/A";
|
|
|
|
FirstInvalidCharDigits = "gG";
|
|
|
|
}
|
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
void checkWildcardRegexMatch(StringRef Input,
|
|
|
|
unsigned TrailExtendTo = 0) const {
|
2020-06-19 02:48:55 +08:00
|
|
|
SmallVector<StringRef, 4> Matches;
|
2020-06-11 23:14:24 +08:00
|
|
|
std::string ExtendedInput = Input.str();
|
|
|
|
if (TrailExtendTo > Input.size()) {
|
|
|
|
ExtendedInput.append(TrailExtendTo - Input.size(), Input[0]);
|
|
|
|
}
|
|
|
|
ASSERT_TRUE(WildcardRegex.match(ExtendedInput, &Matches))
|
|
|
|
<< "Wildcard regex does not match " << ExtendedInput;
|
|
|
|
EXPECT_EQ(Matches[0], ExtendedInput);
|
2020-06-19 02:48:55 +08:00
|
|
|
}
|
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
void checkWildcardRegexMatchFailure(StringRef Input) const {
|
2020-06-19 02:48:55 +08:00
|
|
|
EXPECT_FALSE(WildcardRegex.match(Input));
|
|
|
|
}
|
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
void checkWildcardRegexCharMatchFailure(StringRef Chars) const {
|
|
|
|
for (auto C : Chars)
|
|
|
|
EXPECT_FALSE(WildcardRegex.match(StringRef(&C, 1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string padWithLeadingZeros(StringRef NumStr) const {
|
|
|
|
bool Negative = NumStr.startswith("-");
|
|
|
|
if (NumStr.size() - unsigned(Negative) >= Precision)
|
|
|
|
return NumStr.str();
|
|
|
|
|
|
|
|
std::string PaddedStr;
|
|
|
|
if (Negative) {
|
|
|
|
PaddedStr = "-";
|
|
|
|
NumStr = NumStr.drop_front();
|
|
|
|
}
|
|
|
|
PaddedStr.append(Precision - NumStr.size(), '0');
|
|
|
|
PaddedStr.append(NumStr.str());
|
|
|
|
return PaddedStr;
|
|
|
|
}
|
|
|
|
|
2020-06-19 02:48:55 +08:00
|
|
|
template <class T> void checkMatchingString(T Val, StringRef ExpectedStr) {
|
|
|
|
Expected<std::string> MatchingString =
|
|
|
|
Format.getMatchingString(ExpressionValue(Val));
|
|
|
|
ASSERT_THAT_EXPECTED(MatchingString, Succeeded())
|
|
|
|
<< "No matching string for " << Val;
|
|
|
|
EXPECT_EQ(*MatchingString, ExpectedStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> void checkMatchingStringFailure(T Val) {
|
|
|
|
Expected<std::string> MatchingString =
|
|
|
|
Format.getMatchingString(ExpressionValue(Val));
|
|
|
|
// Error message tested in ExpressionValue unit tests.
|
|
|
|
EXPECT_THAT_EXPECTED(MatchingString, Failed());
|
|
|
|
}
|
|
|
|
|
|
|
|
Expected<ExpressionValue> getValueFromStringReprFailure(StringRef Str) {
|
|
|
|
StringRef BufferizedStr = bufferize(SM, Str);
|
|
|
|
return Format.valueFromStringRepr(BufferizedStr, SM);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void checkValueFromStringRepr(StringRef Str, T ExpectedVal) {
|
|
|
|
Expected<ExpressionValue> ResultValue = getValueFromStringReprFailure(Str);
|
|
|
|
ASSERT_THAT_EXPECTED(ResultValue, Succeeded())
|
|
|
|
<< "Failed to get value from " << Str;
|
|
|
|
ASSERT_EQ(ResultValue->isNegative(), ExpectedVal < 0)
|
|
|
|
<< "Value for " << Str << " is not " << ExpectedVal;
|
|
|
|
if (ResultValue->isNegative())
|
|
|
|
EXPECT_EQ(cantFail(ResultValue->getSignedValue()),
|
|
|
|
static_cast<int64_t>(ExpectedVal));
|
|
|
|
else
|
|
|
|
EXPECT_EQ(cantFail(ResultValue->getUnsignedValue()),
|
|
|
|
static_cast<uint64_t>(ExpectedVal));
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkValueFromStringReprFailure(StringRef Str) {
|
|
|
|
StringRef OverflowErrorStr = "unable to represent numeric value";
|
|
|
|
Expected<ExpressionValue> ResultValue = getValueFromStringReprFailure(Str);
|
|
|
|
expectDiagnosticError(OverflowErrorStr, ResultValue.takeError());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(ExpressionFormatParameterisedFixture, FormatGetWildcardRegex) {
|
|
|
|
// Wildcard regex is valid.
|
2020-06-11 23:14:24 +08:00
|
|
|
Expected<std::string> WildcardPattern = Format.getWildcardRegex();
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(WildcardPattern, Succeeded());
|
2020-06-11 23:14:24 +08:00
|
|
|
WildcardRegex = Regex((Twine("^") + *WildcardPattern + "$").str());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_TRUE(WildcardRegex.isValid());
|
2020-06-19 02:48:55 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Does not match empty string.
|
2020-06-19 02:48:55 +08:00
|
|
|
checkWildcardRegexMatchFailure("");
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Matches all decimal digits and matches several of them.
|
2020-06-11 23:14:24 +08:00
|
|
|
StringRef LongNumber = "12345678901234567890";
|
|
|
|
checkWildcardRegexMatch(LongNumber);
|
2020-06-19 02:48:55 +08:00
|
|
|
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
// Matches negative digits.
|
2020-06-11 23:14:24 +08:00
|
|
|
LongNumber = "-12345678901234567890";
|
2020-06-19 02:48:55 +08:00
|
|
|
if (Signed)
|
2020-06-11 23:14:24 +08:00
|
|
|
checkWildcardRegexMatch(LongNumber);
|
2020-06-19 02:48:55 +08:00
|
|
|
else
|
2020-06-11 23:14:24 +08:00
|
|
|
checkWildcardRegexMatchFailure(LongNumber);
|
2020-06-19 02:48:55 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Check non digits or digits with wrong casing are not matched.
|
|
|
|
if (AllowHex) {
|
2020-06-11 23:14:24 +08:00
|
|
|
checkWildcardRegexMatch(AcceptedHexOnlyDigits, 16);
|
|
|
|
checkWildcardRegexCharMatchFailure(RefusedHexOnlyDigits);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
}
|
2020-06-11 23:14:24 +08:00
|
|
|
checkWildcardRegexCharMatchFailure(FirstInvalidCharDigits);
|
|
|
|
|
|
|
|
// Check leading zeros are only accepted if number of digits is less than the
|
|
|
|
// precision.
|
|
|
|
LongNumber = "01234567890123456789";
|
|
|
|
if (Precision) {
|
|
|
|
checkWildcardRegexMatch(LongNumber.take_front(Precision));
|
|
|
|
checkWildcardRegexMatchFailure(LongNumber.take_front(Precision - 1));
|
|
|
|
if (Precision < LongNumber.size())
|
|
|
|
checkWildcardRegexMatchFailure(LongNumber.take_front(Precision + 1));
|
|
|
|
} else
|
|
|
|
checkWildcardRegexMatch(LongNumber);
|
2020-06-19 02:48:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(ExpressionFormatParameterisedFixture, FormatGetMatchingString) {
|
2020-06-11 23:14:24 +08:00
|
|
|
checkMatchingString(0, padWithLeadingZeros("0"));
|
|
|
|
checkMatchingString(9, padWithLeadingZeros("9"));
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
if (Signed) {
|
2020-06-11 23:14:24 +08:00
|
|
|
checkMatchingString(-5, padWithLeadingZeros("-5"));
|
2020-06-19 02:48:55 +08:00
|
|
|
checkMatchingStringFailure(MaxUint64);
|
2020-06-11 23:14:24 +08:00
|
|
|
checkMatchingString(MaxInt64, padWithLeadingZeros(MaxInt64Str));
|
|
|
|
checkMatchingString(MinInt64, padWithLeadingZeros(MinInt64Str));
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
} else {
|
2020-06-19 02:48:55 +08:00
|
|
|
checkMatchingStringFailure(-5);
|
2020-06-11 23:14:24 +08:00
|
|
|
checkMatchingString(MaxUint64, padWithLeadingZeros(MaxUint64Str));
|
|
|
|
checkMatchingString(MaxInt64, padWithLeadingZeros(MaxInt64Str));
|
2020-06-19 02:48:55 +08:00
|
|
|
checkMatchingStringFailure(MinInt64);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
}
|
2020-06-19 02:48:55 +08:00
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
checkMatchingString(10, padWithLeadingZeros(TenStr));
|
|
|
|
checkMatchingString(15, padWithLeadingZeros(FifteenStr));
|
2020-06-19 02:48:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(ExpressionFormatParameterisedFixture, FormatValueFromStringRepr) {
|
|
|
|
checkValueFromStringRepr("0", 0);
|
|
|
|
checkValueFromStringRepr("9", 9);
|
|
|
|
|
2020-06-19 22:52:07 +08:00
|
|
|
if (Signed) {
|
2020-06-19 02:48:55 +08:00
|
|
|
checkValueFromStringRepr("-5", -5);
|
|
|
|
checkValueFromStringReprFailure(MaxUint64Str);
|
2020-06-19 22:52:07 +08:00
|
|
|
} else {
|
2020-06-19 02:48:55 +08:00
|
|
|
checkValueFromStringReprFailure("-5");
|
|
|
|
checkValueFromStringRepr(MaxUint64Str, MaxUint64);
|
2020-06-19 22:52:07 +08:00
|
|
|
}
|
2020-06-19 02:48:55 +08:00
|
|
|
|
|
|
|
checkValueFromStringRepr(TenStr, 10);
|
|
|
|
checkValueFromStringRepr(FifteenStr, 15);
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Wrong casing is not tested because valueFromStringRepr() relies on
|
|
|
|
// StringRef's getAsInteger() which does not allow to restrict casing.
|
2020-06-19 02:48:55 +08:00
|
|
|
checkValueFromStringReprFailure("G");
|
|
|
|
}
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
2020-06-19 02:48:55 +08:00
|
|
|
TEST_P(ExpressionFormatParameterisedFixture, FormatBoolOperator) {
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_TRUE(bool(Format));
|
|
|
|
}
|
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
AllowedExplicitExpressionFormat, ExpressionFormatParameterisedFixture,
|
|
|
|
::testing::Values(std::make_pair(ExpressionFormat::Kind::Unsigned, 0),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Signed, 0),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::HexLower, 0),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::HexUpper, 0),
|
|
|
|
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Unsigned, 1),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Signed, 1),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::HexLower, 1),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::HexUpper, 1),
|
|
|
|
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Unsigned, 16),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Signed, 16),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::HexLower, 16),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::HexUpper, 16),
|
|
|
|
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Unsigned, 20),
|
|
|
|
std::make_pair(ExpressionFormat::Kind::Signed, 20)), );
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
|
|
|
TEST_F(FileCheckTest, NoFormatProperties) {
|
|
|
|
ExpressionFormat NoFormat(ExpressionFormat::Kind::NoFormat);
|
|
|
|
expectError<StringError>("trying to match value with invalid format",
|
|
|
|
NoFormat.getWildcardRegex().takeError());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
expectError<StringError>(
|
|
|
|
"trying to match value with invalid format",
|
|
|
|
NoFormat.getMatchingString(ExpressionValue(18u)).takeError());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_FALSE(bool(NoFormat));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, FormatEqualityOperators) {
|
|
|
|
ExpressionFormat UnsignedFormat(ExpressionFormat::Kind::Unsigned);
|
|
|
|
ExpressionFormat UnsignedFormat2(ExpressionFormat::Kind::Unsigned);
|
|
|
|
EXPECT_TRUE(UnsignedFormat == UnsignedFormat2);
|
|
|
|
EXPECT_FALSE(UnsignedFormat != UnsignedFormat2);
|
|
|
|
|
|
|
|
ExpressionFormat HexLowerFormat(ExpressionFormat::Kind::HexLower);
|
|
|
|
EXPECT_FALSE(UnsignedFormat == HexLowerFormat);
|
|
|
|
EXPECT_TRUE(UnsignedFormat != HexLowerFormat);
|
|
|
|
|
|
|
|
ExpressionFormat NoFormat(ExpressionFormat::Kind::NoFormat);
|
|
|
|
ExpressionFormat NoFormat2(ExpressionFormat::Kind::NoFormat);
|
|
|
|
EXPECT_FALSE(NoFormat == NoFormat2);
|
|
|
|
EXPECT_TRUE(NoFormat != NoFormat2);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, FormatKindEqualityOperators) {
|
|
|
|
ExpressionFormat UnsignedFormat(ExpressionFormat::Kind::Unsigned);
|
|
|
|
EXPECT_TRUE(UnsignedFormat == ExpressionFormat::Kind::Unsigned);
|
|
|
|
EXPECT_FALSE(UnsignedFormat != ExpressionFormat::Kind::Unsigned);
|
|
|
|
EXPECT_FALSE(UnsignedFormat == ExpressionFormat::Kind::HexLower);
|
|
|
|
EXPECT_TRUE(UnsignedFormat != ExpressionFormat::Kind::HexLower);
|
|
|
|
ExpressionFormat NoFormat(ExpressionFormat::Kind::NoFormat);
|
|
|
|
EXPECT_TRUE(NoFormat == ExpressionFormat::Kind::NoFormat);
|
|
|
|
EXPECT_FALSE(NoFormat != ExpressionFormat::Kind::NoFormat);
|
|
|
|
}
|
|
|
|
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
template <class T1, class T2>
|
|
|
|
static Expected<ExpressionValue> doValueOperation(binop_eval_t Operation,
|
|
|
|
T1 LeftValue, T2 RightValue) {
|
|
|
|
ExpressionValue LeftOperand(LeftValue);
|
|
|
|
ExpressionValue RightOperand(RightValue);
|
|
|
|
return Operation(LeftOperand, RightOperand);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static void expectValueEqual(ExpressionValue ActualValue, T ExpectedValue) {
|
|
|
|
EXPECT_EQ(ExpectedValue < 0, ActualValue.isNegative());
|
|
|
|
if (ExpectedValue < 0) {
|
|
|
|
Expected<int64_t> SignedActualValue = ActualValue.getSignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(SignedActualValue, Succeeded());
|
|
|
|
EXPECT_EQ(*SignedActualValue, static_cast<int64_t>(ExpectedValue));
|
|
|
|
} else {
|
|
|
|
Expected<uint64_t> UnsignedActualValue = ActualValue.getUnsignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(UnsignedActualValue, Succeeded());
|
|
|
|
EXPECT_EQ(*UnsignedActualValue, static_cast<uint64_t>(ExpectedValue));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T1, class T2, class TR>
|
|
|
|
static void expectOperationValueResult(binop_eval_t Operation, T1 LeftValue,
|
|
|
|
T2 RightValue, TR ResultValue) {
|
|
|
|
Expected<ExpressionValue> OperationResult =
|
|
|
|
doValueOperation(Operation, LeftValue, RightValue);
|
|
|
|
ASSERT_THAT_EXPECTED(OperationResult, Succeeded());
|
|
|
|
expectValueEqual(*OperationResult, ResultValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T1, class T2>
|
|
|
|
static void expectOperationValueResult(binop_eval_t Operation, T1 LeftValue,
|
|
|
|
T2 RightValue) {
|
|
|
|
expectError<OverflowError>(
|
|
|
|
"overflow error",
|
|
|
|
doValueOperation(Operation, LeftValue, RightValue).takeError());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ExpressionValueGetUnsigned) {
|
|
|
|
// Test positive value.
|
|
|
|
Expected<uint64_t> UnsignedValue = ExpressionValue(10).getUnsignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(UnsignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*UnsignedValue, 10U);
|
|
|
|
|
|
|
|
// Test 0.
|
|
|
|
UnsignedValue = ExpressionValue(0).getUnsignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(UnsignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*UnsignedValue, 0U);
|
|
|
|
|
|
|
|
// Test max positive value.
|
|
|
|
UnsignedValue = ExpressionValue(MaxUint64).getUnsignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(UnsignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*UnsignedValue, MaxUint64);
|
|
|
|
|
|
|
|
// Test failure with negative value.
|
|
|
|
expectError<OverflowError>(
|
|
|
|
"overflow error", ExpressionValue(-1).getUnsignedValue().takeError());
|
|
|
|
|
|
|
|
// Test failure with min negative value.
|
|
|
|
expectError<OverflowError>(
|
|
|
|
"overflow error",
|
|
|
|
ExpressionValue(MinInt64).getUnsignedValue().takeError());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ExpressionValueGetSigned) {
|
|
|
|
// Test positive value.
|
|
|
|
Expected<int64_t> SignedValue = ExpressionValue(10).getSignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(SignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*SignedValue, 10);
|
|
|
|
|
|
|
|
// Test 0.
|
|
|
|
SignedValue = ExpressionValue(0).getSignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(SignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*SignedValue, 0);
|
|
|
|
|
|
|
|
// Test max int64_t.
|
|
|
|
SignedValue = ExpressionValue(MaxInt64).getSignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(SignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*SignedValue, MaxInt64);
|
|
|
|
|
|
|
|
// Test failure with too big positive value.
|
|
|
|
expectError<OverflowError>(
|
|
|
|
"overflow error", ExpressionValue(static_cast<uint64_t>(MaxInt64) + 1)
|
|
|
|
.getSignedValue()
|
|
|
|
.takeError());
|
|
|
|
|
|
|
|
// Test failure with max uint64_t.
|
|
|
|
expectError<OverflowError>(
|
|
|
|
"overflow error",
|
|
|
|
ExpressionValue(MaxUint64).getSignedValue().takeError());
|
|
|
|
|
|
|
|
// Test negative value.
|
|
|
|
SignedValue = ExpressionValue(-10).getSignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(SignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*SignedValue, -10);
|
|
|
|
|
|
|
|
// Test min int64_t.
|
|
|
|
SignedValue = ExpressionValue(MinInt64).getSignedValue();
|
|
|
|
ASSERT_THAT_EXPECTED(SignedValue, Succeeded());
|
|
|
|
EXPECT_EQ(*SignedValue, MinInt64);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ExpressionValueAbsolute) {
|
|
|
|
// Test positive value.
|
|
|
|
expectValueEqual(ExpressionValue(10).getAbsolute(), 10);
|
|
|
|
|
|
|
|
// Test 0.
|
|
|
|
expectValueEqual(ExpressionValue(0).getAbsolute(), 0);
|
|
|
|
|
|
|
|
// Test max uint64_t.
|
|
|
|
expectValueEqual(ExpressionValue(MaxUint64).getAbsolute(), MaxUint64);
|
|
|
|
|
|
|
|
// Test negative value.
|
|
|
|
expectValueEqual(ExpressionValue(-10).getAbsolute(), 10);
|
|
|
|
|
|
|
|
// Test absence of overflow on min int64_t.
|
|
|
|
expectValueEqual(ExpressionValue(MinInt64).getAbsolute(),
|
|
|
|
static_cast<uint64_t>(-(MinInt64 + 10)) + 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ExpressionValueAddition) {
|
|
|
|
// Test both negative values.
|
|
|
|
expectOperationValueResult(operator+, -10, -10, -20);
|
|
|
|
|
|
|
|
// Test both negative values with underflow.
|
|
|
|
expectOperationValueResult(operator+, MinInt64, -1);
|
|
|
|
expectOperationValueResult(operator+, MinInt64, MinInt64);
|
|
|
|
|
|
|
|
// Test negative and positive value.
|
|
|
|
expectOperationValueResult(operator+, -10, 10, 0);
|
|
|
|
expectOperationValueResult(operator+, -10, 11, 1);
|
|
|
|
expectOperationValueResult(operator+, -11, 10, -1);
|
|
|
|
|
|
|
|
// Test positive and negative value.
|
|
|
|
expectOperationValueResult(operator+, 10, -10, 0);
|
|
|
|
expectOperationValueResult(operator+, 10, -11, -1);
|
|
|
|
expectOperationValueResult(operator+, 11, -10, 1);
|
|
|
|
|
|
|
|
// Test both positive values.
|
|
|
|
expectOperationValueResult(operator+, 10, 10, 20);
|
|
|
|
|
|
|
|
// Test both positive values with overflow.
|
|
|
|
expectOperationValueResult(operator+, MaxUint64, 1);
|
|
|
|
expectOperationValueResult(operator+, MaxUint64, MaxUint64);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ExpressionValueSubtraction) {
|
|
|
|
// Test negative value and value bigger than int64_t max.
|
|
|
|
expectOperationValueResult(operator-, -10, MaxUint64);
|
|
|
|
|
|
|
|
// Test negative and positive value with underflow.
|
|
|
|
expectOperationValueResult(operator-, MinInt64, 1);
|
|
|
|
|
|
|
|
// Test negative and positive value.
|
|
|
|
expectOperationValueResult(operator-, -10, 10, -20);
|
|
|
|
|
|
|
|
// Test both negative values.
|
|
|
|
expectOperationValueResult(operator-, -10, -10, 0);
|
|
|
|
expectOperationValueResult(operator-, -11, -10, -1);
|
|
|
|
expectOperationValueResult(operator-, -10, -11, 1);
|
|
|
|
|
|
|
|
// Test positive and negative values.
|
|
|
|
expectOperationValueResult(operator-, 10, -10, 20);
|
|
|
|
|
|
|
|
// Test both positive values with result positive.
|
|
|
|
expectOperationValueResult(operator-, 10, 5, 5);
|
|
|
|
|
|
|
|
// Test both positive values with underflow.
|
|
|
|
expectOperationValueResult(operator-, 0, MaxUint64);
|
|
|
|
expectOperationValueResult(operator-, 0,
|
|
|
|
static_cast<uint64_t>(-(MinInt64 + 10)) + 11);
|
|
|
|
|
|
|
|
// Test both positive values with result < -(max int64_t)
|
|
|
|
expectOperationValueResult(operator-, 10,
|
|
|
|
static_cast<uint64_t>(MaxInt64) + 11,
|
|
|
|
-MaxInt64 - 1);
|
|
|
|
|
|
|
|
// Test both positive values with 0 > result > -(max int64_t)
|
|
|
|
expectOperationValueResult(operator-, 10, 11, -1);
|
|
|
|
}
|
|
|
|
|
2020-06-01 18:09:58 +08:00
|
|
|
TEST_F(FileCheckTest, ExpressionValueMultiplication) {
|
|
|
|
// Test mixed signed values.
|
|
|
|
expectOperationValueResult(operator*, -3, 10, -30);
|
|
|
|
expectOperationValueResult(operator*, 2, -17, -34);
|
|
|
|
expectOperationValueResult(operator*, 0, MinInt64, 0);
|
|
|
|
expectOperationValueResult(operator*, MinInt64, 1, MinInt64);
|
|
|
|
expectOperationValueResult(operator*, 1, MinInt64, MinInt64);
|
|
|
|
expectOperationValueResult(operator*, MaxInt64, -1, -MaxInt64);
|
|
|
|
expectOperationValueResult(operator*, -1, MaxInt64, -MaxInt64);
|
|
|
|
|
|
|
|
// Test both negative values.
|
|
|
|
expectOperationValueResult(operator*, -3, -10, 30);
|
|
|
|
expectOperationValueResult(operator*, -2, -17, 34);
|
|
|
|
expectOperationValueResult(operator*, MinInt64, -1, AbsoluteMinInt64);
|
|
|
|
|
|
|
|
// Test both positive values.
|
|
|
|
expectOperationValueResult(operator*, 3, 10, 30);
|
|
|
|
expectOperationValueResult(operator*, 2, 17, 34);
|
|
|
|
expectOperationValueResult(operator*, 0, MaxUint64, 0);
|
|
|
|
|
|
|
|
// Test negative results that underflow.
|
|
|
|
expectOperationValueResult(operator*, -10, MaxInt64);
|
|
|
|
expectOperationValueResult(operator*, MaxInt64, -10);
|
|
|
|
expectOperationValueResult(operator*, 10, MinInt64);
|
|
|
|
expectOperationValueResult(operator*, MinInt64, 10);
|
|
|
|
expectOperationValueResult(operator*, -1, MaxUint64);
|
|
|
|
expectOperationValueResult(operator*, MaxUint64, -1);
|
|
|
|
expectOperationValueResult(operator*, -1, AbsoluteMaxInt64 + 2);
|
|
|
|
expectOperationValueResult(operator*, AbsoluteMaxInt64 + 2, -1);
|
|
|
|
|
|
|
|
// Test positive results that overflow.
|
|
|
|
expectOperationValueResult(operator*, 10, MaxUint64);
|
|
|
|
expectOperationValueResult(operator*, MaxUint64, 10);
|
|
|
|
expectOperationValueResult(operator*, MinInt64, -10);
|
|
|
|
expectOperationValueResult(operator*, -10, MinInt64);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ExpressionValueDivision) {
|
|
|
|
// Test mixed signed values.
|
|
|
|
expectOperationValueResult(operator/, -30, 10, -3);
|
|
|
|
expectOperationValueResult(operator/, 34, -17, -2);
|
|
|
|
expectOperationValueResult(operator/, 0, -10, 0);
|
|
|
|
expectOperationValueResult(operator/, MinInt64, 1, MinInt64);
|
|
|
|
expectOperationValueResult(operator/, MaxInt64, -1, -MaxInt64);
|
|
|
|
expectOperationValueResult(operator/, -MaxInt64, 1, -MaxInt64);
|
|
|
|
|
|
|
|
// Test both negative values.
|
|
|
|
expectOperationValueResult(operator/, -30, -10, 3);
|
|
|
|
expectOperationValueResult(operator/, -34, -17, 2);
|
|
|
|
|
|
|
|
// Test both positive values.
|
|
|
|
expectOperationValueResult(operator/, 30, 10, 3);
|
|
|
|
expectOperationValueResult(operator/, 34, 17, 2);
|
|
|
|
expectOperationValueResult(operator/, 0, 10, 0);
|
|
|
|
|
|
|
|
// Test divide by zero.
|
|
|
|
expectOperationValueResult(operator/, -10, 0);
|
|
|
|
expectOperationValueResult(operator/, 10, 0);
|
|
|
|
expectOperationValueResult(operator/, 0, 0);
|
|
|
|
|
|
|
|
// Test negative result that underflows.
|
|
|
|
expectOperationValueResult(operator/, MaxUint64, -1);
|
|
|
|
expectOperationValueResult(operator/, AbsoluteMaxInt64 + 2, -1);
|
|
|
|
}
|
|
|
|
|
2020-06-01 18:09:58 +08:00
|
|
|
TEST_F(FileCheckTest, ExpressionValueEquality) {
|
|
|
|
// Test negative and positive value.
|
|
|
|
EXPECT_FALSE(ExpressionValue(5) == ExpressionValue(-3));
|
|
|
|
EXPECT_TRUE(ExpressionValue(5) != ExpressionValue(-3));
|
|
|
|
EXPECT_FALSE(ExpressionValue(-2) == ExpressionValue(6));
|
|
|
|
EXPECT_TRUE(ExpressionValue(-2) != ExpressionValue(6));
|
|
|
|
EXPECT_FALSE(ExpressionValue(-7) == ExpressionValue(7));
|
|
|
|
EXPECT_TRUE(ExpressionValue(-7) != ExpressionValue(7));
|
|
|
|
EXPECT_FALSE(ExpressionValue(4) == ExpressionValue(-4));
|
|
|
|
EXPECT_TRUE(ExpressionValue(4) != ExpressionValue(-4));
|
|
|
|
EXPECT_FALSE(ExpressionValue(MaxUint64) == ExpressionValue(-1));
|
|
|
|
EXPECT_TRUE(ExpressionValue(MaxUint64) != ExpressionValue(-1));
|
|
|
|
|
|
|
|
// Test both negative values.
|
|
|
|
EXPECT_FALSE(ExpressionValue(-2) == ExpressionValue(-7));
|
|
|
|
EXPECT_TRUE(ExpressionValue(-2) != ExpressionValue(-7));
|
|
|
|
EXPECT_TRUE(ExpressionValue(-3) == ExpressionValue(-3));
|
|
|
|
EXPECT_FALSE(ExpressionValue(-3) != ExpressionValue(-3));
|
|
|
|
EXPECT_FALSE(ExpressionValue(MinInt64) == ExpressionValue(-1));
|
|
|
|
EXPECT_TRUE(ExpressionValue(MinInt64) != ExpressionValue(-1));
|
|
|
|
EXPECT_FALSE(ExpressionValue(MinInt64) == ExpressionValue(-0));
|
|
|
|
EXPECT_TRUE(ExpressionValue(MinInt64) != ExpressionValue(-0));
|
|
|
|
|
|
|
|
// Test both positive values.
|
|
|
|
EXPECT_FALSE(ExpressionValue(8) == ExpressionValue(9));
|
|
|
|
EXPECT_TRUE(ExpressionValue(8) != ExpressionValue(9));
|
|
|
|
EXPECT_TRUE(ExpressionValue(1) == ExpressionValue(1));
|
|
|
|
EXPECT_FALSE(ExpressionValue(1) != ExpressionValue(1));
|
|
|
|
|
|
|
|
// Check the signedness of zero doesn't affect equality.
|
|
|
|
EXPECT_TRUE(ExpressionValue(0) == ExpressionValue(0));
|
|
|
|
EXPECT_FALSE(ExpressionValue(0) != ExpressionValue(0));
|
|
|
|
EXPECT_TRUE(ExpressionValue(0) == ExpressionValue(-0));
|
|
|
|
EXPECT_FALSE(ExpressionValue(0) != ExpressionValue(-0));
|
|
|
|
EXPECT_TRUE(ExpressionValue(-0) == ExpressionValue(0));
|
|
|
|
EXPECT_FALSE(ExpressionValue(-0) != ExpressionValue(0));
|
|
|
|
EXPECT_TRUE(ExpressionValue(-0) == ExpressionValue(-0));
|
|
|
|
EXPECT_FALSE(ExpressionValue(-0) != ExpressionValue(-0));
|
|
|
|
}
|
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
TEST_F(FileCheckTest, Literal) {
|
2020-04-04 08:02:45 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
// Eval returns the literal's value.
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionLiteral Ten(bufferize(SM, "10"), 10u);
|
|
|
|
Expected<ExpressionValue> Value = Ten.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(Value, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(10, cantFail(Value->getSignedValue()));
|
2020-04-04 08:02:45 +08:00
|
|
|
Expected<ExpressionFormat> ImplicitFormat = Ten.getImplicitFormat(SM);
|
|
|
|
ASSERT_THAT_EXPECTED(ImplicitFormat, Succeeded());
|
|
|
|
EXPECT_EQ(*ImplicitFormat, ExpressionFormat::Kind::NoFormat);
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
// Min value can be correctly represented.
|
|
|
|
ExpressionLiteral Min(bufferize(SM, std::to_string(MinInt64)), MinInt64);
|
|
|
|
Value = Min.eval();
|
|
|
|
ASSERT_TRUE(bool(Value));
|
|
|
|
EXPECT_EQ(MinInt64, cantFail(Value->getSignedValue()));
|
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
// Max value can be correctly represented.
|
2020-04-04 08:02:45 +08:00
|
|
|
ExpressionLiteral Max(bufferize(SM, std::to_string(MaxUint64)), MaxUint64);
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
Value = Max.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(Value, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(MaxUint64, cantFail(Value->getUnsignedValue()));
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
}
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
TEST_F(FileCheckTest, Expression) {
|
2020-04-04 08:02:45 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
std::unique_ptr<ExpressionLiteral> Ten =
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
std::make_unique<ExpressionLiteral>(bufferize(SM, "10"), 10u);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionLiteral *TenPtr = Ten.get();
|
|
|
|
Expression Expr(std::move(Ten),
|
|
|
|
ExpressionFormat(ExpressionFormat::Kind::HexLower));
|
|
|
|
EXPECT_EQ(Expr.getAST(), TenPtr);
|
|
|
|
EXPECT_EQ(Expr.getFormat(), ExpressionFormat::Kind::HexLower);
|
|
|
|
}
|
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
static void
|
|
|
|
expectUndefErrors(std::unordered_set<std::string> ExpectedUndefVarNames,
|
|
|
|
Error Err) {
|
2020-01-29 03:23:46 +08:00
|
|
|
EXPECT_THAT_ERROR(handleErrors(std::move(Err),
|
|
|
|
[&](const UndefVarError &E) {
|
|
|
|
EXPECT_EQ(ExpectedUndefVarNames.erase(
|
|
|
|
std::string(E.getVarName())),
|
|
|
|
1U);
|
|
|
|
}),
|
|
|
|
Succeeded());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_TRUE(ExpectedUndefVarNames.empty()) << toString(ExpectedUndefVarNames);
|
|
|
|
}
|
|
|
|
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
TEST_F(FileCheckTest, NumericVariable) {
|
2020-04-04 08:02:45 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
|
[FileCheck] Forbid using var defined on same line
Summary:
Commit r366897 introduced the possibility to set a variable from an
expression, such as [[#VAR2:VAR1+3]]. While introducing this feature, it
introduced extra logic to allow using such a variable on the same line
later on. Unfortunately that extra logic is flawed as it relies on a
mapping from variable to expression defining it when the mapping is from
variable definition to expression. This flaw causes among other issues
PR42896.
This commit avoids the problem by forbidding all use of a variable
defined on the same line, and removes the now useless logic. Redesign
will be done in a later commit because it will require some amount of
refactoring first for the solution to be clean. One example is the need
for some sort of transaction mechanism to set a variable temporarily and
from an expression and rollback if the CHECK pattern does not match so
that diagnostics show the right variable values.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66141
llvm-svn: 370663
2019-09-02 22:04:00 +08:00
|
|
|
// Undefined variable: getValue and eval fail, error returned by eval holds
|
|
|
|
// the name of the undefined variable.
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
NumericVariable FooVar("FOO",
|
|
|
|
ExpressionFormat(ExpressionFormat::Kind::Unsigned), 1);
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
EXPECT_EQ("FOO", FooVar.getName());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(FooVar.getImplicitFormat(), ExpressionFormat::Kind::Unsigned);
|
2019-12-12 07:48:01 +08:00
|
|
|
NumericVariableUse FooVarUse("FOO", &FooVar);
|
2020-04-04 08:02:45 +08:00
|
|
|
Expected<ExpressionFormat> ImplicitFormat = FooVarUse.getImplicitFormat(SM);
|
|
|
|
ASSERT_THAT_EXPECTED(ImplicitFormat, Succeeded());
|
|
|
|
EXPECT_EQ(*ImplicitFormat, ExpressionFormat::Kind::Unsigned);
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_FALSE(FooVar.getValue());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
Expected<ExpressionValue> EvalResult = FooVarUse.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"FOO"}, EvalResult.takeError());
|
[FileCheck] Fix numeric variable redefinition
Summary:
Commit r365249 changed usage of FileCheckNumericVariable to have one
instance of that class per variable as opposed to one instance per
definition of a given variable as was done before. However, it retained
the safety check in setValue that it should only be called with the
variable unset, even after r365625.
However this causes assert failure when a non-pseudo variable is being
redefined. And while redefinition of @LINE at each CHECK line work in
the general case, it caused problem when a substitution failed (fixed in
r365624) and still causes problem when a CHECK line does not match since
@LINE's value is cleared after substitutions in match() happened but
printSubstitutions also attempts a substitution.
This commit solves the root of the problem by changing setValue to set a
new value regardless of whether a value was set or not, thus fixing all
the aforementioned issues.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64882
llvm-svn: 366434
2019-07-18 21:39:04 +08:00
|
|
|
|
2020-07-29 06:09:47 +08:00
|
|
|
// Defined variable without string: only getValue and eval return value set.
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
FooVar.setValue(ExpressionValue(42u));
|
|
|
|
Optional<ExpressionValue> Value = FooVar.getValue();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_TRUE(Value);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(42, cantFail(Value->getSignedValue()));
|
2020-07-29 06:09:47 +08:00
|
|
|
EXPECT_FALSE(FooVar.getStringValue());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EvalResult = FooVarUse.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(EvalResult, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(42, cantFail(EvalResult->getSignedValue()));
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
2020-07-29 06:09:47 +08:00
|
|
|
// Defined variable with string: getValue, eval, and getStringValue return
|
|
|
|
// value set.
|
|
|
|
StringRef StringValue = "925";
|
|
|
|
FooVar.setValue(ExpressionValue(925u), StringValue);
|
|
|
|
Value = FooVar.getValue();
|
|
|
|
ASSERT_TRUE(Value);
|
|
|
|
EXPECT_EQ(925, cantFail(Value->getSignedValue()));
|
|
|
|
// getStringValue should return the same memory not just the same characters.
|
|
|
|
EXPECT_EQ(StringValue.begin(), FooVar.getStringValue().getValue().begin());
|
|
|
|
EXPECT_EQ(StringValue.end(), FooVar.getStringValue().getValue().end());
|
|
|
|
EvalResult = FooVarUse.eval();
|
|
|
|
ASSERT_THAT_EXPECTED(EvalResult, Succeeded());
|
|
|
|
EXPECT_EQ(925, cantFail(EvalResult->getSignedValue()));
|
|
|
|
EXPECT_EQ(925, cantFail(EvalResult->getSignedValue()));
|
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
// Clearing variable: getValue and eval fail. Error returned by eval holds
|
|
|
|
// the name of the cleared variable.
|
[FileCheck] Simplify numeric variable interface
Summary:
This patch simplifies 2 aspects in the FileCheckNumericVariable code.
First, setValue() method is turned into a void function since being
called only on undefined variable is an invariant and is now asserted
rather than returned. This remove the assert from the callers.
Second, clearValue() method is also turned into a void function since
the only caller does not check its return value since it may be trying
to clear the value of variable that is already cleared without this
being noteworthy.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64231
> llvm-svn: 365249
llvm-svn: 365625
2019-07-10 20:49:28 +08:00
|
|
|
FooVar.clearValue();
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
EXPECT_FALSE(FooVar.getValue());
|
2020-07-29 06:09:47 +08:00
|
|
|
EXPECT_FALSE(FooVar.getStringValue());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EvalResult = FooVarUse.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"FOO"}, EvalResult.takeError());
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
}
|
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
TEST_F(FileCheckTest, Binop) {
|
2020-04-04 08:02:45 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
|
|
|
|
StringRef ExprStr = bufferize(SM, "FOO+BAR");
|
|
|
|
StringRef FooStr = ExprStr.take_front(3);
|
|
|
|
NumericVariable FooVar(FooStr,
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionFormat(ExpressionFormat::Kind::Unsigned), 1);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
FooVar.setValue(ExpressionValue(42u));
|
2019-12-12 07:48:01 +08:00
|
|
|
std::unique_ptr<NumericVariableUse> FooVarUse =
|
2020-04-04 08:02:45 +08:00
|
|
|
std::make_unique<NumericVariableUse>(FooStr, &FooVar);
|
|
|
|
StringRef BarStr = ExprStr.take_back(3);
|
|
|
|
NumericVariable BarVar(BarStr,
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionFormat(ExpressionFormat::Kind::Unsigned), 2);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
BarVar.setValue(ExpressionValue(18u));
|
2019-12-12 07:48:01 +08:00
|
|
|
std::unique_ptr<NumericVariableUse> BarVarUse =
|
2020-04-04 08:02:45 +08:00
|
|
|
std::make_unique<NumericVariableUse>(BarStr, &BarVar);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
binop_eval_t doAdd = operator+;
|
2020-04-04 08:02:45 +08:00
|
|
|
BinaryOperation Binop(ExprStr, doAdd, std::move(FooVarUse),
|
|
|
|
std::move(BarVarUse));
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Defined variables: eval returns right value; implicit format is as
|
|
|
|
// expected.
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
Expected<ExpressionValue> Value = Binop.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(Value, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(60, cantFail(Value->getSignedValue()));
|
2020-04-04 08:02:45 +08:00
|
|
|
Expected<ExpressionFormat> ImplicitFormat = Binop.getImplicitFormat(SM);
|
|
|
|
ASSERT_THAT_EXPECTED(ImplicitFormat, Succeeded());
|
|
|
|
EXPECT_EQ(*ImplicitFormat, ExpressionFormat::Kind::Unsigned);
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
// 1 undefined variable: eval fails, error contains name of undefined
|
|
|
|
// variable.
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
FooVar.clearValue();
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
Value = Binop.eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"FOO"}, Value.takeError());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
|
|
|
|
// 2 undefined variables: eval fails, error contains names of all undefined
|
|
|
|
// variables.
|
|
|
|
BarVar.clearValue();
|
|
|
|
Value = Binop.eval();
|
|
|
|
expectUndefErrors({"FOO", "BAR"}, Value.takeError());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
|
|
|
// Literal + Variable has format of variable.
|
2020-04-04 08:02:45 +08:00
|
|
|
ExprStr = bufferize(SM, "FOO+18");
|
|
|
|
FooStr = ExprStr.take_front(3);
|
|
|
|
StringRef EighteenStr = ExprStr.take_back(2);
|
|
|
|
FooVarUse = std::make_unique<NumericVariableUse>(FooStr, &FooVar);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
std::unique_ptr<ExpressionLiteral> Eighteen =
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
std::make_unique<ExpressionLiteral>(EighteenStr, 18u);
|
2020-04-04 08:02:45 +08:00
|
|
|
Binop = BinaryOperation(ExprStr, doAdd, std::move(FooVarUse),
|
|
|
|
std::move(Eighteen));
|
|
|
|
ImplicitFormat = Binop.getImplicitFormat(SM);
|
|
|
|
ASSERT_THAT_EXPECTED(ImplicitFormat, Succeeded());
|
|
|
|
EXPECT_EQ(*ImplicitFormat, ExpressionFormat::Kind::Unsigned);
|
|
|
|
ExprStr = bufferize(SM, "18+FOO");
|
|
|
|
FooStr = ExprStr.take_back(3);
|
|
|
|
EighteenStr = ExprStr.take_front(2);
|
|
|
|
FooVarUse = std::make_unique<NumericVariableUse>(FooStr, &FooVar);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
Eighteen = std::make_unique<ExpressionLiteral>(EighteenStr, 18u);
|
2020-04-04 08:02:45 +08:00
|
|
|
Binop = BinaryOperation(ExprStr, doAdd, std::move(Eighteen),
|
|
|
|
std::move(FooVarUse));
|
|
|
|
ImplicitFormat = Binop.getImplicitFormat(SM);
|
|
|
|
ASSERT_THAT_EXPECTED(ImplicitFormat, Succeeded());
|
|
|
|
EXPECT_EQ(*ImplicitFormat, ExpressionFormat::Kind::Unsigned);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
|
|
|
// Variables with different implicit format conflict.
|
2020-04-04 08:02:45 +08:00
|
|
|
ExprStr = bufferize(SM, "FOO+BAZ");
|
|
|
|
FooStr = ExprStr.take_front(3);
|
|
|
|
StringRef BazStr = ExprStr.take_back(3);
|
|
|
|
NumericVariable BazVar(BazStr,
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionFormat(ExpressionFormat::Kind::HexLower), 3);
|
2020-04-04 08:02:45 +08:00
|
|
|
FooVarUse = std::make_unique<NumericVariableUse>(FooStr, &FooVar);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
std::unique_ptr<NumericVariableUse> BazVarUse =
|
2020-04-04 08:02:45 +08:00
|
|
|
std::make_unique<NumericVariableUse>(BazStr, &BazVar);
|
|
|
|
Binop = BinaryOperation(ExprStr, doAdd, std::move(FooVarUse),
|
|
|
|
std::move(BazVarUse));
|
|
|
|
ImplicitFormat = Binop.getImplicitFormat(SM);
|
|
|
|
expectDiagnosticError(
|
|
|
|
"implicit format conflict between 'FOO' (%u) and 'BAZ' (%x), "
|
|
|
|
"need an explicit format specifier",
|
|
|
|
ImplicitFormat.takeError());
|
|
|
|
|
|
|
|
// All variable conflicts are reported.
|
|
|
|
ExprStr = bufferize(SM, "(FOO+BAZ)+(FOO+QUUX)");
|
|
|
|
StringRef Paren1ExprStr = ExprStr.substr(1, 7);
|
|
|
|
FooStr = Paren1ExprStr.take_front(3);
|
|
|
|
BazStr = Paren1ExprStr.take_back(3);
|
|
|
|
StringRef Paren2ExprStr = ExprStr.substr(ExprStr.rfind('(') + 1, 8);
|
|
|
|
StringRef FooStr2 = Paren2ExprStr.take_front(3);
|
|
|
|
StringRef QuuxStr = Paren2ExprStr.take_back(4);
|
|
|
|
FooVarUse = std::make_unique<NumericVariableUse>(FooStr, &FooVar);
|
|
|
|
BazVarUse = std::make_unique<NumericVariableUse>(BazStr, &BazVar);
|
|
|
|
std::unique_ptr<NumericVariableUse> FooVarUse2 =
|
|
|
|
std::make_unique<NumericVariableUse>(FooStr2, &FooVar);
|
|
|
|
NumericVariable QuuxVar(
|
|
|
|
QuuxStr, ExpressionFormat(ExpressionFormat::Kind::HexLower), 4);
|
|
|
|
std::unique_ptr<NumericVariableUse> QuuxVarUse =
|
|
|
|
std::make_unique<NumericVariableUse>(QuuxStr, &QuuxVar);
|
|
|
|
std::unique_ptr<BinaryOperation> Binop1 = std::make_unique<BinaryOperation>(
|
|
|
|
ExprStr.take_front(9), doAdd, std::move(FooVarUse), std::move(BazVarUse));
|
|
|
|
std::unique_ptr<BinaryOperation> Binop2 = std::make_unique<BinaryOperation>(
|
|
|
|
ExprStr.take_back(10), doAdd, std::move(FooVarUse2),
|
|
|
|
std::move(QuuxVarUse));
|
|
|
|
std::unique_ptr<BinaryOperation> OuterBinop =
|
|
|
|
std::make_unique<BinaryOperation>(ExprStr, doAdd, std::move(Binop1),
|
|
|
|
std::move(Binop2));
|
|
|
|
ImplicitFormat = OuterBinop->getImplicitFormat(SM);
|
|
|
|
expectSameErrors<ErrorDiagnostic>(
|
2020-08-09 02:45:24 +08:00
|
|
|
{("implicit format conflict between 'FOO' (%u) and 'BAZ' (%x), need an "
|
|
|
|
"explicit format specifier"),
|
|
|
|
("implicit format conflict between 'FOO' (%u) and 'QUUX' (%x), need an "
|
|
|
|
"explicit format specifier")},
|
2020-04-04 08:02:45 +08:00
|
|
|
ImplicitFormat.takeError());
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
}
|
|
|
|
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
TEST_F(FileCheckTest, ValidVarNameStart) {
|
2019-12-12 07:48:01 +08:00
|
|
|
EXPECT_TRUE(Pattern::isValidVarNameStart('a'));
|
|
|
|
EXPECT_TRUE(Pattern::isValidVarNameStart('G'));
|
|
|
|
EXPECT_TRUE(Pattern::isValidVarNameStart('_'));
|
|
|
|
EXPECT_FALSE(Pattern::isValidVarNameStart('2'));
|
|
|
|
EXPECT_FALSE(Pattern::isValidVarNameStart('$'));
|
|
|
|
EXPECT_FALSE(Pattern::isValidVarNameStart('@'));
|
|
|
|
EXPECT_FALSE(Pattern::isValidVarNameStart('+'));
|
|
|
|
EXPECT_FALSE(Pattern::isValidVarNameStart('-'));
|
|
|
|
EXPECT_FALSE(Pattern::isValidVarNameStart(':'));
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ParseVar) {
|
2019-06-20 07:47:10 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
StringRef OrigVarName = bufferize(SM, "GoodVar42");
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
StringRef VarName = OrigVarName;
|
2019-12-12 07:48:01 +08:00
|
|
|
Expected<Pattern::VariableProperties> ParsedVarResult =
|
|
|
|
Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, OrigVarName);
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_TRUE(VarName.empty());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = OrigVarName = bufferize(SM, "$GoodGlobalVar");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, OrigVarName);
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_TRUE(VarName.empty());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = OrigVarName = bufferize(SM, "@GoodPseudoVar");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, OrigVarName);
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_TRUE(VarName.empty());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_TRUE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = bufferize(SM, "42BadVar");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("invalid variable name", ParsedVarResult.takeError());
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = bufferize(SM, "$@");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("invalid variable name", ParsedVarResult.takeError());
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = OrigVarName = bufferize(SM, "B@dVar");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_EQ(VarName, OrigVarName.substr(1));
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, "B");
|
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = OrigVarName = bufferize(SM, "B$dVar");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_EQ(VarName, OrigVarName.substr(1));
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, "B");
|
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = bufferize(SM, "BadVar+");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_EQ(VarName, "+");
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, "BadVar");
|
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = bufferize(SM, "BadVar-");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_EQ(VarName, "-");
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, "BadVar");
|
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
VarName = bufferize(SM, "BadVar:");
|
2019-12-12 07:48:01 +08:00
|
|
|
ParsedVarResult = Pattern::parseVariable(VarName, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ParsedVarResult, Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
EXPECT_EQ(VarName, ":");
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ(ParsedVarResult->Name, "BadVar");
|
|
|
|
EXPECT_FALSE(ParsedVarResult->IsPseudo);
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
}
|
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
static void expectNotFoundError(Error Err) {
|
|
|
|
expectError<NotFoundError>("String not found in input", std::move(Err));
|
|
|
|
}
|
|
|
|
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
class PatternTester {
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
private:
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
size_t LineNumber = 1;
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
SourceMgr SM;
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
FileCheckRequest Req;
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
FileCheckPatternContext Context;
|
2020-01-15 08:02:15 +08:00
|
|
|
Pattern P{Check::CheckPlain, &Context, LineNumber};
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
|
|
|
|
public:
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
PatternTester() {
|
2020-05-14 18:32:58 +08:00
|
|
|
std::vector<StringRef> GlobalDefines = {"#FOO=42", "BAR=BAZ", "#add=7"};
|
[FileCheck] Use ASSERT for fatal unit tests
Summary:
A number of EXPECT statements in FileCheck's unit tests are dependent
from results of other values being tested. This commit changes those
earlier test to use ASSERT instead of EXPECT to avoid cascade errors
when they are all related to the same issue.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64921
> llvm-svn: 366862
llvm-svn: 366899
2019-07-24 20:38:34 +08:00
|
|
|
// An ASSERT_FALSE would make more sense but cannot be used in a
|
|
|
|
// constructor.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_ERROR(Context.defineCmdlineVariables(GlobalDefines, SM),
|
|
|
|
Succeeded());
|
[FileCheck] Share variable instance among uses
Summary:
This patch changes expression support to use one instance of
FileCheckNumericVariable per numeric variable rather than one per
variable and per definition. The current system was only necessary for
the last patch of the numeric expression support patch series in order
to handle a line using a variable defined earlier on the same line from
the input text. However this can be dealt more efficiently.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64229
llvm-svn: 365220
2019-07-06 00:25:46 +08:00
|
|
|
Context.createLineVariable();
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
// Call parsePattern to have @LINE defined.
|
|
|
|
P.parsePattern("N/A", "CHECK", SM, Req);
|
|
|
|
// parsePattern does not expect to be called twice for the same line and
|
|
|
|
// will set FixedStr and RegExStr incorrectly if it is. Therefore prepare
|
|
|
|
// a pattern for a different line.
|
|
|
|
initNextPattern();
|
|
|
|
}
|
|
|
|
|
|
|
|
void initNextPattern() {
|
2020-01-15 08:02:15 +08:00
|
|
|
P = Pattern(Check::CheckPlain, &Context, ++LineNumber);
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
}
|
|
|
|
|
2020-01-15 08:02:15 +08:00
|
|
|
size_t getLineNumber() const { return LineNumber; }
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
Expected<std::unique_ptr<Expression>>
|
2020-01-16 20:14:13 +08:00
|
|
|
parseSubst(StringRef Expr, bool IsLegacyLineExpr = false) {
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
StringRef ExprBufferRef = bufferize(SM, Expr);
|
2019-12-12 07:48:01 +08:00
|
|
|
Optional<NumericVariable *> DefinedNumericVariable;
|
2020-01-16 20:14:13 +08:00
|
|
|
return P.parseNumericSubstitutionBlock(
|
|
|
|
ExprBufferRef, DefinedNumericVariable, IsLegacyLineExpr, LineNumber,
|
|
|
|
&Context, SM);
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
}
|
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
bool parsePattern(StringRef Pattern) {
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
StringRef PatBufferRef = bufferize(SM, Pattern);
|
|
|
|
return P.parsePattern(PatBufferRef, "CHECK", SM, Req);
|
|
|
|
}
|
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
Expected<size_t> match(StringRef Buffer) {
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
StringRef BufferRef = bufferize(SM, Buffer);
|
|
|
|
size_t MatchLen;
|
2020-01-16 20:14:13 +08:00
|
|
|
return P.match(BufferRef, MatchLen, SM);
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
}
|
2020-07-29 06:09:47 +08:00
|
|
|
|
|
|
|
void printVariableDefs(FileCheckDiag::MatchType MatchTy,
|
|
|
|
std::vector<FileCheckDiag> &Diags) {
|
|
|
|
P.printVariableDefs(SM, MatchTy, &Diags);
|
|
|
|
}
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
};
|
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
TEST_F(FileCheckTest, ParseNumericSubstitutionBlock) {
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
PatternTester Tester;
|
|
|
|
|
|
|
|
// Variable definition.
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("invalid variable name",
|
|
|
|
Tester.parseSubst("%VAR:").takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("definition of pseudo numeric variable unsupported",
|
|
|
|
Tester.parseSubst("@LINE:").takeError());
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("string variable with name 'BAR' already exists",
|
|
|
|
Tester.parseSubst("BAR:").takeError());
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("unexpected characters after numeric variable name",
|
|
|
|
Tester.parseSubst("VAR GARBAGE:").takeError());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Change of format.
|
|
|
|
expectDiagnosticError("format different from previous variable definition",
|
|
|
|
Tester.parseSubst("%X,FOO:").takeError());
|
|
|
|
|
|
|
|
// Invalid format.
|
|
|
|
expectDiagnosticError("invalid matching format specification in expression",
|
|
|
|
Tester.parseSubst("X,VAR1:").takeError());
|
|
|
|
expectDiagnosticError("invalid format specifier in expression",
|
|
|
|
Tester.parseSubst("%F,VAR1:").takeError());
|
|
|
|
expectDiagnosticError("invalid matching format specification in expression",
|
|
|
|
Tester.parseSubst("%X a,VAR1:").takeError());
|
|
|
|
|
|
|
|
// Acceptable variable definition.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("VAR1:"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst(" VAR2:"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("VAR3 :"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("VAR3: "), Succeeded());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
|
|
|
// Acceptable variable definition with format specifier. Use parsePattern for
|
|
|
|
// variables whose definition needs to be visible for later checks.
|
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[#%u, VAR_UNSIGNED:]]"));
|
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[#%x, VAR_LOWER_HEX:]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%X, VAR_UPPER_HEX:"), Succeeded());
|
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
// Acceptable variable definition with precision specifier.
|
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[#%.8X, PADDED_ADDR:]]"));
|
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[#%.8, PADDED_NUM:]]"));
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Acceptable variable definition from a numeric expression.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOOBAR: FOO+1"), Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Numeric expression. Switch to next line to make above valid definition
|
|
|
|
// available in expressions.
|
|
|
|
Tester.initNextPattern();
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Invalid variable name.
|
2019-07-17 23:15:52 +08:00
|
|
|
expectDiagnosticError("invalid matching constraint or operand format",
|
2020-01-16 20:14:13 +08:00
|
|
|
Tester.parseSubst("%VAR").takeError());
|
|
|
|
|
|
|
|
expectDiagnosticError("invalid pseudo numeric variable '@FOO'",
|
|
|
|
Tester.parseSubst("@FOO").takeError());
|
|
|
|
|
|
|
|
// parsePattern() is used here instead of parseSubst() for the variable to be
|
|
|
|
// recorded in GlobalNumericVariableTable and thus appear defined to
|
|
|
|
// parseNumericVariableUse(). Note that the same pattern object is used for
|
|
|
|
// the parsePattern() and parseSubst() since no initNextPattern() is called,
|
|
|
|
// thus appearing as being on the same line from the pattern's point of view.
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#SAME_LINE_VAR:]]"));
|
|
|
|
expectDiagnosticError("numeric variable 'SAME_LINE_VAR' defined earlier in "
|
|
|
|
"the same CHECK directive",
|
|
|
|
Tester.parseSubst("SAME_LINE_VAR").takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Invalid use of variable defined on the same line from an expression not
|
|
|
|
// using any variable defined on the same line.
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#SAME_LINE_EXPR_VAR:@LINE+1]]"));
|
|
|
|
expectDiagnosticError("numeric variable 'SAME_LINE_EXPR_VAR' defined earlier "
|
|
|
|
"in the same CHECK directive",
|
|
|
|
Tester.parseSubst("SAME_LINE_EXPR_VAR").takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Valid use of undefined variable which creates the variable and record it
|
|
|
|
// in GlobalNumericVariableTable.
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(Tester.parseSubst("UNDEF"), Succeeded());
|
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[UNDEF:.*]]"));
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Invalid literal.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("unsupported operation 'U'",
|
|
|
|
Tester.parseSubst("42U").takeError());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
// Valid empty expression.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst(""), Succeeded());
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
|
2019-07-17 23:15:52 +08:00
|
|
|
// Invalid equality matching constraint with empty expression.
|
|
|
|
expectDiagnosticError("empty numeric expression should not have a constraint",
|
|
|
|
Tester.parseSubst("==").takeError());
|
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Valid single operand expression.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOO"), Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("18"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst(std::to_string(MaxUint64)),
|
|
|
|
Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("0x12"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("-30"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst(std::to_string(MinInt64)),
|
|
|
|
Succeeded());
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
|
2019-07-17 23:15:52 +08:00
|
|
|
// Valid optional matching constraint.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("==FOO"), Succeeded());
|
|
|
|
|
|
|
|
// Invalid matching constraint.
|
|
|
|
expectDiagnosticError("invalid matching constraint or operand format",
|
|
|
|
Tester.parseSubst("+=FOO").takeError());
|
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Invalid format.
|
|
|
|
expectDiagnosticError("invalid matching format specification in expression",
|
|
|
|
Tester.parseSubst("X,FOO:").takeError());
|
|
|
|
expectDiagnosticError("invalid format specifier in expression",
|
|
|
|
Tester.parseSubst("%F,FOO").takeError());
|
|
|
|
expectDiagnosticError("invalid matching format specification in expression",
|
|
|
|
Tester.parseSubst("%X a,FOO").takeError());
|
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Valid expression with 2 or more operands.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOO+3"), Succeeded());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOO+0xC"), Succeeded());
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOO-3+FOO"), Succeeded());
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("unsupported operation '/'",
|
|
|
|
Tester.parseSubst("@LINE/2").takeError());
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("missing operand in expression",
|
|
|
|
Tester.parseSubst("@LINE+").takeError());
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Errors in RHS operand are bubbled up by parseBinop() to
|
2020-01-16 20:14:13 +08:00
|
|
|
// parseNumericSubstitutionBlock().
|
2019-07-17 23:15:52 +08:00
|
|
|
expectDiagnosticError("invalid operand format",
|
2020-01-16 20:14:13 +08:00
|
|
|
Tester.parseSubst("@LINE+%VAR").takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Invalid legacy @LINE expression with non literal rhs.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError(
|
2019-07-17 23:15:52 +08:00
|
|
|
"invalid operand format",
|
2020-01-16 20:14:13 +08:00
|
|
|
Tester.parseSubst("@LINE+@LINE", /*IsLegacyNumExpr=*/true).takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Invalid legacy @LINE expression made of a single literal.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError(
|
|
|
|
"invalid variable name",
|
|
|
|
Tester.parseSubst("2", /*IsLegacyNumExpr=*/true).takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Invalid hex literal in legacy @LINE expression.
|
|
|
|
expectDiagnosticError(
|
|
|
|
"unexpected characters at end of expression 'xC'",
|
|
|
|
Tester.parseSubst("@LINE+0xC", /*LegacyLineExpr=*/true).takeError());
|
|
|
|
|
|
|
|
// Valid expression with format specifier.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%u, FOO"), Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%d, FOO"), Succeeded());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%x, FOO"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%X, FOO"), Succeeded());
|
|
|
|
|
2020-06-11 23:14:24 +08:00
|
|
|
// Valid expression with precision specifier.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%.8u, FOO"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%.8, FOO"), Succeeded());
|
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Valid legacy @LINE expression.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("@LINE+2", /*IsLegacyNumExpr=*/true),
|
|
|
|
Succeeded());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Invalid legacy @LINE expression with more than 2 operands.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError(
|
|
|
|
"unexpected characters at end of expression '+@LINE'",
|
|
|
|
Tester.parseSubst("@LINE+2+@LINE", /*IsLegacyNumExpr=*/true).takeError());
|
|
|
|
expectDiagnosticError(
|
|
|
|
"unexpected characters at end of expression '+2'",
|
|
|
|
Tester.parseSubst("@LINE+2+2", /*IsLegacyNumExpr=*/true).takeError());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
|
|
|
// Valid expression with several variables when their implicit formats do not
|
|
|
|
// conflict.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOO+VAR_UNSIGNED"), Succeeded());
|
|
|
|
|
|
|
|
// Valid implicit format conflict in presence of explicit formats.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("%X,FOO+VAR_LOWER_HEX"), Succeeded());
|
|
|
|
|
|
|
|
// Implicit format conflict.
|
|
|
|
expectDiagnosticError(
|
2020-04-04 08:02:45 +08:00
|
|
|
"implicit format conflict between 'FOO' (%u) and "
|
|
|
|
"'VAR_LOWER_HEX' (%x), need an explicit format specifier",
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
Tester.parseSubst("FOO+VAR_LOWER_HEX").takeError());
|
2020-05-27 22:13:42 +08:00
|
|
|
|
|
|
|
// Simple parenthesized expressions:
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("(1)"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("(1+1)"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("(1)+1"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("((1)+1)"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("((1)+X)"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("((X)+Y)"), Succeeded());
|
|
|
|
|
|
|
|
expectDiagnosticError("missing operand in expression",
|
|
|
|
Tester.parseSubst("(").takeError());
|
|
|
|
expectDiagnosticError("missing ')' at end of nested expression",
|
|
|
|
Tester.parseSubst("(1").takeError());
|
|
|
|
expectDiagnosticError("missing operand in expression",
|
|
|
|
Tester.parseSubst("(1+").takeError());
|
|
|
|
expectDiagnosticError("missing ')' at end of nested expression",
|
|
|
|
Tester.parseSubst("(1+1").takeError());
|
|
|
|
expectDiagnosticError("missing ')' at end of nested expression",
|
|
|
|
Tester.parseSubst("((1+2+3").takeError());
|
|
|
|
expectDiagnosticError("missing ')' at end of nested expression",
|
|
|
|
Tester.parseSubst("((1+2)+3").takeError());
|
|
|
|
|
|
|
|
// Test missing operation between operands:
|
|
|
|
expectDiagnosticError("unsupported operation '('",
|
|
|
|
Tester.parseSubst("(1)(2)").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation '('",
|
|
|
|
Tester.parseSubst("2(X)").takeError());
|
|
|
|
|
|
|
|
// Test more closing than opening parentheses. The diagnostic messages are
|
|
|
|
// not ideal, but for now simply check that we reject invalid input.
|
2019-07-17 23:15:52 +08:00
|
|
|
expectDiagnosticError("invalid matching constraint or operand format",
|
2020-05-27 22:13:42 +08:00
|
|
|
Tester.parseSubst(")").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation ')'",
|
|
|
|
Tester.parseSubst("1)").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation ')'",
|
|
|
|
Tester.parseSubst("(1+2))").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation ')'",
|
|
|
|
Tester.parseSubst("(2))").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation ')'",
|
|
|
|
Tester.parseSubst("(1))(").takeError());
|
2020-05-14 18:32:58 +08:00
|
|
|
|
|
|
|
// Valid expression with function call.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add(FOO,3)"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add (FOO,3)"), Succeeded());
|
|
|
|
// Valid expression with nested function call.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add(FOO, min(BAR,10))"), Succeeded());
|
|
|
|
// Valid expression with function call taking expression as argument.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add(FOO, (BAR+10) + 3)"),
|
|
|
|
Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add(FOO, min (BAR,10) + 3)"),
|
|
|
|
Succeeded());
|
|
|
|
// Valid expression with variable named the same as a function.
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add+FOO"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("FOO+add"), Succeeded());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.parseSubst("add(add,add)+add"), Succeeded());
|
|
|
|
|
|
|
|
// Malformed call syntax.
|
|
|
|
expectDiagnosticError("missing ')' at end of call expression",
|
|
|
|
Tester.parseSubst("add(FOO,(BAR+7)").takeError());
|
|
|
|
expectDiagnosticError("missing ')' at end of call expression",
|
|
|
|
Tester.parseSubst("add(FOO,min(BAR,7)").takeError());
|
|
|
|
expectDiagnosticError("missing argument",
|
|
|
|
Tester.parseSubst("add(FOO,)").takeError());
|
|
|
|
expectDiagnosticError("missing argument",
|
|
|
|
Tester.parseSubst("add(,FOO)").takeError());
|
|
|
|
expectDiagnosticError("missing argument",
|
|
|
|
Tester.parseSubst("add(FOO,,3)").takeError());
|
|
|
|
|
|
|
|
// Valid call, but to an unknown function.
|
|
|
|
expectDiagnosticError("call to undefined function 'bogus_function'",
|
|
|
|
Tester.parseSubst("bogus_function(FOO,3)").takeError());
|
|
|
|
expectDiagnosticError("call to undefined function '@add'",
|
|
|
|
Tester.parseSubst("@add(2,3)").takeError());
|
|
|
|
expectDiagnosticError("call to undefined function '$add'",
|
|
|
|
Tester.parseSubst("$add(2,3)").takeError());
|
|
|
|
expectDiagnosticError("call to undefined function 'FOO'",
|
|
|
|
Tester.parseSubst("FOO(2,3)").takeError());
|
|
|
|
expectDiagnosticError("call to undefined function 'FOO'",
|
|
|
|
Tester.parseSubst("FOO (2,3)").takeError());
|
|
|
|
|
|
|
|
// Valid call, but with incorrect argument count.
|
|
|
|
expectDiagnosticError("function 'add' takes 2 arguments but 1 given",
|
|
|
|
Tester.parseSubst("add(FOO)").takeError());
|
|
|
|
expectDiagnosticError("function 'add' takes 2 arguments but 3 given",
|
|
|
|
Tester.parseSubst("add(FOO,3,4)").takeError());
|
|
|
|
|
|
|
|
// Valid call, but not part of a valid expression.
|
|
|
|
expectDiagnosticError("unsupported operation 'a'",
|
|
|
|
Tester.parseSubst("2add(FOO,2)").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation 'a'",
|
|
|
|
Tester.parseSubst("FOO add(FOO,2)").takeError());
|
|
|
|
expectDiagnosticError("unsupported operation 'a'",
|
|
|
|
Tester.parseSubst("add(FOO,2)add(FOO,2)").takeError());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, ParsePattern) {
|
|
|
|
PatternTester Tester;
|
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Invalid space in string substitution.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[ BAR]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Invalid variable name in string substitution.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[42INVALID]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Invalid string variable definition.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[@PAT:]]"));
|
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[PAT+2:]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
|
|
|
// Collision with numeric variable.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[FOO:]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Valid use of string variable.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[BAR]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Valid string variable definition.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[PAT:[0-9]+]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Invalid numeric substitution.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[#42INVALID]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Valid numeric substitution.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[#FOO]]"));
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
|
|
|
|
// Valid legacy @LINE expression.
|
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[@LINE+2]]"));
|
|
|
|
|
|
|
|
// Invalid legacy @LINE expression with non decimal literal.
|
|
|
|
EXPECT_TRUE(Tester.parsePattern("[[@LINE+0x3]]"));
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(FileCheckTest, Match) {
|
|
|
|
PatternTester Tester;
|
|
|
|
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
// Check a substitution error is diagnosed.
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#%u, -1]]"));
|
|
|
|
expectDiagnosticError(
|
|
|
|
"unable to substitute variable or numeric expression: overflow error",
|
|
|
|
Tester.match("").takeError());
|
|
|
|
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
// Check matching an empty expression only matches a number.
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
Tester.initNextPattern();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#]]"));
|
|
|
|
expectNotFoundError(Tester.match("FAIL").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Check matching a definition only matches a number with the right format.
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
Tester.initNextPattern();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR:]]"));
|
|
|
|
expectNotFoundError(Tester.match("FAIL").takeError());
|
|
|
|
expectNotFoundError(Tester.match("").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
Tester.initNextPattern();
|
|
|
|
Tester.parsePattern("[[#%u,NUMVAR_UNSIGNED:]]");
|
|
|
|
expectNotFoundError(Tester.match("C").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("20"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
Tester.parsePattern("[[#%x,NUMVAR_LOWER_HEX:]]");
|
|
|
|
expectNotFoundError(Tester.match("g").takeError());
|
|
|
|
expectNotFoundError(Tester.match("C").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("c"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
Tester.parsePattern("[[#%X,NUMVAR_UPPER_HEX:]]");
|
|
|
|
expectNotFoundError(Tester.match("H").takeError());
|
|
|
|
expectNotFoundError(Tester.match("b").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("B"), Succeeded());
|
|
|
|
|
|
|
|
// Check matching expressions with no explicit format matches the values in
|
|
|
|
// the right format.
|
|
|
|
Tester.initNextPattern();
|
|
|
|
Tester.parsePattern("[[#NUMVAR_UNSIGNED-5]]");
|
|
|
|
expectNotFoundError(Tester.match("f").takeError());
|
|
|
|
expectNotFoundError(Tester.match("F").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("15"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
Tester.parsePattern("[[#NUMVAR_LOWER_HEX+1]]");
|
|
|
|
expectNotFoundError(Tester.match("13").takeError());
|
|
|
|
expectNotFoundError(Tester.match("D").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("d"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
Tester.parsePattern("[[#NUMVAR_UPPER_HEX+1]]");
|
|
|
|
expectNotFoundError(Tester.match("12").takeError());
|
|
|
|
expectNotFoundError(Tester.match("c").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("C"), Succeeded());
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Check matching an undefined variable returns a NotFound error.
|
|
|
|
Tester.initNextPattern();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("100"));
|
|
|
|
expectNotFoundError(Tester.match("101").takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Check matching the defined variable matches the correct number only.
|
|
|
|
Tester.initNextPattern();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
// Check matching several substitutions does not match them independently.
|
FileCheck [6/12]: Introduce numeric variable definition
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces support for defining
numeric variable in a CHECK directive.
This commit introduces support for defining numeric variable from a
litteral value in the input text. Numeric expressions can then use the
variable provided it is on a later line.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60386
llvm-svn: 362705
2019-06-06 21:21:06 +08:00
|
|
|
Tester.initNextPattern();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR]] [[#NUMVAR+2]]"));
|
|
|
|
expectNotFoundError(Tester.match("19 21").takeError());
|
|
|
|
expectNotFoundError(Tester.match("18 21").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18 20"), Succeeded());
|
[FileCheck] Fix @LINE value after match failure
Summary:
The value of the FileCheckNumericVariable class instance representing
the @LINE numeric variable is set and cleared respectively before and
after substitutions are made, if any. However, when a substitution
fails, the value is not cleared. This causes the next substitution of
@LINE later on to give the wrong value since setValue is a nop if the
value is already set. This is what caused failures after commit r365249.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64449
llvm-svn: 365624
2019-07-10 20:49:17 +08:00
|
|
|
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
// Check matching a numeric expression using @LINE after a match failure uses
|
[FileCheck] Fix @LINE value after match failure
Summary:
The value of the FileCheckNumericVariable class instance representing
the @LINE numeric variable is set and cleared respectively before and
after substitutions are made, if any. However, when a substitution
fails, the value is not cleared. This causes the next substitution of
@LINE later on to give the wrong value since setValue is a nop if the
value is already set. This is what caused failures after commit r365249.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64449
llvm-svn: 365624
2019-07-10 20:49:17 +08:00
|
|
|
// the correct value for @LINE.
|
|
|
|
Tester.initNextPattern();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#@LINE]]"));
|
2020-01-15 08:02:15 +08:00
|
|
|
// Ok, @LINE matches the current line number.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Tester.match(std::to_string(Tester.getLineNumber())),
|
|
|
|
Succeeded());
|
[FileCheck] Fix @LINE value after match failure
Summary:
The value of the FileCheckNumericVariable class instance representing
the @LINE numeric variable is set and cleared respectively before and
after substitutions are made, if any. However, when a substitution
fails, the value is not cleared. This causes the next substitution of
@LINE later on to give the wrong value since setValue is a nop if the
value is already set. This is what caused failures after commit r365249.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64449
llvm-svn: 365624
2019-07-10 20:49:17 +08:00
|
|
|
Tester.initNextPattern();
|
2020-01-15 08:02:15 +08:00
|
|
|
// Match with substitution failure.
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#UNKNOWN]]"));
|
|
|
|
expectUndefErrors({"UNKNOWN"}, Tester.match("FOO").takeError());
|
[FileCheck] Fix @LINE value after match failure
Summary:
The value of the FileCheckNumericVariable class instance representing
the @LINE numeric variable is set and cleared respectively before and
after substitutions are made, if any. However, when a substitution
fails, the value is not cleared. This causes the next substitution of
@LINE later on to give the wrong value since setValue is a nop if the
value is already set. This is what caused failures after commit r365249.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64449
llvm-svn: 365624
2019-07-10 20:49:17 +08:00
|
|
|
Tester.initNextPattern();
|
2020-01-15 08:02:15 +08:00
|
|
|
// Check that @LINE matches the later (given the calls to initNextPattern())
|
|
|
|
// line number.
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_FALSE(Tester.parsePattern("[[#@LINE]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match(std::to_string(Tester.getLineNumber())),
|
|
|
|
Succeeded());
|
FileCheck [3/12]: Stricter parsing of @LINE expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the @LINE expressions.
Rather than detect parsing errors at matching time, this commit adds
enhance parsing to detect issues with @LINE expressions at parse time
and diagnose them more accurately.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60383
llvm-svn: 359475
2019-04-30 01:46:26 +08:00
|
|
|
}
|
|
|
|
|
2020-05-27 22:13:42 +08:00
|
|
|
TEST_F(FileCheckTest, MatchParen) {
|
|
|
|
PatternTester Tester;
|
|
|
|
// Check simple parenthesized expressions
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR:]]"));
|
|
|
|
expectNotFoundError(Tester.match("FAIL").takeError());
|
|
|
|
expectNotFoundError(Tester.match("").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
|
|
|
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR + (2 + 2)]]"));
|
|
|
|
expectNotFoundError(Tester.match("21").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("22"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR + (2)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("20"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR+(2)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("20"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR+(NUMVAR)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("36"), Succeeded());
|
|
|
|
|
|
|
|
// Check nested parenthesized expressions:
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR+(2+(2))]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("22"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR+(2+(NUMVAR))]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("38"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR+((((NUMVAR))))]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("36"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR+((((NUMVAR)))-1)-1]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("34"), Succeeded());
|
|
|
|
|
|
|
|
// Parentheses can also be the first character after the '#':
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#(NUMVAR)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#(NUMVAR+2)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("20"), Succeeded());
|
|
|
|
}
|
|
|
|
|
2020-05-14 18:32:58 +08:00
|
|
|
TEST_F(FileCheckTest, MatchBuiltinFunctions) {
|
|
|
|
PatternTester Tester;
|
|
|
|
// Esnure #NUMVAR has the expected value.
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#NUMVAR:]]"));
|
|
|
|
expectNotFoundError(Tester.match("FAIL").takeError());
|
|
|
|
expectNotFoundError(Tester.match("").takeError());
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
|
|
|
|
|
|
|
// Check each builtin function generates the expected result.
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#add(NUMVAR,13)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("31"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
2020-06-01 18:09:58 +08:00
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#div(NUMVAR,3)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("6"), Succeeded());
|
2020-05-14 18:32:58 +08:00
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#max(NUMVAR,5)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#max(NUMVAR,99)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("99"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#min(NUMVAR,5)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("5"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#min(NUMVAR,99)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("18"), Succeeded());
|
2020-06-01 18:09:58 +08:00
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#mul(NUMVAR,3)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("54"), Succeeded());
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#sub(NUMVAR,7)]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("11"), Succeeded());
|
2020-05-14 18:32:58 +08:00
|
|
|
|
|
|
|
// Check nested function calls.
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#add(min(7,2),max(4,10))]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("12"), Succeeded());
|
|
|
|
|
|
|
|
// Check function call that uses a variable of the same name.
|
|
|
|
Tester.initNextPattern();
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[#add(add,add)+min (add,3)+add]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("24"), Succeeded());
|
|
|
|
}
|
|
|
|
|
FileCheck [4/12]: Introduce @LINE numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces the @LINE numeric
expressions.
This commit introduces a new syntax to express a relation a numeric
value in the input text must have with the line number of a given CHECK
pattern: [[#<@LINE numeric expression>]]. Further commits build on that
to express relations between several numeric values in the input text.
To help with naming, regular variables are renamed into pattern
variables and old @LINE expression syntax is referred to as legacy
numeric expression.
Compared to existing @LINE expressions, this new syntax allow arbitrary
spacing between the component of the expression. It offers otherwise the
same functionality but the commit serves to introduce some of the data
structure needed to support more general numeric expressions.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60384
llvm-svn: 359741
2019-05-02 08:04:38 +08:00
|
|
|
TEST_F(FileCheckTest, Substitution) {
|
|
|
|
SourceMgr SM;
|
|
|
|
FileCheckPatternContext Context;
|
2020-04-15 20:30:21 +08:00
|
|
|
EXPECT_THAT_ERROR(Context.defineCmdlineVariables({"FOO=BAR"}, SM),
|
2020-01-16 20:14:13 +08:00
|
|
|
Succeeded());
|
FileCheck [4/12]: Introduce @LINE numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces the @LINE numeric
expressions.
This commit introduces a new syntax to express a relation a numeric
value in the input text must have with the line number of a given CHECK
pattern: [[#<@LINE numeric expression>]]. Further commits build on that
to express relations between several numeric values in the input text.
To help with naming, regular variables are renamed into pattern
variables and old @LINE expression syntax is referred to as legacy
numeric expression.
Compared to existing @LINE expressions, this new syntax allow arbitrary
spacing between the component of the expression. It offers otherwise the
same functionality but the commit serves to introduce some of the data
structure needed to support more general numeric expressions.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60384
llvm-svn: 359741
2019-05-02 08:04:38 +08:00
|
|
|
|
2019-06-20 07:47:10 +08:00
|
|
|
// Substitution of an undefined string variable fails and error holds that
|
|
|
|
// variable's name.
|
2019-12-12 07:48:01 +08:00
|
|
|
StringSubstitution StringSubstitution(&Context, "VAR404", 42);
|
2019-06-20 07:47:10 +08:00
|
|
|
Expected<std::string> SubstValue = StringSubstitution.getResult();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"VAR404"}, SubstValue.takeError());
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Numeric substitution blocks constituted of defined numeric variables are
|
|
|
|
// substituted for the variable's value.
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
NumericVariable NVar("N", ExpressionFormat(ExpressionFormat::Kind::Unsigned),
|
|
|
|
1);
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
NVar.setValue(ExpressionValue(10u));
|
2019-12-12 07:48:01 +08:00
|
|
|
auto NVarUse = std::make_unique<NumericVariableUse>("N", &NVar);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
auto ExpressionN = std::make_unique<Expression>(
|
|
|
|
std::move(NVarUse), ExpressionFormat(ExpressionFormat::Kind::HexUpper));
|
|
|
|
NumericSubstitution SubstitutionN(&Context, "N", std::move(ExpressionN),
|
2020-01-16 07:02:03 +08:00
|
|
|
/*InsertIdx=*/30);
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
SubstValue = SubstitutionN.getResult();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(SubstValue, Succeeded());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ("A", *SubstValue);
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
|
|
|
|
// Substitution of an undefined numeric variable fails, error holds name of
|
|
|
|
// undefined variable.
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
NVar.clearValue();
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
SubstValue = SubstitutionN.getResult();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"N"}, SubstValue.takeError());
|
FileCheck [4/12]: Introduce @LINE numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces the @LINE numeric
expressions.
This commit introduces a new syntax to express a relation a numeric
value in the input text must have with the line number of a given CHECK
pattern: [[#<@LINE numeric expression>]]. Further commits build on that
to express relations between several numeric values in the input text.
To help with naming, regular variables are renamed into pattern
variables and old @LINE expression syntax is referred to as legacy
numeric expression.
Compared to existing @LINE expressions, this new syntax allow arbitrary
spacing between the component of the expression. It offers otherwise the
same functionality but the commit serves to introduce some of the data
structure needed to support more general numeric expressions.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60384
llvm-svn: 359741
2019-05-02 08:04:38 +08:00
|
|
|
|
FileCheck: Improve FileCheck variable terminology
Summary:
Terminology introduced by [[#]] blocks is confusing and does not
integrate well with existing terminology.
First, variables referred by [[]] blocks are called "pattern variables"
while the text a CHECK directive needs to match is called a "CHECK
pattern". This is inconsistent with variables in [[#]] blocks since
[[#]] blocks are also found in CHECK pattern yet those variables are
called "numeric variable".
Second, the replacing of both [[]] and [[#]] blocks by the value of the
variable or expression they contain is represented by a
FileCheckPatternSubstitution class. The naming refers to being a
substitution in a CHECK pattern but could be wrongly understood as being
a substitution of a pattern variable.
Third and lastly, comments use "numeric expression" to refer both to the
[[#]] blocks as well as to the numeric expressions these blocks contain
which get evaluated at match time.
This patch solves these confusions by
- calling variables in [[]] and [[#]] blocks as string and numeric
variables respectively;
- referring to [[]] and [[#]] as substitution *blocks*, with the former
being a string substitution block and the latter a numeric
substitution block;
- calling [[]] and [[#]] blocks to be replaced by the value of a
variable or expression they contain a substitution (as opposed to
definition when these blocks are used to defined a variable), with the
former being a string substitution and the latter a numeric
substitution;
- renaming the FileCheckPatternSubstitution as a FileCheckSubstitution
class with FileCheckStringSubstitution and
FileCheckNumericSubstitution subclasses;
- restricting the use of "numeric expression" to refer to the expression
that is evaluated in a numeric substitution.
While numeric substitution blocks only support numeric substitutions of
numeric expressions at the moment there are plans to augment numeric
substitution blocks to support numeric definitions as well as both a
numeric definition and numeric substitution in the same numeric
substitution block.
Reviewers: jhenderson, jdenny, probinson, arichardson
Subscribers: hiraditya, arichardson, probinson, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62146
llvm-svn: 361445
2019-05-23 08:10:14 +08:00
|
|
|
// Substitution of a defined string variable returns the right value.
|
2019-12-12 07:48:01 +08:00
|
|
|
Pattern P(Check::CheckPlain, &Context, 1);
|
|
|
|
StringSubstitution = llvm::StringSubstitution(&Context, "FOO", 42);
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
SubstValue = StringSubstitution.getResult();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(SubstValue, Succeeded());
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
EXPECT_EQ("BAR", *SubstValue);
|
FileCheck [4/12]: Introduce @LINE numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces the @LINE numeric
expressions.
This commit introduces a new syntax to express a relation a numeric
value in the input text must have with the line number of a given CHECK
pattern: [[#<@LINE numeric expression>]]. Further commits build on that
to express relations between several numeric values in the input text.
To help with naming, regular variables are renamed into pattern
variables and old @LINE expression syntax is referred to as legacy
numeric expression.
Compared to existing @LINE expressions, this new syntax allow arbitrary
spacing between the component of the expression. It offers otherwise the
same functionality but the commit serves to introduce some of the data
structure needed to support more general numeric expressions.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60384
llvm-svn: 359741
2019-05-02 08:04:38 +08:00
|
|
|
}
|
|
|
|
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
TEST_F(FileCheckTest, FileCheckContext) {
|
2019-10-04 23:47:23 +08:00
|
|
|
FileCheckPatternContext Cxt;
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
SourceMgr SM;
|
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// No definition.
|
2020-04-15 20:30:21 +08:00
|
|
|
EXPECT_THAT_ERROR(Cxt.defineCmdlineVariables({}, SM), Succeeded());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
// Missing equal sign.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("missing equal sign in global definition",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"LocalVar"}, SM));
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("missing equal sign in global definition",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"#LocalNumVar"}, SM));
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
// Empty variable name.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("empty variable name",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"=18"}, SM));
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("empty variable name",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"#=18"}, SM));
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
// Invalid variable name.
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("invalid variable name",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"18LocalVar=18"}, SM));
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError("invalid variable name",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"#18LocalNumVar=18"}, SM));
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
|
|
|
|
// Name conflict between pattern and numeric variable.
|
2020-04-15 20:30:21 +08:00
|
|
|
expectDiagnosticError(
|
|
|
|
"string variable with name 'LocalVar' already exists",
|
|
|
|
Cxt.defineCmdlineVariables({"LocalVar=18", "#LocalVar=36"}, SM));
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
Cxt = FileCheckPatternContext();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectDiagnosticError(
|
|
|
|
"numeric variable with name 'LocalNumVar' already exists",
|
2020-04-15 20:30:21 +08:00
|
|
|
Cxt.defineCmdlineVariables({"#LocalNumVar=18", "LocalNumVar=36"}, SM));
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
Cxt = FileCheckPatternContext();
|
|
|
|
|
|
|
|
// Invalid numeric value for numeric variable.
|
2020-04-15 20:30:21 +08:00
|
|
|
expectUndefErrors({"x"}, Cxt.defineCmdlineVariables({"#LocalNumVar=x"}, SM));
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
// Define local variables from command-line.
|
2020-04-15 20:30:21 +08:00
|
|
|
std::vector<StringRef> GlobalDefines;
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
// Clear local variables to remove dummy numeric variable x that
|
|
|
|
// parseNumericSubstitutionBlock would have created and stored in
|
|
|
|
// GlobalNumericVariableTable.
|
|
|
|
Cxt.clearLocalVars();
|
2020-04-15 20:30:21 +08:00
|
|
|
GlobalDefines.emplace_back("LocalVar=FOO");
|
|
|
|
GlobalDefines.emplace_back("EmptyVar=");
|
|
|
|
GlobalDefines.emplace_back("#LocalNumVar1=18");
|
|
|
|
GlobalDefines.emplace_back("#%x,LocalNumVar2=LocalNumVar1+2");
|
|
|
|
GlobalDefines.emplace_back("#LocalNumVar3=0xc");
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_ERROR(Cxt.defineCmdlineVariables(GlobalDefines, SM), Succeeded());
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
|
2020-01-16 07:02:03 +08:00
|
|
|
// Create @LINE pseudo numeric variable and check it is present by matching
|
|
|
|
// it.
|
|
|
|
size_t LineNumber = 1;
|
|
|
|
Pattern P(Check::CheckPlain, &Cxt, LineNumber);
|
|
|
|
FileCheckRequest Req;
|
|
|
|
Cxt.createLineVariable();
|
|
|
|
ASSERT_FALSE(P.parsePattern("[[@LINE]]", "CHECK", SM, Req));
|
|
|
|
size_t MatchLen;
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(P.match("1", MatchLen, SM), Succeeded());
|
2020-01-16 07:02:03 +08:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
// Recreating @LINE pseudo numeric variable fails.
|
|
|
|
EXPECT_DEATH(Cxt.createLineVariable(),
|
|
|
|
"@LINE pseudo numeric variable already created");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Check defined variables are present and undefined ones are absent.
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
StringRef LocalVarStr = "LocalVar";
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
StringRef LocalNumVar1Ref = bufferize(SM, "LocalNumVar1");
|
|
|
|
StringRef LocalNumVar2Ref = bufferize(SM, "LocalNumVar2");
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
StringRef LocalNumVar3Ref = bufferize(SM, "LocalNumVar3");
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
StringRef EmptyVarStr = "EmptyVar";
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
StringRef UnknownVarStr = "UnknownVar";
|
2019-06-20 07:47:10 +08:00
|
|
|
Expected<StringRef> LocalVar = Cxt.getPatternVarValue(LocalVarStr);
|
2020-01-16 07:02:03 +08:00
|
|
|
P = Pattern(Check::CheckPlain, &Cxt, ++LineNumber);
|
2019-12-12 07:48:01 +08:00
|
|
|
Optional<NumericVariable *> DefinedNumericVariable;
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
Expected<std::unique_ptr<Expression>> ExpressionPointer =
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
P.parseNumericSubstitutionBlock(LocalNumVar1Ref, DefinedNumericVariable,
|
2020-01-16 07:02:03 +08:00
|
|
|
/*IsLegacyLineExpr=*/false, LineNumber,
|
|
|
|
&Cxt, SM);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(LocalVar, Succeeded());
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
EXPECT_EQ(*LocalVar, "FOO");
|
FileCheck [7/12]: Arbitrary long numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch extend numeric expression to
support an arbitrary number of operands, either variable or literals.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60387
llvm-svn: 366001
2019-07-13 21:24:30 +08:00
|
|
|
Expected<StringRef> EmptyVar = Cxt.getPatternVarValue(EmptyVarStr);
|
|
|
|
Expected<StringRef> UnknownVar = Cxt.getPatternVarValue(UnknownVarStr);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
Expected<ExpressionValue> ExpressionVal =
|
|
|
|
(*ExpressionPointer)->getAST()->eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionVal, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(cantFail(ExpressionVal->getSignedValue()), 18);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionPointer = P.parseNumericSubstitutionBlock(
|
2020-01-16 07:02:03 +08:00
|
|
|
LocalNumVar2Ref, DefinedNumericVariable,
|
|
|
|
/*IsLegacyLineExpr=*/false, LineNumber, &Cxt, SM);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
|
|
|
ExpressionVal = (*ExpressionPointer)->getAST()->eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionVal, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(cantFail(ExpressionVal->getSignedValue()), 20);
|
|
|
|
ExpressionPointer = P.parseNumericSubstitutionBlock(
|
|
|
|
LocalNumVar3Ref, DefinedNumericVariable,
|
|
|
|
/*IsLegacyLineExpr=*/false, LineNumber, &Cxt, SM);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
|
|
|
ExpressionVal = (*ExpressionPointer)->getAST()->eval();
|
|
|
|
ASSERT_THAT_EXPECTED(ExpressionVal, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(cantFail(ExpressionVal->getSignedValue()), 12);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(EmptyVar, Succeeded());
|
FileCheck [2/12]: Stricter parsing of -D option
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch gives earlier and better
diagnostics for the -D option.
Prior to this change, parsing of -D option was very loose: it assumed
that there is an equal sign (which to be fair is now checked by the
FileCheck executable) and that the part on the left of the equal sign
was a valid variable name. This commit adds logic to ensure that this
is the case and gives diagnostic when it is not, making it clear that
the issue came from a command-line option error. This is achieved by
sharing the variable parsing code into a new function ParseVariable.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60382
llvm-svn: 359447
2019-04-29 21:32:36 +08:00
|
|
|
EXPECT_EQ(*EmptyVar, "");
|
2020-01-29 03:23:46 +08:00
|
|
|
expectUndefErrors({std::string(UnknownVarStr)}, UnknownVar.takeError());
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
|
|
|
|
// Clear local variables and check they become absent.
|
|
|
|
Cxt.clearLocalVars();
|
FileCheck [4/12]: Introduce @LINE numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces the @LINE numeric
expressions.
This commit introduces a new syntax to express a relation a numeric
value in the input text must have with the line number of a given CHECK
pattern: [[#<@LINE numeric expression>]]. Further commits build on that
to express relations between several numeric values in the input text.
To help with naming, regular variables are renamed into pattern
variables and old @LINE expression syntax is referred to as legacy
numeric expression.
Compared to existing @LINE expressions, this new syntax allow arbitrary
spacing between the component of the expression. It offers otherwise the
same functionality but the commit serves to introduce some of the data
structure needed to support more general numeric expressions.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60384
llvm-svn: 359741
2019-05-02 08:04:38 +08:00
|
|
|
LocalVar = Cxt.getPatternVarValue(LocalVarStr);
|
2020-01-29 03:23:46 +08:00
|
|
|
expectUndefErrors({std::string(LocalVarStr)}, LocalVar.takeError());
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
// Check a numeric expression's evaluation fails if called after clearing of
|
|
|
|
// local variables, if it was created before. This is important because local
|
|
|
|
// variable clearing due to --enable-var-scope happens after numeric
|
|
|
|
// expressions are linked to the numeric variables they use.
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
expectUndefErrors({"LocalNumVar3"},
|
|
|
|
(*ExpressionPointer)->getAST()->eval().takeError());
|
2020-01-16 07:02:03 +08:00
|
|
|
P = Pattern(Check::CheckPlain, &Cxt, ++LineNumber);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionPointer = P.parseNumericSubstitutionBlock(
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
LocalNumVar1Ref, DefinedNumericVariable, /*IsLegacyLineExpr=*/false,
|
2020-01-16 07:02:03 +08:00
|
|
|
LineNumber, &Cxt, SM);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
|
|
|
ExpressionVal = (*ExpressionPointer)->getAST()->eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"LocalNumVar1"}, ExpressionVal.takeError());
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionPointer = P.parseNumericSubstitutionBlock(
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
LocalNumVar2Ref, DefinedNumericVariable, /*IsLegacyLineExpr=*/false,
|
2020-01-16 07:02:03 +08:00
|
|
|
LineNumber, &Cxt, SM);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
|
|
|
ExpressionVal = (*ExpressionPointer)->getAST()->eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"LocalNumVar2"}, ExpressionVal.takeError());
|
FileCheck [4/12]: Introduce @LINE numeric expressions
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch introduces the @LINE numeric
expressions.
This commit introduces a new syntax to express a relation a numeric
value in the input text must have with the line number of a given CHECK
pattern: [[#<@LINE numeric expression>]]. Further commits build on that
to express relations between several numeric values in the input text.
To help with naming, regular variables are renamed into pattern
variables and old @LINE expression syntax is referred to as legacy
numeric expression.
Compared to existing @LINE expressions, this new syntax allow arbitrary
spacing between the component of the expression. It offers otherwise the
same functionality but the commit serves to introduce some of the data
structure needed to support more general numeric expressions.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60384
llvm-svn: 359741
2019-05-02 08:04:38 +08:00
|
|
|
EmptyVar = Cxt.getPatternVarValue(EmptyVarStr);
|
2020-01-16 20:14:13 +08:00
|
|
|
expectUndefErrors({"EmptyVar"}, EmptyVar.takeError());
|
[FileCheck] Don't diagnose undef vars at parse time
Summary:
Diagnosing use of undefined variables takes place in
parseNumericVariableUse() and printSubstitutions() for numeric variables
but only takes place in printSubstitutions() for string variables. The
reason for the split location of diagnostics is that parsing is not
aware of the clearing of variables due to --enable-var-scope and thus
use of variables cleared in this way can only be catched by
printSubstitutions().
Beyond the code level inconsistency, there is also a user facing
inconsistency since diagnostics look different between the two
functions. While the diagnostic in printSubstitutions is more verbose,
doing the diagnostic there allows to diagnose all undefined variables
rather than just the first one and error out.
This patch create dummy variable definition when encountering a use of
undefined variable so that parsing can proceed and be diagnosed by
printSubstitutions() later. Tests that were testing whether parsing
fails in such case are thus modified accordingly.
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64228
llvm-svn: 365219
2019-07-06 00:25:33 +08:00
|
|
|
// Clear again because parseNumericSubstitutionBlock would have created a
|
|
|
|
// dummy variable and stored it in GlobalNumericVariableTable.
|
|
|
|
Cxt.clearLocalVars();
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
|
|
|
|
// Redefine global variables and check variables are defined again.
|
2020-04-15 20:30:21 +08:00
|
|
|
GlobalDefines.emplace_back("$GlobalVar=BAR");
|
|
|
|
GlobalDefines.emplace_back("#$GlobalNumVar=36");
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_ERROR(Cxt.defineCmdlineVariables(GlobalDefines, SM), Succeeded());
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
StringRef GlobalVarStr = "$GlobalVar";
|
Reinstate "FileCheck [5/12]: Introduce regular numeric variables"
This reinstates r360578 (git e47362c1ec1ea31b626336cc05822035601c3e57),
reverted in r360653 (git 004393681c25e34e921adccc69ae6378090dee54),
with a fix for the list added in FileCheck.rst to build without error.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar,
arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar,
arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60385
llvm-svn: 360665
2019-05-14 19:58:30 +08:00
|
|
|
StringRef GlobalNumVarRef = bufferize(SM, "$GlobalNumVar");
|
2019-06-20 07:47:10 +08:00
|
|
|
Expected<StringRef> GlobalVar = Cxt.getPatternVarValue(GlobalVarStr);
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(GlobalVar, Succeeded());
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
EXPECT_EQ(*GlobalVar, "BAR");
|
2020-01-16 07:02:03 +08:00
|
|
|
P = Pattern(Check::CheckPlain, &Cxt, ++LineNumber);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionPointer = P.parseNumericSubstitutionBlock(
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
GlobalNumVarRef, DefinedNumericVariable, /*IsLegacyLineExpr=*/false,
|
2020-01-16 07:02:03 +08:00
|
|
|
LineNumber, &Cxt, SM);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
|
|
|
ExpressionVal = (*ExpressionPointer)->getAST()->eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionVal, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(cantFail(ExpressionVal->getSignedValue()), 36);
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
|
|
|
|
// Clear local variables and check global variables remain defined.
|
|
|
|
Cxt.clearLocalVars();
|
2020-01-16 20:14:13 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Cxt.getPatternVarValue(GlobalVarStr), Succeeded());
|
2020-01-16 07:02:03 +08:00
|
|
|
P = Pattern(Check::CheckPlain, &Cxt, ++LineNumber);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ExpressionPointer = P.parseNumericSubstitutionBlock(
|
FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.
This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.
It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.
It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60388
> llvm-svn: 366860
llvm-svn: 366897
2019-07-24 20:38:22 +08:00
|
|
|
GlobalNumVarRef, DefinedNumericVariable, /*IsLegacyLineExpr=*/false,
|
2020-01-16 07:02:03 +08:00
|
|
|
LineNumber, &Cxt, SM);
|
FileCheck [9/12]: Add support for matching formats
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support for selecting a
matching format to match a numeric value against (ie. decimal, hex lower
case letters or hex upper case letters).
This commit allows to select what format a numeric value should be
matched against. The following formats are supported: decimal value,
lower case hex value and upper case hex value. Matching formats impact
both the format of numeric value to be matched as well as the format of
accepted numbers in a definition with empty numeric expression
constraint.
Default for absence of format is decimal value unless the numeric
expression constraint is non null and use a variable in which case the
format is the one used to define that variable. Conclict of format in
case of several variable being used is diagnosed and forces the user to
select a matching format explicitely.
This commit also enables immediates in numeric expressions to be in any
radix known to StringRef's GetAsInteger method, except for legacy
numeric expressions (ie [[@LINE+<offset>]] which only support decimal
immediates.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: daltenty, MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60389
2019-03-06 07:20:29 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionPointer, Succeeded());
|
|
|
|
ExpressionVal = (*ExpressionPointer)->getAST()->eval();
|
2020-01-16 20:14:13 +08:00
|
|
|
ASSERT_THAT_EXPECTED(ExpressionVal, Succeeded());
|
FileCheck [10/12]: Add support for signed numeric values
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds support signed numeric
values, thus allowing negative numeric values.
As such, the patch adds a new class to represent a signed or unsigned
value and add the logic for type promotion and type conversion in
numeric expression mixing signed and unsigned values. It also adds
the %d format specifier to represent signed value.
Finally, it also adds underflow and overflow detection when performing a
binary operation.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson
Reviewed By: jhenderson, arichardson
Subscribers: MaskRay, hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60390
2019-03-06 07:20:29 +08:00
|
|
|
EXPECT_EQ(cantFail(ExpressionVal->getSignedValue()), 36);
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
}
|
2020-07-29 06:09:47 +08:00
|
|
|
|
|
|
|
TEST_F(FileCheckTest, CapturedVarDiags) {
|
|
|
|
PatternTester Tester;
|
|
|
|
ASSERT_FALSE(Tester.parsePattern("[[STRVAR:[a-z]+]] [[#NUMVAR:@LINE]]"));
|
|
|
|
EXPECT_THAT_EXPECTED(Tester.match("foobar 2"), Succeeded());
|
|
|
|
std::vector<FileCheckDiag> Diags;
|
|
|
|
Tester.printVariableDefs(FileCheckDiag::MatchFoundAndExpected, Diags);
|
|
|
|
EXPECT_EQ(Diags.size(), 2ul);
|
|
|
|
for (FileCheckDiag Diag : Diags) {
|
|
|
|
EXPECT_EQ(Diag.CheckTy, Check::CheckPlain);
|
|
|
|
EXPECT_EQ(Diag.MatchTy, FileCheckDiag::MatchFoundAndExpected);
|
|
|
|
EXPECT_EQ(Diag.InputStartLine, 1u);
|
|
|
|
EXPECT_EQ(Diag.InputEndLine, 1u);
|
|
|
|
}
|
|
|
|
EXPECT_EQ(Diags[0].InputStartCol, 1u);
|
|
|
|
EXPECT_EQ(Diags[0].InputEndCol, 7u);
|
|
|
|
EXPECT_EQ(Diags[1].InputStartCol, 8u);
|
|
|
|
EXPECT_EQ(Diags[1].InputEndCol, 9u);
|
|
|
|
EXPECT_EQ(Diags[0].Note, "captured var \"STRVAR\"");
|
|
|
|
EXPECT_EQ(Diags[1].Note, "captured var \"NUMVAR\"");
|
|
|
|
}
|
FileCheck [1/12]: Move variable table in new object
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch adds a new class to hold
pattern matching global state.
The table holding the values of FileCheck variable constitutes some sort
of global state for the matching phase, yet is passed as parameters of
all functions using it. This commit create a new FileCheckPatternContext
class pointed at from FileCheckPattern. While it increases the line
count, it separates local data from global state. Later commits build
on that to add numeric expression global state to that class.
Copyright:
- Linaro (changes up to diff 183612 of revision D55940)
- GraphCore (changes in later versions of revision D55940 and
in new revision created off D55940)
Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk
Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60381
llvm-svn: 358390
2019-04-15 18:10:11 +08:00
|
|
|
} // namespace
|