r332314 - [AST] Fix printing tag decl groups in decl contexts

Joel E. Denny via cfe-commits cfe-commits at lists.llvm.org
Tue May 15 10:30:18 PDT 2018


Hi Hans,

On Tue, May 15, 2018 at 6:23 AM, Hans Wennborg <hans at chromium.org> wrote:

> This broke the ast-print-record-decl.c test on Windows, see for
> example http://lab.llvm.org:8011/builders/clang-with-thin-lto-
> windows/builds/9066
>
> One way to reproduce the failure on Linux is to pass a Windows triple
> to this ast-print command:
>
> --- a/test/Misc/ast-print-record-decl.c
> +++ b/test/Misc/ast-print-record-decl.c
> @@ -54,7 +54,7 @@
>  //   RUN:        -DKW=struct -DBASES=' : B' -o - -xc++ %s \
>  //   RUN: | FileCheck --check-prefixes=CHECK,LLVM %s
>  //
> -//   RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++
> %s \
> +//   RUN: %clang_cc1 -verify -triple i686-pc-win32 -ast-print
> -DKW=struct -DBASES=' : B' -xc++ %s \
>  //   RUN: > %t.cpp
>  //   RUN: FileCheck --check-prefixes=CHECK,PRINT,PRINT-CXX -DKW=struct \
>  //   RUN:           -DBASES=' : B' %s --input-file %t.cpp
>
> What's happening is that on Windows, "__single_inheritance(1)" is
> printed before T1. But if I change the test to allow that in the
> output, it still doesn't pass as Clang doesn't seem able to parse it.
>

The underlying bug is present at least as far back as 4.0.1.  The bug is
revealed by an earlier patch, r332281, simply because it introduces this
test.

There are two parts to this bug.  First, implicit attributes shouldn't
print as that's not faithful to the original source.  I'm addressing that at

https://reviews.llvm.org/D46894

Second, when this attribute is explicit, the "(1)" shouldn't print as it's
not part of the accepted syntax.  I'll address that in another patch.

Thanks.

Joel



>
> I've worked around the problem by adding a Linux triple here in
> r332335, but someone should probably look into it properly.
>
> Thanks,
> Hans
>
> On Tue, May 15, 2018 at 2:44 AM, Joel E. Denny via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: jdenny
> > Date: Mon May 14 17:44:14 2018
> > New Revision: 332314
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332314&view=rev
> > Log:
> > [AST] Fix printing tag decl groups in decl contexts
> >
> > For example, given:
> >
> >   struct T1 {
> >     struct T2 *p0;
> >   };
> >
> > -ast-print produced:
> >
> >   struct T1 {
> >     struct T2;
> >     struct T2 *p0;
> >   };
> >
> > Compiling that produces a warning that the first struct T2 declaration
> > does not declare anything.
> >
> > Details:
> >
> > A tag decl group is one or more decls that share a type specifier that
> > is a tag decl (that is, a struct/union/class/enum decl).  Within
> > functions, the parser builds such a tag decl group as part of a
> > DeclStmt.  However, in decl contexts, such as file scope or a member
> > list, the parser does not group together the members of a tag decl
> > group.  Previously, detection of tag decl groups during printing was
> > implemented but only if the tag decl was unnamed.  Otherwise, as in
> > the above example, the members of the group did not print together and
> > so sometimes introduced warnings.
> >
> > This patch extends detection of tag decl groups in decl contexts to
> > any tag decl that is recorded in the AST as not free-standing.
> >
> > Reviewed by: rsmith
> >
> > Differential Revision: https://reviews.llvm.org/D45465
> >
> > Modified:
> >     cfe/trunk/lib/AST/DeclPrinter.cpp
> >     cfe/trunk/test/Misc/ast-print-enum-decl.c
> >     cfe/trunk/test/Misc/ast-print-record-decl.c
> >     cfe/trunk/test/Sema/ast-print.c
> >     cfe/trunk/test/SemaCXX/ast-print.cpp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180515/52d01479/attachment.html>


More information about the cfe-commits mailing list