Commit Graph

234 Commits

Author SHA1 Message Date
Bruno Ricci 473fbc90d1
[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumper
In general there is no way to get to the ASTContext from most AST nodes
(Decls are one of the exception). This will be a problem when implementing
the rest of APValue::dump since we need the ASTContext to dump some kinds of
APValues.

The ASTContext* in ASTDumper and TextNodeDumper is not always non-null.
This is because we still want to be able to use the various dump() functions
in a debugger.

No functional changes intended.

Reverted in fcf4d5e449 since a few dump()
functions in lldb where missed.
2020-07-03 13:59:22 +01:00
Bruno Ricci fcf4d5e449
Revert "[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumper"
This reverts commit aa7fd905e4.

I missed some dump() functions.
2020-07-02 19:40:09 +01:00
Bruno Ricci aa7fd905e4
[clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumper
In general there is no way to get to the ASTContext from most AST nodes
(Decls are one of the exception). This will be a problem when implementing
the rest of APValue::dump since we need the ASTContext to dump some kinds of
APValues.

The ASTContext* in ASTDumper and TextNodeDumper is not always
non-null. This is because we still want to be able to use the various
dump() functions in a debugger.

No functional changes intended.
2020-07-02 19:29:02 +01:00
Martin Boehme 2e92b397ae [clang] Rename Decl::isHidden() to isUnconditionallyVisible().
Also invert the sense of the return value.

As pointed out by the FIXME that this change resolves, isHidden() wasn't
a very accurate name for this function.

I haven't yet changed any of the strings that are output in
ASTDumper.cpp / JSONNodeDumper.cpp / TextNodeDumper.cpp in response to
whether isHidden() is set because

a) I'm not sure whether it's actually desired to change these strings
   (would appreciate feedback on this), and

b) In any case, I'd like to get this pure rename out of the way first,
   without any changes to tests. Changing the strings that are output in
   the various ...Dumper.cpp files will require changes to quite a few
   tests, and I'd like to make those in a separate change.

Differential Revision: https://reviews.llvm.org/D81392

Reviewed By: rsmith
2020-06-12 09:33:42 +02:00
Aaron Ballman e091ab1b2d When dumping the AST to JSON, dump the type information from a typeid expression with a type operand.
llvm-svn: 361769
2019-05-27 14:34:31 +00:00
Aaron Ballman 86abee8185 Add support for dumping AST comment nodes to JSON.
llvm-svn: 361265
2019-05-21 14:38:29 +00:00
Stephen Kelly c8dcbed6e4 Extract ASTDumper to a header file
Summary:
This class has member APIs which are useful to clients.  Make it
possible to use those APIs without adding them to dump() member
functions.  Doing so does not scale.  The optional arguments to dump()
should be designed to be useful in a debugging context.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61835

llvm-svn: 361034
2019-05-17 13:59:15 +00:00
Aaron Ballman 2ce598a44a Introduce the ability to dump the AST to JSON.
This adds the -ast-dump=json cc1 flag (in addition to -ast-dump=default, which is the default if no dump format is specified), as well as some initial AST dumping functionality and tests.

llvm-svn: 360622
2019-05-13 21:39:55 +00:00
Stephen Kelly c49330152e [AST] Extract ASTNodeTraverser class from ASTDumper
Summary:
This new traverser class allows clients to re-use the traversal logic
which was previously part of ASTDumper.  This means that alternative
visit logic may be implemented, such as

* Dump to alternative data formats such as JSON
* Implement AST Matcher parent/child visitation matching AST dumps

Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D57472

llvm-svn: 352989
2019-02-03 14:06:54 +00:00
Michael Kruse 251e1488e1 [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive.
This patch implements parsing and sema for "omp declare mapper"
directive. User defined mapper, i.e., declare mapper directive, is a new
feature in OpenMP 5.0. It is introduced to extend existing map clauses
for the purpose of simplifying the copy of complex data structures
between host and device (i.e., deep copy). An example is shown below:

    struct S {  int len;  int *d; };
    #pragma omp declare mapper(struct S s) map(s, s.d[0:s.len]) // Memory region that d points to is also mapped using this mapper.

Contributed-by: Lingda Li <lildmh@gmail.com>

Differential Revision: https://reviews.llvm.org/D56326

llvm-svn: 352906
2019-02-01 20:25:04 +00:00
Stephen Kelly ee7e4cf48f [ASTDump] Inline traverse methods into class
This API will be extracted into a new template class.  This change will
make the follow-up commit easier to review.

llvm-svn: 352676
2019-01-30 21:48:32 +00:00
Stephen Kelly 7e880b0262 [ASTDump] Make method definition order matches declaration order
This will make follow-up changes easier to review.

llvm-svn: 352663
2019-01-30 20:06:52 +00:00
Stephen Kelly 0808a25182 [ASTDump] Re-arrange method declarations to group Visit together
This will make follow-up commits easier to review.

llvm-svn: 352661
2019-01-30 20:03:47 +00:00
Stephen Kelly 6d110d6afe [ASTDump] Rename methods which are conceptually Visits
This is consistent with the TextNodeDumper, and is the appropriate name
for the traverser class which will be extracted.

llvm-svn: 352657
2019-01-30 19:49:49 +00:00
Stephen Kelly d8aeb55e64 [ASTDump] NFC: Inline vestigial methods
This was a porting aid.

llvm-svn: 352656
2019-01-30 19:41:04 +00:00
Stephen Kelly b6318c923e [ASTDump] Move Decl node dumping to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

Differential Revision: https://reviews.llvm.org/D57419

llvm-svn: 352655
2019-01-30 19:32:48 +00:00
Roman Lebedev 4f9e3ce070 [ASTDumper][OpenMP] CapturedDecl has a 'nothrow' bit
Summary:
Was trying to understand how complicated it would be to write
a clang-tidy `openmp-exception-escape`-ish check once D57100 lands.

Just so it happens, all the data is already there,
it is just conveniently omitted from AST dump.

Reviewers: aaron.ballman, steveire, ABataev

Reviewed By: ABataev

Subscribers: ABataev, guansong, cfe-commits

Tags: #openmp, #clang

Differential Revision: https://reviews.llvm.org/D57452

llvm-svn: 352631
2019-01-30 15:41:20 +00:00
Stephen Kelly aecce85da6 NFC: Move GenericSelectionExpr dump to NodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56961

llvm-svn: 352558
2019-01-29 22:58:28 +00:00
Stephen Kelly fbf40f4500 NFC: Implement GenericSelectionExpr::Association dump with Visitor
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56960

llvm-svn: 352552
2019-01-29 22:22:55 +00:00
Bruno Ricci 1ec7fd35ce Re-commit "[AST] Introduce GenericSelectionExpr::Association"
This time with a fix to make gcc 4.8 happy.

llvm-svn: 352486
2019-01-29 12:57:11 +00:00
Bruno Ricci 586d949b9c Revert "[AST] Introduce GenericSelectionExpr::Association"
This breaks GCC 4.8.4. Reported by email by Hans Wennborg.

llvm-svn: 352403
2019-01-28 18:40:26 +00:00
Bruno Ricci 9feaecf22c [AST] Introduce GenericSelectionExpr::Association
Introduce a new class GenericSelectionExpr::Association which bundle together
an association expression and its TypeSourceInfo.

An iterator GenericSelectionExpr::AssociationIterator is additionally added to
make it possible to iterate over ranges of Associations. This iterator is a
kind of proxy iterator which abstract over how exactly the expressions and the
TypeSourceInfos are stored.

Differential Revision: https://reviews.llvm.org/D57106

Reviewed By: aaron.ballman

Reviewers: aaron.ballman, steveire, dblaikie, mclow.lists
llvm-svn: 352369
2019-01-28 14:18:11 +00:00
Stephen Kelly 8805f67da9 [ASTDump] NFC: Convert iterative loops to cxx_range_for
This is coming up a lot in reviews. Better just to change them all at
once.

llvm-svn: 351647
2019-01-19 09:57:59 +00:00
Stephen Kelly aaebc5f2c5 [ASTDump] NFC: Use `const auto` in cxx_range_for loops
This is coming up a lot in reviews. Better just to do them all at once.

llvm-svn: 351646
2019-01-19 09:57:51 +00:00
Stephen Kelly 25f18bfd4f Move decl context dumping to TextNodeDumper
Summary: Only an obscure case is moved.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56829

llvm-svn: 351637
2019-01-19 09:05:55 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Stephen Kelly 1e07f4e2e7 [ASTDump] NFC: Move variable into if() statement
llvm-svn: 351605
2019-01-18 22:15:09 +00:00
Stephen Kelly 4e35baa842 [ASTDump] NFC: Remove redundant condition
These conditions are duplicated from the dumpDeclContext function called
within the if(). This is presumably an attempt to avoid calling the
function in the case it will do nothing.

That may have made sense in the past if the code was different, but it
doesn't make sense now.

llvm-svn: 351604
2019-01-18 22:15:05 +00:00
Stephen Kelly f4129fd58b [ASTDump] NFC: Remove non-needed braces
llvm-svn: 351603
2019-01-18 22:14:59 +00:00
Stephen Kelly bbd08cce79 [ASTDump] Mark null params with a tag rather than a child node
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56753

llvm-svn: 351601
2019-01-18 22:00:16 +00:00
Stephen Kelly 5110ebd9fe [ASTDump] Mark BlockDecls which capture this with a tag
Summary:
Removal of the child node makes it easier to separate traversal from
output generation.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56752

llvm-svn: 351600
2019-01-18 21:55:24 +00:00
Stephen Kelly 149119dc5f [ASTDump] Mark variadic declarations with a tag instead of child node
Summary:
This makes it easier to separate traversal of the AST from output
generation.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56751

llvm-svn: 351597
2019-01-18 21:38:30 +00:00
Stephen Kelly a4fd381dc2 Re-order type param children of ObjC nodes
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55394

llvm-svn: 351272
2019-01-15 23:07:30 +00:00
Stephen Kelly e80e4cbd20 NFC: Some cleanups that I missed in the previous commit
llvm-svn: 351271
2019-01-15 23:05:11 +00:00
Stephen Kelly 42d9950073 Re-order overrides in FunctionDecl dump
Output all content which is local to the FunctionDecl before traversing
to child AST nodes.

This is necessary so that all of the part which is local to the
FunctionDecl can be split into a different method.

Reviewers: aaron.ballman

Differential Revision: https://reviews.llvm.org/D55083

llvm-svn: 351269
2019-01-15 22:50:37 +00:00
Stephen Kelly b418937793 NFC: Replace iterator loop with cxx_range_for
llvm-svn: 351268
2019-01-15 22:45:46 +00:00
Stephen Kelly fbf424e101 Implement BlockDecl::Capture dump in terms of visitors
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56709

llvm-svn: 351239
2019-01-15 20:41:37 +00:00
Stephen Kelly 3cdd1a7d47 NFC: Implement OMPClause dump in terms of visitors
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56708

llvm-svn: 351236
2019-01-15 20:31:31 +00:00
Stephen Kelly 0e050fa542 Implement CXXCtorInitializer dump in terms of Visitor
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56707

llvm-svn: 351235
2019-01-15 20:17:33 +00:00
Stephen Kelly d83fe89497 NFC: Move Decl node handling to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56643

llvm-svn: 351175
2019-01-15 09:35:52 +00:00
Stephen Kelly f08ca204ac [ASTDump] NFC: Move dump of type nodes to NodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56642

llvm-svn: 351172
2019-01-15 09:30:00 +00:00
Stephen Kelly 58c6504543 [ASTDump] NFC: Move dumping of QualType node to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56641

llvm-svn: 351116
2019-01-14 20:15:29 +00:00
Stephen Kelly bc2438d014 [ASTDump] NFC: Canonicalize handling of TypeLocInfo
Summary: No need to avoid the Visit method.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56640

llvm-svn: 351115
2019-01-14 20:13:09 +00:00
Stephen Kelly 449fa76d05 [ASTDump] NFC: Move Type Visit implementation to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56639

llvm-svn: 351114
2019-01-14 20:11:02 +00:00
Stephen Kelly 4b5e7cd416 NFC: Fix nits I missed before
llvm-svn: 351112
2019-01-14 19:50:34 +00:00
Stephen Kelly 07b76d23b4 [ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55340

llvm-svn: 351014
2019-01-12 16:53:27 +00:00
Stephen Kelly 63a6f3acbd Implement TemplateArgument dumping in terms of Visitor
Summary: Split the output streaming from the traversal to other AST nodes.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55491

llvm-svn: 351012
2019-01-12 16:35:37 +00:00
Stephen Kelly de82b5bef1 NFC: Port loop to cxx_range_for
llvm-svn: 350984
2019-01-12 00:42:59 +00:00
Stephen Kelly db8fac140e Implement Attr dumping in terms of visitors
Remove now-vestigial dumpType and dumpBareDeclRef methods. The old
tablegen generated code used to expect them to be present, but the new
generated code has no such requirement.

Reviewers: aaron.ballman

Subscribers: mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D55492

llvm-svn: 350958
2019-01-11 19:16:01 +00:00
Stephen Kelly 0df805db73 [ASTDump] Add utility for dumping a label with child nodes
Summary:
Use it to add optional label nodes to Stmt dumps.  This preserves
behavior of InitExprList dump:

// CHECK-NEXT: `-InitListExpr {{.+}} <col:13, col:15> 'U [3]'
// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}} <col:15> 'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT:   `-InitListExpr {{.+}} <col:14> 'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT:     `-IntegerLiteral {{.+}} <col:14> 'int' 1

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55488

llvm-svn: 350957
2019-01-11 19:11:17 +00:00