]> granicus.if.org Git - clang/log
clang
5 years agoAdd --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]
Sterling Augustine [Tue, 19 Mar 2019 20:01:59 +0000 (20:01 +0000)]
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]

"clang++ hello.cc --rtlib=compiler-rt"

now can works without specifying additional unwind or exception
handling libraries.

This reworked version of the feature no longer modifies today's default
unwind library for compiler-rt: which is nothing. Rather, a user
can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring
the compiler.

This should address the issues from the previous version.

Update tests for new --unwindlib semantics.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356508 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove options to separate checks that do not need to immediately follow the previous...
Douglas Yung [Tue, 19 Mar 2019 19:34:15 +0000 (19:34 +0000)]
Move options to separate checks that do not need to immediately follow the previous option. NFCI

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356507 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix unused variable warning. NFCI.
Simon Pilgrim [Tue, 19 Mar 2019 18:39:46 +0000 (18:39 +0000)]
Fix unused variable warning. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356497 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Check that global vars require predefined allocator.
Alexey Bataev [Tue, 19 Mar 2019 18:39:11 +0000 (18:39 +0000)]
[OPENMP]Check that global vars require predefined allocator.

According to OpenMP, 2.11.3 allocate Directive, Restrictions, C / C++,
if a list item has a static storage type, the allocator expression in
  the allocator clause must be a constant expression that evaluates to
  one of the predefined memory allocator values. Added check for this
  restriction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356496 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Remove unused parameter, NFC.
Alexey Bataev [Tue, 19 Mar 2019 17:09:52 +0000 (17:09 +0000)]
[OPENMP]Remove unused parameter, NFC.

Parameter CodeGenModule &CGM is not required for CGOpenMPRuntime member
functions, since class holds the reference to the CGM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356480 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Minor improvements in default header testing
Anastasia Stulova [Tue, 19 Mar 2019 17:09:06 +0000 (17:09 +0000)]
[OpenCL] Minor improvements in default header testing

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356479 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Adjust addr space of reference operand in compound assignment
Anastasia Stulova [Tue, 19 Mar 2019 16:50:21 +0000 (16:50 +0000)]
[Sema] Adjust addr space of reference operand in compound assignment

When we create overloads for the builtin compound assignment operators
we need to preserve address space for the reference operand taking it
from the argument that is passed in.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356475 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP] Codegen for local variables with the allocate pragma.
Alexey Bataev [Tue, 19 Mar 2019 16:41:16 +0000 (16:41 +0000)]
[OPENMP] Codegen for local variables with the allocate pragma.

Added initial codegen for the local variables with the #pragma omp
allocate directive. Instead of allocating the variables on the stack,
__kmpc_alloc|__kmpc_free functions are used for memory (de-)allocation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356472 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoEnsure that const variables declared at namespace scope correctly have external linka...
Aaron Ballman [Tue, 19 Mar 2019 14:53:52 +0000 (14:53 +0000)]
Ensure that const variables declared at namespace scope correctly have external linkage when marked as dllexport and targeting the MSVC ABI.

Patch thanks to Zahira Ammarguellat.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356458 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Fix redecl failures of FunctionTemplateSpec
Gabor Marton [Tue, 19 Mar 2019 14:04:50 +0000 (14:04 +0000)]
[ASTImporter] Fix redecl failures of FunctionTemplateSpec

Summary:
Redecl chains of function template specializations are not handled well
currently. We want to handle them similarly to functions, i.e. try to
keep the structure of the original AST as much as possible. The aim is
to not squash a prototype with a definition, rather we create both and
put them in a redecl chain.

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356455 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Fix redecl failures of ClassTemplateSpec
Gabor Marton [Tue, 19 Mar 2019 13:34:10 +0000 (13:34 +0000)]
[ASTImporter] Fix redecl failures of ClassTemplateSpec

Summary:
Redecl chains of class template specializations are not handled well
currently. We want to handle them similarly to functions, i.e. try to
keep the structure of the original AST as much as possible. The aim is
to not squash a prototype with a definition, rather we create both and
put them in a redecl chain.

Reviewers: a_sidorin, shafik, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, jdoerfert, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356452 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Improved testing of default header.
Anastasia Stulova [Tue, 19 Mar 2019 13:04:17 +0000 (13:04 +0000)]
[OpenCL] Improved testing of default header.

Improved some checks and moved testing of the default header
in C++ mode into the Headers folder.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356450 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] [JS] handle private members.
Martin Probst [Tue, 19 Mar 2019 12:28:41 +0000 (12:28 +0000)]
[clang-format] [JS] handle private members.

Addresses PR40999 https://bugs.llvm.org/show_bug.cgi?id=40999

Private fields and methods in JavaScript would get incorrectly indented
(it sees them as preprocessor directives and hence left aligns them)

In this revision `#identifier` tokens `tok::hash->tok::identifier` are
merged into a single new token `tok::identifier` with the `#` contained
inside the TokenText.

Before:

```
class Example {
  pub = 1;

  static pub2 = "foo";
  static #priv2 = "bar";

  method() { this.#priv = 5; }

  static staticMethod() {
    switch (this.#priv) {
    case '1':
      break;
    }
  }

  this.#privateMethod(); // infinite loop
}

static #staticPrivateMethod() {}
}
```

After this fix the code will be correctly indented

```
class Example {
  pub = 1;
  #priv = 2;

  static pub2 = "foo";
  static #priv2 = "bar";

  method() { this.#priv = 5; }

  static staticMethod() {
    switch (this.#priv) {
    case '1':
      #priv = 3;
      break;
    }
  }

  #privateMethod() {
    this.#privateMethod(); // infinite loop
  }

  static #staticPrivateMethod() {}
}
```

NOTE: There might be some JavaScript code out there which uses the C
processor to preprocess .js files
http://www.nongnu.org/espresso/js-cpp.html. It's not clear how this
revision or even private fields and methods would interact.

Patch originally by MyDeveloperDays (thanks!).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356449 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] [JS] Don't break between template string and tag
Martin Probst [Tue, 19 Mar 2019 11:15:52 +0000 (11:15 +0000)]
[clang-format] [JS] Don't break between template string and tag

Before:
    const x = veryLongIdentifier
        `hello`;
After:
    const x =
        veryLongIdentifier`hello`;

While it's allowed to have the template string and tag identifier
separated by a line break, currently the clang-format output is not
stable when a break is forced. Additionally, disallowing a line break
makes it clear that the identifier is actually a tag for a template
string.

Patch originally by mitchellwills (thanks!).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356447 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Tooling] Add more scope specifiers until spelling is not ambiguous.
Eric Liu [Tue, 19 Mar 2019 10:12:15 +0000 (10:12 +0000)]
[Tooling] Add more scope specifiers until spelling is not ambiguous.

Summary:
Previously, when the renamed spelling is ambiguous, we simply use the
full-qualfied name (with leading "::"). This patch makes it try adding
additional specifiers one at a time until name is no longer ambiguous,
which allows us to find better disambuguated spelling.

Reviewers: kadircet, gribozavr

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356446 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRefactor cast<>'s in if conditionals, which can only assert on failure.
Don Hinton [Tue, 19 Mar 2019 06:14:14 +0000 (06:14 +0000)]
Refactor cast<>'s in if conditionals, which can only assert on failure.

Summary:
This patch refactors several instances of cast<> used in if
conditionals.  Since cast<> asserts on failure, the else branch can
never be taken.

In some cases, the fix is to replace cast<> with dyn_cast<>.  While
others required the removal of the conditional and some minor
refactoring.

A discussion can be seen here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190318/265044.html

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356441 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Change wasm.throw's first argument to an immediate
Heejin Ahn [Tue, 19 Mar 2019 04:58:59 +0000 (04:58 +0000)]
[WebAssembly] Change wasm.throw's first argument to an immediate

Summary:
`wasm.throw` builtin's first 'tag' argument should be an immediate index
into the event section.

Reviewers: dschuff, craig.topper

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356436 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFactor out repeated code parsing and concatenating header-names from
Richard Smith [Tue, 19 Mar 2019 01:51:19 +0000 (01:51 +0000)]
Factor out repeated code parsing and concatenating header-names from
tokens.

We now actually form an angled_string_literal token for a header name by
concatenation rather than just working out what its contents would be.
This substantially simplifies downstream processing and is necessary for
C++20 header unit imports.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356433 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDon't apply the include depth limit until we actually decide to enter
Richard Smith [Tue, 19 Mar 2019 01:51:17 +0000 (01:51 +0000)]
Don't apply the include depth limit until we actually decide to enter
the file.

NFC unless a skipped #include is found at the final permitted #include
level.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356432 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMinor renaming as suggested in review [NFC]
Aaron Puchert [Tue, 19 Mar 2019 00:14:46 +0000 (00:14 +0000)]
Minor renaming as suggested in review [NFC]

See D59455.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356430 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoThread safety analysis: Add note for unlock kind mismatch
Aaron Puchert [Mon, 18 Mar 2019 23:26:54 +0000 (23:26 +0000)]
Thread safety analysis: Add note for unlock kind mismatch

Summary:
Similar to D56967, we add the existing diag::note_locked_here to tell
the user where we saw the locking that isn't matched correctly.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356427 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MS] Skip vbase construction in abstract class ctors
Reid Kleckner [Mon, 18 Mar 2019 22:41:50 +0000 (22:41 +0000)]
[MS] Skip vbase construction in abstract class ctors

As background, when constructing a complete object, virtual bases are
constructed first. If an exception is thrown later in the ctor, those
virtual bases are destroyed, so sema marks the relevant constructors and
destructors of virtual bases as referenced. If necessary, they are
emitted.

However, an abstract class can never be used to construct a complete
object. In the Itanium C++ ABI, this works out nicely, because we never
end up emitting the "complete" constructor variant, only the "base"
constructor variant, which can be called by constructors of derived
classes. Clang's Sema::MarkBaseAndMemberDestructorsReferenced is aware
of this optimization, and it does not mark ctors and dtors of virtual
bases referenced when the constructor of an abstract class is emitted.

In the Microsoft ABI, there are no complete/base variants, so before
this change, the constructor of an abstract class could reference ctors
and dtors of a virtual base without marking them referenced. This could
lead to unresolved symbol errors at link time, as reported in PR41065.

The fix is to implement the same optimization as Sema: If the class is
abstract, don't bother initializing its virtual bases. The "is this
class the most derived class" check in the constructor will never pass,
and the virtual base constructor calls are always dead. Skip them.

I think Richard noticed this missed optimization back in 2016 when he
was implementing inheriting constructors. I wasn't able to find any bugs
or email about it, though.

Fixes PR41065

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356425 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Add gcc rotate intrinsics to ia32intrin.h
Craig Topper [Mon, 18 Mar 2019 22:25:57 +0000 (22:25 +0000)]
[X86] Add gcc rotate intrinsics to ia32intrin.h

This is another attempt at what Erich Keane tried to do in r355322.

This adds rolb, rolw, rold, rolq and their ror equivalent as always_inline wrappers around __builtin_rotate* which will lower to funnel shift intrinsics in IR.

Additionally, when _MSC_VER is not defined we will define _rotl, _lrotl, _rotr, _lrotr as macros to one of the always_inline intrinsics mentioned above. Making sure that _lrotl/_lrotr use either 32 or 64 bit based on the size of long. These need to be macros because we have builtins with the same name for MS compatibility, but _MSC_VER isn't always defined when those builtins are enabled.

We also define _rotwl and _rotwr as macros aliasing to rolw/rorw just like gcc to complete the set. These don't need to be gated with _MSC_VER because these aren't MS builtins.

I've added tests both for non-MS and -ms-extensions with and without _MSC_VER being defined.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356423 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Add some compile time _FORTIFY_SOURCE diagnostics
Erik Pilkington [Mon, 18 Mar 2019 19:23:45 +0000 (19:23 +0000)]
[Sema] Add some compile time _FORTIFY_SOURCE diagnostics

These diagnose overflowing calls to subset of fortifiable functions. Some
functions, like sprintf or strcpy aren't supported right not, but we should
probably support these in the future. We previously supported this kind of
functionality with -Wbuiltin-memcpy-chk-size, but that diagnostic doesn't work
with _FORTIFY implementations that use wrapper functions. Also unlike that
diagnostic, we emit these warnings regardless of whether _FORTIFY_SOURCE is
actually enabled, which is nice for programs that don't enable the runtime
checks.

Why not just use diagnose_if, like Bionic does? We can get better diagnostics in
the compiler (i.e. mention the sizes), and we have the potential to diagnose
sprintf and strcpy which is impossible with diagnose_if (at least, in languages
that don't support C++14 constexpr). This approach also saves standard libraries
from having to add diagnose_if.

rdar://48006655

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356397 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP] Set scheduling for doacross loops as schedule, 1.
Alexey Bataev [Mon, 18 Mar 2019 18:40:00 +0000 (18:40 +0000)]
[OPENMP] Set scheduling for doacross loops as schedule, 1.

The default scheduling for doacross loops is changed from static to
static, 1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356388 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AMDGPU] Add the missing clang change of the experimental buffer fat pointer
Michael Liao [Mon, 18 Mar 2019 18:11:37 +0000 (18:11 +0000)]
[AMDGPU] Add the missing clang change of the experimental buffer fat pointer

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356385 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd testcase from bug 41079
Matt Arsenault [Sun, 17 Mar 2019 23:16:31 +0000 (23:16 +0000)]
Add testcase from bug 41079

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356354 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoCodeGen: Preserve packed attribute in constStructWithPadding.
Peter Collingbourne [Sat, 16 Mar 2019 19:25:39 +0000 (19:25 +0000)]
CodeGen: Preserve packed attribute in constStructWithPadding.

Otherwise the object may have an incorrect size due to tail padding.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356328 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] ConditionBRVisitor: Unknown condition evaluation support
Csaba Dabis [Sat, 16 Mar 2019 13:47:55 +0000 (13:47 +0000)]
[analyzer] ConditionBRVisitor: Unknown condition evaluation support

Summary:
If the constraint information is not changed between two program states the
analyzer has not learnt new information and made no report. But it is
possible to happen because we have no information at all. The new approach
evaluates the condition to determine if that is the case and let the user
know we just `Assuming...` some value.

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ

Subscribers: llvm-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin,
mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gsd, gerazo

Tags: #clang, #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356323 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] ConditionBRVisitor: Remove GDM checking
Csaba Dabis [Sat, 16 Mar 2019 11:55:07 +0000 (11:55 +0000)]
[analyzer] ConditionBRVisitor: Remove GDM checking

Summary:
Removed the `GDM` checking what could prevent reports made by this visitor.
Now we rely on constraint changes instead.
(It reapplies 356318 with a feature from 356319 because build-bot failure.)

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ

Subscribers: cfe-commits, jdoerfert, gerazo, xazax.hun, baloghadamsoftware,
szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356322 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[analyzer] ConditionBRVisitor: Remove GDM checking"
Csaba Dabis [Sat, 16 Mar 2019 10:44:49 +0000 (10:44 +0000)]
Revert "[analyzer] ConditionBRVisitor: Remove GDM checking"

This reverts commit f962485adad9d646511fd3240c0408d9554e6784.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356321 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[analyzer] ConditionBRVisitor: Unknown condition evaluation support"
Csaba Dabis [Sat, 16 Mar 2019 10:06:06 +0000 (10:06 +0000)]
Revert "[analyzer] ConditionBRVisitor: Unknown condition evaluation support"

This reverts commit 0fe67a61cd4aec13c7969a179517f1cc06ab05cd.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356320 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] ConditionBRVisitor: Unknown condition evaluation support
Csaba Dabis [Sat, 16 Mar 2019 09:24:30 +0000 (09:24 +0000)]
[analyzer] ConditionBRVisitor: Unknown condition evaluation support

Summary: If the constraint information is not changed between two program states the analyzer has not learnt new information and made no report. But it is possible to happen because we have no information at all. The new approach evaluates the condition to determine if that is the case and let the user know we just 'Assuming...' some value.

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gsd, gerazo

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356319 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] ConditionBRVisitor: Remove GDM checking
Csaba Dabis [Sat, 16 Mar 2019 09:16:16 +0000 (09:16 +0000)]
[analyzer] ConditionBRVisitor: Remove GDM checking

Summary: Removed the `GDM` checking what could prevent reports made by this visitor. Now we rely on constraint changes instead.

Reviewers: NoQ, george.karpenkov

Reviewed By: NoQ

Subscribers: jdoerfert, gerazo, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356318 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Use rethrow intrinsic in the rethrow block
Heejin Ahn [Sat, 16 Mar 2019 05:39:12 +0000 (05:39 +0000)]
[WebAssembly] Use rethrow intrinsic in the rethrow block

Summary:
Because in wasm we merge all catch clauses into one big catchpad, in
case none of the types in catch handlers matches after we test against
each of them, we should unwind to the next EH enclosing scope. For this,
we should NOT use a call to `__cxa_rethrow` but rather a call to our own
rethrow intrinsic, because what we're trying to do here is just to
transfer the control flow into the next enclosing EH pad (or the
caller). Calls to `__cxa_rethrow` should only be used after a call to
`__cxa_begin_catch`.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356317 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Teach scan-build to find clang when installed in /usr/local/bin/
Devin Coughlin [Sat, 16 Mar 2019 01:01:29 +0000 (01:01 +0000)]
[analyzer] Teach scan-build to find clang when installed in /usr/local/bin/

Change scan-build to support the scenario where scan-build is installed in
$TOOLCHAIN/usr/local/bin/ but clang itself is installed in $TOOLCHAIN/usr/bin/.

This is restricted to when 'xcrun' is present; that is, on the Mac.

rdar://problem/48914634

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356308 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agohello, clang
Csaba Dabis [Fri, 15 Mar 2019 23:44:35 +0000 (23:44 +0000)]
hello, clang

Test commit with head and body.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356307 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[coroutines][PR40978] Emit error for co_yield within catch block
Brian Gesiak [Fri, 15 Mar 2019 20:25:49 +0000 (20:25 +0000)]
[coroutines][PR40978] Emit error for co_yield within catch block

Summary:
As reported in https://bugs.llvm.org/show_bug.cgi?id=40978, it's an
error to use the `co_yield` or `co_await` keywords outside of a valid
"suspension context" as defined by [expr.await]p2 of
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4775.pdf.

Whether or not the current scope was in a function-try-block's
(https://en.cppreference.com/w/cpp/language/function-try-block) handler
could be determined using scope flag `Scope::FnTryCatchScope`. No
such flag existed for a simple C++ catch statement, so this commit adds
one.

Reviewers: GorNishanov, tks2103, rsmith

Reviewed By: GorNishanov

Subscribers: EricWF, jdoerfert, cfe-commits, lewissbaker

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356296 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CUDA][Windows] Partial fix for bug 38811 (Step 2 of 3)
Evgeny Mankov [Fri, 15 Mar 2019 19:04:46 +0000 (19:04 +0000)]
[CUDA][Windows] Partial fix for bug 38811 (Step 2 of 3)

Partial fix for the clang Bug 38811 "Clang fails to compile with CUDA-9.x on Windows".

[Synopsis]
__sptr is a new Microsoft specific modifier (https://docs.microsoft.com/en-us/cpp/cpp/sptr-uptr?view=vs-2017).

[Solution]
Replace all `__sptr` occurrences with `__s` (and all `__cptr` with `__c` as well) to eliminate the below clang compilation error on Windows.

In file included from C:\GIT\LLVM\trunk\llvm-64-release-vs2017-15.9.5\dist\lib\clang\9.0.0\include\__clang_cuda_runtime_wrapper.h:162:
C:\GIT\LLVM\trunk\llvm-64-release-vs2017-15.9.5\dist\lib\clang\9.0.0\include\__clang_cuda_device_functions.h:524:33: error: expected expression
  return __nv_fast_sincosf(__a, __sptr, __cptr);
                                ^
Reviewed by: Artem Belevich

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356291 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[HIP-Clang] propagate -mllvm options to opt and llc
Aaron Enye Shi [Fri, 15 Mar 2019 17:31:51 +0000 (17:31 +0000)]
[HIP-Clang] propagate -mllvm options to opt and llc

Change the HIP Toolchain to pass the OPT_mllvm options into OPT and LLC stages. Added a lit test to verify the command args.

Reviewers: yaxunl

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356277 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CUDA][Windows] Partial fix for bug #38811 (Step 1 of 3)
Evgeny Mankov [Fri, 15 Mar 2019 12:05:36 +0000 (12:05 +0000)]
[CUDA][Windows] Partial fix for bug #38811 (Step 1 of 3)

Partial fix for the clang Bug https://bugs.llvm.org/show_bug.cgi?id=38811 "Clang fails to compile with CUDA-9.x on Windows".

Adding defined(_WIN64) check along with existing #if defined(__LP64__) eliminates the below clang (64-bit) compilation error on Windows.

C:/GIT/LLVM/trunk/llvm-64-release-vs2017/dist/lib/clang/9.0.0\include\__clang_cuda_device_functions.h(1609,45): error GEF7559A7: no matching function for call to 'roundf'
 __DEVICE__ long lroundf(float __a) { return roundf(__a); }

Reviewed by: Artem Belevich

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356255 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMake getFullyQualifiedName qualify both the pointee and class type for member ptr...
Benjamin Kramer [Fri, 15 Mar 2019 11:09:41 +0000 (11:09 +0000)]
Make getFullyQualifiedName qualify both the pointee and class type for member ptr types

We already handle pointers and references, member ptrs are just another
special case. Fixes PR40732.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356250 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove an assert in template pack deduction during nested instantiation.
Richard Trieu [Fri, 15 Mar 2019 04:26:02 +0000 (04:26 +0000)]
Remove an assert in template pack deduction during nested instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356231 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd missing override specifier [NFC]
Aaron Puchert [Fri, 15 Mar 2019 02:30:07 +0000 (02:30 +0000)]
Add missing override specifier [NFC]

This should fix a -Winconsistent-missing-override warning that is only
visible when Z3 is enabled.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356228 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] RetainCount: A function isn't a CFRetain if it takes no arguments.
Artem Dergachev [Fri, 15 Mar 2019 00:26:17 +0000 (00:26 +0000)]
[analyzer] RetainCount: A function isn't a CFRetain if it takes no arguments.

Don't crash when a function has a name that starts with "CF" and ends with
"Retain" but takes 0 arguments. In particular, don't try to treat it as if
it returns its first argument.

These problems are inevitable because the checker is naming-convention-based,
but at least we shouldn't crash.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356223 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Support C++17 aggregates with bases without constructors.
Artem Dergachev [Fri, 15 Mar 2019 00:22:59 +0000 (00:22 +0000)]
[analyzer] Support C++17 aggregates with bases without constructors.

RegionStore now knows how to bind a nonloc::CompoundVal that represents the
value of an aggregate initializer when it has its initial segment of sub-values
correspond to base classes.

Additionally, fixes the crash from pr40022.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356222 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland the rest of "Add AIX Target Info"
Jason Liu [Thu, 14 Mar 2019 21:54:30 +0000 (21:54 +0000)]
Reland the rest of "Add AIX Target Info"

llvm-svn 356197 relanded previously failing test case max_align.c.
This commit will reland the rest of llvm-svn 356060 commit.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356208 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Fix crash for the ordered(n) clause.
Alexey Bataev [Thu, 14 Mar 2019 20:36:00 +0000 (20:36 +0000)]
[OPENMP]Fix crash for the ordered(n) clause.

If the doacross lop construct is used and the loop counter is declare
outside of the loop, the compiler might crash trying to get the address
of the loop counter. Patch fixes this problem.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356198 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland part of "Add AIX Target Info"
Jason Liu [Thu, 14 Mar 2019 20:27:39 +0000 (20:27 +0000)]
Reland part of "Add AIX Target Info"

This patch reland the test case max_align.c which is failing at
Windows and PS4 platform in the previous commit.

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

original llvm-svn: 356060

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356197 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeGen] Consider tied operands when adjusting inline asm operands.
Eli Friedman [Thu, 14 Mar 2019 19:46:51 +0000 (19:46 +0000)]
[CodeGen] Consider tied operands when adjusting inline asm operands.

The constraint "0" in the following asm did not consider the its
relationship with "=y" when try to replace the type of the operands.

asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));

Patch by Xiang Zhang.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356196 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Fix a use-after-free of a _Nonnull ParsedAttr
Erik Pilkington [Thu, 14 Mar 2019 18:38:02 +0000 (18:38 +0000)]
[Sema] Fix a use-after-free of a _Nonnull ParsedAttr

We were allocating the implicit attribute in the declarator's attribute pool,
but putting into the declaration specifier's ParsedAttributesView. If there are
multiple declarators, then we'll use the attribute from the declaration
specifier after clearing out the declarators attribute pool. Fix this by
allocating the attribute in the declaration specifier's pool.

rdar://48529718

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356187 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd PragmaHandler for MSVC pragma execution_character_set
Reid Kleckner [Thu, 14 Mar 2019 18:12:17 +0000 (18:12 +0000)]
Add PragmaHandler for MSVC pragma execution_character_set

__pragma(execution_character_set(push, "UTF-8")) is used in
TraceLoggingProvider.h. This commit implements a no-op handler for
compatability, similar to how the flag -fexec_charset is handled.

Patch by Matt Gardner!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356185 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Fix an assertation failure for invalid sourcelocation, add a new debug...
Kristof Umann [Thu, 14 Mar 2019 16:10:29 +0000 (16:10 +0000)]
[analyzer] Fix an assertation failure for invalid sourcelocation, add a new debug checker

For a rather short code snippet, if debug.ReportStmts (added in this patch) was
enabled, a bug reporter visitor crashed:

struct h {
  operator int();
};

int k() {
  return h();
}

Ultimately, this originated from PathDiagnosticLocation::createMemberLoc, as it
didn't handle the case where it's MemberExpr typed parameter returned and
invalid SourceLocation for MemberExpr::getMemberLoc. The solution was to find
any related valid SourceLocaion, and Stmt::getBeginLoc happens to be just that.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356161 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeGen][ObjC] Remove the leading 'l' from symbols for protocol
Akira Hatanaka [Thu, 14 Mar 2019 15:17:37 +0000 (15:17 +0000)]
[CodeGen][ObjC] Remove the leading 'l' from symbols for protocol
metadata and protocol list

The leading 'l' tells ld64 to remove the symbol name, which can make
debugging difficult.

rdar://problem/47256637

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356156 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix test after r356148
Nico Weber [Thu, 14 Mar 2019 14:40:48 +0000 (14:40 +0000)]
Fix test after r356148

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356154 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove unused variable to silence compiler warning [NFC]
Mikael Holmen [Thu, 14 Mar 2019 14:20:50 +0000 (14:20 +0000)]
Remove unused variable to silence compiler warning [NFC]

The only use of MI was removed in r356142.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356152 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Fix import of NestedNameSpecifierLoc.
Balazs Keri [Thu, 14 Mar 2019 14:20:23 +0000 (14:20 +0000)]
[ASTImporter] Fix import of NestedNameSpecifierLoc.

Summary:
Import type location in case of TypeSpec and TypeSpecWithTemplate.
Without this fix the imported NespedNameSpecifierLoc will have an
invalid begin location.

Reviewers: a.sidorin, shafik, a_sidorin, martong

Reviewed By: a_sidorin

Subscribers: rnkovacs, jdoerfert, dkrupp, martong, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356151 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoObjective-C++11: Support static_assert() in @interface/@implementation ivar lists...
Nico Weber [Thu, 14 Mar 2019 14:18:56 +0000 (14:18 +0000)]
Objective-C++11: Support static_assert() in @interface/@implementation ivar lists and method declarations

This adds support for static_assert() (and _Static_assert()) in
@interface/@implementation ivar lists and in @interface method declarations.

It was already supported in @implementation blocks outside of the ivar lists.

The assert AST nodes are added at file scope, matching where other
(non-Objective-C) declarations at @interface / @implementation level go (cf
`allTUVariables`).

Also add a `__has_feature(objc_c_static_assert)` that's true in C11 (and
`__has_extension(objc_c_static_assert)` that's always true) and
`__has_feature(objc_cxx_static_assert)` that's true in C++11 modea fter this
patch, so it's possible to check if this is supported.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356148 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Fix function macro crash
Kristof Umann [Thu, 14 Mar 2019 13:38:16 +0000 (13:38 +0000)]
[analyzer] Fix function macro crash

Re-commit D57893.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356142 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.
Craig Topper [Thu, 14 Mar 2019 05:45:42 +0000 (05:45 +0000)]
[X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode.

Summary:
This define should correspond to CMPXCHG16B being available which requires 64-bit mode.

I checked and gcc also seems to only define this in 64-bit mode.

Reviewers: RKSimon, spatel, efriedma, jyknight, jfb

Reviewed By: jfb

Subscribers: jfb, cfe-commits, llvm-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356118 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix invocation of Gold plugin with LTO after r355331
Nemanja Ivanovic [Wed, 13 Mar 2019 23:54:52 +0000 (23:54 +0000)]
Fix invocation of Gold plugin with LTO after r355331

The above commit breaks the usage of PGO and LTO when -fprofile-use is
supplied without a path. This patch changes the usage of this argument
to be inline with its use in addPGOAndCoverageFlags().

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356111 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Add a new attribute, fortify_stdlib"
Erik Pilkington [Wed, 13 Mar 2019 21:37:01 +0000 (21:37 +0000)]
Revert "Add a new attribute, fortify_stdlib"

This reverts commit r353765. After talking with our c stdlib folks, we decided
to use the existing pass_object_size attribute to implement _FORTIFY_SOURCE
wrappers, like Bionic does (I didn't realize that pass_object_size could be used
for this purpose). Sorry for the flip/flop, and thanks to James Y. Knight for
pointing this out to me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356103 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] Propagate inferred language to getLLVMStyle() in getPredefinedStyle()
Jordan Rupprecht [Wed, 13 Mar 2019 21:13:01 +0000 (21:13 +0000)]
[clang-format] Propagate inferred language to getLLVMStyle() in getPredefinedStyle()

rC355158 added an optional language parameter to getLLVMStyle(), but this parameter was not used in getPredefinedStyle(). Because unit tests directly specify the style, this codepath wasn't tested. Add an additional unit test for getStyle().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356099 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Fix PR37283: Assertion failure on openmp task with by reference
Alexey Bataev [Wed, 13 Mar 2019 20:46:28 +0000 (20:46 +0000)]
[OPENMP]Fix PR37283: Assertion failure on openmp task with by reference
array.

If the firstprivate variable is a reference, we may incorrectly classify
the kind of the private copy. Use the type of the private copy instead
of the original shared variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356098 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format][NFC] Include TableGen in enum->string mapping used for debugging
Jordan Rupprecht [Wed, 13 Mar 2019 20:34:34 +0000 (20:34 +0000)]
[clang-format][NFC] Include TableGen in enum->string mapping used for debugging

Running `clang-format -debug` prints "Unknown" for tablegen files because of this missing mapping, even though it is recognized as a tablegen file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356097 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[LibTooling] Add retrieval of extended AST-node source to FixIt library
Yitzhak Mandelbaum [Wed, 13 Mar 2019 19:48:51 +0000 (19:48 +0000)]
[LibTooling] Add retrieval of extended AST-node source to FixIt library

Summary:
Introduces variants of `getText` and `getSourceRange` that extract the source text of an AST node potentially with a trailing token.

Some of the new functions manipulate `CharSourceRange`s, rather than `SourceRange`s, because they document and dynamically enforce their type.  So, this revision also updates the corresponding existing FixIt functions to manipulate `CharSourceRange`s.  This change is not strictly necessary, but seems like the correct choice, to keep the API self-consistent.

This revision is the first in a series intended to improve the abstractions available to users for writing source-to-source transformations.  A full discussion of the end goal can be found on the cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling".

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: kimgr, riccibruno, JonasToth, jdoerfert, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356095 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Disable ADL in C for user-defined reductions.
Alexey Bataev [Wed, 13 Mar 2019 19:31:34 +0000 (19:31 +0000)]
[OPENMP]Disable ADL in C for user-defined reductions.

C does not support ADL, disable it for C to prevent compiler crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356089 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Analyzer] Clean up test/Analysis/ptr-sort.cpp
Mandeep Singh Grang [Wed, 13 Mar 2019 19:21:11 +0000 (19:21 +0000)]
[Analyzer] Clean up test/Analysis/ptr-sort.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356088 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix a failing test.
Erik Pilkington [Wed, 13 Mar 2019 19:20:45 +0000 (19:20 +0000)]
Fix a failing test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356087 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Analyzer] Update the LLVM license in PointerSortingChecker.cpp
Mandeep Singh Grang [Wed, 13 Mar 2019 19:09:48 +0000 (19:09 +0000)]
[Analyzer] Update the LLVM license in PointerSortingChecker.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356086 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Parse] Parse '#pragma clang attribute' as an external-declaration
Erik Pilkington [Wed, 13 Mar 2019 18:30:59 +0000 (18:30 +0000)]
[Parse] Parse '#pragma clang attribute' as an external-declaration

Previously, we parsed it only in the top level, which excludes namespaces and
extern "C" blocks.

rdar://problem/48818890

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356075 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP][NVPTX]Fix PR40893: Size doesn't match for
Alexey Bataev [Wed, 13 Mar 2019 18:21:10 +0000 (18:21 +0000)]
[OPENMP][NVPTX]Fix PR40893: Size doesn't match for
'_openmp_teams_reductions_buffer_$_.

nvlink does not handle weak linkage correctly, same symbols with the
different sizes are reported as erroneous though the largest size must
be chosen instead. Patch fixes this problem by using Internal linkage
instead of the Common.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356072 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Add AIX Target Info"
Jason Liu [Wed, 13 Mar 2019 17:57:23 +0000 (17:57 +0000)]
Revert "Add AIX Target Info"

This reverts commit 4e192d0e1e72ce32fabf1bccc06ac31ab5385e78.
The newly added test case max_align.c do not work on all platforms.

original llvm-svn: 356060

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356070 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libclang] Expose aligned() attribute.
Emilio Cobos Alvarez [Wed, 13 Mar 2019 16:16:54 +0000 (16:16 +0000)]
[libclang] Expose aligned() attribute.

Summary:
This is useful because otherwise there's no easy way to distinguish #pragma
packed(N) from attribute(packed, aligned(N)) that isn't looking at field
offsets (since pragma packed() also creates a packed attribute).

Reviewers: Anastasia, arphaman, serge-sans-paille

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356062 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd AIX Target Info
Jason Liu [Wed, 13 Mar 2019 16:02:26 +0000 (16:02 +0000)]
Add AIX Target Info

Summary:
A first pass over platform-specific properties of the C API/ABI
on AIX for both 32-bit and 64-bit modes.
This is a continuation of D18360 by Andrew Paprocki and further work by Wu Zhao.

Patch by Andus Yu

Reviewers: apaprocki, chandlerc, hubert.reinterpretcast, jasonliu,
xingxue, sfertile

Reviewed by: hubert.reinterpretcast, apaprocki, sfertile

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356060 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Analyzer] Skip symbolic regions based on conjured symbols in comparison of the conta...
Adam Balogh [Wed, 13 Mar 2019 13:55:11 +0000 (13:55 +0000)]
[Analyzer] Skip symbolic regions based on conjured symbols in comparison of the containers of iterators

Checking whether two regions are the same is a partially decidable problem:
either we know for sure that they are the same or we cannot decide. A typical
case for this are the symbolic regions based on conjured symbols. Two
different conjured symbols are either the same or they are different. Since
we cannot decide this and want to reduce false positives as much as possible
we exclude these regions whenever checking whether two containers are the
same at iterator mismatch check.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356049 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`
Aleksandr Urakov [Wed, 13 Mar 2019 13:38:12 +0000 (13:38 +0000)]
[AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`

Summary:
This patch fixes several small problems with external layouts support in
`MicrosoftRecordLayoutBuilder`:
- aligns properly the size of a struct that ends with a bit field. It was
  aligned on byte before, not on the size of the field, so the struct size was
  smaller than it should be;
- adjusts the struct size when injecting a vbptr in the case when there were no
  bases or fields allocated after the vbptr. Similarly, without the adjustment
  the struct was smaller than it should be;
- the same fix as above for the vfptr.
All these fixes affect the non-virtual size of a struct, so they are tested
through non-virtual inheritance.

Reviewers: rnk, zturner, rsmith

Reviewed By: rnk

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356047 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else...
Paul Hoad [Wed, 13 Mar 2019 08:26:39 +0000 (08:26 +0000)]
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
    if(true) var++;
    else  {
        var--;
    }
```

is reformatted to be

```
  if (true)
    var++;
  else {
    var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356031 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working...
Paul Hoad [Wed, 13 Mar 2019 08:15:03 +0000 (08:15 +0000)]
Revert "[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present"

This reverts commit b358cbb9b78389e20f7be36e1a98e26515c3ecce.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356030 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else...
Paul Hoad [Wed, 13 Mar 2019 08:07:46 +0000 (08:07 +0000)]
[clang-format] [PR25010] AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

Summary:
Addressing: PR25010 - https://bugs.llvm.org/show_bug.cgi?id=25010

Code like:

```
    if(true) var++;
    else  {
        var--;
    }
```

is reformatted to be

```
  if (true)
    var++;
  else {
    var--;
  }
```

Even when `AllowShortIfStatementsOnASingleLine` is true

The following revision comes from a +1'd suggestion in the PR to support AllowShortIfElseStatementsOnASingleLine

This suppresses the clause prevents the merging of the if when there is a compound else

Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, reuk
Reviewed By: reuk
Subscribers: reuk, Higuoxing, jdoerfert, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59087

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356029 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Remove 'cx16' from 'prescott' and 'yonah' as they are 32-bit only CPUs and...
Craig Topper [Wed, 13 Mar 2019 05:14:52 +0000 (05:14 +0000)]
[X86] Remove 'cx16' from 'prescott' and 'yonah' as they are 32-bit only CPUs and cmpxchg16b requires 64-bit mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356008 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Add 'yonah' test to predefined-arch-macros.c test.
Craig Topper [Wed, 13 Mar 2019 05:14:50 +0000 (05:14 +0000)]
[X86] Add 'yonah' test to predefined-arch-macros.c test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356007 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDelete unused declaration of DeclContextPrintAction after the removal of -print-decl...
Fangrui Song [Wed, 13 Mar 2019 03:22:33 +0000 (03:22 +0000)]
Delete unused declaration of DeclContextPrintAction after the removal of -print-decl-contexts by D52529

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356005 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd XCOFF triple object format type for AIX
Jason Liu [Tue, 12 Mar 2019 22:01:10 +0000 (22:01 +0000)]
Add XCOFF triple object format type for AIX

This patch adds an XCOFF triple object format type into LLVM.
This XCOFF triple object file type will be used later by object file and assembly generation for the AIX platform.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355989 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][clang][PCH][ObjC] Add some missing `VisitStmt(S);`
Roman Lebedev [Tue, 12 Mar 2019 21:31:00 +0000 (21:31 +0000)]
[NFC][clang][PCH][ObjC] Add some missing `VisitStmt(S);`

Summary:
These ObjC AST classes inherit from Stmt, but don't call `VisitStmt(S);`.
Some were founded with help of existing tests (with `NumStmtFields` bumped to `1`),
but some of them don't even have PCH test coverage. :/

Reviewers: arphaman, sammccall, smeenai, aprantl, rsmith, jordan_rose

Reviewed By: jordan_rose

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355987 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland "[Remarks] Add -foptimization-record-passes to filter remark emission"
Francis Visoiu Mistrih [Tue, 12 Mar 2019 21:22:27 +0000 (21:22 +0000)]
Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"

Currently we have -Rpass for filtering the remarks that are displayed as
diagnostics, but when using -fsave-optimization-record, there is no way
to filter the remarks while generating them.

This adds support for filtering remarks by passes using a regex.
Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline`

will only emit the remarks coming from the pass `inline`.

This adds:

* `-fsave-optimization-record` to the driver
* `-opt-record-passes` to cc1
* `-lto-pass-remarks-filter` to the LTOCodeGenerator
* `--opt-remarks-passes` to lld
* `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2
* `-opt-remarks-passes` to gold-plugin

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

Original llvm-svn: 355964

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355984 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[Remarks] Add -foptimization-record-passes to filter remark emission"
Francis Visoiu Mistrih [Tue, 12 Mar 2019 20:54:18 +0000 (20:54 +0000)]
Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"

This reverts commit 20fff32b7d1f1a1bd417b22aa9f26ededd97a3e5.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355976 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Remarks] Add -foptimization-record-passes to filter remark emission
Francis Visoiu Mistrih [Tue, 12 Mar 2019 20:28:50 +0000 (20:28 +0000)]
[Remarks] Add -foptimization-record-passes to filter remark emission

Currently we have -Rpass for filtering the remarks that are displayed as
diagnostics, but when using -fsave-optimization-record, there is no way
to filter the remarks while generating them.

This adds support for filtering remarks by passes using a regex.
Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline`

will only emit the remarks coming from the pass `inline`.

This adds:

* `-fsave-optimization-record` to the driver
* `-opt-record-passes` to cc1
* `-lto-pass-remarks-filter` to the LTOCodeGenerator
* `--opt-remarks-passes` to lld
* `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2
* `-opt-remarks-passes` to gold-plugin

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355964 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Allow to redefine entry for the variables definitions.
Alexey Bataev [Tue, 12 Mar 2019 20:05:17 +0000 (20:05 +0000)]
[OPENMP]Allow to redefine entry for the variables definitions.

If the variable was declared and marked as declare target, a new offload
entry with size 0 is created. But if later a definition is created and
marked as declare target, this definition is not added to the entry set
and the definition remains not mapped to the target. Patch fixes this
problem allowing to redefine the size and linkage for
previously registered declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355960 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP 5.0]Initial support for 'allocator' clause.
Alexey Bataev [Tue, 12 Mar 2019 18:52:33 +0000 (18:52 +0000)]
[OPENMP 5.0]Initial support for 'allocator' clause.

Added parsing/sema analysis/serialization/deserialization for the
'allocator' clause of the 'allocate' directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355952 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoModules: Add LangOptions::CacheGeneratedPCH
Duncan P. N. Exon Smith [Tue, 12 Mar 2019 18:38:04 +0000 (18:38 +0000)]
Modules: Add LangOptions::CacheGeneratedPCH

Add an option to cache the generated PCH in the ModuleCache when
emitting it.  This protects clients that build PCHs and read them in the
same process, allowing them to avoid race conditions between parallel
jobs the same way that Clang's implicit module build system does.

rdar://problem/48740787

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355950 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd a creduce script for clang crashes
George Burgess IV [Tue, 12 Mar 2019 17:48:53 +0000 (17:48 +0000)]
Add a creduce script for clang crashes

This CL adds a script that calls C-Reduce on an input file and given the
clang crash script, which is used to generate an interestingness test
for C-Reduce.

Patch by Amy Huang!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355944 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CMake] Tell libc++ that we're using compiler-rt on Apple platforms
Louis Dionne [Tue, 12 Mar 2019 15:32:00 +0000 (15:32 +0000)]
[CMake] Tell libc++ that we're using compiler-rt on Apple platforms

Reviewers: beanz, arphaman, EricWF

Subscribers: dberris, mgorny, jkorous, dexonsmith, jdoerfert, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355927 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[PR41007][OpenCL] Allow printf in C++ mode.
Anastasia Stulova [Tue, 12 Mar 2019 12:46:56 +0000 (12:46 +0000)]
[PR41007][OpenCL] Allow printf in C++ mode.

As for OpenCL C, we need to allow using printf and toolchain variadic
functions (prefixed by "__") in C++ mode.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355915 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[analyzer] Fix function macro crash"
Kristof Umann [Tue, 12 Mar 2019 11:22:30 +0000 (11:22 +0000)]
Revert "[analyzer] Fix function macro crash"

Buildbot breaks when LLVm is compiled with memory sanitizer.

WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xa3d16d8 in getMacroNameAndPrintExpansion(blahblah)
                             lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:903:11

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355911 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Fix function macro crash
Kristof Umann [Tue, 12 Mar 2019 10:03:32 +0000 (10:03 +0000)]
[analyzer] Fix function macro crash

When there is a functor-like macro which is passed as parameter to another
"function" macro then its parameters are not listed at the place of expansion:

#define foo(x) int bar() { return x; }
#define hello(fvar) fvar(0)
hello(foo)
int main() { 1 / bar(); }

Expansion of hello(foo) asserted Clang, because it expected an l_paren token in
the 3rd line after "foo", since it is a function-like token.

Patch by Tibor Brunner!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355903 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Driver] Support object files in addition to static and shared libraries in compiler-rt
Petr Hosek [Tue, 12 Mar 2019 02:12:48 +0000 (02:12 +0000)]
[Driver] Support object files in addition to static and shared libraries in compiler-rt

This change introduces support for object files in addition to static
and shared libraries which were already supported which requires
changing the type of the argument from boolean to an enum.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355891 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[DebugInfo] Add test cases for FlagNonTrivial
Aaron Smith [Tue, 12 Mar 2019 02:00:39 +0000 (02:00 +0000)]
[DebugInfo] Add test cases for FlagNonTrivial

Summary:
This is a test case to go with D44406 which added FlagNonTrivial to mark that a C++ record is non-trivial to support CodeView debug emission.

While it looks like FlagTypePassByValue can imply triviality and FlagTypePassByReference can imply non-triviality that is not true. Some non-trivial cases use a combination of FlagNonTrivial and FlagTypePassByValue instead of FlagTypePassByReference. See the test cases and D44406 for discussion.

Reviewers: dblaikie, rnk, zturner

Reviewed By: dblaikie

Subscribers: jdoerfert, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355890 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove esan.
Nico Weber [Mon, 11 Mar 2019 20:23:40 +0000 (20:23 +0000)]
Remove esan.

It hasn't seen active development in years, and it hasn't reached a
state where it was useful.

Remove the code until someone is interested in working on it again.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355862 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Fix codegen for declare target link in target regions.
Alexey Bataev [Mon, 11 Mar 2019 19:51:42 +0000 (19:51 +0000)]
[OPENMP]Fix codegen for declare target link in target regions.

If the declare target link global is used in the target region
indirectly (used in the inner parallel, teams, etc. regions), we may
miss this variable and it leads to incorrect codegen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355858 91177308-0d34-0410-b5e6-96231b3b80d8