public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joern Rennecke <joern.rennecke@embecosm.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: Vineet Gupta <vineetg@rivosinc.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: committed [RISC-V]: Harden test scan patterns
Date: Wed, 11 Oct 2023 08:12:16 +0100	[thread overview]
Message-ID: <CAMqJFCquxCqjjLjDiLvzkSHnKLdDgfJ3Q14mBT7jNFU1pjY4Vg@mail.gmail.com> (raw)
In-Reply-To: <CAMqJFCo+e424rjCUCYGv9yDQtdEhV6J8zwuCb24bEQ286u-nwQ@mail.gmail.com>

On Wed, 11 Oct 2023 at 05:48, Joern Rennecke
<joern.rennecke@embecosm.com> wrote:

> So I propose we look at the first character of the regexp, and if it's neither
> ^ nor \ (neither caret nor backslash), we consider the regexp un-anchored,
> and prepend ^[^"]* , so it won't allow a match after a double quote.

Looking at the sources for dg-scan / scan-assembler-times / scan-assembler-dem /
scan-assembler-dem-not, and the tcl regexp command and re_syntax manual
pages, I realise it won't work like that.  The backslash-escaped
characters in the
source file end up just as single characters if enclosed merely with
double quotes,
so "\t" is a single character, although {\t} and {\m} will  be passed
as two characters
to regexp (and "\m" is just an m).

And ^ , by default, matches only the begin of the text, which for the
aforementioned scan-assembler* procs means the entire (demangled for *-dem)
output file.
(The manual is a bit muddled about start of string or start of line,
but a test with
tclsh shows the default is indeed start of string.)
We can make use embedded options to make a prepended string work, i.e.
(?w)^[^"]*?

Although I'm not sure what that'd do on macOS - would the compiler output
contain lines terminated only with \r, and these be invisible to ^ ?
I see that we have a number of scan patterns that start with \n ing++.dg,
so I would hope that we can rely on lines ending with \n .
(\n\r or \r\n are OK for this purpose.)

Incidentally, these patterns should also work  with (?w^[^"]*? prepended,
as a line that ends should also have a start, but it could get a low count for
scan-assembler-times.  There are a number of tests in gcc.target/s390
that have directives starting with: scan-assembler-times {\n\t
which are perfectly anchored, but we might depress the count if we
prepend a pattern that matches the start of the line that has the newline.

We'd also have to make an exception for regexps that start with a parenthesis
to avoid disabling REs with embedded options.

So it seems we have to except patterns starting wit any of:
\\ \t \n (
Maybe we should also add [ to that list, for "[\n\r]" ?

  reply	other threads:[~2023-10-11  7:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27  9:26 Joern Rennecke
2023-09-27 17:22 ` Jeff Law
2023-09-27 18:22   ` Joern Rennecke
2023-09-27 20:14     ` Jeff Law
2023-09-27 22:12       ` Andrew Pinski
2023-09-27 23:21       ` Vineet Gupta
2023-09-29 13:54         ` Jeff Law
2023-09-30 21:12           ` Joern Rennecke
2023-10-11  4:48             ` Joern Rennecke
2023-10-11  7:12               ` Joern Rennecke [this message]
2023-11-08 15:14               ` Joern Rennecke
2023-11-08 16:00           ` RFA: make scan-assembler* ignore LTO sections (Was: Re: committed [RISC-V]: Harden test scan patterns) Joern Rennecke
2023-11-10  6:02             ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMqJFCquxCqjjLjDiLvzkSHnKLdDgfJ3Q14mBT7jNFU1pjY4Vg@mail.gmail.com \
    --to=joern.rennecke@embecosm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=vineetg@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).