Commit Graph

556 Commits

Author SHA1 Message Date
Aaron Ballman a503855906 Track in the AST whether the operand to a UnaryOperator can overflow and then use that logic when evaluating constant expressions and emitting codegen.
llvm-svn: 322074
2018-01-09 13:07:03 +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
Aaron Ballman 207ee3d0a7 Add 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.

llvm-svn: 321223
2017-12-20 22:04:54 +00:00
Aaron Ballman adf66b6174 Determine the attribute subject for diagnostics based on declarative information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing.
This also clarifies some terminology used by the diagnostic (methods -> Objective-C methods, fields -> non-static data members, etc).

Many of the tests needed to be updated in multiple places for the diagnostic wording tweaks. The first instance of the diagnostic for that attribute is fully specified and subsequent instances cut off the complete list (to make it easier if additional subjects are added in the future for the attribute).

llvm-svn: 319002
2017-11-26 20:01:12 +00:00
Aaron Ballman 606093a53b Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a proposal to add [[]] attributes to C2x, but also allows you to enable these attributes in C++98, or disable them in C++11 or later.
llvm-svn: 315856
2017-10-15 15:01:42 +00:00
Konstantin Zhuravlyov 202c1b715f Revert "Mark test as unsupported until r315808 is fixed"
Test is fixed in r315830

llvm-svn: 315831
2017-10-14 22:24:31 +00:00
Bruno Cardoso Lopes b37d05c9c1 Mark test as unsupported until r315808 is fixed
This is causing:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/43381

llvm-svn: 315829
2017-10-14 22:14:23 +00:00
Richard Smith 9bfa970a40 PR34822: Fix a collection of related bugs with our handling of C89 implicit function declarations.
We were injecting the function into the wrong semantic context, resulting in it
failing to be registered as a global for redeclaration lookup. As a
consequence, we accepted invalid code since r310616.

Fixing that resulted in the "out-of-scope declaration" diagnostic firing a lot
more often. It turned out that warning codepath was non-conforming, because it
did not cause us to inject the implicitly-declared function into the enclosing
block scope. We now only warn if the type of the out-of-scope declaration
doesn't match the type of an implicitly-declared function; in all other cases,
we produce the normal warning for an implicitly-declared function.

llvm-svn: 314871
2017-10-04 01:49:22 +00:00
Erich Keane 8eec6dde6a Fix test change missed in r314456
llvm-svn: 314460
2017-09-28 20:23:43 +00:00
Erich Keane de22fe5b5b Add Documentation to attribute-nothrow. Additionally, limit to functions.
Attribute nothrow is only allowed on functions, so I added that. Additionally,
it lacks any documentation, so I added some.

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

llvm-svn: 314456
2017-09-28 20:08:03 +00:00
Akira Hatanaka 98a49337be Add support for attribute 'noescape'.
The attribute informs the compiler that the annotated pointer parameter
of a function cannot escape and enables IRGen to attach attribute
'nocapture' to parameters that are annotated with the attribute. That is
the only optimization that currently takes advantage of 'noescape', but
there are other optimizations that will be added later that improves
IRGen for ObjC blocks.

This recommits r313722, which was reverted in r313725 because clang
couldn't build compiler-rt. It failed to build because there were
function declarations that were missing 'noescape'. That has been fixed
in r313929.

rdar://problem/19886775

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

llvm-svn: 313945
2017-09-22 00:41:05 +00:00
Richard Smith dfc4bff19b Extend -ast-dump for CXXRecordDecl to dump the flags from the DefinitionData.
llvm-svn: 313943
2017-09-22 00:11:15 +00:00
Akira Hatanaka 30c93dba5b Revert "Add support for attribute 'noescape'."
This reverts commit r313722.

It looks like compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc cannot be
compiled because some of the functions declared in the file do not match
the ones in the SDK headers (which are annotated with 'noescape').

llvm-svn: 313725
2017-09-20 06:55:43 +00:00
Akira Hatanaka e974479fa5 Add support for attribute 'noescape'.
The attribute informs the compiler that the annotated pointer parameter
of a function cannot escape and enables IRGen to attach attribute
'nocapture' to parameters that are annotated with the attribute. That is
the only optimization that currently takes advantage of 'noescape', but
there are other optimizations that will be added later that improves
IRGen for ObjC blocks.

rdar://problem/19886775

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

llvm-svn: 313722
2017-09-20 06:32:45 +00:00
Akira Hatanaka 1b9418e163 Revert "Add support for attribute 'noescape'."
This reverts r313717.

I closed the wrong phabricator review.

llvm-svn: 313721
2017-09-20 06:27:39 +00:00
Akira Hatanaka fc587e6a57 Add support for attribute 'noescape'.
The attribute informs the compiler that the annotated pointer parameter
of a function cannot escape and enables IRGen to attach attribute
'nocapture' to parameters that are annotated with the attribute. That is
the only optimization that currently takes advantage of 'noescape', but
there are other optimizations that will be added later that improves
IRGen for ObjC blocks.

rdar://problem/19886775

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

llvm-svn: 313720
2017-09-20 06:22:51 +00:00
Jonas Devlieghere 5dc87861d6 [diagtool] Change default tree behavior to print only flags
This patch changes the default behavior of `diagtool tree` to only
display warning flags and not the internal warnings flags. The latter is
an implementation detail of the compiler and usually not what the users
wants.

Furthermore, flags that are enabled by default are now also printed in
green. Originally, this was only the case for the diagnostic names.

Differential revision: https://reviews.llvm.org/D37390

llvm-svn: 312546
2017-09-05 18:04:40 +00:00
Don Hinton 6c2ded879d [diagtool] Add ability to pass in the id and return the name for a
particular diagnostic.

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

llvm-svn: 309955
2017-08-03 16:13:13 +00:00
Richard Smith fb5afbda32 PR33902: Invalidate line number cache when adding more text to existing buffer.
This led to crashes as the line number cache would report a bogus line number
for a line of code, and we'd try to find a nonexistent column within the line
when printing diagnostics.

llvm-svn: 309503
2017-07-30 06:31:29 +00:00
Simon Atanasyan 1a116db120 [CodeGen][mips] Support `long_call/far/near` attributes
This patch adds support for the `long_call`, `far`, and `near` attributes
for MIPS targets. The `long_call` and `far` attributes are synonyms. All
these attributes override `-mlong-calls` / `-mno-long-calls` command
line options for particular function.

Differential revision: https://reviews.llvm.org/D35479

llvm-svn: 308667
2017-07-20 20:34:18 +00:00
Mandeep Singh Grang a16b27cfda [clang] Remove redundant check-prefix=CHECK from tests. NFC.
Reviewers: t.p.northover, mstorsjo, rsmith, mcrosier

Reviewed By: mstorsjo, mcrosier

Subscribers: mcrosier, javed.absar, cfe-commits

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

llvm-svn: 308192
2017-07-17 17:31:44 +00:00
Alex Lorenz ada11923fa [diagtool] Add a 'find-diagnostic-id' subcommand that converts a name of
the diagnostic to its enum value

This will be used by a script that invokes clang in a debugger and forces it
to stop when it reports a particular diagnostic.

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

llvm-svn: 307813
2017-07-12 16:41:49 +00:00
Saleem Abdulrasool d064e91ece Revert "Revert r305164/5/7."
Restore the `-gz` option to the driver with some minor tweaks to handle
the additional case for `-Wa,--compress-debug-sections`.

This intends to make the compression of the debug information
controllable from the driver.  The following is the behaviour:

  -gz           enable compression (ambiguous for format, will default to zlib-gnu)
  -gz=none      disable compression
  -gz=zlib-gnu  enable compression (deprecated GNU style zlib compression)
  -gz=zlib      enable compression (zlib based compression)

Although -Wa,-compress-debug-sections works, it should be discouraged
when using the driver to invoke the assembler.  However, we permit the
assembler to accept the GNU as style argument --compress-debug-sections
to maintain compatibility.

Note, -gz/-gz= does *NOT* imply -g.  That is, you need to additionally
specific -g for debug information to be generated.

llvm-svn: 306115
2017-06-23 15:34:16 +00:00
Richard Smith b2bbd9c9ef Add missing file from r306075.
llvm-svn: 306077
2017-06-23 01:18:27 +00:00
Richard Smith 90dc525472 PR33552: Distinguish between declarations that are owned by no module and
declarations that are owned but unconditionally visible.

This allows us to set declarations as visible even if they have a local owning
module, without losing information. In turn, that means that our Objective-C
support can keep on incorrectly assuming the "hidden" bit on the declaration is
the whole story with regard to name visibility. This will also be useful once
we support the C++ Modules TS export semantics.

Objective-C name visibility is still incorrect in any case where the "hidden"
bit is not the complete story: for instance, in Objective-C++ the set of
visible categories will be wrong during template instantiation, and with local
submodule visibility enabled it will be wrong when building modules. Fixing that
will require a major overhaul of how visibility is handled for Objective-C (and
particularly for categories).

llvm-svn: 306075
2017-06-23 01:04:34 +00:00
Yaron Keren 374b41a6aa Address David Blaikie comment by replacing grep with FileCheck.
llvm-svn: 305215
2017-06-12 18:29:37 +00:00
Yaron Keren c91c46c85e Add regression test for r305179.
llvm-svn: 305213
2017-06-12 18:05:13 +00:00
Alex Lorenz bbf4f7091f ASTPrinter: Objective-C method declarations don't need a space after
the return type

rdar://32332039

llvm-svn: 304553
2017-06-02 15:02:59 +00:00
David Blaikie e16745f4e6 Add compatibility alias for -Wno-#warnings
GCC uses -Wno-cpp for this, so seems reasonable to add an alias to
match.

llvm-svn: 304456
2017-06-01 19:08:34 +00:00
Richard Smith 0c7d4d7e21 Add option to include multiple lines in snippets.
When a diagnostic includes a highlighted range spanning multiple lines, clang
now supports printing out multiple lines of context if necessary to show the
highlighted ranges. This is not yet exposed in the driver, but can be enabled
by "-Xclang -fcaret-diagnostics-max-lines -Xclang N".

This is experimental until we can find out whether it works well in practice,
and if so, what a good default for the maximum number of lines is.

llvm-svn: 303589
2017-05-22 23:51:40 +00:00
Simon Atanasyan 2c87f5341d [mips] Support `micromips` attribute
This patch adds support for the `micromips` and `nomicromips` attributes
for MIPS targets.

Differential revision: https://reviews.llvm.org/D33363

llvm-svn: 303546
2017-05-22 12:47:43 +00:00
Jonathan Roelofs f358d48f23 Fix grammar in comment. NFC
llvm-svn: 302443
2017-05-08 17:06:17 +00:00
Xiuli Pan be6da4bbdb [OpenCL] Add intel_reqd_sub_group_size attribute support
Summary:
Add intel_reqd_sub_group_size attribute support as intel extension  cl_intel_required_subgroup_size from
https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_required_subgroup_size.txt

Reviewers: Anastasia, bader, hfinkel, pxli168

Reviewed By: Anastasia, bader, pxli168

Subscribers: cfe-commits, yaxunl

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

llvm-svn: 302125
2017-05-04 07:31:20 +00:00
Alex Lorenz 472cc79086 Add #pragma clang attribute support to the availability attribute
rdar://31707804

llvm-svn: 300826
2017-04-20 09:35:02 +00:00
Alex Lorenz 24952fbc6f Add #pragma clang attribute support to the external_source_symbol attribute
Prior to this commit the external_source_symbol attribute wasn't supported by
#pragma clang attribute for the following two reasons:

- The Named attribute subject hasn't been supported by TableGen.
- There was no way to specify a subject match rule for #pragma clang attribute
 that could operate on a set of attribute subjects (e.g. the ones that derive
 from NamedDecl).

This commit fixes the two issues and thus adds external_source_symbol support to
#pragma clang attribute.

rdar://31169028

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

llvm-svn: 300712
2017-04-19 15:52:11 +00:00
Alex Lorenz 47fd10c3b5 [ASTPrinter] Print template parameter lists for out-of-line functions
llvm-svn: 300560
2017-04-18 15:12:34 +00:00
Alex Lorenz 9e7bf161ea Add #pragma clang attribute
This is a recommit of r300539 that was reverted in r300543 due to test failures.
The original commit message is displayed below:

The new '#pragma clang attribute' directive can be used to apply attributes to
multiple declarations. An attribute must satisfy the following conditions to
be supported by the pragma:
- It must have a subject list that's defined in the TableGen file.
- It must be documented.
- It must not be late parsed.
- It must have a GNU/C++11 spelling.

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

llvm-svn: 300556
2017-04-18 14:33:39 +00:00
Alex Lorenz 3bfe962afa Revert r300539 - Add #pragma clang attribute
Some tests fail on the Windows buildbots. I will have to investigate more.
This commit reverts r300539, r300540 and r300542.

llvm-svn: 300543
2017-04-18 10:46:41 +00:00
Alex Lorenz 0a849f47d2 Add #pragma clang attribute
The new '#pragma clang attribute' directive can be used to apply attributes to
multiple declarations. An attribute must satisfy the following conditions to
be supported by the pragma:
- It must have a subject list that's defined in the TableGen file.
- It must be documented.
- It must not be late parsed.
- It must have a GNU/C++11 spelling.

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

llvm-svn: 300539
2017-04-18 09:41:47 +00:00
Alex Lorenz a981c7d79e [ASTPrinter] Print nested name specifiers for out-of-line functions
rdar://31501863

llvm-svn: 299962
2017-04-11 16:46:03 +00:00
Matthias Gehre 01a6338180 Add [[clang::suppress(rule, ...)]] attribute
Summary:
This patch implements parsing of [[clang::suppress(rule, ...)]]
and [[gsl::suppress(rule, ...)]] attributes.

C++ Core Guidelines depend heavily on tool support for
rule enforcement. They also propose a way to suppress
warnings [1] which is by annotating any ancestor in AST
with the C++11 attribute [[gsl::suppress(rule1,...)]].
To have a mechanism to suppress non-C++ Core
Guidelines specific, an additional spelling of [[clang::suppress]]
is defined.

For example, to suppress the warning cppcoreguidelines-slicing,
one could do
```
[[clang::suppress("cppcoreguidelines-slicing")]]
void f() { ... code that does slicing ... }
```
or
```
void g() {
  Derived b;
  [[clang::suppress("cppcoreguidelines-slicing")]]
  Base a{b};
  [[clang::suppress("cppcoreguidelines-slicing")]] {
    doSomething();
    Base a2{b};
  }
}
```

This parsing can then be used by clang-tidy, which includes multiple
C++ Core Guidelines rules, to suppress warnings (see
https://reviews.llvm.org/D24888).
For the exact naming of the rule in the attribute, there
are different possibilities, which will be defined in the
corresponding clang-tidy patch.

Currently, clang-tidy supports suppressing of warnings through "//
NOLINT" comments. There are some advantages that the attribute has:
- Suppressing specific warnings instead of all warnings
- Suppressing warnings in a block (namespace, function, compound
  statement)
- Code formatting may split a statement into multiple lines,
  thus a "// NOLINT" comment may be on the wrong line

I'm looking forward to your comments!

[1] https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement

Reviewers: alexfh, aaron.ballman, rsmith

Subscribers: cfe-commits

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

llvm-svn: 298880
2017-03-27 19:45:24 +00:00
Zachary Turner 00c5343d65 Disable warning about MSVC not found.
When this test runs on bots that are configured to default
to MSVC, but MSVC isn't actually installed, we can emit a
warning that MSVC is not found.  Since MSVC isn't actually
needed for this test to succeed, just disable this warning.

llvm-svn: 297858
2017-03-15 16:35:13 +00:00
Alex Lorenz 76377dcf99 Print nested name specifiers for typedefs and type aliases
Printing typedefs or type aliases using clang_getTypeSpelling() is missing the
namespace they are defined in. This is in contrast to other types that always
yield the full typename including namespaces.

Patch by Michael Reiher!

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

llvm-svn: 297465
2017-03-10 15:04:58 +00:00
Argyrios Kyrtzidis a166a2b633 [AST/ObjC] Make ObjCCategoryImplDecl consistent with ObjCCategoryDecl and use the category name as its DeclName
This also addresses the badness in ObjCCategoryImplDecl's API, which was hiding NamedDecl's APIs with different meaning.

llvm-svn: 297131
2017-03-07 09:26:07 +00:00
Alex Lorenz d5d27e16d4 Introduce an 'external_source_symbol' attribute that describes the origin
and the nature of a declaration

This commit adds an external_source_symbol attribute to Clang. This attribute
specifies that a declaration originates from an external source and describes
the nature of that source. This attribute will be used to improve IDE features
like 'jump-to-definition' for mixed-language projects or project that use
auto-generated code.

rdar://30423368

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

llvm-svn: 296649
2017-03-01 18:06:25 +00:00
Richard Smith 1832a028af Add template parameter depth and index to -ast-dump output.
llvm-svn: 295689
2017-02-21 02:04:03 +00:00
Richard Smith 057ec50830 Handle deduction guides better in -ast-print.
llvm-svn: 295521
2017-02-18 01:01:48 +00:00
Vassil Vassilev 352e4412e1 PR31469: Don't add friend template class decls to redecl chain in dependent contexts.
Fixes a crash in modules where the template class decl becomes the most recent
decl in the redeclaration chain and forcing the template instantiator try to
instantiate the friend declaration, rather than the template definition.
    
In practice, A::list<int> produces a TemplateSpecializationType
A::__1::list<int, allocator<type-parameter-0-0> >' failing to replace to
subsitute the default argument to allocator<int>.
    
Kudos Richard Smith (D28399).

llvm-svn: 291753
2017-01-12 09:16:26 +00:00