Commit Graph

372 Commits

Author SHA1 Message Date
Faisal Vali d143a0c2de [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped Enum
- also replace direct equality checks against the ConstantEvaluated enumerator  with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17.

- update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed.

llvm-svn: 299316
2017-04-01 21:30:49 +00:00
Erich Keane a32910da1a Correct class-template deprecation behavior-REDUX
Correct class-template deprecation behavior

Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case:
template<typename T> [[deprecated]] class Foo{}; Foo<int> f;

This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute.

Previous DiffRev: https://reviews.llvm.org/D27486, was reverted.
This patch fixes the issues brought up here by the reverter: https://reviews.llvm.org/rL298410

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

llvm-svn: 298634
2017-03-23 18:51:54 +00:00
Martin Bohme 926572303e Revert "Correct class-template deprecation behavior"
This reverts commit r298410 (which produces incorrect warnings, see
comments on https://reviews.llvm.org/rL298410).

llvm-svn: 298504
2017-03-22 13:34:37 +00:00
Erich Keane 8a8f5f0f00 Correct class-template deprecation behavior
Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case:
template<typename T> [[deprecated]] class Foo{}; Foo<int> f;

This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute.

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

llvm-svn: 298410
2017-03-21 17:49:17 +00:00
Richard Smith b2c82a6970 Improve workaround for Sphinx's lack of support for command line options containing '+', '.' etc. to be more stable as the set of options changes.
llvm-svn: 293252
2017-01-27 01:54:42 +00:00
Richard Smith 081ad4d3e5 [docs] Add TableGen-based generator for command line argument documentation,
and generate documentation for all (non-hidden) options supported by the
'clang' driver.

llvm-svn: 292968
2017-01-24 19:39:46 +00:00
David L. Jones 267b884e81 Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.
Summary:
This patch changes TableGen-generated code in AttrPCHRead to call functions on
ASTRecordReader, instead of passing separate parameters to ASTReader. This is a
follow-up to r290217.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 292868
2017-01-24 01:04:30 +00:00
Justin Lebar 4086fe5cd1 [TableGen] Only normalize the spelling of GNU-style attributes.
Summary:
When Sema looks up an attribute name, it strips off leading and trailing
"__" if the attribute is GNU-style.  That is, __attribute__((foo)) and
__attribute__((__foo__)) are equivalent.

This is only true for GNU-style attributes.  In particular,
__declspec(__foo__) is not equivalent to __declspec(foo), and Sema
respects this difference.

This patch fixes TableGen to match Sema's behavior.  The spelling
'GNU<"__foo__">' should be normalized to 'GNU<"foo">', but
'Declspec<"__foo__">' should not be changed.

This is necessary to make CUDA compilation work on Windows, because e.g.
the __device__ attribute is spelled __declspec(__device__).

Attr.td does not contain any Declspec spellings that start or end with
"__", so this change should not affect any other attributes.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 291129
2017-01-05 16:51:54 +00:00
Matthias Braun f1b01996ef Adapt to llvm/TableGen DagInit changes.
llvm-svn: 288645
2016-12-05 06:00:51 +00:00
Matthias Braun bbbf5d4286 TableGen: Adapt to llvm r288612
llvm-svn: 288614
2016-12-04 05:55:09 +00:00
George Burgess IV 8a36ace5b1 [TableGen] Ignore fake args for parsing-related arg counts.
We should complain about the following:

```
void foo() __attribute__((unavailable("a", "b")));
```

Instead, we currently just ignore "b". (...We also end up ignoring "a",
because we assume elsewhere that this attribute can only have 1 or 0
args.)

This happens because `unavailable` has a fake enum arg, and
`AttributeList::{getMinArgs,getMaxArgs}` include fake args in their
counts.

llvm-svn: 288388
2016-12-01 17:52:39 +00:00
George Burgess IV 1881a573e9 [TableGen] Minor clean-ups. NFC.
Primarily: try to use DenseSet<StringRef> instead of
std::set<std::string>, and use pretty range algos where we can.

Small sizes were arbitrarily chosen.

llvm-svn: 288297
2016-12-01 00:13:18 +00:00
Eugene Zelenko 58ab22fe48 Fix some Clang-tidy and Include What You Use warnings; other minor fixes (NFC).
This preparation to remove SetVector.h dependency on SmallSet.h.

llvm-svn: 288213
2016-11-29 22:44:24 +00:00
Reid Kleckner 6432d45f7b Use noexcept instead of LLVM_NOEXCEPT now that all compilers support it
llvm-svn: 284667
2016-10-19 23:39:55 +00:00
Mehdi Amini 732afdd09a Turn cl::values() (for enum) from a vararg function to using C++ variadic template
The core of the change is supposed to be NFC, however it also fixes
what I believe was an undefined behavior when calling:

 va_start(ValueArgs, Desc);

with Desc being a StringRef.

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

llvm-svn: 283671
2016-10-08 19:41:06 +00:00
Richard Smith 8cba29181b [docs] Order diagnostic cross-references alphabetically rather than based on
order in the .td file.

llvm-svn: 281434
2016-09-14 01:55:42 +00:00
Richard Smith ce9d586fdb Update DiagnosticsReference and fix emitter to emit -Wpedantic diagnostics and groups in a deterministic order.
llvm-svn: 281433
2016-09-14 01:51:10 +00:00
Reid Kleckner 003bb09e78 Fix a FIXME about MSVC 2013 in the diagnostic doc generation code
Ultimately it boiled down to adding a move constructor.

llvm-svn: 281408
2016-09-13 22:22:56 +00:00
Richard Smith 85edca95c6 Work around MSVC 2013's inability to default move special members.
llvm-svn: 281382
2016-09-13 20:00:02 +00:00
Richard Smith ffa0241a03 Work around a GCC 4.7-specific issue: due to implementing older rules for
implicit declarations of move operations, GCC 4.7 would find that SelectPiece
has neither a move constructor nor a copy constructor. The copy constructor was
(correctly) deleted because the class has a member of move-only type, and the
move constructor was (incorrectly, per current C++ rules) not provided because
the class has a copy-only base class (in turn because it explicitly declares a
destructor).

llvm-svn: 281363
2016-09-13 18:35:34 +00:00
Richard Smith 67462ffce9 Add virtual destructor (necessary due to the switch to shared_ptr).
llvm-svn: 281198
2016-09-12 06:51:11 +00:00
Richard Smith 94a2fe5c8d Attempt #3 to placate MSVC.
llvm-svn: 281197
2016-09-12 06:38:31 +00:00
Richard Smith c14994f290 Attempt #2 to placate MSVC
llvm-svn: 281195
2016-09-12 06:23:26 +00:00
Richard Smith cd608d1a20 Attempt to placate MSVC.
llvm-svn: 281194
2016-09-12 06:13:44 +00:00
Richard Smith b6a3b4ba61 Add a mode to clang-tblgen to generate reference documentation for warning and
remark flags. For now I'm checking in a copy of the built documentation, but we
can replace this with a placeholder (as we do for the attributes reference
documentation) once we enable building this server-side.

llvm-svn: 281192
2016-09-12 05:58:29 +00:00
Akira Hatanaka 3d17313734 [tablegen] Check that an optional IdentifierArgument of an attribute is
provided before trying to print it.

This fixes a segfault that occurs when function printPretty generated by
tablegen tries to print an optional argument of attribute
objc_bridge_related.

rdar://problem/28155469

llvm-svn: 281132
2016-09-10 03:29:43 +00:00
Nico Weber 20e08048ec Add plumbing for new attribute type "Microsoft".
This is for attributes in []-delimited lists preceding a class, like e.g.
`[uuid("...")] class Foo {};`  Not used by anything yet, so no behavior change.
Part of https://reviews.llvm.org/D23895

llvm-svn: 280575
2016-09-03 02:55:10 +00:00
Eric Fiselier 341e825eae Implement __attribute__((require_constant_initialization)) for safe static initialization.
Summary:
This attribute specifies expectations about the initialization of static and
thread local variables. Specifically that the variable has a
[constant initializer](http://en.cppreference.com/w/cpp/language/constant_initialization)
according to the rules of [basic.start.static]. Failure to meet this expectation
will result in an error.

Static objects with constant initializers avoid hard-to-find bugs caused by
the indeterminate order of dynamic initialization. They can also be safely
used by other static constructors across translation units.

This attribute acts as a compile time assertion that the requirements
for constant initialization have been met. Since these requirements change
between dialects and have subtle pitfalls it's important to fail fast instead
of silently falling back on dynamic initialization.

```c++
  // -std=c++14
  #define SAFE_STATIC __attribute__((require_constant_initialization)) static
  struct T {
    constexpr T(int) {}
    ~T();
  };
  SAFE_STATIC T x = {42}; // OK.
  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer
  // copy initialization is not a constant expression on a non-literal type.
```
This attribute can only be applied to objects with static or thread-local storage
duration.

Reviewers: majnemer, rsmith, aaron.ballman

Subscribers: jroelofs, cfe-commits

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

llvm-svn: 280525
2016-09-02 18:53:31 +00:00
Eric Fiselier bcdcbd11ba Revert r280516 since it contained accidental changes.
llvm-svn: 280521
2016-09-02 18:43:25 +00:00
Eric Fiselier 92f8935e63 Implement __attribute__((require_constant_initialization)) for safe static initialization.
Summary:
This attribute specifies expectations about the initialization of static and
thread local variables. Specifically that the variable has a
[constant initializer](http://en.cppreference.com/w/cpp/language/constant_initialization)
according to the rules of [basic.start.static]. Failure to meet this expectation
will result in an error.

Static objects with constant initializers avoid hard-to-find bugs caused by
the indeterminate order of dynamic initialization. They can also be safely
used by other static constructors across translation units.

This attribute acts as a compile time assertion that the requirements
for constant initialization have been met. Since these requirements change
between dialects and have subtle pitfalls it's important to fail fast instead
of silently falling back on dynamic initialization.

```c++
  // -std=c++14
  #define SAFE_STATIC __attribute__((require_constant_initialization)) static
  struct T {
    constexpr T(int) {}
    ~T();
  };
  SAFE_STATIC T x = {42}; // OK.
  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer
  // copy initialization is not a constant expression on a non-literal type.
```
This attribute can only be applied to objects with static or thread-local storage
duration.

Reviewers: majnemer, rsmith, aaron.ballman

Subscribers: jroelofs, cfe-commits

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

llvm-svn: 280516
2016-09-02 18:25:29 +00:00
Vedant Kumar 957d7a00bc [clang-tblgen] Remove unused #include (NFC)
llvm-svn: 277885
2016-08-05 22:48:53 +00:00
Mehdi Amini 9670f847b8 [NFC] Header cleanup
Summary: Removed unused headers, replaced some headers with forward class declarations

Patch by: Eugene <claprix@yandex.ru>

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

llvm-svn: 275882
2016-07-18 19:02:11 +00:00
Saleem Abdulrasool 511f2e5a89 Sema: support __declspec(dll*) on ObjC interfaces
Extend the __declspec(dll*) attribute to cover ObjC interfaces.  This was
requested by Microsoft for their ObjC support.  Cover both import and export.
This only adds the semantic analysis portion of the support, code-generation
still remains outstanding.  Add some basic initial documentation on the
attributes that were previously empty.  Tweak the previous tests to use the
relative expected-warnings to make the tests easier to read.

llvm-svn: 275610
2016-07-15 20:41:10 +00:00
David Majnemer f7e3609f77 Use ranges to concisely express iteration
No functional change is intended, this should just clean things up a
little.

llvm-svn: 273522
2016-06-23 00:15:04 +00:00
Richard Smith dfed58a527 Update to match LLVM r272232.
llvm-svn: 272233
2016-06-09 00:53:41 +00:00
Reid Kleckner ebeb0ca80d Work around MinGW's macro definition of 'interface' to 'struct'
Previous attempts to rename the IBOutletCollection argument to something
other than "Interface" were undone (r127127 and r139620).  Instead of
renaming it, work around this in tablegen, so the public facing getter
can have the usual name of 'getInterface'.

Fixes PR26682

llvm-svn: 271305
2016-05-31 17:42:56 +00:00
Benjamin Kramer cfeacf56f0 Apply clang-tidy's misc-move-constructor-init throughout Clang.
No functionality change intended, maybe a tiny performance improvement.

llvm-svn: 270996
2016-05-27 14:27:13 +00:00
Benjamin Kramer 2e018efa9b Turn copies into references as suggested by clang-tidy's performance-unnecessary-copy-initialization.
llvm-svn: 270994
2016-05-27 13:36:58 +00:00
Richard Smith 1997856936 Fix use-after-free ASan failures for modules / PCH files that deserialize abi_tag or no_sanitize attributes.
llvm-svn: 269869
2016-05-18 00:16:51 +00:00
Eugene Zelenko a9f3e908bf Fix Clang-tidy modernize-use-bool-literals in generated code.
Reduce space in empty constructors and between data members and first public section.

Fix some Include What You Use warnings.

Differential revision: http://reviews.llvm.org/D20213

llvm-svn: 269371
2016-05-12 22:27:08 +00:00
Peter Collingbourne 7dab685e55 Revert unnecessary tblgen change.
llvm-svn: 267788
2016-04-27 20:49:44 +00:00
Peter Collingbourne a8b2f7c0d7 Rework interface for bitset-using features to use a notion of LTO visibility.
Bitsets, and the compiler features they rely on (vtable opt, CFI),
only have visibility within the LTO'd part of the linkage unit. Therefore,
only enable these features for classes with hidden LTO visibility. This
notion is based on object file visibility or (on Windows)
dllimport/dllexport attributes.

We provide the [[clang::lto_visibility_public]] attribute to override the
compiler's LTO visibility inference in cases where the class is defined
in the non-LTO'd part of the linkage unit, or where the ABI supports
calling classes derived from abstract base classes with hidden visibility
in other linkage units (e.g. COM on Windows).

If the cross-DSO CFI mode is enabled, bitset checks are emitted even for
classes with public LTO visibility, as that mode uses a separate mechanism
to cause bitsets to be exported.

This mechanism replaces the whole-program-vtables blacklist, so remove the
-fwhole-program-vtables-blacklist flag.

Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the
support for the special attr:uuid blacklist entry is removed.

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

llvm-svn: 267784
2016-04-27 20:39:53 +00:00
Richard Smith 290d801916 Re-commit r265518 ("[modules] Continue factoring encoding of AST records out of
ASTWriter."), reverted in r265526, with a fix for an iterator invalidation bug
(thanks, MSan!).

llvm-svn: 265564
2016-04-06 17:06:00 +00:00
Dmitry Polukhin 790b540099 Revert "[modules] Continue factoring encoding of AST records out of ASTWriter."
This reverts commit r265518.

llvm-svn: 265526
2016-04-06 10:01:46 +00:00
Richard Smith 5811c40bb3 [modules] Continue factoring encoding of AST records out of ASTWriter.
llvm-svn: 265518
2016-04-06 06:26:08 +00:00
Manman Ren c7890fed01 Add an optional string argument to DeprecatedAttr for Fix-It.
We only add this to __attribute__((deprecated)).

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

llvm-svn: 263652
2016-03-16 18:50:49 +00:00
Manman Ren 42e09eb022 Print strict in Availability attribute when it is on.
llvm-svn: 263172
2016-03-10 23:54:12 +00:00
Richard Smith 4f902c7ecc P0188R1: add support for standard [[fallthrough]] attribute. This is almost
exactly the same as clang's existing [[clang::fallthrough]] attribute, which
has been updated to have the same semantics. The one significant difference
is that [[fallthrough]] is ill-formed if it's not used immediately before a
switch label (even when -Wimplicit-fallthrough is disabled). To support that,
we now build a CFG of any function that uses a '[[fallthrough]];' statement
to check.

In passing, fix some bugs with our support for statement attributes -- in
particular, diagnose their use on declarations, rather than asserting.

llvm-svn: 262881
2016-03-08 00:32:55 +00:00
John McCall 477f2bb0d5 Semantic analysis for the swiftcall calling convention.
I've tried to keep the infrastructure behind parameter ABI
treatments fairly general.

llvm-svn: 262587
2016-03-03 06:39:32 +00:00
John McCall 5d7cf778e4 Add an llvm_unreachable back to the autogeneration of this covered switch.
llvm-svn: 262288
2016-03-01 02:09:20 +00:00