[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 3 13:47:11 PST 2020


nickdesaulniers created this revision.
nickdesaulniers added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nickdesaulniers added a comment.

I still plan to add CodeGen support for `asm inline` before the next release, which should be as simple as emitting an additional `inlinehint`, but I'd like to save that for a follow up patch on top of this.


The parsing of GNU C extended asm statements was a little brittle and
had a few issues:

- It was using Parse::ParseTypeQualifierListOpt to parse the `volatile` qualifier.  That parser is really meant for TypeQualifiers; an asm statement doesn't really have a type qualifier. This is still maybe nice to have, but not necessary. We now can check for the `volatile` token by properly expanding the grammer, rather than abusing Parse::ParseTypeQualifierListOpt.
- The parsing of `goto` was position dependent, so `asm goto volatile` wouldn't parse. The qualifiers should be position independent to one another. Now they are.
- We would warn on duplicate `volatile`, but the parse error for duplicate `goto` was a generic parse error and wasn't clear.
- We need to add support for the recent GNU C extension `asm inline`. Adding support to the parser with the above issues highlighted the need for this refactoring.

Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/Parser/asm-qualifiers.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75563.248010.patch
Type: text/x-patch
Size: 8520 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200303/405dc80c/attachment-0001.bin>


More information about the cfe-commits mailing list