Commit Graph

27 Commits

Author SHA1 Message Date
Bruno Ricci e2806f857b [AST] Only store the needed data in SwitchStmt
Don't store the data for the init statement and condition variable
if not needed. This cuts the size of SwitchStmt by up to 2 pointers.
The order of the children is intentionally kept the same.

Also use the newly available space in the bit-fields of Stmt
to store the bit representing whether all enums have been covered
instead of using a PointerIntPair.

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

Reviewed By: rjmccall

llvm-svn: 345510
2018-10-29 16:12:37 +00:00
Bruno Ricci 5b30571753 [AST] Don't store data for GNU range case statement if not needed
Don't store the data for case statements of the form LHS ... RHS if not
needed. This cuts the size of CaseStmt by 1 pointer + 1 SourceLocation in
the common case.

Also use the newly available space in the bit-fields of Stmt to store the
keyword location of SwitchCase and move the small accessor
SwitchCase::getSubStmt to the header.

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

Reviewed By: rjmccall

llvm-svn: 345472
2018-10-28 12:30:53 +00:00
Aaron Ballman 8c20828b5c Re-commit r321223, which adds a printing policy to the ASTDumper.
This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

Fixes the -Wreorder issue and fixes the ast-dump-color.cpp test.

llvm-svn: 321310
2017-12-21 21:42:42 +00:00
Aaron Ballman e8d71e0c50 Reverting a file that snuck in with r321229 by accident.
llvm-svn: 321237
2017-12-21 01:34:46 +00:00
Aaron Ballman 9d6501f6cd Reverting r321223 and its follow-up commit because of failing bots due to Misc/ast-dump-color.cpp.
llvm-svn: 321229
2017-12-20 23:17:29 +00:00
Richard Smith 5a2e6b97f7 Indicate in AST dump whether special member functions are defaulted and trivial.
llvm-svn: 287599
2016-11-21 23:43:54 +00:00
Aaron Ballman 22b5a4d597 Speculative fix for this test case (the test doesn't run on my typical build environment).
llvm-svn: 263034
2016-03-09 17:34:16 +00:00
Richard Smith 9b88a4cdf4 [modules] Add an assert for redeclarations that we never added to their redecl
chain and fix the cases where it fires.

 * Handle the __va_list_tag as a predefined decl. Previously we failed to merge
   sometimes it because it's not visible to name lookup. (In passing, remove
   redundant __va_list_tag typedefs that we were creating for some ABIs. These
   didn't affect the mangling or representation of the type.)

 * For Decls derived from Redeclarable that are not in fact redeclarable
   (implicit params, function params, ObjC type parameters), remove them from
   the list of expected redeclarable decls.

llvm-svn: 243259
2015-07-27 05:40:23 +00:00
Hans Wennborg 76b005398d ASTDumper: print whether a function is constexpr
llvm-svn: 223538
2014-12-05 22:38:57 +00:00
Richard Smith f7514454a7 Refactor tree printing in AST dumping.
Instead of manually maintaining a flag indicating whether we're about to print
out the last child of the parent node (to determine whether we print "`" or
"|"), capture a callable to print that child and defer printing it until we
either see a next child or finish the parent.

No functionality change intended.

llvm-svn: 220930
2014-10-30 21:02:37 +00:00
Ben Langmuir 2f8e6b87ef Move calls to ResolveExceptionSpec out of SetDeclDefaulted and into DefineImplicit*
This fixes an assertion failure in CodeGen where we were not resolving
an exception specification.

llvm-svn: 218466
2014-09-25 20:55:00 +00:00
Nico Weber 728894340f Add -Wunused-local-typedef, a warning that finds unused local typedefs.
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.

This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:

    template <class T>
    void template_fun(T t) {
      typename T::Foo s3foo;  // YYY
      (void)s3foo;
    }
    void template_fun_user() {
      struct Local {
        typedef int Foo;  // XXX
      } p;
      template_fun(p);
    }

Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.

Finally, consider a function using C++14 auto return types to return a local
type defined in a header:

    auto f() {
      struct S { typedef int a; };
      return S();
    }

Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)

Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.

(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)

llvm-svn: 217298
2014-09-06 01:25:55 +00:00
Richard Smith d9967cccfb Add AST dumping for VarDecl init kind.
llvm-svn: 212774
2014-07-10 22:54:03 +00:00
Richard Smith 71b09acb73 Extend AST dump to include 'used' and 'referenced' flags, and put 'invalid' flag in the right place.
llvm-svn: 210872
2014-06-13 02:24:47 +00:00
Alexander Kornienko 83a4e18f4c Retain isImplicit flag for local variable declarations when instantiating
templates.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3924

llvm-svn: 209686
2014-05-27 21:29:22 +00:00
David Blaikie 5ee3d0080a Add the location of Decls to ast dump.
While investigating some debug info issues, Eric and I came across a
particular template case where the location of a decl was quite
different from the range of the same decl. It might've been rather
helpful if the dumper had actually showed us this.

llvm-svn: 205396
2014-04-02 05:48:29 +00:00
Richard Trieu 532018f7a5 Change the color of comment nodes from bright yellow to blue. Bright yellow on
a white background is difficult to read.  Also include a chart showing which
colors are used by which elements in the AST dump.

llvm-svn: 203050
2014-03-06 01:09:03 +00:00
Aaron Ballman 4853a10e57 Updating this test case to appease build bots which support ANSI escape sequences (unlike my dev box).
llvm-svn: 203014
2014-03-05 21:59:02 +00:00
Aaron Ballman b762de1662 Attempting to fix the build bot due to some missing text in the ast dump.
llvm-svn: 201590
2014-02-18 17:56:41 +00:00
Aaron Ballman 9a75e25801 Missed updating this test case with r201585 -- the lockable attribute is now internally represented by CapabilityAttr.
llvm-svn: 201587
2014-02-18 17:46:17 +00:00
Alp Toker 98571fd9b7 Fix ast-dump-color.cpp test following r198883
The commit added a source location that used to be missing from the AST.

llvm-svn: 198892
2014-01-09 21:43:39 +00:00
Richard Smith 99bc1b99d3 Mention in AST dump whether a class declaration is a definition.
llvm-svn: 189647
2013-08-30 05:32:29 +00:00
Richard Smith adaa015900 AST dumping: if a declaration has an uncomputed or uninstantiated exception specification, include that in the dump.
llvm-svn: 182070
2013-05-17 02:09:46 +00:00
Richard Trieu de5cc7d3d8 Add indents to AST dumping and removed parenthesis from AST nodes.
Indents were given the color blue when outputting with color.
AST dumping now looks like this:

Node
|-Node
| `-Node
`-Node
  `-Node

Compared to the previous:

(Node
  (Node
    (Node))
  (Node
    (Node)))

llvm-svn: 174022
2013-01-31 01:44:26 +00:00
NAKAMURA Takumi 6350e07ecd clang/test/Misc/ast-dump-color.cpp: Symbolize color sequences in FileCheck.
FIXME: If FileCheck had expressions something predefined well-known...
llvm-svn: 173558
2013-01-26 03:48:55 +00:00
Richard Trieu d006f6eb5f Fix test case by being more lenient on what to accept as a path name.
llvm-svn: 173553
2013-01-26 01:54:31 +00:00
Richard Trieu d215b8d557 Highlight various parts of the AST dump with color. Colors are controlled by
-f(no-)color-diagnostics.  In addition, dumpColor() function calls are added
to force color printing.  No structural changes to -ast-dump.

llvm-svn: 173548
2013-01-26 01:31:20 +00:00