Commit Graph

47911 Commits

Author SHA1 Message Date
Francois Ferrand 5f07f443be clang-format: Fix C99 designated initializers corner cases
Summary:
This fixes the missing space before the designated initializer when `Cpp11BracedListStyle=false` :

  const struct A a = { .a = 1, .b = 2 };
                      ^

Also, wrapping between opening brace and designated array initializers used to have an excessive penalty (like breaking between an expression and the subscript operator), leading to unexpected wrapping:

  const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa =
      {[1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
       [2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb};

instead of:

  const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa = {
      [1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
      [2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb};

Finally, designated array initializers are not binpacked, just like designated member initializers.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, krasimir, klimek

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

llvm-svn: 305696
2017-06-19 14:41:21 +00:00
Christof Douma cc1c112806 Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc"
This reverts commit 305684.
This patch breaks extra/tools/clang-tidy

llvm-svn: 305688
2017-06-19 12:41:22 +00:00
Christof Douma f9d86db755 [NFC] Refactor DiagnosticRenderer to use FullSourceLoc
Move the DiagnosticRenderer and its dependents to using FullSourceLocs
instead of a SourceLocation and SourceManager pointer. The changeset is
rather large but entirely mechanical.

This is step one to allow DiagnosticRenderer to take either
llvm::SMLocs or clang::SourceLocations.

Patch by Sanne Wouda

Review: https://reviews.llvm.org/D31709

Change-Id: If351a112cdf6718e2d3ef6721b8da9c6376b32dd
llvm-svn: 305684
2017-06-19 12:05:58 +00:00
Alex Lorenz ae9afeb5fa Add missing OS check to r305678
That commit failed on non-macOS buildbots as I've forgotten to make sure that
the system on which Clang is running on is actually macOS.

llvm-svn: 305680
2017-06-19 11:25:37 +00:00
Alex Lorenz dad1e1a3b5 [driver][macOS] Pick the system version for the deployment target
if the SDK is newer than the system

This commit improves the driver by making sure that it picks the system version
for the deployment target when the version of the macOS SDK is newer than the
system version.

rdar://29449467

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

llvm-svn: 305678
2017-06-19 10:57:27 +00:00
Daniel Marjamaki 9c6e848989 [analyzer] Fix logical not for pointers with different bit width
Differential Revision: https://reviews.llvm.org/D31029

llvm-svn: 305669
2017-06-19 08:55:51 +00:00
Daniel Jasper f92659e4ea clang-format: Improve understanding of combined typedef+record declarations
Fixes an issue where struct A { int X; }; would be broken onto multiple
lines, but typedef struct A { int X; } A2; was collapsed onto a single
line.

Patch by Jacob Bandes-Storch. Thank you.

llvm-svn: 305667
2017-06-19 07:45:41 +00:00
Daniel Jasper 6a7d5a7a22 clang-format: Handle "if constexpr".
c++1z adds the following constructions to the language:

  if constexpr (cond)
    statement1;
  else if constexpr (cond)
    statement2;
  else if constexpr (cond)
    statement3;
  else
    statement4;

A first version of this was proposed in reviews.llvm.org/D26953 by
Francis Visoiu Mistrih, but never commited. This patch additionally
fixes the behavior when allowing short if statements on a single line
and was authored by Jacob Bandes-Storch. Thank you to both authors.

llvm-svn: 305666
2017-06-19 07:40:49 +00:00
Leslie Zhai d91d19e6dc [analyzer] Teach CloneDetection about Qt Meta-Object Compiler
Reviewers: v.g.vassilev, zaks.anna, NoQ, teemperor

Reviewed By: v.g.vassilev, zaks.anna, NoQ, teemperor

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

llvm-svn: 305659
2017-06-19 01:55:50 +00:00
Saleem Abdulrasool 91d9bfcec5 CodeGen: make the type match the comment for a libcall
Fix the type for a (runtime) library call to match both the comment and
the runtime implementation.  As it happens, the type being used matched,
this just makes it more precise.

llvm-svn: 305638
2017-06-17 17:30:31 +00:00
Lang Hames 8ca265f4a1 Call setMustBuildLookupTable on TagDecls in ExternalASTMerger
Summary:
setMustBuildLookupTable should be called on imported TagDecls otherwise we may fail
to import their member decls (if they have any).

Not calling the setMustBuildLookupTable method results in a failure in the attached test
case when lookup for the 'x' member fails on struct S, which hasn't had its decls imported
elsewhere. (By contrast the member-in-struct testcase hasn't run into this issue
because the import of its decls is triggered when the struct instance is defined, and the
member access follows this).

Reviewers: spyffe, rsmith

Reviewed By: spyffe, rsmith

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

llvm-svn: 305619
2017-06-17 00:12:38 +00:00
Aaron Ballman 4fc36ae50d Killing a tab and some other spurious whitespace; NFC.
llvm-svn: 305586
2017-06-16 20:52:59 +00:00
Alex Lorenz fb7654a8fc [PR33394] Avoid lexing editor placeholders when Clang is used only
for preprocessing

r300667 added support for editor placeholder to Clang. That commit didn’t take
into account that users who use Clang for preprocessing only (-E) will get the
"editor placeholder in source file" error when preprocessing their source
(PR33394). This commit ensures that Clang doesn't lex editor placeholders when
running a preprocessor only action.

rdar://32718000

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

llvm-svn: 305576
2017-06-16 20:13:39 +00:00
Yuka Takahashi cdb5348738 Fix a bug that warnings generated with -M or -MM flags
This is a patch for bug: https://bugs.llvm.org/show_bug.cgi?id=6817

Warnings should not be emitted with -M and -MM flags, because this mode
is only used for generate MakeFiles.

llvm-svn: 305561
2017-06-16 16:01:13 +00:00
Dinar Temirbulatov 7b22425dff Expand vector oparation to as IR constants, PR28129.
llvm-svn: 305551
2017-06-16 12:09:52 +00:00
Vedant Kumar c420d14b29 [ubsan] PR33081: Skip the standard type checks for volatile
Skip checks for null dereference, alignment violation, object size
violation, and dynamic type violation if the pointer points to volatile
data.

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

llvm-svn: 305546
2017-06-16 03:27:36 +00:00
Dean Michael Berris 7456a281dd [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions
Summary:
Before this change, we couldn't capture the `this` pointer that's
implicitly the first argument of class member functions. There are some
interesting things we can do with capturing even just this single
argument for zero-argument member functions.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

llvm-svn: 305544
2017-06-16 03:22:09 +00:00
Richard Trieu 6e13ff33c8 [ODRHash] Hash VarDecl members.
These VarDecl's are static data members of classes.  Since the initializers are
also hashed, this also provides checking for default arguments to methods.

llvm-svn: 305543
2017-06-16 02:44:29 +00:00
Alex Lorenz 8a7a4cfa43 [Completion] Code complete the members for a dependent type after a '::'
This commit is a follow up to r302797 which added support for dependent
completions after the '.' and '->' operators. This commit adds support for
dependent completions after the '::' operator.

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

llvm-svn: 305511
2017-06-15 21:40:54 +00:00
Alex Lorenz 8a656c9597 [index] Record C++17 global binding declarations
The global C++17 binding declarations should be indexed as variable symbols.

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

llvm-svn: 305508
2017-06-15 21:19:01 +00:00
Alex Lorenz 60aac43813 [index] Index static_assert declarations
static_assert declarations have to be visited while indexing so that we can
gather the references to declarations that are present in their assert
expression.

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

llvm-svn: 305504
2017-06-15 20:50:43 +00:00
Eric Fiselier 461b141a9c [coroutines] Remove pass-through operator co_await; Replace it with the input expression
Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

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

llvm-svn: 305498
2017-06-15 20:00:54 +00:00
Eric Fiselier cddaf8728f [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
Summary:
The title says it all.


Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: rjmccall, cfe-commits

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

llvm-svn: 305496
2017-06-15 19:43:36 +00:00
Peter Collingbourne dbd2fed6a1 Apply summary-based dead stripping to regular LTO modules with summaries.
If a regular LTO module has a summary index, then instead of linking
it into the combined regular LTO module right away, add it to the
combined summary index and associate it with a special module that
represents the combined regular LTO module.

Any such modules are linked during LTO::run(), at which time we use
the results of summary-based dead stripping to control whether to
link prevailing symbols.

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

llvm-svn: 305482
2017-06-15 17:26:13 +00:00
Vassil Vassilev a91cbdc60f Revert "Load lazily the template specialization in multi-module setups."
This broke our libcxx modules builds.

llvm-svn: 305460
2017-06-15 11:05:32 +00:00
Daniel Jasper d078254049 Revert "Define _GNU_SOURCE for rtems c++"
This reverts commit r305399.

This breaks a build in libcxx:
libcxx/src/system_error.cpp:90:16: error: assigning to 'int' from incompatible type 'char *'
    if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Which makes sense according to:
https://linux.die.net/man/3/strerror_r

Not entirely sure how this needs to be fixed.

llvm-svn: 305456
2017-06-15 09:17:12 +00:00
Richard Trieu d9201d0a02 [ODRHash] Hash TemplateArgument::Pack and TemplateTypeParmType
llvm-svn: 305440
2017-06-15 01:35:06 +00:00
Aaron Ballman 08d3b3911a Handle -ast-dump-all when passed as the only option.
Patch by Don Hinton

llvm-svn: 305432
2017-06-15 00:00:08 +00:00
Erich Keane 8691d6e678 [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments,
correct getNumArguments

StringifiedArguments is allocated (resized) based on the size the 
getNumArguments function. However, this function ACTUALLY currently 
returns the amount of total UnexpArgTokens which is minimum the same as 
the new implementation of getNumMacroArguments, since empty/omitted arguments 
result in 1 UnexpArgToken, and included ones at minimum include 2 
(1 for the arg itself, 1 for eof).

This patch renames the otherwise unused getNumArguments to be more clear 
that it is the number of arguments that the Macro expects, and thus the maximum 
number that can be stringified. This patch also replaces the explicit memset 
(which results in value instantiation of the new tokens, PLUS clearing the 
memory) with brace initialization.

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

llvm-svn: 305425
2017-06-14 23:09:01 +00:00
Duncan P. N. Exon Smith eae8caa3bb AST: Add missing break at end of switch
llvm-svn: 305418
2017-06-14 21:26:31 +00:00
James Y Knight 02b0e9d97a Define _GNU_SOURCE for rtems c++
This is required by the libc++ locale support.

Patch by Walter Lee.

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

llvm-svn: 305399
2017-06-14 17:01:18 +00:00
Yuka Takahashi 50a9dfa271 Be more strict when checking the -flto option value
Summary:
It seems -flto must be either "thin" or "full". I think the use of
containValue is just a typo.

Reviewers: ruiu, tejohnson

Subscribers: mehdi_amini, inglorion

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

llvm-svn: 305392
2017-06-14 15:37:11 +00:00
Francois Ferrand e56a829e09 clang-format: Add CompactNamespaces option
Summary:
Add CompactNamespaces option, to pack namespace declarations on the
same line (somewhat similar to C++17 nested namespace definition).

With this option, consecutive namespace declarations are kept on the
same line:

  namespace foo { namespace bar {
      ...
  }} // namespace foo::bar

Reviewers: krasimir, djasper, klimek

Reviewed By: djasper

Subscribers: kimgr, cfe-commits, klimek

Tags: #clang-tools-extra

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

llvm-svn: 305384
2017-06-14 12:29:47 +00:00
Serge Pavlov a4ab1b1c59 Reverted 305379 (Function with unparsed body is a definition)
It broke clang-x86_64-linux-selfhost-modules-2 and some other buildbots.

llvm-svn: 305381
2017-06-14 10:57:56 +00:00
Serge Pavlov c73c81be5c Function with unparsed body is a definition
While a function body is being parsed, the function declaration is not considered
as a definition because it does not have a body yet. In some cases it leads to
incorrect interpretation, the case is presented in
https://bugs.llvm.org/show_bug.cgi?id=14785:
```
    template<typename T> struct Somewhat {
      void internal() const {}
      friend void operator+(int const &, Somewhat<T> const &) {}
    };
void operator+(int const &, Somewhat<char> const &x) { x.internal(); }
```
When statement `x.internal()` in the body of global `operator+` is parsed, the type
of `x` must be completed, so the instantiation of `Somewhat<char>` is started. It
instantiates the declaration of `operator+` defined inline, and makes a check for
redefinition. The check does not detect another definition because the declaration
of `operator+` is still not defining as does not have a body yet.

To solves this problem the function `isThisDeclarationADefinition` considers
a function declaration as a definition if it has flag `WillHaveBody` set.

This change fixes PR14785.

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

llvm-svn: 305379
2017-06-14 10:07:02 +00:00
Dmitry Polukhin d4b3bbc73a Fix for Itanium mangler issue with templates
Patch by Serge Preis

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

llvm-svn: 305377
2017-06-14 09:47:47 +00:00
Eric Fiselier b936a393ee [coroutines] Fix co_await for range statement
Summary:
Currently we build the co_await expressions on the wrong implicit statements of the implicit ranged for; Specifically we build the co_await expression wrapping the range declaration, but it should wrap the begin expression.

This patch fixes co_await on range for.

Reviewers: rsmith, GorNishanov

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 305363
2017-06-14 03:24:55 +00:00
Richard Trieu ee64f5eb93 [ODRHash] Remove debugging code from r305361
llvm-svn: 305362
2017-06-14 03:19:58 +00:00
Richard Trieu ee132d6eb2 [ODRHash] Hash Template and TemplateExpansion in TemplateArgument.
llvm-svn: 305361
2017-06-14 03:17:26 +00:00
Richard Trieu 1dcb405ca1 [ODRHash] Hash Expr for TemplateArgument::Expression
llvm-svn: 305360
2017-06-14 01:28:00 +00:00
Richard Trieu 3b261bb725 [ODRHash] Add TemplateArgument kind to hash.
llvm-svn: 305328
2017-06-13 22:21:18 +00:00
Xinliang David Li 4ec3606835 Preserve cold attribute for function decls
Differential Revision: http://reviews.llvm.org/D34133

llvm-svn: 305325
2017-06-13 21:14:07 +00:00
Yi Kong 7db514064a Fix spurious Wunused-lambda-capture warning
Summary:
Clang emits unused-lambda-capture warning for captures in generic lambdas even though they are actually used.

Fixes PR31815.

Reviewers: malcolm.parsons, aaron.ballman, rsmith

Reviewed By: malcolm.parsons

Subscribers: ahatanak, cfe-commits

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

llvm-svn: 305315
2017-06-13 18:38:31 +00:00
Florian Hahn 3dbcced000 Align definition of DW_OP_plus with DWARF spec [2/3]
Summary:
This patch is part of 3 patches that together form a single patch, but must be introduced in stages in order not to break things.
 
The way that LLVM interprets DW_OP_plus in DIExpression nodes is basically that of the DW_OP_plus_uconst operator since LLVM expects an unsigned constant operand. This unnecessarily restricts the DW_OP_plus operator, preventing it from being used to describe the evaluation of runtime values on the expression stack. These patches try to align the semantics of DW_OP_plus and DW_OP_minus with that of the DWARF definition, which pops two elements off the expression stack, performs the operation and pushes the result back on the stack.
 
This is done in three stages:
	•	The first patch (LLVM) adds support for DW_OP_plus_uconst and changes all uses (and tests) of DW_OP_plus to use DW_OP_plus_uconst.
 
	•	The second patch (Clang) contains changes to use DW_OP_plus_uconst instead of DW_OP_plus.
 
	•	The third patch (LLVM) changes the semantics of DW_OP_plus to be in line with it’s DWARF meaning. It also does this for DW_OP_minus.

Patch by Sander de Smalen.

Reviewers: echristo, pcc, aprantl

Reviewed By: aprantl

Subscribers: aprantl, cfe-commits

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

llvm-svn: 305312
2017-06-13 18:06:15 +00:00
Gheorghe-Teodor Bercea 47633db42e Add comma to comment.
llvm-svn: 305294
2017-06-13 15:35:27 +00:00
Krasimir Georgiev 54ef4bafbe [clang-format] Document the StartOfTokenColumn parameter, NFC
llvm-svn: 305293
2017-06-13 14:58:55 +00:00
Diana Picus bec724cbb0 Revert "Revert r301742 which made ExprConstant checking apply to all full-exprs."
This reverts commit r305239 because it broke the buildbots (the
diag-flags.cpp test is failing).

llvm-svn: 305287
2017-06-13 12:50:06 +00:00
Francois Ferrand 2a81ca8d61 clang-format: add option to merge empty function body
Summary:
This option supplements the AllowShortFunctionsOnASingleLine flag, to
merge empty function body at the beginning of the line: e.g. when the
function is not short-enough and breaking braces after function.

  int f()
  {}

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 305272
2017-06-13 07:02:43 +00:00
Nick Lewycky 54992386f3 Revert r301742 which made ExprConstant checking apply to all full-exprs.
This patch also exposed pre-existing bugs in clang, see PR32864 and PR33140#c3 .

llvm-svn: 305239
2017-06-12 21:59:18 +00:00
Richard Trieu 11d566acee [ODRHash] Add diagnostic messages for typedef and type alias.
llvm-svn: 305238
2017-06-12 21:58:22 +00:00