Commit Graph

65306 Commits

Author SHA1 Message Date
Adam Nemet f2b6883ac8 Revert "Add -fdiagnostics-show-hotness"
This reverts commit r281276.

Many bots are failing.

llvm-svn: 281279
2016-09-13 00:16:49 +00:00
Reid Kleckner 6c7b1c6212 [DebugInfo] Deduplicate debug info limiting logic
We should be doing the same checks when a type is completed as we do
when a complete type is used during emission. Previously, we duplicated
the logic, and it got out of sync. This could be observed with
dllimported classes.

Also reduce a test case for this slightly.

Implementing review feedback from David Blaikie on r281057.

llvm-svn: 281278
2016-09-13 00:01:23 +00:00
George Burgess IV f8f6324983 [Sema] Fix PR30346: relax __builtin_object_size checks.
This patch makes us act more conservatively when trying to determine
the objectsize for an array at the end of an object. This is in
response to code like the following:

```
struct sockaddr {
  /* snip */
  char sa_data[14];
};

void foo(const char *s) {
  size_t slen = strlen(s) + 1;
  size_t added_len = slen <= 14 ? 0 : slen - 14;
  struct sockaddr *sa = malloc(sizeof(struct sockaddr) + added_len);
  strcpy(sa->sa_data, s);
  // ...
}
```

`__builtin_object_size(sa->sa_data, 1)` would return 14, when there
could be more than 14 bytes at `sa->sa_data`.

Code like this is apparently not uncommon. FreeBSD's manual even
explicitly mentions this pattern:
https://www.freebsd.org/doc/en/books/developers-handbook/sockets-essential-functions.html
(section 7.5.1.1.2).

In light of this, we now just give up on any array at the end of an
object if we can't find the object's initial allocation.

I lack numbers for how much more conservative we actually become as a
result of this change, so I chose the fix that would make us as
compatible with GCC as possible. If we want to be more aggressive, I'm
happy to consider some kind of whitelist or something instead.

llvm-svn: 281277
2016-09-12 23:50:35 +00:00
Adam Nemet a340eff335 Add -fdiagnostics-show-hotness
Summary:
I've recently added the ability for optimization remarks to include the
hotness of the corresponding code region.  This uses PGO and allows
filtering of the optimization remarks by relevance.  The idea was first
discussed here:
http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334

The general goal is to produce a YAML file with the remarks.  Then, an
external tool could dynamically filter these by hotness and perhaps by
other things.

That said it makes sense to also expose this at the more basic level
where we just include the hotness info with each optimization remark.
For example, in D22694, the clang flag was pretty useful to measure the
overhead of the additional analyses required to include hotness.
(Without the flag we don't even run the analyses.)

For the record, Hal has already expressed support for the idea of this
patch on IRC.

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

llvm-svn: 281276
2016-09-12 23:48:16 +00:00
Adam Nemet d2a4da09ad Fix a long comment line
llvm-svn: 281275
2016-09-12 23:48:11 +00:00
Saleem Abdulrasool 62c07eb2fa CodeGen: use some range-based for loops
Use range-based for loops to simplify the logic.  Add an explicit check for
MachO as the inline asm uses MachO specific directives.

llvm-svn: 281261
2016-09-12 21:15:23 +00:00
Richard Smith 7707c4a109 Add a couple of test files missed in r281258.
llvm-svn: 281259
2016-09-12 21:07:09 +00:00
Richard Smith 6561f92b62 [modules] When we merge two definitions of a function, mark the retained
definition as visible in the discarded definition's module, as we do for
other kinds of definition.

llvm-svn: 281258
2016-09-12 21:06:40 +00:00
Richard Smith ac20531203 Diagnostics reference: "error:" should be red, not orange.
llvm-svn: 281241
2016-09-12 17:55:49 +00:00
Jonathan Roelofs 96cb94b2a9 Trivial documentation fix regarding Obj-C ARC objc_arc_weak_reference_unavailable
Fixed incorrect docs that referred to:
  objc_arc_weak_unavailable
when it should be:
  objc_arc_weak_reference_unavailable

Patch by: Sean McBride!

llvm-svn: 281227
2016-09-12 16:14:52 +00:00
Daniel Jasper c6a123111a clang-format: Make emacs integration work with narrowed buffers.
Use (call-process region nil ...) instead of (point-min) so that the
call works in narrowed buffers.

Patch by Philipp Stephani, thank you!

llvm-svn: 281203
2016-09-12 10:02:46 +00:00
Martin Bohme 0eb4403f24 [CFG] Add iterator_ranges to CFG and CFGBlock.
Summary: (Needed for D23353.)

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 281200
2016-09-12 08:28:21 +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
David Majnemer cb60a4305b [MS ABI] Add /include directives for dynamic TLS
MSVC emits /include directives in the .drective section for the
__dyn_tls_init function (decorated as ___dyn_tls_init@12 for 32-bit).

This fixes PR30347.

llvm-svn: 281189
2016-09-12 02:51:43 +00:00
Saleem Abdulrasool 4fab7454c5 CodeGen: remove unnecessary else case
Refactor the assignment so that its much more clear that the if-clause contains
the lookup, and once cached is directly used.  NFC.

llvm-svn: 281150
2016-09-11 01:25:15 +00:00
Nico Weber b5bdf3410e Add missing test coverage for an inheritance model attrib merge diag.
Without this, no tests fail if I remove the Diag() in the first if in
Sema::mergeMSInheritanceAttr().

llvm-svn: 281136
2016-09-10 13:03:59 +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
Manman Ren ec315f1002 Modules: for ObjectiveC try to keep the definition invariant.
When deserializing ObjCInterfaceDecl with definition data, if we already have
a definition, try to keep the definition invariant; also pull in the
categories even if it is not what getDefinition returns (this effectively
combines categories).

rdar://27926200
rdar://26708823

llvm-svn: 281119
2016-09-09 23:48:27 +00:00
Adrian Prantl 432d3d2619 Debug info: Bump the default DWARF version on Darwin to 4.
This is a spiritual re-commit of r201375 with only a brief delay
for upgrading the green dragon builders.

llvm-svn: 281094
2016-09-09 21:10:35 +00:00
Justin Lebar 5057f17716 [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.
Summary:
This fixes a bug where we were unable to compile the following CUDA
file with libstdc++ (didn't try libc++):

  #include <future>
  void foo() { std::shared_future<int> x; }

The problem is that <future> only defines std::shared_future if
__GCC_ATOMIC_INT_LOCK_FREE > 1.  When we compiled this file for device,
the macro was set to 1, and then the class didn't exist at all.

Reviewers: tra

Subscribers: cfe-commits, jhen

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

llvm-svn: 281089
2016-09-09 20:35:43 +00:00
Manman Ren 7d2f5c4a91 Modules: revert r280728.
In post-commit review, Richard suggested a better way to fix this.
rdar://27926200

llvm-svn: 281078
2016-09-09 19:03:07 +00:00
Douglas Katzman 3972f9e6df Myriad: nominally "support" ASAN.
Doesn't work, but needs to be enabled in order to get there.

llvm-svn: 281071
2016-09-09 18:20:49 +00:00
Eric Liu 01426ff875 Also cleanup comments around redundant colons/commas in format::cleanup.
Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 281064
2016-09-09 17:50:49 +00:00
Reid Kleckner 22466a92e1 [DebugInfo] Ensure complete type is emitted with -fstandalone-debug
The logic for upgrading a class from a forward decl to a complete type
was not checking the debug info emission level before applying the
vtable optimization. This meant we ended up without debug info for a
class which was required to be complete. I noticed it because it
triggered an assertion during CodeView emission, but that's a separate
issue.

llvm-svn: 281057
2016-09-09 17:03:53 +00:00
Reid Kleckner b6bee5164d Make -fstandalone-debug and -flimit-debug-info available in clang-cl
Our limited debug info optimizations are breaking down at DLL
boundaries, so we're going to evaluate the size impact of these
settings, and possibly change the default.

Users should be able to override our settings, though.

llvm-svn: 281056
2016-09-09 16:42:50 +00:00
Reid Kleckner c9404e1039 [codeview] Extend the heuristic for detecting classes imported from DLLs
If a dynamic class contains a dllimport method, then assume the class
may not be constructed in this DLL, and therefore the vtable will live
in a different PDB.

This heuristic is still incomplete, and will miss things like abstract
base classes that are only constructed on one side of the DLL interface.
That said, this heuristic does detect some cases that are currently
problematic, and may be useful to other projects that don't use many
DLLs.

llvm-svn: 281053
2016-09-09 16:27:04 +00:00
Amaury Sechet 21f51b3a32 Update clang for D21514. NFC
Summary: As per title.

Reviewers: ahatanak, bkramer, whitequark, mehdi_amini, void

Subscribers: cfe-commits

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

llvm-svn: 281018
2016-09-09 04:42:49 +00:00
George Burgess IV 5104e30590 [Docs] Fix typos, remove trailing whitespace.
Avoided wrapping NullabilityDocs at 80cols, since that would've made
this diff much bigger, and never-ending lines seems to be the style for
many of the null-related docs.

llvm-svn: 281017
2016-09-09 02:45:48 +00:00
Richard Smith 8df390f9eb C++ Modules TS: Add parsing and some semantic analysis support for
export-declarations. These don't yet have an effect on name visibility;
we still export everything by default.

llvm-svn: 280999
2016-09-08 23:14:54 +00:00
Vedant Kumar 10037b93e9 [Driver] Report invalid -mtune/-mcpu parameters when -arch=arm64
Differential Revision: https://reviews.llvm.org/D23643

llvm-svn: 280998
2016-09-08 22:53:19 +00:00
Albert Gutowski b6a11acb53 Implement MS _rot intrinsics
Reviewers: thakis, Prazek, compnerd, rnk

Subscribers: majnemer, cfe-commits

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

llvm-svn: 280997
2016-09-08 22:32:19 +00:00
Vassil Vassilev 714b81c40a [modules] Apply ODR merging for function scoped tags only in C++ mode.
In C mode, if we have a visible declaration but not a visible definition, a tag
defined in the declaration should be have a visible definition. In C++ we rely
on the ODR merging, whereas in C we cannot because each declaration of a
function gets its own set of declarations in its prototype scope.

Patch developed in collaboration with Richard Smith!

llvm-svn: 280984
2016-09-08 20:34:41 +00:00
Renato Golin 0f1fcd6fc6 Revert "[XRay] ARM 32-bit no-Thumb support in Clang"
This reverts commit r280889, as the original LLVM commits broke the thumb
buildbots.

llvm-svn: 280968
2016-09-08 17:12:32 +00:00
Simon Pilgrim 4acc49e58d Moved unreachable to appease msvc, gcc and clang
llvm-svn: 280921
2016-09-08 11:03:41 +00:00
Simon Pilgrim 48c32b1504 Fixed a 'not all control paths return a value' warning on MSVC builds
llvm-svn: 280917
2016-09-08 09:59:58 +00:00
Peter Collingbourne f3fe5a7445 Add explicit casts to size_t to try to appease MSVC.
llvm-svn: 280899
2016-09-08 01:45:28 +00:00
Peter Collingbourne e53683f97b CodeGen: Clean up implementation of vtable initializer builder. NFC.
- Simplify signature of CreateVTableInitializer function.
- Move vtable component builder to a separate function.
- Remove unnecessary accessors from VTableLayout class.

This is in preparation for a future change that will alter the type of the
vtable initializer.

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

llvm-svn: 280897
2016-09-08 01:14:39 +00:00
Dean Michael Berris 6f2622e253 [XRay] ARM 32-bit no-Thumb support in Clang
Just a test for now, adapted from x86_64 tests of XRay.
This is one of 3 commits to different repositories of XRay ARM port. The
other 2 are:

1. https://reviews.llvm.org/D23931 (LLVM)
2. https://reviews.llvm.org/D23933 (compiler-rt)

Differential Review: https://reviews.llvm.org/D23932

llvm-svn: 280889
2016-09-08 00:23:28 +00:00
Daniel Jasper 28d8a5ab43 clang-format: [JavaScript] Change default AllowShortFunctionsOnASingleLine
for Google style to "empty".

llvm-svn: 280878
2016-09-07 23:01:13 +00:00
Daniel Jasper 496c199959 clang-format: [JavaScript] Do requoting in a separate pass
The attempt to fix requoting behavior in r280487 after changes to
tooling::Replacements are incomplete. We essentially need to add to
replacements at the same position, one to insert a line break and one to
change the quoting and that's incompatible with the new
tooling::Replacement API, which does not allow for order-dependent
Replacements. To make the order clear, Replacements::merge() has to be
used, but that requires the merged Replacement to actually refer to the
changed text, which is hard to reproduce for the requoting.

This change fixes the behavior by moving the requoting to a completely
separate pass. The added benefit is that no weird ColumnWidth
calculations are necessary anymore and this should just work even if we
implement string literal splitting in the future.

llvm-svn: 280874
2016-09-07 22:48:53 +00:00
Eugene Zelenko e95e7d5d64 Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D24115

llvm-svn: 280870
2016-09-07 21:53:17 +00:00
George Burgess IV 2da19a5a08 Move CHECK right before the function it describes.
llvm-svn: 280852
2016-09-07 20:15:03 +00:00
George Burgess IV fbad5b2f1b [Sema] Compare bad conversions in overload resolution.
r280553 introduced an issue where we'd emit ambiguity errors for code
like:

```
void foo(int *, int);
void foo(unsigned int *, unsigned int);

void callFoo() {
  unsigned int i;
  foo(&i, 0); // ambiguous: int->unsigned int is worse than int->int,
              // but unsigned int*->unsigned int* is better than
              // int*->int*.
}
```

This patch fixes this issue by changing how we handle ill-formed (but
valid) implicit conversions. Candidates with said conversions now always
rank worse than candidates without them, and two candidates are
considered to be equally bad if they both have these conversions for
the same argument.

Additionally, this fixes a case in C++11 where we'd complain about an
ambiguity in a case like:

```
void f(char *, int);
void f(const char *, unsigned);
void g() { f("abc", 0); }
```

...Since conversion to char* from a string literal is considered
ill-formed in C++11 (and deprecated in C++03), but we accept it as an
extension.

llvm-svn: 280847
2016-09-07 20:03:19 +00:00
Nico Weber 82f729bf4e Add a few more test for []-style uuid attributes.
- Should diag on a function (clang-cl warns; it's an error in cl)
- Test the attribute on nested classes (clang-cl is more permissive and more
  self-consistent than cl here)

llvm-svn: 280845
2016-09-07 19:41:35 +00:00
Yaxun Liu 43712e05ea Do not validate pch when -fno-validate-pch is set
There is a bug causing pch to be validated even though -fno-validate-pch is set. This patch fixes it.

ASTReader relies on ASTReaderListener to initialize SuggestedPredefines, which is required for compilations using PCH. Before this change, PCHValidator is the default ASTReaderListener. After this change, when -fno-validate-pch is set, PCHValidator is disabled, but we need a replacement ASTReaderListener to initialize SuggestedPredefines. Class SimpleASTReaderListener is implemented for this purpose.

This change only affects -fno-validate-pch. There is no functional change if -fno-validate-pch is not set.

If -fno-validate-pch is not set, conflicts in predefined macros between pch and current compiler instance causes error.

If -fno-validate-pch is set, predefine macros in current compiler override those in pch so that compilation can continue.

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

llvm-svn: 280842
2016-09-07 18:40:20 +00:00
Ismail Pazarbasi 4a00774e59 Try contextually converting condition of constexpr if to Boolean value
Summary:
C++1z 6.4.1/p2:
 If the if statement is of the form if constexpr, the value of the
 condition shall be a contextually converted constant expression of type
 bool [...]
C++1z 5.20/p4:
 [...] A contextually converted constant expression of type bool is an
 expression, contextually converted to bool (Clause4), where the
 converted expression is a constant expression and the conversion
 sequence contains only the conversions above. [...]

Contextually converting result of an expression `e` to a Boolean value
requires `bool t(e)` to be well-formed.

An explicit conversion function is only considered as a user-defined
conversion for direct-initialization, which is essentially what
//contextually converted to bool// requires.

Also, fixes PR28470.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 280838
2016-09-07 18:24:54 +00:00