]> granicus.if.org Git - clang/log
clang
5 years ago[ASTMatcher] Add clang-query disclaimer to two more matchers that take enum
Roman Lebedev [Thu, 21 Mar 2019 15:33:43 +0000 (15:33 +0000)]
[ASTMatcher] Add clang-query disclaimer to two more matchers that take enum

As we have figured out in
https://reviews.llvm.org/D57112
and
https://bugs.llvm.org/show_bug.cgi?id=41176

this kind-of works, but needs special care.

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

5 years ago[ASTMatchers][OpenMP] OpenMP Structured-block-related matchers
Roman Lebedev [Thu, 21 Mar 2019 15:33:35 +0000 (15:33 +0000)]
[ASTMatchers][OpenMP] OpenMP Structured-block-related matchers

Summary: Exposes to the  for ASTMatchers the interface/modelling
of OpenMP structured-block.

Reviewers: gribozavr, aaron.ballman, JonasToth, george.karpenkov

Reviewed By: gribozavr, aaron.ballman

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang, #openmp

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

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

5 years ago[ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handling
Roman Lebedev [Thu, 21 Mar 2019 15:33:24 +0000 (15:33 +0000)]
[ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handling

Summary:
`OMPClause` is the base class, it is not descendant from **any**
other class, therefore for it to work with e.g.
`VariadicDynCastAllOfMatcher<>`, it needs to be handled here.

Reviewers: sbenza, bkramer, pcc, klimek, hokein, gribozavr, aaron.ballman, george.karpenkov

Reviewed By: gribozavr, aaron.ballman

Subscribers: guansong, jdoerfert, alexfh, ABataev, cfe-commits

Tags: #openmp, #clang

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

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

5 years ago[ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.
Roman Lebedev [Thu, 21 Mar 2019 15:33:10 +0000 (15:33 +0000)]
[ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.

Summary:
A simple matcher for `OMPExecutableDirective` Stmt type.
Split off from D57113.

Reviewers: gribozavr, aaron.ballman, JonasToth, george.karpenkov

Reviewed By: gribozavr, aaron.ballman

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

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

5 years agoPermit redeclarations of a builtin to specify calling convention.
Erich Keane [Thu, 21 Mar 2019 13:30:56 +0000 (13:30 +0000)]
Permit redeclarations of a builtin to specify calling convention.

After https://reviews.llvm.org/rL355317 we noticed that quite a decent
amount of code redeclares builtins (memcpy in particular, I believe
reduced from an MSVC header) with a calling convention specified.
This gets particularly troublesome when the user specifies a new
'default' calling convention on the command line.

When looking to add a diagnostic for this case, it was noticed that we
had 3 other diagnostics that differed only slightly.  This patch ALSO
unifies those under a 'select'.  Unfortunately, the order of words in
ONE of these diagnostics was reversed ("'thiscall' calling convention"
vs "calling convention 'thiscall'"), so this patch also standardizes on
the former.

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

Change-Id: I79f99fe7c2301640755ffdd774b46eb44526bb22

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

5 years ago[clang-format] Add basic support for formatting C# files
Paul Hoad [Thu, 21 Mar 2019 13:09:22 +0000 (13:09 +0000)]
[clang-format] Add basic support for formatting C# files

Summary:

This revision adds basic support for formatting C# files with clang-format, I know the barrier to entry is high here  so I'm sending this revision in to test the water as to whether this might be something we'd consider landing.

Tracking in Bugzilla as:
https://bugs.llvm.org/show_bug.cgi?id=40850

Justification:
C# code just looks ugly in comparison to the C++ code in our source tree which is clang-formatted.

I've struggled with Visual Studio reformatting to get a clean and consistent style, I want to format our C# code on saving like I do now for C++ and i want it to have the same style as defined in our .clang-format file, so it consistent as it can be with C++.  (Braces/Breaking/Spaces/Indent etc..)

Using clang format without this patch leaves the code in a bad state, sometimes when the BreakStringLiterals is set, it  fails to compile.

Mostly the C# is similar to Java, except instead of JavaAnnotations I try to reuse the TT_AttributeSquare.

Almost the most valuable portion is to have a new Language in order to partition the configuration for C# within a common .clang-format file, with the auto detection on the .cs extension. But there are other C# specific styles that could be added later if this is accepted. in particular how  `{ set;get }` is formatted.

Reviewers: djasper, klimek, krasimir, benhamilton, JonasToth

Reviewed By: klimek

Subscribers: llvm-commits, mgorny, jdoerfert, cfe-commits

Tags: #clang, #clang-tools-extra

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

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

5 years agocreduce-clang-crash.py: preprocess file + reduce commandline
George Burgess IV [Thu, 21 Mar 2019 01:01:53 +0000 (01:01 +0000)]
creduce-clang-crash.py: preprocess file + reduce commandline

This CL causes our creduce-clang-crash.py util to:

- try to preprocess the file before reducing
- try to remove some command line arguments
- now require a llvm bin directory, since the generated crash script
  doesn't have an absolute path for clang

It also marks it as executable, since I forgot to do that in the last
commit. :)

Patch by Amy Huang!

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

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

5 years ago[CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in constructors.
Artem Dergachev [Thu, 21 Mar 2019 00:15:07 +0000 (00:15 +0000)]
[CFG] [analyzer] pr41142: C++17: Skip transparent InitListExprs in constructors.

When searching for construction contexts, i.e. figuring out which statements
define the object that is constructed by each construct-expression, ignore
transparent init-list expressions because they don't add anything to the
context. This allows the Static Analyzer to model construction, destruction,
materialization, lifetime extension correctly in more cases. Also fixes
a crash caused by incorrectly evaluating initial values of variables
initialized with such expressions.

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

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

5 years agoRemove extra white spaces
Jennifer Yu [Wed, 20 Mar 2019 23:05:18 +0000 (23:05 +0000)]
Remove extra white spaces

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

5 years agoRevert "[clangd] Print arguments in template specializations"
Jordan Rupprecht [Wed, 20 Mar 2019 22:51:56 +0000 (22:51 +0000)]
Revert "[clangd] Print arguments in template specializations"

This reverts commit 44a63f6a150dec72dea43730d2a89d292e58bd6f. It segfaults on an internal test case (will follow up off thread).

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

5 years ago[clang-format][NFC] fix release notes build issue
Paul Hoad [Wed, 20 Mar 2019 21:02:12 +0000 (21:02 +0000)]
[clang-format][NFC] fix release notes build issue

build issue from r356613

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

5 years ago[clang][OpenMP] Fix build when using libgomp
Jordan Rupprecht [Wed, 20 Mar 2019 21:01:56 +0000 (21:01 +0000)]
[clang][OpenMP] Fix build when using libgomp

Summary: rL356570 introduced a test which only passes with the default openmp library, libomp, and fails with other openmp libraries, such as libgomp. Explicitly choose libomp.

Reviewers: lebedev.ri

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

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

5 years ago[clang-format] BeforeHash added to IndentPPDirectives
Paul Hoad [Wed, 20 Mar 2019 20:49:43 +0000 (20:49 +0000)]
[clang-format] BeforeHash added to IndentPPDirectives

Summary:
The option BeforeHash added to IndentPPDirectives.
Fixes Bug 36019. https://bugs.llvm.org/show_bug.cgi?id=36019

Reviewers: djasper, klimek, krasimir, sammccall, mprobst, Nicola, MyDeveloperDay

Reviewed By: klimek, MyDeveloperDay

Subscribers: kadircet, MyDeveloperDay, mnussbaum, geleji, ufna, cfe-commits

Patch by to-mix.

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

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

5 years ago[X86] Add __crc32b/__crc32w/__crc32d/__crc32q intrinsics to match gcc and icc.
Craig Topper [Wed, 20 Mar 2019 20:25:28 +0000 (20:25 +0000)]
[X86] Add __crc32b/__crc32w/__crc32d/__crc32q intrinsics to match gcc and icc.

gcc has these intrinsics in ia32intrin.h as well. And icc implements them
though they aren't documented in the Intel Intrinsics Guide.

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

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

5 years ago[OPENMP]Improve detection of omp_allocator_handle_t type and predefined
Alexey Bataev [Wed, 20 Mar 2019 20:14:22 +0000 (20:14 +0000)]
[OPENMP]Improve detection of omp_allocator_handle_t type and predefined
allocators.

It is better to deduce omp_allocator_handle_t type from the predefined
allocators, because omp.h header might not define it explicitly. Plus,
it allows to identify the predefined allocators correctly when trying to
build the allcoator for the global variables.

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

5 years agoFix implicit ios -> watchOS availability version mapping for
Alex Lorenz [Wed, 20 Mar 2019 20:02:00 +0000 (20:02 +0000)]
Fix implicit ios -> watchOS availability version mapping for
versions that have the major number only

rdar://48018651

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

5 years agoAdd a __has_extension check for '#pragma clang attribute' as an external-declaration
Erik Pilkington [Wed, 20 Mar 2019 19:26:37 +0000 (19:26 +0000)]
Add a __has_extension check for '#pragma clang attribute' as an external-declaration

This was added in r356075.

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

5 years ago[Sema] Deduplicate some availability checking logic
Erik Pilkington [Wed, 20 Mar 2019 19:26:33 +0000 (19:26 +0000)]
[Sema] Deduplicate some availability checking logic

Before this commit, we emit unavailable errors for calls to functions during
overload resolution, and for references to all other declarations in
DiagnoseUseOfDecl. The early checks during overload resolution aren't as good as
the DiagnoseAvailabilityOfDecl based checks, as they error on the code from
PR40991. This commit fixes this by removing the early checking.

llvm.org/PR40991
rdar://48564179

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

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

5 years agoRecommit "Support attribute used in member funcs of class templates"
Rafael Auler [Wed, 20 Mar 2019 19:22:24 +0000 (19:22 +0000)]
Recommit "Support attribute used in member funcs of class templates"

This diff previously exposed a bug in LLVM's IRLinker, breaking
buildbots that tried to self-host LLVM with monolithic LTO.
The bug is now in LLVM by D59552

Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.

Test Plan: Added a testcase

Reviewed By: aaron.ballman

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

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

5 years agoRemove the unused return value in ASTImporter::Imported [NFC]
Raphael Isemann [Wed, 20 Mar 2019 19:00:25 +0000 (19:00 +0000)]
Remove the unused return value in ASTImporter::Imported [NFC]

Summary:
`ASTImporter::Imported` currently returns a Decl, but that return value is not used by the ASTImporter (or anywhere else)
nor is it documented.

Reviewers: balazske, martong, a.sidorin, shafik

Reviewed By: balazske, martong

Subscribers: rnkovacs, cfe-commits

Tags: #clang

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

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

5 years ago[X86] Remove getCPUKindCanonicalName which is unused.
Craig Topper [Wed, 20 Mar 2019 17:26:51 +0000 (17:26 +0000)]
[X86] Remove getCPUKindCanonicalName which is unused.

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

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

5 years ago[NFC][ASTMatchers] Alphabetically sort REGISTER_MATCHER() macros in RegistryMaps...
Roman Lebedev [Wed, 20 Mar 2019 17:15:47 +0000 (17:15 +0000)]
[NFC][ASTMatchers] Alphabetically sort REGISTER_MATCHER() macros in RegistryMaps::RegistryMaps()

As noted in https://reviews.llvm.org/D59453#inline-526253

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

5 years ago[AST] Disable ast-dump-openmp-parallel-master-XFAIL.c test
Roman Lebedev [Wed, 20 Mar 2019 17:14:49 +0000 (17:14 +0000)]
[AST] Disable ast-dump-openmp-parallel-master-XFAIL.c test

Fails on MSVC buildbot (but not locally).
Not important as it is 'testing' something that isn't supported yet anyway:
https://bugs.llvm.org/show_bug.cgi?id=41022

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

5 years ago[clang-format] structured binding in range for detected as Objective C
Paul Hoad [Wed, 20 Mar 2019 17:10:23 +0000 (17:10 +0000)]
[clang-format] structured binding in range for detected as Objective C

Summary:
Sometime after 6.0.0 and the current trunk 9.0.0 the following code would be considered as objective C and not C++

Reported by: https://twitter.com/mattgodbolt/status/1096188576503644160

$ clang-format.exe test.h
Configuration file(s) do(es) not support Objective-C: C:\clang\build\.clang-format

--- test.h --
```

std::vector<std::pair<std::string,std::string>> C;

void foo()
{
   for (auto && [A,B] : C)
   {
       std::string D = A + B;
   }
}
```
The following code fixes this issue of incorrect detection

Reviewers: djasper, klimek, JonasToth, reuk

Reviewed By: klimek

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

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

5 years ago[OpenCL] Generate 'unroll.enable' metadata for __attribute__((opencl_unroll_hint))
Andrew Savonichev [Wed, 20 Mar 2019 16:43:07 +0000 (16:43 +0000)]
[OpenCL] Generate 'unroll.enable' metadata for  __attribute__((opencl_unroll_hint))

Summary:
[OpenCL] Generate 'unroll.enable' metadata for  __attribute__((opencl_unroll_hint))

For both !{!"llvm.loop.unroll.enable"} and !{!"llvm.loop.unroll.full"} the unroller
will try to fully unroll a loop unless the trip count is not known at compile time.
In that case for '.full' metadata no unrolling will be processed, while for '.enable'
the loop will be partially unrolled with a heuristically chosen unroll factor.

See: docs/LanguageExtensions.rst

From https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/attributes-loopUnroll.html

    __attribute__((opencl_unroll_hint))
    for (int i=0; i<2; i++)
    {
        ...
    }

In the example above, the compiler will determine how much to unroll the loop.

Before the patch for  __attribute__((opencl_unroll_hint)) was generated metadata
!{!"llvm.loop.unroll.full"}, which limits ability of loop unroller to decide, how
much to unroll the loop.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: zzheng, dmgreen, jdoerfert, cfe-commits, asavonic, AlexeySotkin

Tags: #clang

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

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

5 years ago[clang][OpeMP] Model OpenMP structured-block in AST (PR40563)
Roman Lebedev [Wed, 20 Mar 2019 16:32:36 +0000 (16:32 +0000)]
[clang][OpeMP] Model OpenMP structured-block in AST (PR40563)

Summary:
https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-5.0.pdf, page 3:
```
structured block

For C/C++, an executable statement, possibly compound, with a single entry at the
top and a single exit at the bottom, or an OpenMP construct.

COMMENT: See Section 2.1 on page 38 for restrictions on structured
blocks.
```
```
2.1 Directive Format

Some executable directives include a structured block. A structured block:
• may contain infinite loops where the point of exit is never reached;
• may halt due to an IEEE exception;
• may contain calls to exit(), _Exit(), quick_exit(), abort() or functions with a
_Noreturn specifier (in C) or a noreturn attribute (in C/C++);
• may be an expression statement, iteration statement, selection statement, or try block, provided
that the corresponding compound statement obtained by enclosing it in { and } would be a
structured block; and

Restrictions
Restrictions to structured blocks are as follows:
• Entry to a structured block must not be the result of a branch.
• The point of exit cannot be a branch out of the structured block.
C / C++
• The point of entry to a structured block must not be a call to setjmp().
• longjmp() and throw() must not violate the entry/exit criteria.
```

Of particular note here is the fact that OpenMP structured blocks are as-if `noexcept`,
in the same sense as with the normal `noexcept` functions in C++.
I.e. if throw happens, and it attempts to travel out of the `noexcept` function
(here: out of the current structured-block), then the program terminates.

Now, one of course can say that since it is explicitly prohibited by the Specification,
then any and all programs that violate this Specification contain undefined behavior,
and are unspecified, and thus no one should care about them. Just don't write broken code /s

But i'm not sure this is a reasonable approach.
I have personally had oss-fuzz issues of this origin - exception thrown inside
of an OpenMP structured-block that is not caught, thus causing program termination.
This issue isn't all that hard to catch, it's not any particularly different from
diagnosing the same situation with the normal `noexcept` function.

Now, clang static analyzer does not presently model exceptions.
But clang-tidy has a simplisic [[ https://clang.llvm.org/extra/clang-tidy/checks/bugprone-exception-escape.html | bugprone-exception-escape ]] check,
and it is even refactored as a `ExceptionAnalyzer` class for reuse.
So it would be trivial to use that analyzer to check for
exceptions escaping out of OpenMP structured blocks. (D59466)

All that sounds too great to be true. Indeed, there is a caveat.
Presently, it's practically impossible to do. To check a OpenMP structured block
you need to somehow 'get' the OpenMP structured block, and you can't because
it's simply not modelled in AST. `CapturedStmt`/`CapturedDecl` is not it's representation.

Now, it is of course possible to write e.g. some AST matcher that would e.g.
match every OpenMP executable directive, and then return the whatever `Stmt` is
the structured block of said executable directive, if any.
But i said //practically//. This isn't practical for the following reasons:
1. This **will** bitrot. That matcher will need to be kept up-to-date,
   and refreshed with every new OpenMP spec version.
2. Every single piece of code that would want that knowledge would need to
   have such matcher. Well, okay, if it is an AST matcher, it could be shared.
   But then you still have `RecursiveASTVisitor` and friends.
   `2 > 1`, so now you have code duplication.

So it would be reasonable (and is fully within clang AST spirit) to not
force every single consumer to do that work, but instead store that knowledge
in the correct, and appropriate place - AST, class structure.

Now, there is another hoop we need to get through.
It isn't fully obvious //how// to model this.
The best solution would of course be to simply add a `OMPStructuredBlock` transparent
node. It would be optimal, it would give us two properties:
* Given this `OMPExecutableDirective`, what's it OpenMP structured block?
* It is trivial to  check whether the `Stmt*` is a OpenMP structured block (`isa<OMPStructuredBlock>(ptr)`)

But OpenMP structured block isn't **necessarily** the first, direct child of `OMP*Directive`.
(even ignoring the clang's `CapturedStmt`/`CapturedDecl` that were inserted inbetween).
So i'm not sure whether or not we could re-create AST statements after they were already created?
There would be other costs to a new AST node: https://bugs.llvm.org/show_bug.cgi?id=40563#c12
```
1. You will need to break the representation of loops. The body should be replaced by the "structured block" entity.
2. You will need to support serialization/deserialization.
3. You will need to support template instantiation.
4. You will need to support codegen and take this new construct to account in each OpenMP directive.
```

Instead, there **is** an functionally-equivalent, alternative solution, consisting of two parts.

Part 1:
* Add a member function `isStandaloneDirective()` to the `OMPExecutableDirective` class,
  that will tell whether this directive is stand-alone or not, as per the spec.
  We need it because we can't just check for the existance of associated statements,
  see code comment.
* Add a member function `getStructuredBlock()` to the OMPExecutableDirective` class itself,
  that assert that this is not a stand-alone directive, and either return the correct loop body
  if this is a loop-like directive, or the captured statement.
This way, given an `OMPExecutableDirective`, we can get it's structured block.
Also, since the knowledge is ingrained into the clang OpenMP implementation,
it will not cause any duplication, and //hopefully// won't bitrot.

Great we achieved 1 of 2 properties of `OMPStructuredBlock` approach.

Thus, there is a second part needed:
* How can we check whether a given `Stmt*` is `OMPStructuredBlock`?
Well, we can't really, in general. I can see this workaround:
```
class FunctionASTVisitor : public RecursiveASTVisitor<FunctionASTVisitor> {
  using Base = RecursiveASTVisitor<FunctionASTVisitor>;
public:
  bool VisitOMPExecDir(OMPExecDir *D) {
    OmpStructuredStmts.emplace_back(D.getStructuredStmt());
  }
  bool VisitSOMETHINGELSE(???) {
    if(InOmpStructuredStmt)
      HI!
  }
  bool TraverseStmt(Stmt *Node) {
    if (!Node)
      return Base::TraverseStmt(Node);
    if (OmpStructuredStmts.back() == Node)
      ++InOmpStructuredStmt;
    Base::TraverseStmt(Node);
    if (OmpStructuredStmts.back() == Node) {
      OmpStructuredStmts.pop_back();
      --InOmpStructuredStmt;
    }
    return true;
  }
  std::vector<Stmt*> OmpStructuredStmts;
  int InOmpStructuredStmt = 0;
};
```
But i really don't see using it in practice.
It's just too intrusive; and again, requires knowledge duplication.

.. but no. The solution lies right on the ground.
Why don't we simply store this `i'm a openmp structured block` in the bitfield of the `Stmt` itself?
This does not appear to have any impact on the memory footprint of the clang AST,
since it's just a single extra bit in the bitfield. At least the static assertions don't fail.
Thus, indeed, we can achieve both of the properties without a new AST node.

We can cheaply set that bit right in sema, at the end of `Sema::ActOnOpenMPExecutableDirective()`,
by just calling the `getStructuredBlock()` that we just added.
Test coverage that demonstrates all this has been added.

This isn't as great with serialization though. Most of it does not use abbrevs,
so we do end up paying the full price (4 bytes?) instead of a single bit.
That price, of course, can be reclaimed by using abbrevs.
In fact, i suspect that //might// not just reclaim these bytes, but pack these PCH significantly.

I'm not seeing a third solution. If there is one, it would be interesting to hear about it.
("just don't write code that would require `isa<OMPStructuredBlock>(ptr)`" is not a solution.)

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40563 | PR40563 ]].

Reviewers: ABataev, rjmccall, hfinkel, rsmith, riccibruno, gribozavr

Reviewed By: ABataev, gribozavr

Subscribers: mgorny, aaron.ballman, steveire, guansong, jfb, jdoerfert, cfe-commits

Tags: #clang, #openmp

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

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

5 years ago[NFC][clang][astdump] Some baseline tests for OpenMP
Roman Lebedev [Wed, 20 Mar 2019 16:31:47 +0000 (16:31 +0000)]
[NFC][clang][astdump] Some baseline tests for OpenMP

Summary:
Split off from D59214.
Not a fully exhaustive test coverage, but better than what there currently is.

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

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

5 years ago[ASTImporter] Remove obsolete function ImportTemplateParameterList.
Balazs Keri [Wed, 20 Mar 2019 15:42:42 +0000 (15:42 +0000)]
[ASTImporter] Remove obsolete function ImportTemplateParameterList.

Summary:
The ASTNodeImporter::ImportTemplateParameterList is replaced by a
template specialization of 'import' that already exists and does
(almost) the same thing.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: martong

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

Tags: #clang

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

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

5 years agoCorrect this attribute group documentation to have a heading, which fixes the docs...
Aaron Ballman [Wed, 20 Mar 2019 11:58:38 +0000 (11:58 +0000)]
Correct this attribute group documentation to have a heading, which fixes the docs builder.

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

5 years agoFix -Wdocumentation warning. NFCI.
Simon Pilgrim [Wed, 20 Mar 2019 10:28:08 +0000 (10:28 +0000)]
Fix -Wdocumentation warning. NFCI.

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

5 years ago[clangd] Print arguments in template specializations
Kadir Cetinkaya [Wed, 20 Mar 2019 09:43:38 +0000 (09:43 +0000)]
[clangd] Print arguments in template specializations

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

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

5 years ago[X86] Separate PentiumPro and i686. They aren't aliases in the backend.
Craig Topper [Wed, 20 Mar 2019 07:31:18 +0000 (07:31 +0000)]
[X86] Separate PentiumPro and i686. They aren't aliases in the backend.

PentiumPro has HasNOPL set in the backend. i686 does not.

Despite having a function that looks like it canonicalizes alias names. It
doesn't seem to be called. So I don't think this is a functional change. But its
good to be consistent between the backend and frontend.

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

5 years agoReplace tok::angle_string_literal with new tok::header_name.
Richard Smith [Tue, 19 Mar 2019 22:09:55 +0000 (22:09 +0000)]
Replace tok::angle_string_literal with new tok::header_name.

Use the new kind for both angled header-name tokens and for
double-quoted header-name tokens.

This is in preparation for C++20's context-sensitive header-name token
formation rules.

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

5 years agoFix CodeGen/arm64-microsoft-status-reg.cpp test
Jordan Rupprecht [Tue, 19 Mar 2019 20:55:14 +0000 (20:55 +0000)]
Fix CodeGen/arm64-microsoft-status-reg.cpp test

Summary: This test is failing after r356499 (verified with `ninja check-clang-codegen`). Update the register selection used in the test from x0 to x8.

Reviewers: arsenm, MatzeB, efriedma

Reviewed By: efriedma

Subscribers: efriedma, wdng, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

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

5 years agoAdd a spelling of pass_object_size that uses __builtin_dynamic_object_size
Erik Pilkington [Tue, 19 Mar 2019 20:44:18 +0000 (20:44 +0000)]
Add a spelling of pass_object_size that uses __builtin_dynamic_object_size

The attribute pass_dynamic_object_size(n) behaves exactly like
pass_object_size(n), but instead of evaluating __builtin_object_size on calls,
it evaluates __builtin_dynamic_object_size, which has the potential to produce
runtime code when the object size can't be determined statically.

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

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

5 years ago[OPENMP]Warn if the different allocator is used for the variable.
Alexey Bataev [Tue, 19 Mar 2019 20:33:44 +0000 (20:33 +0000)]
[OPENMP]Warn if the different allocator is used for the variable.

If the allocator was specified for the variable and next one is found
with the different allocator, the warning is emitted, and the allocator
is ignored.

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

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