[PATCH] D58797: [Sema] Add some compile time _FORTIFY_SOURCE diagnostics

2019-03-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

This is causing false positive warnings for the Linux kernel:
https://github.com/ClangBuiltLinux/linux/issues/423
:(

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/statfs.c#n128
Consider this untested case:

if (sizeof(buf) == sizeof(*st))
memcpy(, st, sizeof(*st));

fs/statfs.c:129:3: warning: 'memcpy' will always overflow; destination buffer 
has size 64, but size argument is 88 [-Wfortify-source]

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/statfs.c#n169,
 too.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58797/new/

https://reviews.llvm.org/D58797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42034: [clang-format] In tests, expected code should be format-stable

2019-03-21 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added inline comments.



Comment at: cfe/trunk/unittests/Format/FormatTest.cpp:78
 EXPECT_EQ(Expected.str(), format(Code, Style));
 if (Style.Language == FormatStyle::LK_Cpp) {
   // Objective-C++ is a superset of C++, so everything checked for C++

MyDeveloperDay wrote:
> @ mzeren-vmw just a minor comment related to a change you made last year.
> 
> When FormatTest  fails, all we are told is that it fails on line 75,or 77 
> (currently in trunk its 48,49) for every failure, with so many test cases 
> written as "foo()" or "aa()" it can often be hard to pinpoint the exact 
> test failure.
> 
> If verifyFormat was given an additional default argument of `int line`
> 
> Then verifyFormat could be used via a macro
> 
> ```
> #define VERIFYFORMAT(expected,code,style)
>  verifyFormat(expected,code,style,__LINE__);
> ```
> 
> The line numbers could then be passed as an additional failure message to 
> gtest by passing the __LINE__ of the test location down.
> 
> ```
> void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
> const FormatStyle  = getLLVMStyle(),int 
> line=__LINE__) {
> EXPECT_EQ(Expected.str(), format(Expected, Style))
> << "Expected code is not stable at " << line;
> EXPECT_EQ(Expected.str(), format(Code, Style) << " at " << line;
> }
> ```
> 
> When the test fails we'd know the exact line of the test case that failed.
> 
> Also because of this, we get 2 failures for every failure, the second will 
> almost always fail as well if the first case does (from what I can tell), is 
> there anyway we can query the first failed result and not bother doing the 
> second if the first one failed?
All good points. I don't think I'll be able to get to this in the near future.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D42034/new/

https://reviews.llvm.org/D42034



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59377: Frontend: Remove CompilerInstance::VirtualFileSystem, NFC

2019-03-21 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59377/new/

https://reviews.llvm.org/D59377



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47358: : Implement {un,}synchronized_pool_resource.

2019-03-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 191815.
Quuxplusone added a comment.
Herald added a subscriber: jdoerfert.

Rebased. Added `_NOEXCEPT` to `upstream_resource()` and `options()` (this is OK 
per [res.on.exception.handling]/5).


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47358/new/

https://reviews.llvm.org/D47358

Files:
  include/experimental/memory_resource
  src/experimental/memory_resource.cpp
  
test/libcxx/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsynchronized_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.ctor/ctor_does_not_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.ctor/sync_with_default_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.ctor/unsync_with_default_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/equality.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_allocate_overaligned_request.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_allocate_reuse_blocks.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/sync_deallocate_matches_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_allocate.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_allocate_overaligned_request.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_allocate_reuse_blocks.pass.cpp
  
test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_deallocate_matches_allocate.pass.cpp
  test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
  test/support/count_new.hpp

Index: test/support/count_new.hpp
===
--- test/support/count_new.hpp
+++ test/support/count_new.hpp
@@ -210,6 +210,11 @@
 return disable_checking || n != delete_called;
 }
 
+bool checkDeleteCalledGreaterThan(int n) const
+{
+return disable_checking || delete_called > n;
+}
+
 bool checkAlignedNewCalledEq(int n) const
 {
 return disable_checking || n == aligned_new_called;
Index: test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
@@ -0,0 +1,26 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: apple-clang-7
+
+// 
+
+// struct pool_options
+
+#include 
+#include 
+
+int main()
+{
+const std::experimental::pmr::pool_options p;
+assert(p.max_blocks_per_chunk == 0);
+assert(p.largest_required_pool_block == 0);
+}
Index: test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_deallocate_matches_allocate.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.pool/memory.resource.pool.mem/unsync_deallocate_matches_allocate.pass.cpp
@@ -0,0 +1,110 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class unsynchronized_pool_resource
+
+#include 
+#include 
+#include 
+
+struct allocation_record {
+size_t bytes;
+size_t align;
+explicit allocation_record(size_t b, size_t a) : bytes(b), align(a) {}
+bool operator==(const allocation_record& rhs) const {
+return (bytes == rhs.bytes) && (align == rhs.align);
+}
+bool operator<(const allocation_record& rhs) const {
+if (bytes != rhs.bytes) return (bytes < rhs.bytes);
+return (align < rhs.align);
+}
+};
+
+class test_resource : public std::experimental::pmr::memory_resource {
+void *do_allocate(size_t bytes, size_t align) override {
+void *result = std::experimental::pmr::new_delete_resource()->allocate(bytes, align);
+

[PATCH] D59407: [clangd] Add RelationSlab

2019-03-21 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 8 inline comments as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/index/Index.h:43
+public:
+  using value_type = std::pair>;
+  using const_iterator = std::vector::const_iterator;

kadircet wrote:
> nridge wrote:
> > kadircet wrote:
> > > gribozavr wrote:
> > > > `struct Relation`?  And in the comments for it, please explain which 
> > > > way the relationship is directed (is the SymbolID in the key the 
> > > > subtype?  or is the SymbolID in the ArrayRef the subtype?).
> > > Ah exactly my thoughts, forget to mention this.
> > > 
> > > I believe current usage is the counter-intuitive one. For example, we 
> > > will most likely query with something like:
> > > `getRelations(SymbolID, baseOf)` to get all relations where `SymbolID` is 
> > > `baseOf` something else(which says get children of `SymbolID`)
> > > 
> > > So that this valueType can be read like, 
> > > ```
> > > `SymbolID` is `RelationKind` every `SymbolID inside array`
> > > ```
> > > WDYT?
> > The way I was thinking of it is that `getRelations(SymbolID, baseOf)` would 
> > return all the bases of `SymbolID`. However, the opposite interpretation is 
> > also reasonable, we just need to pick one and document it. I'm happy to go 
> > with your suggested one.
> It looks like IndexingAPI is also using the interpretation I suggested, so 
> let's move with that one if you don't have any other concerns.
Already updated to this interpretation :)



Comment at: clang-tools-extra/clangd/index/Relation.h:45
+  // in Value are the base classes of Key.Symbol).
+  struct Relation {
+RelationKey Key;

gribozavr wrote:
> Lift it up into the `clang::clangd` namespace?  (like `Symbol` and `Ref`)
This comment made me realize that I haven't addressed your previous comment 
properly: I haven't changed `RelationSlab::value_type` from 
`std::pair>` to `Relation`.

I tried to make that change this time, and ran into a problem:

In the rest of the subtypes patch (D58880), one of the things I do is extend 
the `MemIndex` constructor so that, in addition to taking a symbol range and a 
ref range, it takes a relation range.

That constructor assumes that the elements of that range have members of some 
name - either `first` and `second` (as currently in D58880), or `Key` and 
`Value`.

However, that constructor has two call sites. In `MemIndex::build()`, we pass 
in the slabs themselves as the ranges. So, if we make this change, the field 
names for that call site will be `Key` and `Value`. However, for the second 
call site in `FileSymbols::buildIndex()`, the ranges that are passed in are 
`DenseMap`s, and therefore their elements' field names are necessarily `first` 
and `second`. The same constructor cannot therefore accept both ranges.

How do you propose we address this?

 * Scrap `struct Relation`, and keep `value_type` as `std::pair>`?
 * Keep `struct Relation`, but make its fields named `first` and `second`?
 * Split the constructor of `MemIndex` into two constructors, to accomodate 
both sets of field names?
 * Something else?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59407/new/

https://reviews.llvm.org/D59407



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47111: : Implement monotonic_buffer_resource.

2019-03-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 191814.
Quuxplusone added a comment.
Herald added a subscriber: jdoerfert.

Rebased on master. Added `_NOEXCEPT` to the `resource()` method (this is OK per 
[res.on.exception.handling]/5).

@ckennelly ping!


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47111/new/

https://reviews.llvm.org/D47111

Files:
  include/experimental/memory_resource
  src/experimental/memory_resource.cpp
  
test/libcxx/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/copy_move.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/with_default_resource.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.ctor/without_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_deallocate.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_exception_safety.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_initial_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_underaligned_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_from_zero_sized_buffer.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_in_geometric_progression.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_overaligned_request.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
  
test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp

Index: test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/equality.pass.cpp
@@ -0,0 +1,64 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class monotonic_buffer_resource
+
+#include 
+#include 
+#include 
+#include 
+
+struct assert_on_compare : public std::experimental::pmr::memory_resource
+{
+protected:
+void *do_allocate(size_t, size_t)
+{ assert(false); }
+
+void do_deallocate(void *, size_t, size_t)
+{ assert(false); }
+
+bool do_is_equal(std::experimental::pmr::memory_resource const &) const noexcept
+{ assert(false); }
+};
+
+int main(int, char**)
+{
+// Same object
+{
+std::experimental::pmr::monotonic_buffer_resource r1;
+std::experimental::pmr::monotonic_buffer_resource r2;
+assert(r1 == r1);
+assert(r1 != r2);
+
+std::experimental::pmr::memory_resource & p1 = r1;
+std::experimental::pmr::memory_resource & p2 = r2;
+assert(p1 == p1);
+assert(p1 != p2);
+assert(p1 == r1);
+assert(r1 == p1);
+assert(p1 != r2);
+assert(r2 != p1);
+}
+// Different types
+{
+std::experimental::pmr::monotonic_buffer_resource mono1;
+std::experimental::pmr::memory_resource & r1 = mono1;
+assert_on_compare c;
+std::experimental::pmr::memory_resource & r2 = c;
+assert(r1 != r2);
+assert(!(r1 == r2));
+}
+
+  return 0;
+}
Index: test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.monotonic.buffer/monotonic.buffer.mem/allocate_with_initial_size.pass.cpp
@@ -0,0 +1,53 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class monotonic_buffer_resource
+
+#include 
+#include 
+
+#include "count_new.hpp"
+
+void test(size_t initial_buffer_size)
+{
+

[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2019-03-21 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Yes, I don’t have commit access and would need someone else to land the patch.  
Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40988/new/

https://reviews.llvm.org/D40988



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59665: Call to HandleNameConflict in VisitEnumDecl mistakeningly using Name instead of SearchName

2019-03-21 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a subscriber: davide.
a_sidorin added a comment.

Hi Shafik,

Honestly, I was always wondering what does HandleNameConflict actually do. Its 
implementation in ASTImporter is trivial and I don't see any of its overrides 
in LLDB code too. Why do we check its result to be non-empty is a question to 
me as well. And the more I look at it (and the bug you pointed in it), the more 
I think there is something wrong with it. Maybe it is better to just remove it 
at all? I hope LLDB developers have more knowledge about it. Shafik, Davide 
@davide , do you know its actual purpose?




Comment at: lib/AST/ASTImporter.cpp:2463
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),

If I understand correctly, this will replace Name with SearchName causing an 
anonymous enum to be imported as a named a few lines below. It doesn't look 
like a correct behaviour to me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59665/new/

https://reviews.llvm.org/D59665



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59673: [Driver] Allow setting the DWO name DWARF attribute separately

2019-03-21 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 191813.
aaronpuchert added a comment.

Use llvm-dwarfdump to inspect debug info, remove unneeded flags.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59673/new/

https://reviews.llvm.org/D59673

Files:
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/split-debug-dwo-name-attr.c


Index: test/CodeGen/split-debug-dwo-name-attr.c
===
--- /dev/null
+++ test/CodeGen/split-debug-dwo-name-attr.c
@@ -0,0 +1,8 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited 
-enable-split-dwarf -split-dwarf-file %t -fsplit-dwarf-dwo-name-attr=foo.dwo 
-emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s
+// RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=DWO %s
+
+int f() { return 0; }
+
+// CHECK: DW_AT_GNU_dwo_name ("foo.dwo")
+// DWO: .dwo
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -714,6 +714,8 @@
   Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
   Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
+  Opts.SplitDwarfDwoNameAttr =
+  Args.getLastArgValue(OPT_fsplit_dwarf_dwo_name_attr_EQ);
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
 
   if (Arg *A =
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -464,7 +464,9 @@
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
-Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
+Options.MCOptions.SplitDwarfFile = 
CodeGenOpts.SplitDwarfDwoNameAttr.empty()
+   ? CodeGenOpts.SplitDwarfFile
+   : CodeGenOpts.SplitDwarfDwoNameAttr;
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,6 +1849,8 @@
   Flags<[CC1Option]>, HelpText<"Use DWARF base address selection entries in 
debug_ranges">;
 def fno_debug_ranges_base_address: Flag <["-"], 
"fno-debug-ranges-base-address">, Group,
   Flags<[CC1Option]>;
+def fsplit_dwarf_dwo_name_attr_EQ: Joined<["-"], 
"fsplit-dwarf-dwo-name-attr=">, Group,
+  Flags<[CC1Option]>, HelpText<"Set the name for the split debug info file to 
be used in the object file">;
 def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, 
Group,
   Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the 
object/executable to facilitate online symbolication/stack traces in the 
absence of .dwo/.dwp files when using Split DWARF">;
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, 
Group,
Index: include/clang/Basic/CodeGenOptions.h
===
--- include/clang/Basic/CodeGenOptions.h
+++ include/clang/Basic/CodeGenOptions.h
@@ -188,6 +188,10 @@
   /// in the backend for setting the name in the skeleton cu.
   std::string SplitDwarfFile;
 
+  /// Overrides \ref SplitDwarfFile as value of DW_AT_[GNU_]dwo_name to be used
+  /// in the skeleton CU, if not empty. Does not change the output file name.
+  std::string SplitDwarfDwoNameAttr;
+
   /// The name of the relocation model to use.
   llvm::Reloc::Model RelocationModel;
 


Index: test/CodeGen/split-debug-dwo-name-attr.c
===
--- /dev/null
+++ test/CodeGen/split-debug-dwo-name-attr.c
@@ -0,0 +1,8 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t -fsplit-dwarf-dwo-name-attr=foo.dwo -emit-obj -o - %s | llvm-dwarfdump -debug-info - | FileCheck %s
+// RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=DWO %s
+
+int f() { return 0; }
+
+// CHECK: DW_AT_GNU_dwo_name ("foo.dwo")
+// DWO: .dwo
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -714,6 +714,8 @@
   Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
   Opts.LTOVisibilityPublicStd = 

[PATCH] D59673: [Driver] Allow setting the DWO name DWARF attribute separately

2019-03-21 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D59673#1438716 , @dblaikie wrote:

> Use llvm-dwarfdump rather than llvm-objdump to dump the contents of the 
> debug_info section and test the dwo_name there (rather than dumping hex)


I didn't know about llvm-dwarfdump, I wondered why llvm-objdump wouldn't 
pretty-print the debug info as objdump does. That makes a lot of sense then.

> probably the objdump part of the test isn't needed?

Actually I only need to check that the DWO file is there (under the proper file 
name). Any ideas?

> (& I guess there's an LLVM patch to add the rest of this functionality?)

What do we have to do there? Should we add the option to `llc` as well?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59673/new/

https://reviews.llvm.org/D59673



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59631: [AArch64] Support selecting TPIDR_EL[1-3] as the thread base

2019-03-21 Thread Philip Derrin via Phabricator via cfe-commits
philip.derrin updated this revision to Diff 191800.
philip.derrin edited the summary of this revision.
philip.derrin added a comment.

Merged -mtpidr= with existing AArch32 option -mtp=


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59631/new/

https://reviews.llvm.org/D59631

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/clang-translation.c


Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -120,6 +120,36 @@
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
 // ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-hard"
 
+// RUN: %clang -target aarch64-linux -### -S %s -arch armv8a 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_NON %s
+// ARMv8_THREAD_POINTER_NON-NOT: "-target-feature" "+tpidr-el1"
+// ARMv8_THREAD_POINTER_NON-NOT: "-target-feature" "+tpidr-el2"
+// ARMv8_THREAD_POINTER_NON-NOT: "-target-feature" "+tpidr-el3"
+
+// RUN: %clang -target aarch64-linux -### -S %s -arch armv8a -mtp=el0 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL0 %s
+// ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidr-el1"
+// ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidr-el2"
+// ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidr-el3"
+
+// RUN: %clang -target aarch64-linux -### -S %s -arch armv8a -mtp=el1 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL1 %s
+// ARMv8_THREAD_POINTER_EL1: "-target-feature" "+tpidr-el1"
+// ARMv8_THREAD_POINTER_EL1-NOT: "-target-feature" "+tpidr-el2"
+// ARMv8_THREAD_POINTER_EL1-NOT: "-target-feature" "+tpidr-el3"
+
+// RUN: %clang -target aarch64-linux -### -S %s -arch armv8a -mtp=el2 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL2 %s
+// ARMv8_THREAD_POINTER_EL2-NOT: "-target-feature" "+tpidr-el1"
+// ARMv8_THREAD_POINTER_EL2: "-target-feature" "+tpidr-el2"
+// ARMv8_THREAD_POINTER_EL2-NOT: "-target-feature" "+tpidr-el3"
+
+// RUN: %clang -target aarch64-linux -### -S %s -arch armv8a -mtp=el3 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL3 %s
+// ARMv8_THREAD_POINTER_EL3-NOT: "-target-feature" "+tpidr-el1"
+// ARMv8_THREAD_POINTER_EL3-NOT: "-target-feature" "+tpidr-el2"
+// ARMv8_THREAD_POINTER_EL3: "-target-feature" "+tpidr-el3"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu \
 // RUN: -### -S %s -mcpu=G5 2>&1 | FileCheck -check-prefix=PPCG5 %s
 // PPCG5: clang
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -194,6 +194,18 @@
 Features.push_back("-neon");
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) {
+StringRef Mtp = A->getValue();
+if (Mtp == "el3")
+  Features.push_back("+tpidr-el3");
+else if (Mtp == "el2")
+  Features.push_back("+tpidr-el2");
+else if (Mtp == "el1")
+  Features.push_back("+tpidr-el1");
+else if (Mtp != "el0")
+  D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);
+  }
+
   // En/disable crc
   if (Arg *A = Args.getLastArg(options::OPT_mcrc, options::OPT_mnocrc)) {
 if (A->getOption().matches(options::OPT_mcrc))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2016,8 +2016,8 @@
   HelpText<"Disallow generation of data access to code sections (ARM only)">;
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
   HelpText<"Allow generation of data access to code sections (ARM only)">;
-def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft, cp15">,
-  HelpText<"Read thread pointer from coprocessor register (ARM only)">;
+def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft,cp15,el0,el1,el2,el3">,
+  HelpText<"Thread pointer access method (AArch32/AArch64 only)">;
 def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for 
GCC compatibility
 def mno_pure_code : Flag<["-"], "mno-pure-code">, Alias;
 def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group;


Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -120,6 +120,36 @@
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
 // ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-hard"
 
+// RUN: %clang -target aarch64-linux -### -S %s -arch armv8a 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_NON %s
+// ARMv8_THREAD_POINTER_NON-NOT: "-target-feature" "+tpidr-el1"
+// ARMv8_THREAD_POINTER_NON-NOT: "-target-feature" "+tpidr-el2"
+// 

[PATCH] D59631: [AArch64] Support selecting TPIDR_EL[1-3] as the thread base

2019-03-21 Thread Philip Derrin via Phabricator via cfe-commits
philip.derrin removed a reviewer: olista01.
philip.derrin added a comment.

In D59631#1437744 , @olista01 wrote:

> Is there an existing compiler which this option is trying to be compatible 
> with? GCC for AArch64 doesn't currently have an option for this, so we don't 
> have to worry about compatibility with that. If possible, I'd prefer for the 
> option to be "-mtp=", to match the option accepted by clang and GCC for 
> AArch32.


No, there's no existing option as far as I'm aware.

I'm happy to use `-mtp=`, as long as it is ok for it to remain in 
`Group` and to list values for both AArch32 and AArch64. 
It looks like these things only affect value completion and documentation; is 
that correct?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59631/new/

https://reviews.llvm.org/D59631



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356724 - This test assumes that -rtlib defaults to libgcc. But that isn't true in the face of -DCLANG_DEFAULT_RTLIB=compiler-rt.

2019-03-21 Thread Sterling Augustine via cfe-commits
Author: saugustine
Date: Thu Mar 21 16:30:50 2019
New Revision: 356724

URL: http://llvm.org/viewvc/llvm-project?rev=356724=rev
Log:
This test assumes that -rtlib defaults to libgcc. But that isn't true in the 
face of -DCLANG_DEFAULT_RTLIB=compiler-rt.

Subscribers: dberris, jdoerfert, llvm-commits

Tags: #llvm

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

Modified:
cfe/trunk/test/Driver/compiler-rt-unwind.c

Modified: cfe/trunk/test/Driver/compiler-rt-unwind.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compiler-rt-unwind.c?rev=356724=356723=356724=diff
==
--- cfe/trunk/test/Driver/compiler-rt-unwind.c (original)
+++ cfe/trunk/test/Driver/compiler-rt-unwind.c Thu Mar 21 16:30:50 2019
@@ -2,13 +2,6 @@
 // --unwindlib=XXX properly.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=x86_64-unknown-linux \
-// RUN: --gcc-toolchain="" \
-// RUN:   | FileCheck --check-prefix=RTLIB-EMPTY %s
-// RTLIB-EMPTY: "{{.*}}lgcc"
-// RTLIB-EMPTY: "{{.*}}-lgcc_s"
-//
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=libgcc \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=RTLIB-GCC %s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2019-03-21 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

@russellmcc the patch has been approved by @MyDeveloperDay
https://reviews.llvm.org/D40988#1430502

Do you mean you don't have commit access and need someone to land the patch on 
your behalf?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40988/new/

https://reviews.llvm.org/D40988



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57965: Clean up ObjCPropertyDecl printing

2019-03-21 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for working on this!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57965/new/

https://reviews.llvm.org/D57965



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-03-21 Thread Jan Korous via Phabricator via cfe-commits
jkorous marked an inline comment as done.
jkorous added a comment.

In D58418#1431765 , @thakis wrote:

> In D58418#1431399 , @jkorous wrote:
>
> > In D58418#1430630 , @thakis wrote:
> >
> > > In D58418#1430490 , @jkorous 
> > > wrote:
> > >
> > > > In D58418#1430160 , @thakis 
> > > > wrote:
> > > >
> > > > > Why is this needed for index-while-building? My mental model for 
> > > > > index-while-building is that that streams out build index metadata as 
> > > > > part of the regular compile. Why does that require watching 
> > > > > directories?
> > > >
> > > >
> > > > You're right that this isn't necessary for the indexing phase. But we 
> > > > also provide API so clients can consume the index. This functionality 
> > > > is used for getting notifications about index data changes.
> > > >
> > > > You can see it for example here:
> > > >  
> > > > https://github.com/apple/swift-clang/blob/stable/lib/IndexDataStore/IndexDataStore.cpp#L111
> > >
> > >
> > > Is that code going to live in clang? This seems more like a tool built on 
> > > top of the compiler rather than something core to the compiler itself 
> > > (like the actual index-while-building feature). Maybe this could be in 
> > > clang-tools-extra?
> >
> >
> > It actually is part of the feature as the serialized format of the index 
> > isn't meant as a stable interface, that's what the API is for. 
> > DirectoryWatcher isn't a tool, it's just part of implementation of the 
> > IndexStore API.
>
>
> Maybe I misunderstand what the client of the IndexStore API is. That's not 
> code that will be in the clang binary, right?


No, it won't.

Currently the client using this API is our indexing service.
https://github.com/apple/sourcekit-lsp
In the future clangd might become another client.

In theory we could have the index producing part in clang and the index 
consuming part (IndexStore) somewhere else (clang-tools-extra?) and use 
functionality that also lives somewhere else (llvm?) but reasons I'd rather not 
do it *NOW* are:

1. We'd have to expose the interface between them (the binary file format) 
which has been just an implementation detail so far without any intention to 
keep it stable.
2. From the general perspective - although I am upstreaming a fully developed 
feature (roughly 10kLOC) it is apparent that I am going to rewrite a 
significant part of the code based on the feedback from reviews. This patch is 
#2 out of approximately 10-15 patches total. Since it's probable that the 
design will change in upcoming reviews I'd prefer to discuss this kind of 
questions after a significant part of the whole design has been through the 
review.
3. For any code that we would move up the tree (to llvm repo) I'd like to have 
a clear use-case other than index-while-building first. Designing generic APIs 
is hard/impossible without known specific use-cases (I think the recommended 
minimum is 3).

The most important word is "now". I am totally happy to discuss this and move 
parts somewhere else if it seems reasonable in the future.

Does that make sense?




Comment at: clang/include/clang/DirectoryWatcher/DirectoryWatcher.h:27
+/// be invoked even if the directory is empty.
+class DirectoryWatcher {
+public:

gribozavr wrote:
> I feel like since there's nothing Clang-specific about it, it should go into 
> libSupport in LLVM, what do you think?
This has been brought up before. I prefer to leave it here for now since it's 
not used anywhere else. I'd only move it to llvm/Support once we have another 
use-case as that would mean specific requirements for the interface.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58418/new/

https://reviews.llvm.org/D58418



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59629: [clang-format] correctly format protobuf fields named "enum".

2019-03-21 Thread Donald Chai via Phabricator via cfe-commits
dchai added a comment.

I don't have commit access; can someone please merge this on my behalf?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59629/new/

https://reviews.llvm.org/D59629



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Amara Emerson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356722: [AArch64] Split the neon.addp intrinsic into integer 
and fp variants. (authored by aemerson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59655?vs=191774=191792#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
  cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  llvm/trunk/include/llvm/IR/IntrinsicsAArch64.td
  llvm/trunk/lib/IR/AutoUpgrade.cpp
  llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.cpp
  llvm/trunk/lib/Target/AArch64/AArch64LegalizerInfo.h
  
llvm/trunk/test/CodeGen/AArch64/GlobalISel/fallback-ambiguous-addp-intrinsic.mir
  llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
  llvm/trunk/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
  llvm/trunk/test/CodeGen/AArch64/arm64-vadd.ll
  llvm/trunk/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll

Index: llvm/trunk/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
===
--- llvm/trunk/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
+++ llvm/trunk/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
@@ -0,0 +1,9 @@
+; RUN: opt -S < %s -mtriple=arm64 | FileCheck %s
+declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
+
+; CHECK: call <4 x float> @llvm.aarch64.neon.faddp.v4f32
+define <4 x float> @upgrade_aarch64_neon_addp_float(<4 x float> %a, <4 x float> %b) {
+  %res = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %res
+}
+
Index: llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
===
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
@@ -151,7 +151,7 @@
 # DEBUG:  .. the first uncovered type index: 1, OK
 #
 # DEBUG-NEXT: G_INTRINSIC (opcode {{[0-9]+}}): 0 type indices
-# DEBUG:  .. type index coverage check SKIPPED: user-defined predicate detected
+# DEBUG:  .. type index coverage check SKIPPED: no rules defined
 #
 # DEBUG-NEXT: G_INTRINSIC_W_SIDE_EFFECTS (opcode {{[0-9]+}}): 0 type indices
 # DEBUG:  .. type index coverage check SKIPPED: no rules defined
Index: llvm/trunk/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
===
--- llvm/trunk/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
+++ llvm/trunk/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
@@ -65,27 +65,27 @@
 ret <2 x i64> %val
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>)
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>)
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>)
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>)
+declare <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double>, <2 x double>)
 
 define <2 x float> @test_faddp_v2f32(<2 x float> %lhs, <2 x float> %rhs) {
 ; CHECK: test_faddp_v2f32:
-%val = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+%val = call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
 ; CHECK: faddp v0.2s, v0.2s, v1.2s
 ret <2 x float> %val
 }
 
 define <4 x float> @test_faddp_v4f32(<4 x float> %lhs, <4 x float> %rhs) {
 ; CHECK: test_faddp_v4f32:
-%val = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %lhs, <4 x float> %rhs)
+%val = call <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float> %lhs, <4 x float> %rhs)
 ; CHECK: faddp v0.4s, v0.4s, v1.4s
 ret <4 x float> %val
 }
 
 define <2 x double> @test_faddp_v2f64(<2 x double> %lhs, <2 x double> %rhs) {
 ; CHECK: test_faddp_v2f64:
-%val = call <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double> %lhs, <2 x double> %rhs)
+%val = call <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double> %lhs, <2 x double> %rhs)
 ; CHECK: faddp v0.2d, v0.2d, v1.2d
 ret <2 x double> %val
 }
Index: llvm/trunk/test/CodeGen/AArch64/arm64-vadd.ll
===
--- llvm/trunk/test/CodeGen/AArch64/arm64-vadd.ll
+++ llvm/trunk/test/CodeGen/AArch64/arm64-vadd.ll
@@ -712,7 +712,7 @@
 ;CHECK: faddp.2s
 %tmp1 = load <2 x float>, <2 x float>* %A
 %tmp2 = load <2 x float>, <2 x float>* %B
-%tmp3 = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
+ 

r356722 - [AArch64] Split the neon.addp intrinsic into integer and fp variants.

2019-03-21 Thread Amara Emerson via cfe-commits
Author: aemerson
Date: Thu Mar 21 15:31:37 2019
New Revision: 356722

URL: http://llvm.org/viewvc/llvm-project?rev=356722=rev
Log:
[AArch64] Split the neon.addp intrinsic into integer and fp variants.

This is the result of discussions on the list about how to deal with intrinsics
which require codegen to disambiguate them via only the integer/fp overloads.
It causes problems for GlobalISel as some of that information is lost during
translation, while with other operations like IR instructions the information is
encoded into the instruction opcode.

This patch changes clang to emit the new faddp intrinsic if the vector operands
to the builtin have FP element types. LLVM IR AutoUpgrade has been taught to
upgrade existing calls to aarch64.neon.addp with fp vector arguments, and
we remove the workarounds introduced for GlobalISel in r355865.

This is a more permanent solution to PR40968.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=356722=356721=356722=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Mar 21 15:31:37 2019
@@ -5095,6 +5095,13 @@ Value *CodeGenFunction::EmitCommonNeonBu
 
   switch (BuiltinID) {
   default: break;
+  case NEON::BI__builtin_neon_vpadd_v:
+  case NEON::BI__builtin_neon_vpaddq_v:
+// We don't allow fp/int overloading of intrinsics.
+if (VTy->getElementType()->isFloatingPointTy() &&
+Int == Intrinsic::aarch64_neon_addp)
+  Int = Intrinsic::aarch64_neon_faddp;
+break;
   case NEON::BI__builtin_neon_vabs_v:
   case NEON::BI__builtin_neon_vabsq_v:
 if (VTy->getElementType()->isFloatingPointTy())

Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=356722=356721=356722=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Thu Mar 21 15:31:37 2019
@@ -4411,7 +4411,7 @@ uint32x2_t test_vpadd_u32(uint32x2_t a,
 // CHECK-LABEL: @test_vpadd_f32(
 // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <2 x float> %b to <8 x i8>
-// CHECK:   [[VPADD_V2_I:%.*]] = call <2 x float> 
@llvm.aarch64.neon.addp.v2f32(<2 x float> %a, <2 x float> %b)
+// CHECK:   [[VPADD_V2_I:%.*]] = call <2 x float> 
@llvm.aarch64.neon.faddp.v2f32(<2 x float> %a, <2 x float> %b)
 // CHECK:   [[VPADD_V3_I:%.*]] = bitcast <2 x float> [[VPADD_V2_I]] to <8 x i8>
 // CHECK:   ret <2 x float> [[VPADD_V2_I]]
 float32x2_t test_vpadd_f32(float32x2_t a, float32x2_t b) {
@@ -4475,7 +4475,7 @@ uint32x4_t test_vpaddq_u32(uint32x4_t a,
 // CHECK-LABEL: @test_vpaddq_f32(
 // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <4 x float> %b to <16 x i8>
-// CHECK:   [[VPADDQ_V2_I:%.*]] = call <4 x float> 
@llvm.aarch64.neon.addp.v4f32(<4 x float> %a, <4 x float> %b)
+// CHECK:   [[VPADDQ_V2_I:%.*]] = call <4 x float> 
@llvm.aarch64.neon.faddp.v4f32(<4 x float> %a, <4 x float> %b)
 // CHECK:   [[VPADDQ_V3_I:%.*]] = bitcast <4 x float> [[VPADDQ_V2_I]] to <16 x 
i8>
 // CHECK:   ret <4 x float> [[VPADDQ_V2_I]]
 float32x4_t test_vpaddq_f32(float32x4_t a, float32x4_t b) {
@@ -4485,7 +4485,7 @@ float32x4_t test_vpaddq_f32(float32x4_t
 // CHECK-LABEL: @test_vpaddq_f64(
 // CHECK:   [[TMP0:%.*]] = bitcast <2 x double> %a to <16 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <2 x double> %b to <16 x i8>
-// CHECK:   [[VPADDQ_V2_I:%.*]] = call <2 x double> 
@llvm.aarch64.neon.addp.v2f64(<2 x double> %a, <2 x double> %b)
+// CHECK:   [[VPADDQ_V2_I:%.*]] = call <2 x double> 
@llvm.aarch64.neon.faddp.v2f64(<2 x double> %a, <2 x double> %b)
 // CHECK:   [[VPADDQ_V3_I:%.*]] = bitcast <2 x double> [[VPADDQ_V2_I]] to <16 
x i8>
 // CHECK:   ret <2 x double> [[VPADDQ_V2_I]]
 float64x2_t test_vpaddq_f64(float64x2_t a, float64x2_t b) {

Modified: cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c?rev=356722=356721=356722=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c Thu Mar 21 15:31:37 
2019
@@ -736,14 +736,14 @@ float16x8_t test_vmulxq_f16(float16x8_t
 }
 
 // CHECK-LABEL: test_vpadd_f16
-// CHECK:  [[ADD:%.*]] = call <4 x half> @llvm.aarch64.neon.addp.v4f16(<4 x 
half> %a, <4 x half> %b)
+// CHECK:  [[ADD:%.*]] 

[PATCH] D59673: [Driver] Allow setting the DWO name DWARF attribute separately

2019-03-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Pleasue include mention of the bug (PR40276) in the commit message & clarify 
that while this is useful for some remote compilation models, it's not strictly 
necessary/the only way to do it (a remote compilation model that keeps relative 
paths and uses compilation-dir instead can work without this attribute)

Use llvm-dwarfdump rather than llvm-objdump to dump the contents of the 
debug_info section and test the dwo_name there (rather than dumping hex) & 
probably the objdump part of the test isn't needed? (& I guess there's an LLVM 
patch to add the rest of this functionality?)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59673/new/

https://reviews.llvm.org/D59673



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59673: [Driver] Allow setting the DWO name DWARF attribute separately

2019-03-21 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: dblaikie, echristo.
Herald added subscribers: cfe-commits, jdoerfert, aprantl.
Herald added a project: clang.

With Split DWARF the resulting object file (then called skeleton CU)
contains the file name of another ("DWO") file with the debug info.
This is a problem for remote compilation, as the file name written there
will be that of the compilation server, not of the client.

To reliably enable Split DWARF in the case of of remote compilation, we
need the ability to inject arbitrary file names into this field, which
is now provided by the option

  -fsplit-dwarf-dwo-name-attr=

For now we keep this as CC1 option, but the idea is to promote it
eventually, if it picks up.


Repository:
  rC Clang

https://reviews.llvm.org/D59673

Files:
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/split-debug-dwo-name-attr.c


Index: test/CodeGen/split-debug-dwo-name-attr.c
===
--- /dev/null
+++ test/CodeGen/split-debug-dwo-name-attr.c
@@ -0,0 +1,8 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited 
-enable-split-dwarf -fdebug-compilation-dir /foo 
-fsplit-dwarf-dwo-name-attr=bar.dwo -split-dwarf-file %t -emit-obj -o - %s | 
llvm-objdump -s -section=.debug_str - | FileCheck %s
+// RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=DWO %s
+
+int f() { return 0; }
+
+// CHECK:  2f666f6f 00626172 2e64776f 00/foo.bar.dwo.
+// DWO: .dwo
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -714,6 +714,8 @@
   Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
   Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
+  Opts.SplitDwarfDwoNameAttr =
+  Args.getLastArgValue(OPT_fsplit_dwarf_dwo_name_attr_EQ);
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
 
   if (Arg *A =
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -464,7 +464,9 @@
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
-Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
+Options.MCOptions.SplitDwarfFile = 
CodeGenOpts.SplitDwarfDwoNameAttr.empty()
+   ? CodeGenOpts.SplitDwarfFile
+   : CodeGenOpts.SplitDwarfDwoNameAttr;
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,6 +1849,8 @@
   Flags<[CC1Option]>, HelpText<"Use DWARF base address selection entries in 
debug_ranges">;
 def fno_debug_ranges_base_address: Flag <["-"], 
"fno-debug-ranges-base-address">, Group,
   Flags<[CC1Option]>;
+def fsplit_dwarf_dwo_name_attr_EQ: Joined<["-"], 
"fsplit-dwarf-dwo-name-attr=">, Group,
+  Flags<[CC1Option]>, HelpText<"Set the name for the split debug info file to 
be used in the object file">;
 def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, 
Group,
   Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the 
object/executable to facilitate online symbolication/stack traces in the 
absence of .dwo/.dwp files when using Split DWARF">;
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, 
Group,
Index: include/clang/Basic/CodeGenOptions.h
===
--- include/clang/Basic/CodeGenOptions.h
+++ include/clang/Basic/CodeGenOptions.h
@@ -188,6 +188,10 @@
   /// in the backend for setting the name in the skeleton cu.
   std::string SplitDwarfFile;
 
+  /// Overrides \ref SplitDwarfFile as value of DW_AT_[GNU_]dwo_name to be used
+  /// in the skeleton CU, if not empty. Does not change the output file name.
+  std::string SplitDwarfDwoNameAttr;
+
   /// The name of the relocation model to use.
   llvm::Reloc::Model RelocationModel;
 


Index: test/CodeGen/split-debug-dwo-name-attr.c
===
--- /dev/null
+++ test/CodeGen/split-debug-dwo-name-attr.c
@@ -0,0 +1,8 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -fdebug-compilation-dir 

[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

2019-03-21 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Sorry for the ambiguity.  I meant, "running clang-format on the changed lines 
locally was not enough".  I'll edit the description to clarify.

To go in more detail, let's imagine you changed line 3.  You run clang-format 
locally on line 3, but because of the bug fixed in the patch, this affects 
lines 3 and 4.  Then, when you commit and push to CI, CI will see diffs on 
lines 3 and 4.  CI will then try to ensure that running clang-format on line 
range 3-4 will produce no diffs.  However, due to the same bug will produce a 
diff on line 5, so your code will be rejected by the CI.

The reason our CI works like this is we want to ensure that no _new_ formatting 
errors are introduced into our code.  We're extensive users of git blame and we 
don't want to do a full format pass on our whole codebase.  Clang-format 
documents its line filter option, so in my opinion, it should work correctly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54881/new/

https://reviews.llvm.org/D54881



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57660: [Sema] SequenceChecker: Handle references, members and structured bindings.

2019-03-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Friendly ping. One thing I am wondering about is whether `MemoryLocation` and 
`getMemoryLocation` is duplicating something that is already present somewhere 
else. It feels like something similar should already exist but I can't find 
anything (but that is not saying much).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57660/new/

https://reviews.llvm.org/D57660



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2019-03-21 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Ping!  Still looking for help on this - I definitely don't want to diminish the 
complexity of this code, and would really appreciate any help getting this in.  
I've already apologized for the gap from feedback in July 2018 to response in 
October - and I'm happy to again - unfortunately sometimes life gets in the 
way!  Please let me know if there's anything I can do to get this patch landed. 
 As far as I understand, all outstanding comments on the code have been 
addressed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40988/new/

https://reviews.llvm.org/D40988



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/utils/ExceptionAnalyzer.cpp:226
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyzeBoilerplate(const T *Node) {
+  ExceptionInfo ExceptionList;

lebedev.ri wrote:
> Please bikeshed on the name. I don't think this one is good.
Hmm, `analyzeGeneric`, `analyzeGeneral`, `abstractAnalysis`, `analyzeAbstract`, 
something good in these?

Given its private its not too important either ;)


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.



Comment at: clang-tidy/utils/ExceptionAnalyzer.cpp:226
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyzeBoilerplate(const T *Node) {
+  ExceptionInfo ExceptionList;

Please bikeshed on the name. I don't think this one is good.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 191782.
lebedev.ri added a comment.

Keep templated function out of the public interface.

In D59650#1438603 , @JonasToth wrote:

> > Looks like pointless code duplication that is easily avoidable.
>
> True, but I would prefer the refactoring to be private then (so the template 
> stuff with the boilerplate) and a simple overloading interface dispatching to 
> the templated stuff.
>  In the end I think the public interface is cleaner, easier to understand and 
> not so easily misused (as the template would accept everything in principle, 
> and SFINAE would be worse).


Right. That looks a bit better. Works for me, thank you!


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650

Files:
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h


Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -138,10 +138,16 @@
   throwsException(const Stmt *St, const ExceptionInfo::Throwables ,
   llvm::SmallSet );
 
+  template 
+  void analyze(const T *Node, ExceptionInfo );
+
+  template  ExceptionInfo analyzeBoilerplate(const T *Node);
+
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
   std::map FunctionCache;
 };
+
 } // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -204,10 +204,9 @@
   return Results;
 }
 
-ExceptionAnalyzer::ExceptionInfo
-ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
-  ExceptionInfo ExceptionList;
-
+template <>
+void ExceptionAnalyzer::analyze(const FunctionDecl *Func,
+ExceptionInfo ) {
   // Check if the function has already been analyzed and reuse that result.
   if (FunctionCache.count(Func) == 0) {
 llvm::SmallSet CallStack;
@@ -220,6 +219,14 @@
 FunctionCache.insert(std::make_pair(Func, ExceptionList));
   } else
 ExceptionList = FunctionCache[Func];
+}
+
+template 
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyzeBoilerplate(const T *Node) {
+  ExceptionInfo ExceptionList;
+
+  analyze(Node, ExceptionList);
 
   if (ExceptionList.getBehaviour() == State::NotThrowing ||
   ExceptionList.getBehaviour() == State::Unknown)
@@ -231,6 +238,12 @@
 
   return ExceptionList;
 }
+
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
+  return analyzeBoilerplate(Func);
+}
+
 } // namespace utils
 } // namespace tidy
 


Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -138,10 +138,16 @@
   throwsException(const Stmt *St, const ExceptionInfo::Throwables ,
   llvm::SmallSet );
 
+  template 
+  void analyze(const T *Node, ExceptionInfo );
+
+  template  ExceptionInfo analyzeBoilerplate(const T *Node);
+
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
   std::map FunctionCache;
 };
+
 } // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -204,10 +204,9 @@
   return Results;
 }
 
-ExceptionAnalyzer::ExceptionInfo
-ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
-  ExceptionInfo ExceptionList;
-
+template <>
+void ExceptionAnalyzer::analyze(const FunctionDecl *Func,
+ExceptionInfo ) {
   // Check if the function has already been analyzed and reuse that result.
   if (FunctionCache.count(Func) == 0) {
 llvm::SmallSet CallStack;
@@ -220,6 +219,14 @@
 FunctionCache.insert(std::make_pair(Func, ExceptionList));
   } else
 ExceptionList = FunctionCache[Func];
+}
+
+template 
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyzeBoilerplate(const T *Node) {
+  ExceptionInfo ExceptionList;
+
+  analyze(Node, ExceptionList);
 
   if (ExceptionList.getBehaviour() == State::NotThrowing ||
   ExceptionList.getBehaviour() == State::Unknown)
@@ -231,6 +238,12 @@
 
   return ExceptionList;
 }
+
+ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
+  return analyzeBoilerplate(Func);
+}
+
 } // namespace utils
 } // namespace tidy
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59466: [clang-tidy] openmp-exception-escape - a new check

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 191783.
lebedev.ri added a comment.

Rebased for D59650  changes, NFC.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59466/new/

https://reviews.llvm.org/D59466

Files:
  clang-tidy/openmp/CMakeLists.txt
  clang-tidy/openmp/ExceptionEscapeCheck.cpp
  clang-tidy/openmp/ExceptionEscapeCheck.h
  clang-tidy/openmp/OpenMPTidyModule.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/openmp-exception-escape.rst
  test/clang-tidy/bugprone-exception-escape-openmp.cpp
  test/clang-tidy/openmp-exception-escape.cpp

Index: test/clang-tidy/openmp-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/openmp-exception-escape.cpp
@@ -0,0 +1,126 @@
+// RUN: %check_clang_tidy %s openmp-exception-escape %t -- -extra-arg=-fopenmp -extra-arg=-fexceptions -config="{CheckOptions: [{key: openmp-exception-escape.IgnoredExceptions, value: 'ignored'}]}" --
+
+int thrower() {
+  throw 42;
+}
+
+class ignored {};
+namespace std {
+class bad_alloc {};
+} // namespace std
+
+void parallel() {
+#pragma omp parallel
+  thrower();
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: An exception thrown inside of the OpenMP 'parallel' region is not caught in that same region.
+}
+
+void ignore() {
+#pragma omp parallel
+  throw ignored();
+}
+
+void standalone_directive() {
+#pragma omp taskwait
+  throw ignored(); // not structured block
+}
+
+void ignore_alloc() {
+#pragma omp parallel
+  throw std::bad_alloc();
+}
+
+void parallel_caught() {
+#pragma omp parallel
+  {
+try {
+  thrower();
+} catch (...) {
+}
+  }
+}
+
+void for_header(const int a) {
+  // Only the body of the loop counts.
+#pragma omp for
+  for (int i = 0; i < thrower(); i++)
+;
+}
+
+void forloop(const int a) {
+#pragma omp for
+  for (int i = 0; i < a; i++)
+thrower();
+  // CHECK-MESSAGES: :[[@LINE-3]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+}
+
+void parallel_forloop(const int a) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < a; i++)
+  thrower();
+thrower();
+// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: An exception thrown inside of the OpenMP 'parallel' region is not caught in that same region.
+// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+  }
+}
+
+void parallel_forloop_caught(const int a) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < a; i++) {
+  try {
+thrower();
+  } catch (...) {
+  }
+}
+thrower();
+// CHECK-MESSAGES: :[[@LINE-10]]:9: warning: An exception thrown inside of the OpenMP 'parallel' region is not caught in that same region.
+  }
+}
+
+void parallel_caught_forloop(const int a) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < a; i++)
+  thrower();
+try {
+  thrower();
+} catch (...) {
+}
+// CHECK-MESSAGES: :[[@LINE-7]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+  }
+}
+
+void parallel_outercaught_forloop(const int a) {
+#pragma omp parallel
+  {
+try {
+#pragma omp for
+  for (int i = 0; i < a; i++)
+thrower();
+  thrower();
+} catch (...) {
+}
+// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+  }
+}
+
+void parallel_outercaught_forloop_caught(const int a) {
+#pragma omp parallel
+  {
+try {
+#pragma omp for
+  for (int i = 0; i < a; i++) {
+try {
+  thrower();
+} catch (...) {
+}
+  }
+} catch (...) {
+}
+  }
+}
Index: test/clang-tidy/bugprone-exception-escape-openmp.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-exception-escape-openmp.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-fopenmp -extra-arg=-fexceptions --
+
+int thrower() {
+  throw 42;
+}
+
+void ok_parallel() {
+#pragma omp parallel
+  thrower();
+}
+
+void bad_for_header_XFAIL(const int a) {
+#pragma omp for
+  for (int i = 0; i < thrower(); i++)
+;
+  // FIXME: this really should be caught by bugprone-exception-escape.
+  // https://bugs.llvm.org/show_bug.cgi?id=41102
+}
+
+void ok_forloop(const int a) {
+#pragma omp for
+  for (int i = 0; i < a; i++)
+thrower();
+}
+
+void some_exception_just_so_that_check_clang_tidy_shuts_up() noexcept {
+  thrower();
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: an exception may be thrown in function 'some_exception_just_so_that_check_clang_tidy_shuts_up' which should not throw exceptions

[PATCH] D59670: [Sema] Fix an assert when a block captures a constexpr local

2019-03-21 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rjmccall, rsmith.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

`MarkVarDeclODRUsed` indirectly calls `captureInBlock`, which creates a copy 
expression. The copy expression is insulated in it's own 
`ExpressionEvaluationContext`, so it saves, mutates, and restores 
`MaybeODRUseExprs` as `CleanupVarDeclMarking` is iterating through it, leading 
to a crash. Fix this by iterating through a local copy of `MaybeODRUseExprs`.

rdar://47493525


Repository:
  rC Clang

https://reviews.llvm.org/D59670

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/blocks.cpp


Index: clang/test/SemaCXX/blocks.cpp
===
--- clang/test/SemaCXX/blocks.cpp
+++ clang/test/SemaCXX/blocks.cpp
@@ -145,3 +145,11 @@
 A::foo(); });
   }
 }
+
+namespace test7 {
+struct S {};
+void f() {
+  constexpr S s;
+  auto some_block = ^{ (void)s; };
+}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15686,7 +15686,12 @@
 }
 
 void Sema::CleanupVarDeclMarking() {
-  for (Expr *E : MaybeODRUseExprs) {
+  // Iterate through a local copy in case MarkVarDeclODRUsed makes a recursive
+  // call.
+  MaybeODRUseExprSet LocalMaybeODRUseExprs;
+  std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
+
+  for (Expr *E : LocalMaybeODRUseExprs) {
 VarDecl *Var;
 SourceLocation Loc;
 if (DeclRefExpr *DRE = dyn_cast(E)) {
@@ -15702,8 +15707,6 @@
 MarkVarDeclODRUsed(Var, Loc, *this,
/*MaxFunctionScopeIndex Pointer*/ nullptr);
   }
-
-  MaybeODRUseExprs.clear();
 }
 
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -587,13 +587,13 @@
   /// element type here is ExprWithCleanups::Object.
   SmallVector ExprCleanupObjects;
 
-  /// Store a list of either DeclRefExprs or MemberExprs
-  ///  that contain a reference to a variable (constant) that may or may not
-  ///  be odr-used in this Expr, and we won't know until all lvalue-to-rvalue
-  ///  and discarded value conversions have been applied to all subexpressions
-  ///  of the enclosing full expression.  This is cleared at the end of each
-  ///  full expression.
-  llvm::SmallPtrSet MaybeODRUseExprs;
+  /// Store a set of either DeclRefExprs or MemberExprs that contain a 
reference
+  /// to a variable (constant) that may or may not be odr-used in this Expr, 
and
+  /// we won't know until all lvalue-to-rvalue and discarded value conversions
+  /// have been applied to all subexpressions of the enclosing full expression.
+  /// This is cleared at the end of each full expression.
+  using MaybeODRUseExprSet = llvm::SmallPtrSet;
+  MaybeODRUseExprSet MaybeODRUseExprs;
 
   std::unique_ptr PreallocatedFunctionScope;
 
@@ -1029,7 +1029,7 @@
 /// context (i.e. the number of TypoExprs created).
 unsigned NumTypos;
 
-llvm::SmallPtrSet SavedMaybeODRUseExprs;
+MaybeODRUseExprSet SavedMaybeODRUseExprs;
 
 /// The lambdas that are present within this context, if it
 /// is indeed an unevaluated context.


Index: clang/test/SemaCXX/blocks.cpp
===
--- clang/test/SemaCXX/blocks.cpp
+++ clang/test/SemaCXX/blocks.cpp
@@ -145,3 +145,11 @@
 A::foo(); });
   }
 }
+
+namespace test7 {
+struct S {};
+void f() {
+  constexpr S s;
+  auto some_block = ^{ (void)s; };
+}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15686,7 +15686,12 @@
 }
 
 void Sema::CleanupVarDeclMarking() {
-  for (Expr *E : MaybeODRUseExprs) {
+  // Iterate through a local copy in case MarkVarDeclODRUsed makes a recursive
+  // call.
+  MaybeODRUseExprSet LocalMaybeODRUseExprs;
+  std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
+
+  for (Expr *E : LocalMaybeODRUseExprs) {
 VarDecl *Var;
 SourceLocation Loc;
 if (DeclRefExpr *DRE = dyn_cast(E)) {
@@ -15702,8 +15707,6 @@
 MarkVarDeclODRUsed(Var, Loc, *this,
/*MaxFunctionScopeIndex Pointer*/ nullptr);
   }
-
-  MaybeODRUseExprs.clear();
 }
 
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -587,13 +587,13 @@
   /// element type here is ExprWithCleanups::Object.
   SmallVector ExprCleanupObjects;
 
-  /// Store a list of either DeclRefExprs or MemberExprs
-  ///  that contain a reference to a variable (constant) that may or may not
-  ///  be odr-used in this Expr, and we won't know until all 

[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

> Looks like pointless code duplication that is easily avoidable.

True, but I would prefer the refactoring to be private then (so the template 
stuff with the boilerplate) and a simple overloading interface dispatching to 
the templated stuff.
In the end I think the public interface is cleaner, easier to understand and 
not so easily misused (as the template would accept everything in principle, 
and SFINAE would be worse).


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59665: Call to HandleNameConflict in VisitEnumDecl mistakeningly using Name instead of SearchName

2019-03-21 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I was not able to come up with a test that would detect this issue using either 
`clang-import-test` nor via any of the methods used in `ASTImpoterTest.cpp`. I 
created a regression test on the lldb side, which should pass once this is 
committed:

https://reviews.llvm.org/D59667


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59665/new/

https://reviews.llvm.org/D59665



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59665: Call to HandleNameConflict in VisitEnumDecl mistakeningly using Name instead of SearchName

2019-03-21 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: teemperor, martong, a_sidorin.
Herald added a subscriber: rnkovacs.

https://reviews.llvm.org/D51633 added error handling to the 
`ASTNodeImporter::VisitEnumDecl(...)` for the conflicting names case. This 
could lead to erroneous return of an error in that case since we should have 
been using `SearchName`. `Name` may be empty in the case where we find the name 
via `getTypedefNameForAnonDecl(...)`.


https://reviews.llvm.org/D59665

Files:
  lib/AST/ASTImporter.cpp


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2460,7 +2460,7 @@
 }
 
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2460,7 +2460,7 @@
 }
 
 if (!ConflictingDecls.empty()) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356715 - [OPENMP]Fix a warning about unused variable, NFC.

2019-03-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Mar 21 13:52:04 2019
New Revision: 356715

URL: http://llvm.org/viewvc/llvm-project?rev=356715=rev
Log:
[OPENMP]Fix a warning about unused variable, NFC.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=356715=356714=356715=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Mar 21 13:52:04 2019
@@ -4773,6 +4773,7 @@ Address CGOpenMPRuntimeNVPTX::getAddress
   // UseDefaultAllocator ? Address::invalid :
   // CGOpenMPRuntime::getAddressOfLocalVariable(CGF, VD); when NVPTX libomp
   // supports __kmpc_alloc|__kmpc_free.
+  (void)UseDefaultAllocator; // Prevent a warning.
   return Address::invalid();
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Amara Emerson via Phabricator via cfe-commits
aemerson updated this revision to Diff 191774.
aemerson added a comment.

Simplify logic and don't try to upgrade if IR is invalid.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
  llvm/lib/Target/AArch64/AArch64LegalizerInfo.h
  llvm/test/CodeGen/AArch64/GlobalISel/fallback-ambiguous-addp-intrinsic.mir
  llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
  llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
  llvm/test/CodeGen/AArch64/arm64-vadd.ll
  llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll

Index: llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
@@ -0,0 +1,9 @@
+; RUN: opt -S < %s -mtriple=arm64 | FileCheck %s
+declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
+
+; CHECK: call <4 x float> @llvm.aarch64.neon.faddp.v4f32
+define <4 x float> @upgrade_aarch64_neon_addp_float(<4 x float> %a, <4 x float> %b) {
+  %res = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %res
+}
+
Index: llvm/test/CodeGen/AArch64/arm64-vadd.ll
===
--- llvm/test/CodeGen/AArch64/arm64-vadd.ll
+++ llvm/test/CodeGen/AArch64/arm64-vadd.ll
@@ -712,7 +712,7 @@
 ;CHECK: faddp.2s
 %tmp1 = load <2 x float>, <2 x float>* %A
 %tmp2 = load <2 x float>, <2 x float>* %B
-%tmp3 = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
+%tmp3 = call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
 ret <2 x float> %tmp3
 }
 
@@ -721,7 +721,7 @@
 ;CHECK: faddp.4s
 %tmp1 = load <4 x float>, <4 x float>* %A
 %tmp2 = load <4 x float>, <4 x float>* %B
-%tmp3 = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %tmp1, <4 x float> %tmp2)
+%tmp3 = call <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float> %tmp1, <4 x float> %tmp2)
 ret <4 x float> %tmp3
 }
 
@@ -730,13 +730,13 @@
 ;CHECK: faddp.2d
 %tmp1 = load <2 x double>, <2 x double>* %A
 %tmp2 = load <2 x double>, <2 x double>* %B
-%tmp3 = call <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double> %tmp1, <2 x double> %tmp2)
+%tmp3 = call <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double> %tmp1, <2 x double> %tmp2)
 ret <2 x double> %tmp3
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>) nounwind readnone
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>) nounwind readnone
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>) nounwind readnone
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>) nounwind readnone
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>) nounwind readnone
+declare <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double>, <2 x double>) nounwind readnone
 
 define <2 x i64> @uaddl_duprhs(<4 x i32> %lhs, i32 %rhs) {
 ; CHECK-LABEL: uaddl_duprhs
Index: llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
===
--- llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
+++ llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
@@ -65,27 +65,27 @@
 ret <2 x i64> %val
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>)
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>)
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>)
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>)
+declare <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double>, <2 x double>)
 
 define <2 x float> @test_faddp_v2f32(<2 x float> %lhs, <2 x float> %rhs) {
 ; CHECK: test_faddp_v2f32:
-%val = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+%val = call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
 ; CHECK: faddp v0.2s, v0.2s, v1.2s
 ret <2 x float> %val
 }
 
 define <4 x float> @test_faddp_v4f32(<4 x float> %lhs, <4 x float> %rhs) {
 ; CHECK: test_faddp_v4f32:
-%val = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %lhs, <4 x float> %rhs)
+%val = call <4 x float> 

r356712 - Improve the diagnostic for #include_next occurring in a file not found

2019-03-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar 21 13:42:13 2019
New Revision: 356712

URL: http://llvm.org/viewvc/llvm-project?rev=356712=rev
Log:
Improve the diagnostic for #include_next occurring in a file not found
in the include path.

Instead of making the incorrect claim that the included file has an
absolute path, describe the actual problem: the including file was found
either by absolute path, or relative to such a file, or relative to the
primary source file.

Added:
cfe/trunk/test/Preprocessor/Inputs/include-next-1/
cfe/trunk/test/Preprocessor/Inputs/include-next-1/bar.h
cfe/trunk/test/Preprocessor/Inputs/include-next-1/foo.h
cfe/trunk/test/Preprocessor/Inputs/include-next-2/
cfe/trunk/test/Preprocessor/Inputs/include-next-2/bar.h
cfe/trunk/test/Preprocessor/include-next.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=356712=356711=356712=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Mar 21 13:42:13 2019
@@ -268,12 +268,14 @@ def err_pp_hash_error : Error<"%0">;
 }
 
 def pp_include_next_in_primary : Warning<
-  "#include_next in primary source file">,
+  "#include_next in primary source file; "
+  "will search from start of include path">,
   InGroup>;
 def pp_include_macros_out_of_predefines : Error<
   "the #__include_macros directive is only for internal use by -imacros">;
 def pp_include_next_absolute_path : Warning<
-  "#include_next with absolute path">,
+  "#include_next in file found relative to primary source file or found by "
+  "absolute path; will search from start of include path">,
   InGroup>;
 def ext_c99_whitespace_required_after_macro_name : ExtWarn<
   "ISO C99 requires whitespace after the macro name">, InGroup;

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=356712=356711=356712=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Mar 21 13:42:13 2019
@@ -2085,6 +2085,10 @@ void Preprocessor::HandleIncludeNextDire
 LookupFromFile = CurPPLexer->getFileEntry();
 Lookup = nullptr;
   } else if (!Lookup) {
+// The current file was not found by walking the include path. Either it
+// is the primary file (handled above), or it was found by absolute path,
+// or it was found relative to such a file.
+// FIXME: Track enough information so we know which case we're in.
 Diag(IncludeNextTok, diag::pp_include_next_absolute_path);
   } else {
 // Start looking up in the next directory.

Added: cfe/trunk/test/Preprocessor/Inputs/include-next-1/bar.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/include-next-1/bar.h?rev=356712=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/include-next-1/bar.h (added)
+++ cfe/trunk/test/Preprocessor/Inputs/include-next-1/bar.h Thu Mar 21 13:42:13 
2019
@@ -0,0 +1 @@
+#define BAR 1

Added: cfe/trunk/test/Preprocessor/Inputs/include-next-1/foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/include-next-1/foo.h?rev=356712=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/include-next-1/foo.h (added)
+++ cfe/trunk/test/Preprocessor/Inputs/include-next-1/foo.h Thu Mar 21 13:42:13 
2019
@@ -0,0 +1 @@
+#include_next "bar.h"

Added: cfe/trunk/test/Preprocessor/Inputs/include-next-2/bar.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/include-next-2/bar.h?rev=356712=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/include-next-2/bar.h (added)
+++ cfe/trunk/test/Preprocessor/Inputs/include-next-2/bar.h Thu Mar 21 13:42:13 
2019
@@ -0,0 +1 @@
+#define BAR 2

Added: cfe/trunk/test/Preprocessor/include-next.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/include-next.c?rev=356712=auto
==
--- cfe/trunk/test/Preprocessor/include-next.c (added)
+++ cfe/trunk/test/Preprocessor/include-next.c Thu Mar 21 13:42:13 2019
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s -E -o /dev/null -I%S/Inputs/include-next-1 
-I%S/Inputs/include-next-2 -DTEST=1
+// RUN: %clang_cc1 -verify %s -E -o /dev/null -I%S/Inputs/include-next-1 
-I%S/Inputs/include-next-2 -DTEST=2
+// RUN: %clang_cc1 -verify %s -E -o /dev/null -I%S/Inputs/include-next-1 

[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D59650#1438515 , @JonasToth wrote:

> Why not having normal overloads? The analysis for `Stmt` is implemented with 
> the private methods. Explicit template specialization is a bit overkill and 
> so easily understood (but not too complex in this case either).l


The alternative is to add something like:

  ExceptionAnalyzer::ExceptionInfo
  ExceptionAnalyzer::analyze(const Stmt *Stmt) {
ExceptionInfo ExceptionList;
  
llvm::SmallSet CallStack;
ExceptionList = throwsException(Func, CallStack);
  
if (ExceptionList.getBehaviour() == State::NotThrowing ||
ExceptionList.getBehaviour() == State::Unknown)
  return ExceptionList;
  
// Remove all ignored exceptions from the list of exceptions that can be
// thrown.
ExceptionList.filterIgnoredExceptions(IgnoredExceptions, IgnoreBadAlloc);
  
return ExceptionList;
  }

.. which ends up duplicating all of the boilerplate (blacklist in particular)
from `ExceptionAnalyzer::analyze(const FunctionDecl *Func)`.

Looks like pointless code duplication that is easily avoidable.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59566: [X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus

2019-03-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356709: [X86] Correct the value of MaxAtomicInlineWidth for 
pre-586 cpus (authored by ctopper, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D59566?vs=191643=191771#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59566/new/

https://reviews.llvm.org/D59566

Files:
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/test/CodeGen/attr-cpuspecific.c
  cfe/trunk/test/CodeGen/attr-target-x86-mmx.c
  cfe/trunk/test/CodeGen/attr-target-x86.c
  cfe/trunk/test/CodeGen/attr-target-x87-softfp.c
  cfe/trunk/test/Preprocessor/init.c
  cfe/trunk/test/Preprocessor/predefined-win-macros.c

Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -81,6 +81,7 @@
   bool HasMPX = false;
   bool HasSHSTK = false;
   bool HasSGX = false;
+  bool HasCX8 = false;
   bool HasCX16 = false;
   bool HasFXSR = false;
   bool HasXSAVE = false;
@@ -344,9 +345,8 @@
  (1 << TargetInfo::LongDouble));
 
 // x86-32 has atomics up to 8 bytes
-// FIXME: Check that we actually have cmpxchg8b before setting
-// MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
@@ -382,6 +382,11 @@
 return X86TargetInfo::validateOperandSize(Constraint, Size);
   }
 
+  void setMaxAtomicWidth() override {
+if (hasFeature("cx8"))
+  MaxAtomicInlineWidth = 64;
+  }
+
   ArrayRef getTargetBuiltins() const override;
 };
 
Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -115,6 +115,11 @@
   if (Kind != CK_Lakemont)
 setFeatureEnabledImpl(Features, "x87", true);
 
+  // Enable cmpxchg8 for i586 and greater CPUs. Include generic for backwards
+  // compatibility.
+  if (Kind >= CK_i586 || Kind == CK_Generic)
+setFeatureEnabledImpl(Features, "cx8", true);
+
   switch (Kind) {
   case CK_Generic:
   case CK_i386:
@@ -777,6 +782,8 @@
   HasMOVBE = true;
 } else if (Feature == "+sgx") {
   HasSGX = true;
+} else if (Feature == "+cx8") {
+  HasCX8 = true;
 } else if (Feature == "+cx16") {
   HasCX16 = true;
 } else if (Feature == "+fxsr") {
@@ -1275,12 +1282,12 @@
 break;
   }
 
-  if (CPU >= CK_i486) {
+  if (CPU >= CK_i486 || CPU == CK_Generic) {
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
   }
-  if (CPU >= CK_i586)
+  if (HasCX8)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
   if (HasCX16 && getTriple().getArch() == llvm::Triple::x86_64)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
@@ -1394,6 +1401,7 @@
   .Case("clflushopt", HasCLFLUSHOPT)
   .Case("clwb", HasCLWB)
   .Case("clzero", HasCLZERO)
+  .Case("cx8", HasCX8)
   .Case("cx16", HasCX16)
   .Case("f16c", HasF16C)
   .Case("fma", HasFMA)
Index: cfe/trunk/test/CodeGen/attr-cpuspecific.c
===
--- cfe/trunk/test/CodeGen/attr-cpuspecific.c
+++ cfe/trunk/test/CodeGen/attr-cpuspecific.c
@@ -254,6 +254,6 @@
 // WINDOWS: define dso_local i32 @DispatchFirst.B
 // WINDOWS: ret i32 1
 
-// CHECK: attributes #[[S]] = {{.*}}"target-features"="+avx,+cmov,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
-// CHECK: attributes #[[K]] = {{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
-// CHECK: attributes #[[O]] = {{.*}}"target-features"="+cmov,+mmx,+movbe,+sse,+sse2,+sse3,+ssse3,+x87"
+// CHECK: attributes #[[S]] = {{.*}}"target-features"="+avx,+cmov,+cx8,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[K]] = {{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+cx8,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
+// CHECK: attributes #[[O]] = {{.*}}"target-features"="+cmov,+cx8,+mmx,+movbe,+sse,+sse2,+sse3,+ssse3,+x87"
Index: cfe/trunk/test/CodeGen/attr-target-x86.c
===
--- cfe/trunk/test/CodeGen/attr-target-x86.c
+++ cfe/trunk/test/CodeGen/attr-target-x86.c
@@ -48,11 +48,11 @@
 // CHECK: qq{{.*}} #6
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
-// 

r356709 - [X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus

2019-03-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Mar 21 13:36:08 2019
New Revision: 356709

URL: http://llvm.org/viewvc/llvm-project?rev=356709=rev
Log:
[X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus

Use the new cx8 feature flag that was added to the backend to represent support 
for cmpxchg8b. Use this flag to set the MaxAtomicInlineWidth.

This also assumes all the cmpxchg instructions are enabled for CK_Generic which 
is what cc1 defaults to when nothing is specified.

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

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/test/CodeGen/attr-cpuspecific.c
cfe/trunk/test/CodeGen/attr-target-x86-mmx.c
cfe/trunk/test/CodeGen/attr-target-x86.c
cfe/trunk/test/CodeGen/attr-target-x87-softfp.c
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/test/Preprocessor/predefined-win-macros.c

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=356709=356708=356709=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Thu Mar 21 13:36:08 2019
@@ -115,6 +115,11 @@ bool X86TargetInfo::initFeatureMap(
   if (Kind != CK_Lakemont)
 setFeatureEnabledImpl(Features, "x87", true);
 
+  // Enable cmpxchg8 for i586 and greater CPUs. Include generic for backwards
+  // compatibility.
+  if (Kind >= CK_i586 || Kind == CK_Generic)
+setFeatureEnabledImpl(Features, "cx8", true);
+
   switch (Kind) {
   case CK_Generic:
   case CK_i386:
@@ -777,6 +782,8 @@ bool X86TargetInfo::handleTargetFeatures
   HasMOVBE = true;
 } else if (Feature == "+sgx") {
   HasSGX = true;
+} else if (Feature == "+cx8") {
+  HasCX8 = true;
 } else if (Feature == "+cx16") {
   HasCX16 = true;
 } else if (Feature == "+fxsr") {
@@ -1275,12 +1282,12 @@ void X86TargetInfo::getTargetDefines(con
 break;
   }
 
-  if (CPU >= CK_i486) {
+  if (CPU >= CK_i486 || CPU == CK_Generic) {
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
   }
-  if (CPU >= CK_i586)
+  if (HasCX8)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
   if (HasCX16 && getTriple().getArch() == llvm::Triple::x86_64)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
@@ -1394,6 +1401,7 @@ bool X86TargetInfo::hasFeature(StringRef
   .Case("clflushopt", HasCLFLUSHOPT)
   .Case("clwb", HasCLWB)
   .Case("clzero", HasCLZERO)
+  .Case("cx8", HasCX8)
   .Case("cx16", HasCX16)
   .Case("f16c", HasF16C)
   .Case("fma", HasFMA)

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=356709=356708=356709=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Thu Mar 21 13:36:08 2019
@@ -81,6 +81,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetI
   bool HasMPX = false;
   bool HasSHSTK = false;
   bool HasSGX = false;
+  bool HasCX8 = false;
   bool HasCX16 = false;
   bool HasFXSR = false;
   bool HasXSAVE = false;
@@ -344,9 +345,8 @@ public:
  (1 << TargetInfo::LongDouble));
 
 // x86-32 has atomics up to 8 bytes
-// FIXME: Check that we actually have cmpxchg8b before setting
-// MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
@@ -382,6 +382,11 @@ public:
 return X86TargetInfo::validateOperandSize(Constraint, Size);
   }
 
+  void setMaxAtomicWidth() override {
+if (hasFeature("cx8"))
+  MaxAtomicInlineWidth = 64;
+  }
+
   ArrayRef getTargetBuiltins() const override;
 };
 

Modified: cfe/trunk/test/CodeGen/attr-cpuspecific.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-cpuspecific.c?rev=356709=356708=356709=diff
==
--- cfe/trunk/test/CodeGen/attr-cpuspecific.c (original)
+++ cfe/trunk/test/CodeGen/attr-cpuspecific.c Thu Mar 21 13:36:08 2019
@@ -254,6 +254,6 @@ int DispatchFirst(void) {return 1;}
 // WINDOWS: define dso_local i32 @DispatchFirst.B
 // WINDOWS: ret i32 1
 
-// CHECK: attributes #[[S]] = 
{{.*}}"target-features"="+avx,+cmov,+f16c,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
-// CHECK: attributes #[[K]] = 
{{.*}}"target-features"="+adx,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+cmov,+f16c,+fma,+lzcnt,+mmx,+movbe,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave"
-// CHECK: attributes #[[O]] = 

r356710 - [OPENMP] Simplify codegen for allocate directive on local variables.

2019-03-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Mar 21 13:36:16 2019
New Revision: 356710

URL: http://llvm.org/viewvc/llvm-project?rev=356710=rev
Log:
[OPENMP] Simplify codegen for allocate directive on local variables.

Simplified codegen for the allocate directive for local variables,
initial implementation of the codegen for NVPTX target.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/allocate_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_allocate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=356710=356709=356710=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Mar 21 13:36:16 2019
@@ -9745,54 +9745,50 @@ public:
 
 Address CGOpenMPRuntime::getAddressOfLocalVariable(CodeGenFunction ,
const VarDecl *VD) {
+  if (!VD)
+return Address::invalid();
   const VarDecl *CVD = VD->getCanonicalDecl();
   if (!CVD->hasAttr())
 return Address::invalid();
-  for (const Attr *A: CVD->getAttrs()) {
-if (const auto *AA = dyn_cast(A)) {
-  auto  = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
-  if (!Elem.second.ServiceInsertPt)
-setLocThreadIdInsertPt(CGF);
-  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
-  CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
-  llvm::Value *Size;
-  CharUnits Align = CGM.getContext().getDeclAlign(CVD);
-  if (CVD->getType()->isVariablyModifiedType()) {
-Size = CGF.getTypeSize(CVD->getType());
-Align = CGM.getContext().getTypeAlignInChars(CVD->getType());
-  } else {
-CharUnits Sz = CGM.getContext().getTypeSizeInChars(CVD->getType());
-Align = CGM.getContext().getDeclAlign(CVD);
-Size = CGM.getSize(Sz.alignTo(Align));
-  }
-  llvm::Value *ThreadID = getThreadID(CGF, CVD->getBeginLoc());
-  llvm::Value *Allocator;
-  if (const Expr *AllocExpr = AA->getAllocator()) {
-Allocator = CGF.EmitScalarExpr(AllocExpr);
-  } else {
-// Default allocator in libomp is nullptr.
-Allocator = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
-  }
-  llvm::Value *Args[] = {ThreadID, Size, Allocator};
+  const auto *AA = CVD->getAttr();
+  // Use the default allocation.
+  if (AA->getAllocatorType() == OMPAllocateDeclAttr::OMPDefaultMemAlloc)
+return Address::invalid();
+  auto  = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
+  if (!Elem.second.ServiceInsertPt)
+setLocThreadIdInsertPt(CGF);
+  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
+  CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
+  llvm::Value *Size;
+  CharUnits Align = CGM.getContext().getDeclAlign(CVD);
+  if (CVD->getType()->isVariablyModifiedType()) {
+Size = CGF.getTypeSize(CVD->getType());
+Align = CGM.getContext().getTypeAlignInChars(CVD->getType());
+  } else {
+CharUnits Sz = CGM.getContext().getTypeSizeInChars(CVD->getType());
+Align = CGM.getContext().getDeclAlign(CVD);
+Size = CGM.getSize(Sz.alignTo(Align));
+  }
+  llvm::Value *ThreadID = getThreadID(CGF, CVD->getBeginLoc());
+  assert(AA->getAllocator() &&
+ "Expected allocator expression for non-default allocator.");
+  llvm::Value *Allocator = CGF.EmitScalarExpr(AA->getAllocator());
+  llvm::Value *Args[] = {ThreadID, Size, Allocator};
 
-  llvm::Value *Addr =
-  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_alloc), Args,
-  CVD->getName() + ".void.addr");
-  llvm::Value *FiniArgs[OMPAllocateCleanupTy::CleanupArgs] = {
-  ThreadID, Addr, Allocator};
-  llvm::FunctionCallee FiniRTLFn = 
createRuntimeFunction(OMPRTL__kmpc_free);
+  llvm::Value *Addr =
+  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_alloc), Args,
+  CVD->getName() + ".void.addr");
+  llvm::Value *FiniArgs[OMPAllocateCleanupTy::CleanupArgs] = {ThreadID, Addr,
+  Allocator};
+  llvm::FunctionCallee FiniRTLFn = createRuntimeFunction(OMPRTL__kmpc_free);
 
-  CGF.EHStack.pushCleanup(
-  NormalAndEHCleanup, FiniRTLFn, llvm::makeArrayRef(FiniArgs));
-  Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-  Addr,
-  CGF.ConvertTypeForMem(
-  CGM.getContext().getPointerType(CVD->getType())),
-  CVD->getName() + ".addr");
-  return Address(Addr, Align);
-}
-  }
-  return Address::invalid();
+  CGF.EHStack.pushCleanup(NormalAndEHCleanup, FiniRTLFn,
+llvm::makeArrayRef(FiniArgs));
+  Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Addr,
+  

[libunwind] r356708 - Bump version to 8.0.1

2019-03-21 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Mar 21 13:32:00 2019
New Revision: 356708

URL: http://llvm.org/viewvc/llvm-project?rev=356708=rev
Log:
Bump version to 8.0.1

Modified:
libunwind/branches/release_80/CMakeLists.txt

Modified: libunwind/branches/release_80/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_80/CMakeLists.txt?rev=356708=356707=356708=diff
==
--- libunwind/branches/release_80/CMakeLists.txt (original)
+++ libunwind/branches/release_80/CMakeLists.txt Thu Mar 21 13:32:00 2019
@@ -81,7 +81,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 8.0.0)
+  set(PACKAGE_VERSION 8.0.1)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Why not having normal overloads? The analysis for `Stmt` is implemented with 
the private methods. Explicit template specialization is a bit overkill and so 
easily understood (but not too complex in this case either).l


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59650/new/

https://reviews.llvm.org/D59650



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-21 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In D59279#1438500 , @rnkovacs wrote:

> In D59279#1427017 , @mgrang wrote:
>
> > Following are the assumptions/limitations of this patch:
> >
> >   1. The assumption is that iteration of ordered containers of pointers is 
> > not non-deterministic.
> >
>
>
> Could you please explain which type of non-determinism we are addressing 
> here? If our issue is that iteration order is not consistent across runs, 
> then an unordered set of //integers// seems just as non-deterministic as an 
> unordered set of //pointers//. On the other hand, if our issue is that 
> pointer values vary between runs, then an //ordered// set of pointers seems 
> just as non-deterministic as an //unordered// set of pointers. Are 
> //unordered// sets of //pointers// distinguished because they lie in the 
> intersection of these categories and thus avoid the most false positive 
> cases? If so, for someone debugging non-deterministic behavior in their code, 
> would it be useful to add a strict option that shows other cases too? If not, 
> maybe we could document our reasons somewhere.


Yes, the reason we limit the checks only to //unordered// containers is to 
reduce the false positive rate. Although, as you rightly pointed out that 
//ordered// sets of pointers are as non-deterministic as //unordered// ones. 
Once our checks have the capability to detect what happens inside the loop 
maybe we can add //ordered// sets too. I will add this to the TODO. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59485: [ASTImporter] Add an ImportInternal method to allow customizing Import behavior.

2019-03-21 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 191765.
teemperor retitled this revision from "[ASTImporter] Allow adding a import 
strategy to the ASTImporter" to "[ASTImporter] Add an ImportInternal method to 
allow customizing Import behavior.".
teemperor edited the summary of this revision.
teemperor added a comment.

So I replaced the whole Strategy/Shim thing with a simple `ImportInternal` 
method that we can overwrite and is also no longer public. That also gets rid 
of all the boilerplate code from the first patches and also makes the follow-up 
LLDB patch nicer.

@martong It's not related to lookup or anything like that, it's just that we 
don't have enough information in our debug info AST to allow people to use meta 
programming. The custom logic we have in LLDB looks into the std C++ module to 
fill out these gaps in the AST by hand when they are used in an expression.

The remark about the alternative being slow just means that fixing all the 
templates we have in our debug info AST seems like a costly approach. I'm also 
not sure how well it would work, as I never tried mixing a C++ module in an 
ASTContext that isn't currently being parsed by Clang.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59485/new/

https://reviews.llvm.org/D59485

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -304,6 +304,14 @@
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
+public:
+  /// Allocates an ASTImporter (or one of its subclasses).
+  typedef std::function
+  ImporterConstructor;
+
+private:
   // Buffer for the To context, must live in the test scope.
   std::string ToCode;
 
@@ -316,22 +324,37 @@
 std::unique_ptr Unit;
 TranslationUnitDecl *TUDecl = nullptr;
 std::unique_ptr Importer;
-TU(StringRef Code, StringRef FileName, ArgVector Args)
+// The lambda that constructs the ASTImporter we use in this test.
+ImporterConstructor Creator;
+TU(StringRef Code, StringRef FileName, ArgVector Args,
+   ImporterConstructor C = ImporterConstructor())
 : Code(Code), FileName(FileName),
   Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
  this->FileName)),
-  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {
+  TUDecl(Unit->getASTContext().getTranslationUnitDecl()), Creator(C) {
   Unit->enableSourceFileDiagnostics();
+
+  // If the test doesn't need a specific ASTImporter, we just create a
+  // normal ASTImporter with it.
+  if (!Creator)
+Creator = [](ASTContext , FileManager ,
+ ASTContext , FileManager ,
+ bool MinimalImport, ASTImporterLookupTable *LookupTable) {
+  return new ASTImporter(ToContext, ToFileManager, FromContext,
+ FromFileManager, MinimalImport, LookupTable);
+};
+}
+
+void setImporter(std::unique_ptr I) {
+  Importer = std::move(I);
 }
 
 void lazyInitImporter(ASTImporterLookupTable , ASTUnit *ToAST) {
   assert(ToAST);
-  if (!Importer) {
-Importer.reset(
-new ASTImporter(ToAST->getASTContext(), ToAST->getFileManager(),
-Unit->getASTContext(), Unit->getFileManager(),
-false, ));
-  }
+  if (!Importer)
+Importer.reset(Creator(ToAST->getASTContext(), ToAST->getFileManager(),
+   Unit->getASTContext(), Unit->getFileManager(),
+   false, ));
   assert(>getASTContext() == >getToContext());
   createVirtualFileIfNeeded(ToAST, FileName, Code);
 }
@@ -401,11 +424,12 @@
   // Must not be called more than once within the same test.
   std::tuple
   getImportedDecl(StringRef FromSrcCode, Language FromLang, StringRef ToSrcCode,
-  Language ToLang, StringRef Identifier = DeclToImportID) {
+  Language ToLang, StringRef Identifier = DeclToImportID,
+  ImporterConstructor Creator = ImporterConstructor()) {
 ArgVector FromArgs = getArgVectorForLanguage(FromLang),
   ToArgs = getArgVectorForLanguage(ToLang);
 
-FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs);
+FromTUs.emplace_back(FromSrcCode, InputFileName, FromArgs, Creator);
 TU  = FromTUs.back();
 
 assert(!ToAST);
@@ -455,6 +479,12 @@
 return ToAST->getASTContext().getTranslationUnitDecl();
   }
 
+  ASTImporter (Decl *From, Language ToLang) {
+lazyInitToAST(ToLang, "", OutputFileName);
+TU *FromTU = findFromTU(From);
+return *FromTU->Importer;
+  }
+
   // Import the given Decl into the ToCtx.
  

[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The IR at this




Comment at: llvm/lib/IR/AutoUpgrade.cpp:574
+  if (ArgTy->getElementType()->isFloatingPointTy()) {
+auto fArgs = F->getFunctionType()->params();
+Type *Tys[] = {fArgs[0], fArgs[1]};

aemerson wrote:
> efriedma wrote:
> > This code is weird... you're computing the types in two different ways.  
> > Also, missing a check for F->arg_size() (so we don't crash on invalid IR).
> I'll consolidate the logic, but none of the other code here checks for IR 
> validity. By the time we reach here the IR should be valid, we're just 
> translating it to a newer version. I can put an assert anyway.
The IR during autoupgrade should be loosely "valid", to the point of passing 
the asm/bitcode parser, but we don't check the signature of intrinsics until 
later, so someone could write `declare <4 x float> 
@llvm.aarch64.neon.addp.v4f32()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59523: Thread Safety: also look at ObjC methods

2019-03-21 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: lib/Analysis/ThreadSafetyCommon.cpp:283-285
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {

aaron.ballman wrote:
> Also somewhat orthogonal to your changes, but... ugh, the lack of any common 
> base between `FunctionDecl` and `ObjcMethodDecl` strikes again. I sort of 
> wish we would introduce a CallableDecl base class that these two (and 
> BlockDecl) could all inherit from to take care of this sort of ugly hack.
Seems I was wrong, because `getCanonicalDecl()` is actually virtual. I was 
confused by the different return type, apparently an overriding function 
doesn't need to have the same return type. So no problem here.

This doesn't make our case easier: both `FunctionDecl` and `ObjCMethodDecl` 
inherit from both `Decl` and `DeclContext`, but independently. So we can't 
directly cast from `DeclContext` to `Decl`, we need to know which leaf we are.



Comment at: test/SemaObjCXX/no-crash-thread-safety-analysis.mm:1
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wno-objc-root-class 
%s
+

jfb wrote:
> aaronpuchert wrote:
> > Test is fine for me, but I would like if you could integrate it with the 
> > existing test/SemaObjCXX/warn-thread-safety-analysis.mm. The thread safety 
> > analysis requires a bit of setup, that's why we tend to keep the tests in 
> > one file. I'll admit that the C++ tests have grown quite large, but for 
> > ObjC++ it's still very manageable. 
> Sure thing! I created a header that's shared and simplified this repro a bit. 
> I validated that the shared code was crashing before and this fixes the crash.
I would still like all ObjCXX tests for -Wthread-safety in one file, because 
that's what we have for the other languages as well. (more or less)

It's somewhat easier to see which aspects are tested then and which are not. 
Right now we only have tests for reported crashes, but maybe someday someone 
finds the time to test a bit more exhaustively.

But perhaps @aaron.ballman sees this another way, in that case follow his 
opinion.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59523/new/

https://reviews.llvm.org/D59523



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-21 Thread Artem Dergachev via cfe-commits
This one seems to be fixed by the second patch and is looks similar to 
the testcase that's already there - https://reviews.llvm.org/D59622


Different backtraces are moderately expected :)

On 3/21/19 6:58 AM, Alexander Kornienko wrote:
Thanks for the fix! Meanwhile, I found a couple of code samples that 
trigger this assertion with a slightly different stack trace. Not sure 
if they are substantially different though.


#1:
$ cat t.cc
inline namespace a {
class b typedef c;
}
class A {};
namespace a {
class b : A {};
}  // namespace a
class d {
 public:
  operator c();
};
d e() { c f{e()}; }
$ clang-tidy -checks="-*,clang-analyzer*" t.cc -- -std=c++17
assert.h assertion failed at 
llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2362 in 
(anonymous namespace)::RegionBindingsRef (anonymous 
namespace)::RegionStoreManager::bindStruct(RegionBindingsConstRef, 
const clang::ento::TypedValueRegion *, clang::ento::SVal): 
CRD->isAggregate() && "Non-aggregates are constructed with a constructor!"

    @     0x5605d5ca35c6  __assert_fail
    @     0x5605d44064e4  (anonymous 
namespace)::RegionStoreManager::bindStruct()
    @     0x5605d43fb058  (anonymous 
namespace)::RegionStoreManager::Bind()

    @     0x5605d43e5d2f clang::ento::ProgramState::bindLoc()
    @     0x5605d43975c5 
clang::ento::ExprEngine::processPointerEscapedOnBind()

    @     0x5605d438f143 clang::ento::ExprEngine::evalBind()
    @     0x5605d43a46d3 clang::ento::ExprEngine::VisitDeclStmt()
    @     0x5605d438ddff clang::ento::ExprEngine::Visit()
    @     0x5605d438a7af clang::ento::ExprEngine::ProcessStmt()
    @     0x5605d438a498 clang::ento::ExprEngine::processCFGElement()
    @     0x5605d437e7f5 clang::ento::CoreEngine::HandlePostStmt()
    @     0x5605d437dbec clang::ento::CoreEngine::ExecuteWorkList()
    @     0x5605d40e7feb  (anonymous 
namespace)::AnalysisConsumer::HandleCode()
    @     0x5605d40d1dc5  (anonymous 
namespace)::AnalysisConsumer::HandleTranslationUnit()

    @     0x5605d46ea43c clang::MultiplexConsumer::HandleTranslationUnit()
    @     0x5605d4854e54  clang::ParseAST()
    @     0x5605d46cb203 clang::FrontendAction::Execute()
    @     0x5605d4664451 clang::CompilerInstance::ExecuteAction()
    @     0x5605d45cef61 
clang::tooling::FrontendActionFactory::runInvocation()
    @     0x5605d3d3e997 
clang::tidy::runClangTidy()::ActionFactory::runInvocation()

    @     0x5605d45cecca clang::tooling::ToolInvocation::runInvocation()
    @     0x5605d45ce646 clang::tooling::ToolInvocation::run()
    @     0x5605d45d0f22 clang::tooling::ClangTool::run()
    @     0x5605d3d39c5f  clang::tidy::runClangTidy()
    @     0x5605d0860c45  main

#2 is still being reduced.


On Wed, Mar 20, 2019 at 2:37 AM Artem Dergachev > wrote:


On 3/19/19 11:10 AM, Richard Smith wrote:
> It sounds like there might be a missing check for
> InitListExpr::isTransparent somewhere. (A transparent InitListExpr
> should be treated as equivalent to its one and only subexpression.)
> Either that, or the static analyzer isn't aware that an object of
> class type can be initialized directly from a function call, not
via a
> constructor.

Indeed, thanks! And, as usual, more bugs on top of that.
(https://reviews.llvm.org/D59573)

On 3/19/19 11:00 AM, Alexander Kornienko wrote:
> just adding -std=c++17 on existing code (LLVM, for example ;) could
> help uncover some of the issues

Hmm, fair enough :D I'm glad i asked :)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59279: [Analyzer] Checker for non-determinism caused by iteration of unordered container of pointers

2019-03-21 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

In D59279#1427017 , @mgrang wrote:

> Following are the assumptions/limitations of this patch:
>
>   1. The assumption is that iteration of ordered containers of pointers is 
> not non-deterministic.
>


Could you please explain which type of non-determinism we are addressing here? 
If our issue is that iteration order is not consistent across runs, then an 
unordered set of //integers// seems just as non-deterministic as an unordered 
set of //pointers//. On the other hand, if our issue is that pointer values 
vary between runs, then an //ordered// set of pointers seems just as 
non-deterministic as an //unordered// set of pointers. Are //unordered// sets 
of //pointers// distinguished because they lie in the intersection of these 
categories and thus avoid the most false positive cases? If so, for someone 
debugging non-deterministic behavior in their code, would it be useful to add a 
strict option that shows other cases too? If not, maybe we could document our 
reasons somewhere.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59279/new/

https://reviews.llvm.org/D59279



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

2019-03-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.
Herald added a subscriber: Charusso.

There seems to be a crash in this code. @koldaniel, would you like to take a 
look? https://bugs.llvm.org/show_bug.cgi?id=41185


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D35068/new/

https://reviews.llvm.org/D35068



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59624: [Driver] Pass -malign-double from the driver to the cc1 command line

2019-03-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356706: [Driver] Pass -malign-double from the driver to the 
cc1 command line (authored by ctopper, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59624?vs=191613=191768#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59624/new/

https://reviews.llvm.org/D59624

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/malign_double.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4547,6 +4547,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
+  Args.AddLastArg(CmdArgs, options::OPT_malign_double);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");
Index: cfe/trunk/test/Driver/malign_double.c
===
--- cfe/trunk/test/Driver/malign_double.c
+++ cfe/trunk/test/Driver/malign_double.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -malign-double %s  2>&1 | FileCheck %s
+
+// Make sure -malign-double is passed through the driver.
+
+// CHECK: "-malign-double"


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4547,6 +4547,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
+  Args.AddLastArg(CmdArgs, options::OPT_malign_double);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");
Index: cfe/trunk/test/Driver/malign_double.c
===
--- cfe/trunk/test/Driver/malign_double.c
+++ cfe/trunk/test/Driver/malign_double.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -malign-double %s  2>&1 | FileCheck %s
+
+// Make sure -malign-double is passed through the driver.
+
+// CHECK: "-malign-double"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356706 - [Driver] Pass -malign-double from the driver to the cc1 command line

2019-03-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Mar 21 13:07:24 2019
New Revision: 356706

URL: http://llvm.org/viewvc/llvm-project?rev=356706=rev
Log:
[Driver] Pass -malign-double from the driver to the cc1 command line

-malign-double is currently only implemented in the -cc1 interface. But its 
declared in Options.td so it is a driver option too. But you try to use it with 
the driver you'll get a message about the option being unused.

This patch teaches the driver to pass the option through to cc1 so it won't be 
unused. The Options.td says the option is x86 only but I didn't see any x86 
specific code in its impementation in cc1 so not sure if the documentation is 
wrong or if I should only pass this option through the driver on x86 targets.

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

Added:
cfe/trunk/test/Driver/malign_double.c   (with props)
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=356706=356705=356706=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Mar 21 13:07:24 2019
@@ -4547,6 +4547,7 @@ void Clang::ConstructJob(Compilation ,
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
+  Args.AddLastArg(CmdArgs, options::OPT_malign_double);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");

Added: cfe/trunk/test/Driver/malign_double.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/malign_double.c?rev=356706=auto
==
--- cfe/trunk/test/Driver/malign_double.c (added)
+++ cfe/trunk/test/Driver/malign_double.c Thu Mar 21 13:07:24 2019
@@ -0,0 +1,5 @@
+// RUN: %clang -### -malign-double %s  2>&1 | FileCheck %s
+
+// Make sure -malign-double is passed through the driver.
+
+// CHECK: "-malign-double"

Propchange: cfe/trunk/test/Driver/malign_double.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/Driver/malign_double.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/Driver/malign_double.c
--
svn:mime-type = text/plain


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59656: [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue with notail on x86-64

2019-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356705: [CodeGen][ObjC] Annotate calls to 
objc_retainAutoreleasedReturnValue (authored by ahatanak, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59656?vs=191761=191766#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59656/new/

https://reviews.llvm.org/D59656

Files:
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/test/CodeGenObjC/arc-blocks.m
  cfe/trunk/test/CodeGenObjC/arc-foreach.m
  cfe/trunk/test/CodeGenObjC/arc-literals.m
  cfe/trunk/test/CodeGenObjC/arc-precise-lifetime.m
  cfe/trunk/test/CodeGenObjC/arc-property.m
  cfe/trunk/test/CodeGenObjC/arc-related-result-type.m
  cfe/trunk/test/CodeGenObjC/arc-ternary-op.m
  cfe/trunk/test/CodeGenObjC/arc-unsafeclaim.m
  cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
  cfe/trunk/test/CodeGenObjC/arc.m
  cfe/trunk/test/CodeGenObjC/objc-arc-container-subscripting.m
  cfe/trunk/test/CodeGenObjC/os_log.m
  cfe/trunk/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
  cfe/trunk/test/CodeGenObjCXX/arc.mm
  cfe/trunk/test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
  cfe/trunk/test/CodeGenObjCXX/literals.mm

Index: cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
===
--- cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
+++ cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
@@ -11,7 +11,7 @@
 
 // CHECK-LABEL:define void @test()
 // CHECK:  [[T0:%.*]] = call i8* @make()
-// CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: [[T1:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
 // CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.autorelease(i8* [[T1]])
 // CHECK-NEXT: call void @objc_exception_throw(i8* [[T2]]) [[NR:#[0-9]+]]
 // CHECK-NEXT: unreachable
Index: cfe/trunk/test/CodeGenObjC/arc-property.m
===
--- cfe/trunk/test/CodeGenObjC/arc-property.m
+++ cfe/trunk/test/CodeGenObjC/arc-property.m
@@ -126,7 +126,7 @@
 }
 // CHECK:define internal i8* @"\01-[Test3 copyMachine]"(
 // CHECK:  [[T0:%.*]] = call i8* @test3_helper()
-// CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: [[T1:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
 // CHECK-NEXT: ret i8* [[T1]]
 - (void) setCopyMachine: (id) x {}
 @end
Index: cfe/trunk/test/CodeGenObjC/os_log.m
===
--- cfe/trunk/test/CodeGenObjC/os_log.m
+++ cfe/trunk/test/CodeGenObjC/os_log.m
@@ -21,7 +21,7 @@
 
   // CHECK: %[[CALL:.*]] = tail call %[[TY0:.*]]* (...) @GenString()
   // CHECK: %[[V0:.*]] = bitcast %[[TY0]]* %[[CALL]] to i8*
-  // CHECK: %[[V1:.*]] = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V0]])
+  // CHECK: %[[V1:.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V0]])
   // CHECK: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
   // CHECK: store i8 2, i8* %[[BUF]], align 1
   // CHECK: %[[NUMARGS_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 1
@@ -45,7 +45,7 @@
   // CHECK-O0: %[[V0:.*]] = load i8*, i8** %[[BUF_ADDR]], align 8
   // CHECK-O0: %[[CALL:.*]] = call %[[TY0:.*]]* (...) @GenString()
   // CHECK-O0: %[[V1:.*]] = bitcast %[[TY0]]* %[[CALL]] to i8*
-  // CHECK-O0: %[[V2:.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V1]])
+  // CHECK-O0: %[[V2:.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V1]])
   // CHECK-O0: %[[V3:.*]] = bitcast i8* %[[V2]] to %[[TY0]]*
   // CHECK-O0: %[[V4:.*]] = ptrtoint %[[TY0]]* %[[V3]] to i64
   // CHECK-O0: call void @__os_log_helper_1_2_1_8_64(i8* %[[V0]], i64 %[[V4]])
Index: cfe/trunk/test/CodeGenObjC/objc-arc-container-subscripting.m
===
--- cfe/trunk/test/CodeGenObjC/objc-arc-container-subscripting.m
+++ cfe/trunk/test/CodeGenObjC/objc-arc-container-subscripting.m
@@ -12,7 +12,7 @@
 }
 
 // CHECK: [[call:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
-// CHECK: [[SIX:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[call]]) [[NUW:#[0-9]+]]
+// CHECK: [[SIX:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[call]]) [[NUW:#[0-9]+]]
 // CHECK: [[ARRAY_CASTED:%.*]] = bitcast %0** {{%.*}} to i8**
 // CHECK: call void @llvm.objc.storeStrong(i8** [[ARRAY_CASTED]], i8* null)
 // CHECK: [[EIGHT:%.*]] = tail call i8* @llvm.objc.autoreleaseReturnValue(i8* [[SIX]]) [[NUW]]
Index: cfe/trunk/test/CodeGenObjC/arc-foreach.m
===
--- cfe/trunk/test/CodeGenObjC/arc-foreach.m
+++ 

[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Amara Emerson via Phabricator via cfe-commits
aemerson marked an inline comment as done.
aemerson added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:574
+  if (ArgTy->getElementType()->isFloatingPointTy()) {
+auto fArgs = F->getFunctionType()->params();
+Type *Tys[] = {fArgs[0], fArgs[1]};

efriedma wrote:
> This code is weird... you're computing the types in two different ways.  
> Also, missing a check for F->arg_size() (so we don't crash on invalid IR).
I'll consolidate the logic, but none of the other code here checks for IR 
validity. By the time we reach here the IR should be valid, we're just 
translating it to a newer version. I can put an assert anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356705 - [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue

2019-03-21 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Mar 21 12:59:49 2019
New Revision: 356705

URL: http://llvm.org/viewvc/llvm-project?rev=356705=rev
Log:
[CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue
with notail on x86-64.

On x86-64, the epilogue code inserted before the tail jump blocks the
autoreleased return optimization.

rdar://problem/38675807

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

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/test/CodeGenObjC/arc-blocks.m
cfe/trunk/test/CodeGenObjC/arc-foreach.m
cfe/trunk/test/CodeGenObjC/arc-literals.m
cfe/trunk/test/CodeGenObjC/arc-precise-lifetime.m
cfe/trunk/test/CodeGenObjC/arc-property.m
cfe/trunk/test/CodeGenObjC/arc-related-result-type.m
cfe/trunk/test/CodeGenObjC/arc-ternary-op.m
cfe/trunk/test/CodeGenObjC/arc-unsafeclaim.m
cfe/trunk/test/CodeGenObjC/arc-with-atthrow.m
cfe/trunk/test/CodeGenObjC/arc.m
cfe/trunk/test/CodeGenObjC/objc-arc-container-subscripting.m
cfe/trunk/test/CodeGenObjC/os_log.m
cfe/trunk/test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
cfe/trunk/test/CodeGenObjCXX/arc.mm
cfe/trunk/test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
cfe/trunk/test/CodeGenObjCXX/literals.mm

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=356705=356704=356705=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Mar 21 12:59:49 2019
@@ -1958,10 +1958,10 @@ static void setARCRuntimeFunctionLinkage
 /// Perform an operation having the signature
 ///   i8* (i8*)
 /// where a null input causes a no-op and returns null.
-static llvm::Value *
-emitARCValueOperation(CodeGenFunction , llvm::Value *value,
-  llvm::Type *returnType, llvm::Function *,
-  llvm::Intrinsic::ID IntID, bool isTailCall = false) {
+static llvm::Value *emitARCValueOperation(
+CodeGenFunction , llvm::Value *value, llvm::Type *returnType,
+llvm::Function *, llvm::Intrinsic::ID IntID,
+llvm::CallInst::TailCallKind tailKind = llvm::CallInst::TCK_None) {
   if (isa(value))
 return value;
 
@@ -1976,8 +1976,7 @@ emitARCValueOperation(CodeGenFunction 
 
   // Call the function.
   llvm::CallInst *call = CGF.EmitNounwindRuntimeCall(fn, value);
-  if (isTailCall)
-call->setTailCall();
+  call->setTailCallKind(tailKind);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(call, origType);
@@ -2187,9 +2186,15 @@ static void emitAutoreleasedReturnValueM
 llvm::Value *
 CodeGenFunction::EmitARCRetainAutoreleasedReturnValue(llvm::Value *value) {
   emitAutoreleasedReturnValueMarker(*this);
-  return emitARCValueOperation(*this, value, nullptr,
-  CGM.getObjCEntrypoints().objc_retainAutoreleasedReturnValue,
-   
llvm::Intrinsic::objc_retainAutoreleasedReturnValue);
+  llvm::CallInst::TailCallKind tailKind =
+  CGM.getTargetCodeGenInfo()
+  .shouldSuppressTailCallsOfRetainAutoreleasedReturnValue()
+  ? llvm::CallInst::TCK_NoTail
+  : llvm::CallInst::TCK_None;
+  return emitARCValueOperation(
+  *this, value, nullptr,
+  CGM.getObjCEntrypoints().objc_retainAutoreleasedReturnValue,
+  llvm::Intrinsic::objc_retainAutoreleasedReturnValue, tailKind);
 }
 
 /// Claim a possibly-autoreleased return value at +0.  This is only
@@ -2326,7 +2331,7 @@ CodeGenFunction::EmitARCAutoreleaseRetur
   return emitARCValueOperation(*this, value, nullptr,
 
CGM.getObjCEntrypoints().objc_autoreleaseReturnValue,
llvm::Intrinsic::objc_autoreleaseReturnValue,
-   /*isTailCall*/ true);
+   llvm::CallInst::TCK_Tail);
 }
 
 /// Do a fused retain/autorelease of the given object.
@@ -2336,7 +2341,7 @@ CodeGenFunction::EmitARCRetainAutoreleas
   return emitARCValueOperation(*this, value, nullptr,
  
CGM.getObjCEntrypoints().objc_retainAutoreleaseReturnValue,
  
llvm::Intrinsic::objc_retainAutoreleaseReturnValue,
-   /*isTailCall*/ true);
+   llvm::CallInst::TCK_Tail);
 }
 
 /// Do a fused retain/autorelease of the given object.

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=356705=356704=356705=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Mar 21 12:59:49 2019
@@ -2268,6 +2268,12 @@ public:
 return static_cast(TargetCodeGenInfo::getABIInfo());
   }
 
+  /// Disable tail 

[PATCH] D59076: [coroutines][PR40978] Emit error for co_yield within catch block

2019-03-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

This is causing https://bugs.llvm.org/show_bug.cgi?id=41171.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59076/new/

https://reviews.llvm.org/D59076



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356704 - Refactor handling of #include directives to cleanly separate the

2019-03-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar 21 12:44:17 2019
New Revision: 356704

URL: http://llvm.org/viewvc/llvm-project?rev=356704=rev
Log:
Refactor handling of #include directives to cleanly separate the
"skipped header because it should be imported as a module" cases from
the "skipped header because of some other reason" cases.

Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=356704=356703=356704=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Mar 21 12:44:17 2019
@@ -1813,26 +1813,26 @@ void Preprocessor::HandleIncludeDirectiv
 return;
   }
 
-  // Should we enter the source file? Set to false if either the source file is
+  // Should we enter the source file? Set to Skip if either the source file is
   // known to have no effect beyond its effect on module visibility -- that is,
-  // if it's got an include guard that is already defined or is a modular 
header
-  // we've imported or already built.
-  bool ShouldEnter = true;
+  // if it's got an include guard that is already defined, set to Import if it
+  // is a modular header we've already built and should import.
+  enum { Enter, Import, Skip, IncludeLimitReached } Action = Enter;
 
   if (PPOpts->SingleFileParseMode)
-ShouldEnter = false;
+Action = IncludeLimitReached;
 
   // If we've reached the max allowed include depth, it is usually due to an
   // include cycle. Don't enter already processed files again as it can lead to
   // reaching the max allowed include depth again.
-  if (ShouldEnter && HasReachedMaxIncludeDepth && File &&
+  if (Action == Enter && HasReachedMaxIncludeDepth && File &&
   HeaderInfo.getFileInfo(File).NumIncludes)
-ShouldEnter = false;
+Action = IncludeLimitReached;
 
   // Determine whether we should try to import the module for this #include, if
   // there is one. Don't do so if precompiled module support is disabled or we
   // are processing this module textually (because we're building the module).
-  if (ShouldEnter && File && SuggestedModule && getLangOpts().Modules &&
+  if (Action == Enter && File && SuggestedModule && getLangOpts().Modules &&
   !isForModuleBuilding(SuggestedModule.getModule(),
getLangOpts().CurrentModule,
getLangOpts().ModuleName)) {
@@ -1872,9 +1872,9 @@ void Preprocessor::HandleIncludeDirectiv
 assert((Imported == nullptr || Imported == SuggestedModule.getModule()) &&
"the imported module is different than the suggested one");
 
-if (Imported)
-  ShouldEnter = false;
-else if (Imported.isMissingExpected()) {
+if (Imported) {
+  Action = Import;
+} else if (Imported.isMissingExpected()) {
   // We failed to find a submodule that we assumed would exist (because it
   // was in the directory of an umbrella header, for instance), but no
   // actual module containing it exists (because the umbrella header is
@@ -1907,13 +1907,18 @@ void Preprocessor::HandleIncludeDirectiv
 
   // Ask HeaderInfo if we should enter this #include file.  If not, #including
   // this file will have no effect.
-  bool SkipHeader = false;
-  if (ShouldEnter && File &&
+  if (Action == Enter && File &&
   !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
  getLangOpts().Modules,
  SuggestedModule.getModule())) {
-ShouldEnter = false;
-SkipHeader = true;
+// Even if we've already preprocessed this header once and know that we
+// don't need to see its contents again, we still need to import it if it's
+// modular because we might not have imported it from this submodule 
before.
+//
+// FIXME: We don't do this when compiling a PCH because the AST
+// serialization layer can't cope with it. This means we get local
+// submodule visibility semantics wrong in that case.
+Action = (SuggestedModule && !getLangOpts().CompilingPCH) ? Import : Skip;
   }
 
   if (Callbacks) {
@@ -1922,8 +1927,9 @@ void Preprocessor::HandleIncludeDirectiv
 HashLoc, IncludeTok,
 LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename, isAngled,
 FilenameRange, File, SearchPath, RelativePath,
-ShouldEnter ? nullptr : SuggestedModule.getModule(), FileCharacter);
-if (SkipHeader && !SuggestedModule.getModule())
+Action == Import ? SuggestedModule.getModule() : nullptr,
+FileCharacter);
+if (Action == Skip)
   Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
   }
 
@@ -1968,28 +1974,33 @@ void Preprocessor::HandleIncludeDirectiv
 }
   }
 
-  // If we don't need to enter the file, stop now.
-  if (!ShouldEnter) {
+  switch (Action) {
+  case Skip:
+// If we don't 

[PATCH] D59656: [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue with notail on x86-64

2019-03-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59656/new/

https://reviews.llvm.org/D59656



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356702 - [OPENMP]Codegen support for allocate directive on global variables.

2019-03-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Mar 21 12:35:27 2019
New Revision: 356702

URL: http://llvm.org/viewvc/llvm-project?rev=356702=rev
Log:
[OPENMP]Codegen support for allocate directive on global variables.

For the global variables the allocate directive must specify only the
predefined allocator. This allocator must be translated into the correct
form of the address space for the targets that support different address
spaces.

Added:
cfe/trunk/test/OpenMP/nvptx_allocate_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=356702=356701=356702=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Mar 21 12:35:27 2019
@@ -8928,6 +8928,30 @@ void CGOpenMPRuntime::adjustTargetSpecif
  " Expected target-based directive.");
 }
 
+bool CGOpenMPRuntime::hasAllocateAttributeForGlobalVar(const VarDecl *VD,
+   LangAS ) {
+  if (!VD || !VD->hasAttr())
+return false;
+  const auto *A = VD->getAttr();
+  switch(A->getAllocatorType()) {
+  case OMPAllocateDeclAttr::OMPDefaultMemAlloc:
+  // Not supported, fallback to the default mem space.
+  case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
+  case OMPAllocateDeclAttr::OMPCGroupMemAlloc:
+  case OMPAllocateDeclAttr::OMPHighBWMemAlloc:
+  case OMPAllocateDeclAttr::OMPLowLatMemAlloc:
+  case OMPAllocateDeclAttr::OMPThreadMemAlloc:
+  case OMPAllocateDeclAttr::OMPConstMemAlloc:
+  case OMPAllocateDeclAttr::OMPPTeamMemAlloc:
+AS = LangAS::Default;
+return true;
+  case OMPAllocateDeclAttr::OMPUserDefinedMemAlloc:
+llvm_unreachable("Expected predefined allocator for the variables with the 
"
+ "static storage.");
+  }
+  return false;
+}
+
 CGOpenMPRuntime::DisableAutoDeclareTargetRAII::DisableAutoDeclareTargetRAII(
 CodeGenModule )
 : CGM(CGM) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=356702=356701=356702=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Mar 21 12:35:27 2019
@@ -1598,6 +1598,11 @@ public:
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
   virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
+
+  /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
+  /// the predefined allocator and translates it into the corresponding address
+  /// space.
+  virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS );
 };
 
 /// Class supports emissionof SIMD-only code.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=356702=356701=356702=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Mar 21 12:35:27 2019
@@ -4840,6 +4840,34 @@ unsigned CGOpenMPRuntimeNVPTX::getDefaul
   return CGM.getContext().getTargetAddressSpace(LangAS::cuda_constant);
 }
 
+bool CGOpenMPRuntimeNVPTX::hasAllocateAttributeForGlobalVar(const VarDecl *VD,
+LangAS ) {
+  if (!VD || !VD->hasAttr())
+return false;
+  const auto *A = VD->getAttr();
+  switch(A->getAllocatorType()) {
+  case OMPAllocateDeclAttr::OMPDefaultMemAlloc:
+  // Not supported, fallback to the default mem space.
+  case OMPAllocateDeclAttr::OMPThreadMemAlloc:
+  case OMPAllocateDeclAttr::OMPLargeCapMemAlloc:
+  case OMPAllocateDeclAttr::OMPCGroupMemAlloc:
+  case OMPAllocateDeclAttr::OMPHighBWMemAlloc:
+  case OMPAllocateDeclAttr::OMPLowLatMemAlloc:
+AS = LangAS::Default;
+return true;
+  case OMPAllocateDeclAttr::OMPConstMemAlloc:
+AS = LangAS::cuda_constant;
+return true;
+  case OMPAllocateDeclAttr::OMPPTeamMemAlloc:
+AS = LangAS::cuda_shared;
+return true;
+  case OMPAllocateDeclAttr::OMPUserDefinedMemAlloc:
+llvm_unreachable("Expected predefined allocator for the variables with the 
"
+ "static storage.");
+  }
+  return false;
+}
+
 // Get current CudaArch and ignore any unknown values
 static CudaArch getCudaArch(CodeGenModule ) {
   if (!CGM.getTarget().hasFeature("ptx"))

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 

[PATCH] D59566: [X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus

2019-03-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

> This is needed to get the LLONG_LOCK_FREE macro to be 2 on i586 and greater.

Not sure these tests are really valuable, given we plan to change that 
immediately after this is merged, but fine, I guess.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59566/new/

https://reviews.llvm.org/D59566



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r356700 - [clang][OpenMP] Fix another test when using libgomp.

2019-03-21 Thread Roman Lebedev via cfe-commits
Thank you for the fix.

I remembered of the yesterday's fix, but either forgot about it here,
or incorrectly recalled this code would be relying on the yesterday's code
(as in, no fix would be needed.)

Roman.

On Thu, Mar 21, 2019 at 10:11 PM Jordan Rupprecht via cfe-commits
 wrote:
>
> Author: rupprecht
> Date: Thu Mar 21 12:13:22 2019
> New Revision: 356700
>
> URL: http://llvm.org/viewvc/llvm-project?rev=356700=rev
> Log:
> [clang][OpenMP] Fix another test when using libgomp.
>
> Similarly to r356614, -fopenmp=libomp needs to be used for some omp-related 
> AST matching.
>
> Modified:
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=356700=356699=356700=diff
> ==
> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h (original)
> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h Thu Mar 21 12:13:22 2019
> @@ -237,13 +237,13 @@ testing::AssertionResult notMatchesWithC
>  template 
>  testing::AssertionResult matchesWithOpenMP(const std::string ,
> const T ) {
> -  return matchesConditionally(Code, AMatcher, true, "-fopenmp");
> +  return matchesConditionally(Code, AMatcher, true, "-fopenmp=libomp");
>  }
>
>  template 
>  testing::AssertionResult notMatchesWithOpenMP(const std::string ,
>const T ) {
> -  return matchesConditionally(Code, AMatcher, false, "-fopenmp");
> +  return matchesConditionally(Code, AMatcher, false, "-fopenmp=libomp");
>  }
>
>  template 
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:574
+  if (ArgTy->getElementType()->isFloatingPointTy()) {
+auto fArgs = F->getFunctionType()->params();
+Type *Tys[] = {fArgs[0], fArgs[1]};

This code is weird... you're computing the types in two different ways.  Also, 
missing a check for F->arg_size() (so we don't crash on invalid IR).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59656: [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue with notail on x86-64

2019-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 191761.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Rename function.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59656/new/

https://reviews.llvm.org/D59656

Files:
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/arc-foreach.m
  test/CodeGenObjC/arc-literals.m
  test/CodeGenObjC/arc-precise-lifetime.m
  test/CodeGenObjC/arc-property.m
  test/CodeGenObjC/arc-related-result-type.m
  test/CodeGenObjC/arc-ternary-op.m
  test/CodeGenObjC/arc-unsafeclaim.m
  test/CodeGenObjC/arc-with-atthrow.m
  test/CodeGenObjC/arc.m
  test/CodeGenObjC/objc-arc-container-subscripting.m
  test/CodeGenObjC/os_log.m
  test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
  test/CodeGenObjCXX/arc.mm
  test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
  test/CodeGenObjCXX/literals.mm

Index: test/CodeGenObjCXX/literals.mm
===
--- test/CodeGenObjCXX/literals.mm
+++ test/CodeGenObjCXX/literals.mm
@@ -29,7 +29,7 @@
   // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[TMP_CAST]])
   // CHECK-NEXT: call void @_ZN1XC1Ev({{.*}} [[TMPX]])
   // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
-  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
   // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
   
   // Initializing the second element
@@ -38,7 +38,7 @@
   // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[TMP_CAST]])
   // CHECK-NEXT: invoke void @_ZN1YC1Ev({{.*}} [[TMPY]])
   // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
-  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
   // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
 
   // Build the array
@@ -83,14 +83,14 @@
   // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 0
   // CHECK: call void @_ZN1XC1Ev
   // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
-  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
   // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
   
   // Initializing the second element
   // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 1
   // CHECK: invoke void @_ZN1YC1Ev
   // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
-  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
   // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
 
   // Build the array
Index: test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
===
--- test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
+++ test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
@@ -23,7 +23,7 @@
 }
 // CHECK-LABEL: define void @_Z1fv
 // CHECK:   %[[TMP:.*]] = call i8* @_Z1gv()
-// CHECK:   {{.*}} = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[TMP]])
+// CHECK:   {{.*}} = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[TMP]])
 // CHECK:   call void (%struct.Base*, i8*, ...) @_ZN4BaseC2E6Strongz(%struct.Base* {{.*}}, i8* {{.*}})
 // CHECK-NEXT:  call void @_ZN9InheritorD1Ev(%struct.Inheritor* {{.*}})
 
Index: test/CodeGenObjCXX/arc.mm
===
--- test/CodeGenObjCXX/arc.mm
+++ test/CodeGenObjCXX/arc.mm
@@ -20,7 +20,7 @@
   // TODO: in the non-volatile case, we do not need to be reloading.
 
   // CHECK:  [[T0:%.*]] = call i8* @_Z12test0_helperv()
-  // CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
+  // CHECK-NEXT: [[T1:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
   // CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** {{%.*}}, align 8
   // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
   // CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.retain(i8* [[T3]])
@@ -29,7 +29,7 @@
   id x = *wp = test0_helper();
 
   // CHECK:  [[T0:%.*]] = call i8* @_Z12test0_helperv()
-  // CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
+  // CHECK-NEXT: [[T1:%.*]] = notail call i8* 

r356700 - [clang][OpenMP] Fix another test when using libgomp.

2019-03-21 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Thu Mar 21 12:13:22 2019
New Revision: 356700

URL: http://llvm.org/viewvc/llvm-project?rev=356700=rev
Log:
[clang][OpenMP] Fix another test when using libgomp.

Similarly to r356614, -fopenmp=libomp needs to be used for some omp-related AST 
matching.

Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=356700=356699=356700=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h Thu Mar 21 12:13:22 2019
@@ -237,13 +237,13 @@ testing::AssertionResult notMatchesWithC
 template 
 testing::AssertionResult matchesWithOpenMP(const std::string ,
const T ) {
-  return matchesConditionally(Code, AMatcher, true, "-fopenmp");
+  return matchesConditionally(Code, AMatcher, true, "-fopenmp=libomp");
 }
 
 template 
 testing::AssertionResult notMatchesWithOpenMP(const std::string ,
   const T ) {
-  return matchesConditionally(Code, AMatcher, false, "-fopenmp");
+  return matchesConditionally(Code, AMatcher, false, "-fopenmp=libomp");
 }
 
 template 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356699 - [OPENMP]Simplify the check for the predefined allocators, NFC.

2019-03-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Mar 21 12:05:07 2019
New Revision: 356699

URL: http://llvm.org/viewvc/llvm-project?rev=356699=rev
Log:
[OPENMP]Simplify the check for the predefined allocators, NFC.

Previously implemented check required the reevaluation of the already
evaluated predefined allocator kind for the global variables. Patch
simplifies this evaluation and removes extra code.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=356699=356698=356699=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Mar 21 12:05:07 2019
@@ -2219,35 +2219,22 @@ getAllocatorKind(Sema , DSAStackTy *St
 return OMPAllocateDeclAttr::OMPDefaultMemAlloc;
   if (Allocator->isTypeDependent() || Allocator->isValueDependent() ||
   Allocator->isInstantiationDependent() ||
-  Allocator->containsUnexpandedParameterPack() ||
-  !Allocator->isEvaluatable(S.getASTContext()))
+  Allocator->containsUnexpandedParameterPack())
 return OMPAllocateDeclAttr::OMPUserDefinedMemAlloc;
-  bool Suppress = S.getDiagnostics().getSuppressAllDiagnostics();
-  S.getDiagnostics().setSuppressAllDiagnostics(/*Val=*/true);
   auto AllocatorKindRes = OMPAllocateDeclAttr::OMPUserDefinedMemAlloc;
   for (int I = OMPAllocateDeclAttr::OMPDefaultMemAlloc;
I < OMPAllocateDeclAttr::OMPUserDefinedMemAlloc; ++I) {
 auto AllocatorKind = static_cast(I);
 Expr *DefAllocator = Stack->getAllocator(AllocatorKind);
-// Compare allocator with the predefined allocator and if true - return
-// predefined allocator kind.
-ExprResult DefAllocRes = S.DefaultLvalueConversion(DefAllocator);
-ExprResult AllocRes = S.DefaultLvalueConversion(Allocator);
-ExprResult CompareRes = S.CreateBuiltinBinOp(
-Allocator->getExprLoc(), BO_EQ, DefAllocRes.get(), AllocRes.get());
-if (!CompareRes.isUsable())
-  continue;
-bool Result;
-if (!CompareRes.get()->EvaluateAsBooleanCondition(Result,
-  S.getASTContext()))
-  continue;
-if (Result) {
+const Expr *AE = Allocator->IgnoreParenImpCasts();
+llvm::FoldingSetNodeID AEId, DAEId;
+AE->Profile(AEId, S.getASTContext(), /*Canonical=*/true);
+DefAllocator->Profile(DAEId, S.getASTContext(), /*Canonical=*/true);
+if (AEId == DAEId) {
   AllocatorKindRes = AllocatorKind;
   break;
 }
-
   }
-  S.getDiagnostics().setSuppressAllDiagnostics(Suppress);
   return AllocatorKindRes;
 }
 
@@ -2325,26 +2312,7 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAl
 // allocator clause must be a constant expression that evaluates to one of
 // the predefined memory allocator values.
 if (Allocator && VD->hasGlobalStorage()) {
-  bool IsPredefinedAllocator = false;
-  if (const auto *DRE =
-  dyn_cast(Allocator->IgnoreParenImpCasts())) {
-if (DRE->getType().isConstant(getASTContext())) {
-  DeclarationName DN = DRE->getDecl()->getDeclName();
-  if (DN.isIdentifier()) {
-StringRef PredefinedAllocators[] = {
-"omp_default_mem_alloc", "omp_large_cap_mem_alloc",
-"omp_const_mem_alloc",   "omp_high_bw_mem_alloc",
-"omp_low_lat_mem_alloc", "omp_cgroup_mem_alloc",
-"omp_pteam_mem_alloc",   "omp_thread_mem_alloc",
-};
-IsPredefinedAllocator =
-llvm::any_of(PredefinedAllocators, [](StringRef S) {
-  return DN.getAsIdentifierInfo()->isStr(S);
-});
-  }
-}
-  }
-  if (!IsPredefinedAllocator) {
+  if (AllocatorKind == OMPAllocateDeclAttr::OMPUserDefinedMemAlloc) {
 Diag(Allocator->getExprLoc(),
  diag::err_omp_expected_predefined_allocator)
 << Allocator->getSourceRange();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59656: [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue with notail on x86-64

2019-03-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/TargetInfo.h:161
+  /// marked as 'notail'.
+  virtual bool noTailCallARCRetainRV() const {
+return false;

`shouldSuppressTailCallsOfRetainAutoreleasedReturnValue()`?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59656/new/

https://reviews.llvm.org/D59656



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Amara Emerson via Phabricator via cfe-commits
aemerson added a comment.

I've put up a langref change as a separate review: D59657 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59647: [CUDA][HIP] Warn shared var initialization

2019-03-21 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

> By default it is still treated as error, therefore no behavior change of 
> clang.

Oh, I see, you already did what I'd suggested.  :)

That's better.  I think this needs to be made *much scarier* though.  "Maybe 
race condition" doesn't capture the danger here -- you can very quickly get UB.

Maybe Richard has thoughts on whether we should allow broken things like this.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59647/new/

https://reviews.llvm.org/D59647



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59647: [CUDA][HIP] Warn shared var initialization

2019-03-21 Thread Justin Lebar via Phabricator via cfe-commits
jlebar requested changes to this revision.
jlebar added a comment.
This revision now requires changes to proceed.

I agree with Art.  The fact that nvcc allows this is broken.

If you want a flag that makes this error a warning, that might work for me.  
The flag should probably say "unsafe" or "I promise I will not complain when 
this breaks me" or something to that effect.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59647/new/

https://reviews.llvm.org/D59647



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59647: [CUDA][HIP] Warn shared var initialization

2019-03-21 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

This looks like one of the things we should *not* do as it affects correctness 
-- non-trivial constructor may be arbitrarily complex and the per-TU flag to 
enable this behavior is way too coarse, IMO.
On the other hand, I can believe that someone somewhere did write the code and 
relies to NVCC accepting it.

Is there a specific use case for this, other than matching nvcc bug-for-bug?

I've added Justin and Richard as reviewers for the language-lawyering input.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59647/new/

https://reviews.llvm.org/D59647



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59656: [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue with notail on x86-64

2019-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

There are existing test cases that test notail isn't added to calls on targets 
that aren't x86-64 (for example, test/CodeGenObjC/arc-arm.m), so I didn't write 
a new one.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59656/new/

https://reviews.llvm.org/D59656



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59656: [CodeGen][ObjC] Annotate calls to objc_retainAutoreleasedReturnValue with notail on x86-64

2019-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, erik.pilkington.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

On x86-64, the epilogue code inserted before the tail jump blocks the 
autoreleased return optimization.

ARC optimizer unconditionally turns calls to 
`objc_retainAutoreleasedReturnValue` to tail calls. I plan to fix that too 
after this patch lands.

rdar://problem/38675807


Repository:
  rC Clang

https://reviews.llvm.org/D59656

Files:
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/arc-foreach.m
  test/CodeGenObjC/arc-literals.m
  test/CodeGenObjC/arc-precise-lifetime.m
  test/CodeGenObjC/arc-property.m
  test/CodeGenObjC/arc-related-result-type.m
  test/CodeGenObjC/arc-ternary-op.m
  test/CodeGenObjC/arc-unsafeclaim.m
  test/CodeGenObjC/arc-with-atthrow.m
  test/CodeGenObjC/arc.m
  test/CodeGenObjC/objc-arc-container-subscripting.m
  test/CodeGenObjC/os_log.m
  test/CodeGenObjCXX/arc-forwarded-lambda-call.mm
  test/CodeGenObjCXX/arc.mm
  test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
  test/CodeGenObjCXX/literals.mm

Index: test/CodeGenObjCXX/literals.mm
===
--- test/CodeGenObjCXX/literals.mm
+++ test/CodeGenObjCXX/literals.mm
@@ -29,7 +29,7 @@
   // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[TMP_CAST]])
   // CHECK-NEXT: call void @_ZN1XC1Ev({{.*}} [[TMPX]])
   // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
-  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
   // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
   
   // Initializing the second element
@@ -38,7 +38,7 @@
   // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[TMP_CAST]])
   // CHECK-NEXT: invoke void @_ZN1YC1Ev({{.*}} [[TMPY]])
   // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
-  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
   // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
 
   // Build the array
@@ -83,14 +83,14 @@
   // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 0
   // CHECK: call void @_ZN1XC1Ev
   // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
-  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+  // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT0]])
   // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
   
   // Initializing the second element
   // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 1
   // CHECK: invoke void @_ZN1YC1Ev
   // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
-  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+  // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[OBJECT1]])
   // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
 
   // Build the array
Index: test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
===
--- test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
+++ test/CodeGenObjCXX/inheriting-constructor-cleanup.mm
@@ -23,7 +23,7 @@
 }
 // CHECK-LABEL: define void @_Z1fv
 // CHECK:   %[[TMP:.*]] = call i8* @_Z1gv()
-// CHECK:   {{.*}} = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[TMP]])
+// CHECK:   {{.*}} = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[TMP]])
 // CHECK:   call void (%struct.Base*, i8*, ...) @_ZN4BaseC2E6Strongz(%struct.Base* {{.*}}, i8* {{.*}})
 // CHECK-NEXT:  call void @_ZN9InheritorD1Ev(%struct.Inheritor* {{.*}})
 
Index: test/CodeGenObjCXX/arc.mm
===
--- test/CodeGenObjCXX/arc.mm
+++ test/CodeGenObjCXX/arc.mm
@@ -20,7 +20,7 @@
   // TODO: in the non-volatile case, we do not need to be reloading.
 
   // CHECK:  [[T0:%.*]] = call i8* @_Z12test0_helperv()
-  // CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
+  // CHECK-NEXT: [[T1:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
   // CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** {{%.*}}, align 8
   // CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
   // CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.retain(i8* [[T3]])
@@ -29,7 +29,7 @@
   

[PATCH] D59603: [PR40707][PR41011][OpenCL] Allow addr space spelling without double underscore in C++ mode

2019-03-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59603/new/

https://reviews.llvm.org/D59603



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Amara Emerson via Phabricator via cfe-commits
aemerson updated this revision to Diff 191745.
aemerson added a comment.

Minor test tweak.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59655/new/

https://reviews.llvm.org/D59655

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
  llvm/lib/Target/AArch64/AArch64LegalizerInfo.h
  llvm/test/CodeGen/AArch64/GlobalISel/fallback-ambiguous-addp-intrinsic.mir
  llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
  llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
  llvm/test/CodeGen/AArch64/arm64-vadd.ll
  llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll

Index: llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
@@ -0,0 +1,9 @@
+; RUN: opt -S < %s -mtriple=arm64 | FileCheck %s
+declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
+
+; CHECK: call <4 x float> @llvm.aarch64.neon.faddp.v4f32
+define <4 x float> @upgrade_aarch64_neon_addp_float(<4 x float> %a, <4 x float> %b) {
+  %res = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %res
+}
+
Index: llvm/test/CodeGen/AArch64/arm64-vadd.ll
===
--- llvm/test/CodeGen/AArch64/arm64-vadd.ll
+++ llvm/test/CodeGen/AArch64/arm64-vadd.ll
@@ -712,7 +712,7 @@
 ;CHECK: faddp.2s
 %tmp1 = load <2 x float>, <2 x float>* %A
 %tmp2 = load <2 x float>, <2 x float>* %B
-%tmp3 = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
+%tmp3 = call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
 ret <2 x float> %tmp3
 }
 
@@ -721,7 +721,7 @@
 ;CHECK: faddp.4s
 %tmp1 = load <4 x float>, <4 x float>* %A
 %tmp2 = load <4 x float>, <4 x float>* %B
-%tmp3 = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %tmp1, <4 x float> %tmp2)
+%tmp3 = call <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float> %tmp1, <4 x float> %tmp2)
 ret <4 x float> %tmp3
 }
 
@@ -730,13 +730,13 @@
 ;CHECK: faddp.2d
 %tmp1 = load <2 x double>, <2 x double>* %A
 %tmp2 = load <2 x double>, <2 x double>* %B
-%tmp3 = call <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double> %tmp1, <2 x double> %tmp2)
+%tmp3 = call <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double> %tmp1, <2 x double> %tmp2)
 ret <2 x double> %tmp3
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>) nounwind readnone
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>) nounwind readnone
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>) nounwind readnone
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>) nounwind readnone
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>) nounwind readnone
+declare <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double>, <2 x double>) nounwind readnone
 
 define <2 x i64> @uaddl_duprhs(<4 x i32> %lhs, i32 %rhs) {
 ; CHECK-LABEL: uaddl_duprhs
Index: llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
===
--- llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
+++ llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
@@ -65,27 +65,27 @@
 ret <2 x i64> %val
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>)
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>)
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>)
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>)
+declare <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double>, <2 x double>)
 
 define <2 x float> @test_faddp_v2f32(<2 x float> %lhs, <2 x float> %rhs) {
 ; CHECK: test_faddp_v2f32:
-%val = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+%val = call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
 ; CHECK: faddp v0.2s, v0.2s, v1.2s
 ret <2 x float> %val
 }
 
 define <4 x float> @test_faddp_v4f32(<4 x float> %lhs, <4 x float> %rhs) {
 ; CHECK: test_faddp_v4f32:
-%val = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %lhs, <4 x float> %rhs)
+%val = call <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float> %lhs, <4 x 

[PATCH] D59624: [Driver] Pass -malign-double from the driver to the cc1 command line

2019-03-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59624/new/

https://reviews.llvm.org/D59624



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59655: [AArch64] Split the neon.addp intrinsic into integer and fp variants

2019-03-21 Thread Amara Emerson via Phabricator via cfe-commits
aemerson created this revision.
aemerson added reviewers: paquette, eli.friedman, t.p.northover.
aemerson added projects: LLVM, clang.
Herald added subscribers: Petar.Avramovic, hiraditya, kristof.beyls, 
javed.absar.

This is the result of discussions on the list about how to deal with intrinsics 
which require codegen to disambiguate them via only the integer/fp overloads. 
It causes problems for GlobalISel as some of that information is lost during 
translation, while with other operations like IR instructions the information 
is encoded into the instruction opcode.

This patch changes clang to emit the new faddp intrinsic if the vector operands 
to the builtin have FP element types. LLVM IR AutoUpgrade has been taught to 
upgrade existing calls to aarch64.neon.addp with fp vector arguments, and we 
remove the workarounds introduced for GlobalISel in r355865.

This is a more permanent solution to PR40968.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59655

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
  llvm/lib/Target/AArch64/AArch64LegalizerInfo.h
  llvm/test/CodeGen/AArch64/GlobalISel/fallback-ambiguous-addp-intrinsic.mir
  llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
  llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
  llvm/test/CodeGen/AArch64/arm64-vadd.ll
  llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll

Index: llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/autoupgrade-aarch64-neon-addp-float.ll
@@ -0,0 +1,10 @@
+; RUN: opt -S < %s -mtriple=arm64 | FileCheck %s
+declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>)
+
+; CHECK: @llvm.aarch64.neon.faddp.v4f32
+define <4 x float> @upgrade_aarch64_neon_addp_float(<4 x float> %a, <4 x float> %b) {
+  %res = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %res
+}
+
Index: llvm/test/CodeGen/AArch64/arm64-vadd.ll
===
--- llvm/test/CodeGen/AArch64/arm64-vadd.ll
+++ llvm/test/CodeGen/AArch64/arm64-vadd.ll
@@ -712,7 +712,7 @@
 ;CHECK: faddp.2s
 %tmp1 = load <2 x float>, <2 x float>* %A
 %tmp2 = load <2 x float>, <2 x float>* %B
-%tmp3 = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
+%tmp3 = call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %tmp1, <2 x float> %tmp2)
 ret <2 x float> %tmp3
 }
 
@@ -721,7 +721,7 @@
 ;CHECK: faddp.4s
 %tmp1 = load <4 x float>, <4 x float>* %A
 %tmp2 = load <4 x float>, <4 x float>* %B
-%tmp3 = call <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float> %tmp1, <4 x float> %tmp2)
+%tmp3 = call <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float> %tmp1, <4 x float> %tmp2)
 ret <4 x float> %tmp3
 }
 
@@ -730,13 +730,13 @@
 ;CHECK: faddp.2d
 %tmp1 = load <2 x double>, <2 x double>* %A
 %tmp2 = load <2 x double>, <2 x double>* %B
-%tmp3 = call <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double> %tmp1, <2 x double> %tmp2)
+%tmp3 = call <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double> %tmp1, <2 x double> %tmp2)
 ret <2 x double> %tmp3
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>) nounwind readnone
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>) nounwind readnone
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>) nounwind readnone
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>) nounwind readnone
+declare <4 x float> @llvm.aarch64.neon.faddp.v4f32(<4 x float>, <4 x float>) nounwind readnone
+declare <2 x double> @llvm.aarch64.neon.faddp.v2f64(<2 x double>, <2 x double>) nounwind readnone
 
 define <2 x i64> @uaddl_duprhs(<4 x i32> %lhs, i32 %rhs) {
 ; CHECK-LABEL: uaddl_duprhs
Index: llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
===
--- llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
+++ llvm/test/CodeGen/AArch64/arm64-neon-add-pairwise.ll
@@ -65,27 +65,27 @@
 ret <2 x i64> %val
 }
 
-declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>)
-declare <4 x float> @llvm.aarch64.neon.addp.v4f32(<4 x float>, <4 x float>)
-declare <2 x double> @llvm.aarch64.neon.addp.v2f64(<2 x double>, <2 x double>)
+declare <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float>, <2 x float>)

[PATCH] D59639: [clangd] Print template arguments helper

2019-03-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang/lib/AST/TypePrinter.cpp:1640
+
+static void printArgument(const TemplateArgumentLoc ,
+  const PrintingPolicy , llvm::raw_ostream ) {

It's unclear to me what the new behavior is with changes in this file. Could 
you add comment?

It might make sense to split the clang change into a separate patch and get 
folks who are more familiar to take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59639/new/

https://reviews.llvm.org/D59639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59567: [X86] Add __popcntd and __popcntq to ia32intrin.h to match gcc and icc. Remove popcnt feature flag from _popcnt32/_popcnt64 and move to ia32intrin.h to match gcc

2019-03-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356689: [X86] Add __popcntd and __popcntq to ia32intrin.h to 
match gcc and icc. Remove… (authored by ctopper, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D59567?vs=191625=191742#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59567/new/

https://reviews.llvm.org/D59567

Files:
  lib/Headers/ia32intrin.h
  lib/Headers/popcntintrin.h
  test/CodeGen/popcnt-builtins.c

Index: test/CodeGen/popcnt-builtins.c
===
--- test/CodeGen/popcnt-builtins.c
+++ test/CodeGen/popcnt-builtins.c
@@ -1,24 +1,39 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 
-#include 
+#include 
 
-unsigned int test_mm_popcnt_u32(unsigned int __X) {
-  //CHECK: call i32 @llvm.ctpop.i32
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
   return _mm_popcnt_u32(__X);
 }
+#endif
 
-unsigned int test_popcnt_32(int __X) {
+int test_popcnt32(unsigned int __X) {
   //CHECK: call i32 @llvm.ctpop.i32
   return _popcnt32(__X);
 }
 
-unsigned long long test_mm_popcnt_u64(unsigned long long __X) {
-  //CHECK: call i64 @llvm.ctpop.i64
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
   return _mm_popcnt_u64(__X);
 }
+#endif
 
-unsigned long long test_popcnt_64(long long __X) {
+long long test_popcnt64(unsigned long long __X) {
   //CHECK: call i64 @llvm.ctpop.i64
   return _popcnt64(__X);
 }
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
Index: lib/Headers/popcntintrin.h
===
--- lib/Headers/popcntintrin.h
+++ lib/Headers/popcntintrin.h
@@ -43,22 +43,6 @@
   return __builtin_popcount(__A);
 }
 
-/// Counts the number of bits in the source operand having a value of 1.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  POPCNT  instruction.
-///
-/// \param __A
-///A signed 32-bit integer operand.
-/// \returns A 32-bit integer containing the number of bits with value 1 in the
-///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
-_popcnt32(int __A)
-{
-  return __builtin_popcount(__A);
-}
-
 #ifdef __x86_64__
 /// Counts the number of bits in the source operand having a value of 1.
 ///
@@ -75,22 +59,6 @@
 {
   return __builtin_popcountll(__A);
 }
-
-/// Counts the number of bits in the source operand having a value of 1.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  POPCNT  instruction.
-///
-/// \param __A
-///A signed 64-bit integer operand.
-/// \returns A 64-bit integer containing the number of bits with value 1 in the
-///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
-_popcnt64(long long __A)
-{
-  return __builtin_popcountll(__A);
-}
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
Index: lib/Headers/ia32intrin.h
===
--- lib/Headers/ia32intrin.h
+++ lib/Headers/ia32intrin.h
@@ -28,6 +28,48 @@
 #ifndef __IA32INTRIN_H
 #define __IA32INTRIN_H
 
+/** Counts the number of bits in the source operand having a value of 1.
+ *
+ *  \headerfile 
+ *
+ *  This intrinsic corresponds to the  POPCNT  instruction or a
+ *  a sequence of arithmetic and logic ops to calculate it.
+ *
+ *  \param __A
+ * An unsigned 32-bit integer operand.
+ *  \returns A 32-bit integer containing the number of bits with value 1 in the
+ * source operand.
+ */
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+__popcntd(unsigned int __A)
+{
+  return __builtin_popcount(__A);
+}
+
+#define _popcnt32(A) __popcntd((A))
+
+#ifdef __x86_64__
+/** Counts the number of bits in the source operand having a value of 1.
+ *
+ *  \headerfile 
+ *
+ *  This intrinsic corresponds to the  POPCNT  instruction or a
+ *  a sequence of arithmetic and logic ops to calculate it.
+ *
+ *  \param __A
+ * An unsigned 64-bit integer operand.
+ *  \returns A 64-bit integer containing the number of bits with value 1 in the
+ * source operand.
+ */
+static __inline__ long long __attribute__((__always_inline__, __nodebug__))
+__popcntq(unsigned long long __A)
+{
+  return __builtin_popcountll(__A);
+}
+
+#define _popcnt64(A) __popcntq((A))
+#endif /* __x86_64__ */
+
 #ifdef __x86_64__
 static 

[PATCH] D59640: [clangd] Add TemplateArgumentList into Symbol

2019-03-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

should we update YAML?




Comment at: clang-tools-extra/clangd/index/Symbol.h:48
+  /// non-specializations. Example: ""
+  llvm::StringRef TemplateArgumentList;
   /// The location of the symbol's definition, if one was found.

How about  `TemplateSpecializationArgs`? 

Could you also put this field near `ReturnType` or `Signature`? 



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:526
   S.ID = std::move(ID);
+  std::string TemplateArgumentList = printTemplateArgsAsWritten(ND);
+  S.TemplateArgumentList = TemplateArgumentList;

put this near `ReturnType` initialization.



Comment at: clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp:396
 
 TEST_F(SymbolCollectorTest, Template) {
   Annotations Header(R"(

this test is getting hard to read. could you only make minimum change to the 
existing test and add a new case for the new behavior?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59640/new/

https://reviews.llvm.org/D59640



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356689 - [X86] Add __popcntd and __popcntq to ia32intrin.h to match gcc and icc. Remove popcnt feature flag from _popcnt32/_popcnt64 and move to ia32intrin.h to match gcc

2019-03-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Mar 21 10:43:53 2019
New Revision: 356689

URL: http://llvm.org/viewvc/llvm-project?rev=356689=rev
Log:
[X86] Add __popcntd and __popcntq to ia32intrin.h to match gcc and icc. Remove 
popcnt feature flag from _popcnt32/_popcnt64 and move to ia32intrin.h to match 
gcc

gcc and icc both implement popcntd and popcntq which we did not. gcc doesn't 
seem to require a feature flag for the _popcnt32/_popcnt64 spelling and will 
use a libcall if its not supported.

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

Modified:
cfe/trunk/lib/Headers/ia32intrin.h
cfe/trunk/lib/Headers/popcntintrin.h
cfe/trunk/test/CodeGen/popcnt-builtins.c

Modified: cfe/trunk/lib/Headers/ia32intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ia32intrin.h?rev=356689=356688=356689=diff
==
--- cfe/trunk/lib/Headers/ia32intrin.h (original)
+++ cfe/trunk/lib/Headers/ia32intrin.h Thu Mar 21 10:43:53 2019
@@ -28,6 +28,48 @@
 #ifndef __IA32INTRIN_H
 #define __IA32INTRIN_H
 
+/** Counts the number of bits in the source operand having a value of 1.
+ *
+ *  \headerfile 
+ *
+ *  This intrinsic corresponds to the  POPCNT  instruction or a
+ *  a sequence of arithmetic and logic ops to calculate it.
+ *
+ *  \param __A
+ * An unsigned 32-bit integer operand.
+ *  \returns A 32-bit integer containing the number of bits with value 1 in the
+ * source operand.
+ */
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+__popcntd(unsigned int __A)
+{
+  return __builtin_popcount(__A);
+}
+
+#define _popcnt32(A) __popcntd((A))
+
+#ifdef __x86_64__
+/** Counts the number of bits in the source operand having a value of 1.
+ *
+ *  \headerfile 
+ *
+ *  This intrinsic corresponds to the  POPCNT  instruction or a
+ *  a sequence of arithmetic and logic ops to calculate it.
+ *
+ *  \param __A
+ * An unsigned 64-bit integer operand.
+ *  \returns A 64-bit integer containing the number of bits with value 1 in the
+ * source operand.
+ */
+static __inline__ long long __attribute__((__always_inline__, __nodebug__))
+__popcntq(unsigned long long __A)
+{
+  return __builtin_popcountll(__A);
+}
+
+#define _popcnt64(A) __popcntq((A))
+#endif /* __x86_64__ */
+
 #ifdef __x86_64__
 static __inline__ unsigned long long __attribute__((__always_inline__, 
__nodebug__))
 __readeflags(void)

Modified: cfe/trunk/lib/Headers/popcntintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/popcntintrin.h?rev=356689=356688=356689=diff
==
--- cfe/trunk/lib/Headers/popcntintrin.h (original)
+++ cfe/trunk/lib/Headers/popcntintrin.h Thu Mar 21 10:43:53 2019
@@ -43,22 +43,6 @@ _mm_popcnt_u32(unsigned int __A)
   return __builtin_popcount(__A);
 }
 
-/// Counts the number of bits in the source operand having a value of 1.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  POPCNT  instruction.
-///
-/// \param __A
-///A signed 32-bit integer operand.
-/// \returns A 32-bit integer containing the number of bits with value 1 in the
-///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
-_popcnt32(int __A)
-{
-  return __builtin_popcount(__A);
-}
-
 #ifdef __x86_64__
 /// Counts the number of bits in the source operand having a value of 1.
 ///
@@ -75,22 +59,6 @@ _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
 }
-
-/// Counts the number of bits in the source operand having a value of 1.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  POPCNT  instruction.
-///
-/// \param __A
-///A signed 64-bit integer operand.
-/// \returns A 64-bit integer containing the number of bits with value 1 in the
-///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
-_popcnt64(long long __A)
-{
-  return __builtin_popcountll(__A);
-}
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS

Modified: cfe/trunk/test/CodeGen/popcnt-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/popcnt-builtins.c?rev=356689=356688=356689=diff
==
--- cfe/trunk/test/CodeGen/popcnt-builtins.c (original)
+++ cfe/trunk/test/CodeGen/popcnt-builtins.c Thu Mar 21 10:43:53 2019
@@ -1,24 +1,39 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +popcnt -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o 
- | FileCheck %s
 
 
-#include 
+#include 
 
-unsigned int test_mm_popcnt_u32(unsigned int __X) {
-  //CHECK: call i32 @llvm.ctpop.i32
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call 

[PATCH] D59639: [clangd] Print template arguments helper

2019-03-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-tools-extra/clangd/AST.cpp:88
 static const TemplateArgumentList *
 getTemplateSpecializationArgs(const NamedDecl ) {
   if (auto *Func = llvm::dyn_cast())

can we unify this with `getTemplateSpecializationArgLocs` somehow? 

it seems that args as written would also be favorable here (see FIXME in line 
112)



Comment at: clang-tools-extra/clangd/AST.cpp:131
+  PrintingPolicy Policy(ND.getASTContext().getLangOpts());
+  if (auto Args = getTemplateSpecializationArgLocs(ND))
+printTemplateArgumentList(OS, *Args, Policy);

Eugene.Zelenko wrote:
> Return type is not obvious, so auto should not be used.
nit: I'd suggest keeping `{}` for symmetry.



Comment at: clang-tools-extra/clangd/AST.cpp:133
+printTemplateArgumentList(OS, *Args, Policy);
+  else if (auto *Cls = llvm::dyn_cast()) {
+if (const TypeSourceInfo *TSI = Cls->getTypeAsWritten()) {

why isn't this handled in `getTemplateSpecializationArgLocs`? Add a comment?



Comment at: clang-tools-extra/clangd/AST.cpp:134
+  else if (auto *Cls = llvm::dyn_cast()) {
+if (const TypeSourceInfo *TSI = Cls->getTypeAsWritten()) {
+  auto STL = TSI->getTypeLoc().getAs();

could you add comment/example explaining what's special about this case?



Comment at: clang-tools-extra/clangd/AST.h:54
+/// Returns an empty string if type is not a template specialization.
+std::string printTemplateArgsAsWritten(const NamedDecl );
+

Maybe `printTemplateSpecializationArgs` since we are only handling template 
specialization? 

I think we could drop `AsWritten` from the name. It should be clear to just 
explain in the comment.  



Comment at: clang-tools-extra/unittests/clangd/ASTUtilsTests.cpp:16
+
+TEST(ASTUtils, PrintTemplateArgs) {
+  Annotations Test(R"cpp(

I think this kind of tests would be more readable using `TEST_P` [1] with code 
and expected arguments as parameters.

Up to you though.

[1] 
https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#specifying-names-for-value-parameterized-test-parameters



Comment at: clang/lib/AST/TypePrinter.cpp:1635
 
+static void printArgument(const TemplateArgument , const PrintingPolicy ,
+  llvm::raw_ostream ) {

could you add clang tests for these changes?



Comment at: clang/lib/AST/TypePrinter.cpp:1643
+  const auto  = A.getArgument().getKind();
+  assert(Kind != TemplateArgument::Null &&
+ "TemplateArgumentKind can not be null!");

why? 

```
/// Represents an empty template argument, e.g., one that has not
/// been deduced.
```
It seems legitimate. 

Since this hot code path, we would want to avoid hard assertion if possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59639/new/

https://reviews.llvm.org/D59639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57464: Generalize method overloading on addr spaces to C++

2019-03-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> I think I would lean towards the latter since it means less fudging around 
> with a whole bunch of unrelated methods. Do @rjmccall or @rsmith have any 
> further opinions on this?

Ok, I can change the patch to prototype this approach. I might need some 
example test cases though.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57464/new/

https://reviews.llvm.org/D57464



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356686 - [X86] Use the CPUKind enum from PROC_ALIAS to directly get the CPUKind in fillValidCPUList.

2019-03-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Mar 21 10:33:20 2019
New Revision: 356686

URL: http://llvm.org/viewvc/llvm-project?rev=356686=rev
Log:
[X86] Use the CPUKind enum from PROC_ALIAS to directly get the CPUKind in 
fillValidCPUList.

We were using getCPUKind which translates the string to the enum also using 
PROC_ALIAS. This just cuts out the string compares.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=356686=356685=356686=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Thu Mar 21 10:33:20 2019
@@ -1819,10 +1819,9 @@ void X86TargetInfo::fillValidCPUList(Sma
 #define PROC(ENUM, STRING, IS64BIT)
\
   if (IS64BIT || getTriple().getArch() == llvm::Triple::x86)   
\
 Values.emplace_back(STRING);
-  // Go through CPUKind checking to ensure that the alias is de-aliased and
-  // 64 bit-ness is checked.
+  // For aliases we need to lookup the CPUKind to check get the 64-bit ness.
 #define PROC_ALIAS(ENUM, ALIAS)
\
-  if (checkCPUKind(getCPUKind(ALIAS))) 
\
+  if (checkCPUKind(CK_##ENUM)) 
 \
 Values.emplace_back(ALIAS);
 #include "clang/Basic/X86Target.def"
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58236: Make address space conversions a bit stricter.

2019-03-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D58236#1437690 , @ebevhan wrote:

> Any more input on this?
>
> I could redo the patch to simply fix the bug and not make the conversions 
> stricter, if that's preferable.


I was playing a bit with some examples of enum with pointer field of various 
address spaces and I couldn't find any case where successfully converting 
nested pointers was useful. Instead it could easily result in execution of 
incorrect code. So I am sticking to the opinion to be more strict.

Similarly, C++ is more strict with similar conversions i.e. nested pointers 
between Derived and Base. I still think since we are implementing new rules it 
is good to be more helpful rather than inheriting older logic of permitting 
everything like in C.

Also of course if we find later any issue we could fix them and modify the 
behavior.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58236/new/

https://reviews.llvm.org/D58236



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59627: [clang-format] Keep protobuf "package" statement on one line

2019-03-21 Thread Donald Chai via Phabricator via cfe-commits
dchai updated this revision to Diff 191734.
dchai added a comment.

Use "isOneOf" instead of two calls to "is".


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59627/new/

https://reviews.llvm.org/D59627

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp


Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -387,6 +387,12 @@
"};");
 }
 
+TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
+  verifyFormat(
+  "package"
+  " some.really.long.package.that.exceeds.the.column.limit;");
+}
+
 TEST_F(FormatTestProto, FormatsService) {
   verifyFormat("service SearchService {\n"
"  rpc Search(SearchRequest) returns (SearchResponse) {\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1073,10 +1073,10 @@
   return LT_ImportStatement;
 }
 
-// In .proto files, top-level options are very similar to import statements
-// and should not be line-wrapped.
+// In .proto files, top-level options and package statements are very
+// similar to import statements and should not be line-wrapped.
 if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
-CurrentToken->is(Keywords.kw_option)) {
+CurrentToken->isOneOf(Keywords.kw_option, Keywords.kw_package)) {
   next();
   if (CurrentToken && CurrentToken->is(tok::identifier))
 return LT_ImportStatement;


Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -387,6 +387,12 @@
"};");
 }
 
+TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
+  verifyFormat(
+  "package"
+  " some.really.long.package.that.exceeds.the.column.limit;");
+}
+
 TEST_F(FormatTestProto, FormatsService) {
   verifyFormat("service SearchService {\n"
"  rpc Search(SearchRequest) returns (SearchResponse) {\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1073,10 +1073,10 @@
   return LT_ImportStatement;
 }
 
-// In .proto files, top-level options are very similar to import statements
-// and should not be line-wrapped.
+// In .proto files, top-level options and package statements are very
+// similar to import statements and should not be line-wrapped.
 if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
-CurrentToken->is(Keywords.kw_option)) {
+CurrentToken->isOneOf(Keywords.kw_option, Keywords.kw_package)) {
   next();
   if (CurrentToken && CurrentToken->is(tok::identifier))
 return LT_ImportStatement;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59466: [clang-tidy] openmp-exception-escape - a new check

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 191727.
lebedev.ri added a reviewer: gribozavr.
lebedev.ri added a comment.

Rebased, NFC.
Split base ExceptionEscapeCheck refactoring into D59650 
.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59466/new/

https://reviews.llvm.org/D59466

Files:
  clang-tidy/openmp/CMakeLists.txt
  clang-tidy/openmp/ExceptionEscapeCheck.cpp
  clang-tidy/openmp/ExceptionEscapeCheck.h
  clang-tidy/openmp/OpenMPTidyModule.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/openmp-exception-escape.rst
  test/clang-tidy/bugprone-exception-escape-openmp.cpp
  test/clang-tidy/openmp-exception-escape.cpp

Index: test/clang-tidy/openmp-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/openmp-exception-escape.cpp
@@ -0,0 +1,126 @@
+// RUN: %check_clang_tidy %s openmp-exception-escape %t -- -extra-arg=-fopenmp -extra-arg=-fexceptions -config="{CheckOptions: [{key: openmp-exception-escape.IgnoredExceptions, value: 'ignored'}]}" --
+
+int thrower() {
+  throw 42;
+}
+
+class ignored {};
+namespace std {
+class bad_alloc {};
+} // namespace std
+
+void parallel() {
+#pragma omp parallel
+  thrower();
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: An exception thrown inside of the OpenMP 'parallel' region is not caught in that same region.
+}
+
+void ignore() {
+#pragma omp parallel
+  throw ignored();
+}
+
+void standalone_directive() {
+#pragma omp taskwait
+  throw ignored(); // not structured block
+}
+
+void ignore_alloc() {
+#pragma omp parallel
+  throw std::bad_alloc();
+}
+
+void parallel_caught() {
+#pragma omp parallel
+  {
+try {
+  thrower();
+} catch (...) {
+}
+  }
+}
+
+void for_header(const int a) {
+  // Only the body of the loop counts.
+#pragma omp for
+  for (int i = 0; i < thrower(); i++)
+;
+}
+
+void forloop(const int a) {
+#pragma omp for
+  for (int i = 0; i < a; i++)
+thrower();
+  // CHECK-MESSAGES: :[[@LINE-3]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+}
+
+void parallel_forloop(const int a) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < a; i++)
+  thrower();
+thrower();
+// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: An exception thrown inside of the OpenMP 'parallel' region is not caught in that same region.
+// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+  }
+}
+
+void parallel_forloop_caught(const int a) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < a; i++) {
+  try {
+thrower();
+  } catch (...) {
+  }
+}
+thrower();
+// CHECK-MESSAGES: :[[@LINE-10]]:9: warning: An exception thrown inside of the OpenMP 'parallel' region is not caught in that same region.
+  }
+}
+
+void parallel_caught_forloop(const int a) {
+#pragma omp parallel
+  {
+#pragma omp for
+for (int i = 0; i < a; i++)
+  thrower();
+try {
+  thrower();
+} catch (...) {
+}
+// CHECK-MESSAGES: :[[@LINE-7]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+  }
+}
+
+void parallel_outercaught_forloop(const int a) {
+#pragma omp parallel
+  {
+try {
+#pragma omp for
+  for (int i = 0; i < a; i++)
+thrower();
+  thrower();
+} catch (...) {
+}
+// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: An exception thrown inside of the OpenMP 'for' region is not caught in that same region.
+  }
+}
+
+void parallel_outercaught_forloop_caught(const int a) {
+#pragma omp parallel
+  {
+try {
+#pragma omp for
+  for (int i = 0; i < a; i++) {
+try {
+  thrower();
+} catch (...) {
+}
+  }
+} catch (...) {
+}
+  }
+}
Index: test/clang-tidy/bugprone-exception-escape-openmp.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-exception-escape-openmp.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-fopenmp -extra-arg=-fexceptions --
+
+int thrower() {
+  throw 42;
+}
+
+void ok_parallel() {
+#pragma omp parallel
+  thrower();
+}
+
+void bad_for_header_XFAIL(const int a) {
+#pragma omp for
+  for (int i = 0; i < thrower(); i++)
+;
+  // FIXME: this really should be caught by bugprone-exception-escape.
+  // https://bugs.llvm.org/show_bug.cgi?id=41102
+}
+
+void ok_forloop(const int a) {
+#pragma omp for
+  for (int i = 0; i < a; i++)
+thrower();
+}
+
+void some_exception_just_so_that_check_clang_tidy_shuts_up() noexcept {
+  thrower();
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: an exception may be thrown in function 

[PATCH] D57113: [clang-tidy] openmp-use-default-none - a new check

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 191726.
lebedev.ri marked 4 inline comments as done.
lebedev.ri edited the summary of this revision.
lebedev.ri added a reviewer: gribozavr.
lebedev.ri added a comment.

Rebased, NFC.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57113/new/

https://reviews.llvm.org/D57113

Files:
  clang-tidy/openmp/CMakeLists.txt
  clang-tidy/openmp/OpenMPTidyModule.cpp
  clang-tidy/openmp/UseDefaultNoneCheck.cpp
  clang-tidy/openmp/UseDefaultNoneCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/openmp-use-default-none.rst
  test/clang-tidy/openmp-use-default-none.cpp

Index: test/clang-tidy/openmp-use-default-none.cpp
===
--- /dev/null
+++ test/clang-tidy/openmp-use-default-none.cpp
@@ -0,0 +1,160 @@
+// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -x c++ -fopenmp -fopenmp-version=40
+// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -x c   -fopenmp -fopenmp-version=40
+
+////
+// Null cases.
+////
+
+// 'for' directive can not have 'default' clause, no diagnostics.
+void n0(const int a) {
+#pragma omp for
+  for (int b = 0; b < a; b++)
+;
+}
+
+////
+// Single-directive positive cases.
+////
+
+// 'parallel' directive.
+
+// 'parallel' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p0_0() {
+#pragma omp parallel
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'parallel' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void p0_1() {
+#pragma omp parallel default(none)
+  ;
+}
+
+// 'parallel' directive can have 'default' clause, and said clause is specified,
+// but with 'shared' kind, which is not 'none', diagnose.
+void p0_2() {
+#pragma omp parallel default(shared)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' specifies 'default(shared)' clause. Consider using 'default(none)' clause instead.
+  // CHECK-NOTES: :[[@LINE-3]]:22: note: Existing 'default' clause is specified here.
+}
+
+// 'task' directive.
+
+// 'task' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p1_0() {
+#pragma omp task
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'task' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void p1_1() {
+#pragma omp task default(none)
+  ;
+}
+
+// 'task' directive can have 'default' clause, and said clause is specified,
+// but with 'shared' kind, which is not 'none', diagnose.
+void p1_2() {
+#pragma omp task default(shared)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' specifies 'default(shared)' clause. Consider using 'default(none)' clause instead.
+  // CHECK-NOTES: :[[@LINE-3]]:18: note: Existing 'default' clause is specified here.
+}
+
+// 'teams' directive. (has to be inside of 'target' directive)
+
+// 'teams' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p2_0() {
+#pragma omp target
+#pragma omp teams
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'teams' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void p2_1() {
+#pragma omp target
+#pragma omp teams default(none)
+  ;
+}
+
+// 'teams' directive can have 'default' clause, and said clause is specified,
+// but with 'shared' kind, which is not 'none', diagnose.
+void p2_2() {
+#pragma omp target
+#pragma omp teams default(shared)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' specifies 'default(shared)' clause. Consider using 'default(none)' clause instead.
+  // CHECK-NOTES: :[[@LINE-3]]:19: note: Existing 'default' clause is specified here.
+}
+
+// 'taskloop' directive.
+
+// 'taskloop' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p3_0(const int a) {
+#pragma omp taskloop
+  for (int b = 0; b < a; b++)
+;
+  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'taskloop' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void 

[PATCH] D57571: [clang-tidy] A new OpenMP module

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 191724.
lebedev.ri added a comment.

Rebased, NFC.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57571/new/

https://reviews.llvm.org/D57571

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/openmp/CMakeLists.txt
  clang-tidy/openmp/OpenMPTidyModule.cpp
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -73,6 +73,7 @@
means "C++11") language constructs.
 ``mpi-``   Checks related to MPI (Message Passing Interface).
 ``objc-``  Checks related to Objective-C coding conventions.
+``openmp-``Checks related to OpenMP API.
 ``performance-``   Checks that target performance-related issues.
 ``portability-``   Checks that target portability-related issues that don't
relate to any particular coding style.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -67,6 +67,10 @@
 Improvements to clang-tidy
 --
 
+- New OpenMP module.
+
+  For checks specific to `OpenMP `_ API.
+
 - New :doc:`abseil-duration-addition
   ` check.
 
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -30,6 +30,7 @@
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyObjCModule
+  clangTidyOpenMPModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
Index: clang-tidy/plugin/CMakeLists.txt
===
--- clang-tidy/plugin/CMakeLists.txt
+++ clang-tidy/plugin/CMakeLists.txt
@@ -21,6 +21,7 @@
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyObjCModule
+  clangTidyOpenMPModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
Index: clang-tidy/openmp/OpenMPTidyModule.cpp
===
--- /dev/null
+++ clang-tidy/openmp/OpenMPTidyModule.cpp
@@ -0,0 +1,35 @@
+//===--- OpenMPTidyModule.cpp - clang-tidy===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+
+namespace clang {
+namespace tidy {
+namespace openmp {
+
+/// This module is for OpenMP-specific checks.
+class OpenMPModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories ) override {
+  }
+};
+
+// Register the OpenMPTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add
+X("openmp-module", "Adds OpenMP-specific checks.");
+
+} // namespace openmp
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the OpenMPModule.
+volatile int OpenMPModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/openmp/CMakeLists.txt
===
--- /dev/null
+++ clang-tidy/openmp/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyOpenMPModule
+  OpenMPTidyModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangTidy
+  )
Index: clang-tidy/ClangTidyForceLinker.h
===
--- clang-tidy/ClangTidyForceLinker.h
+++ clang-tidy/ClangTidyForceLinker.h
@@ -77,6 +77,11 @@
 MPIModuleAnchorSource;
 #endif
 
+// This anchor is used to force the linker to link the OpenMPModule.
+extern volatile int OpenMPModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED OpenMPModuleAnchorDestination =
+OpenMPModuleAnchorSource;
+
 // This anchor is used to force the linker to link the PerformanceModule.
 extern volatile int PerformanceModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination =
Index: clang-tidy/CMakeLists.txt
===
--- clang-tidy/CMakeLists.txt
+++ clang-tidy/CMakeLists.txt
@@ -49,6 +49,7 @@
   add_subdirectory(mpi)
 endif()
 add_subdirectory(objc)
+add_subdirectory(openmp)
 add_subdirectory(performance)
 add_subdirectory(plugin)
 add_subdirectory(portability)

[PATCH] D59650: [NFC] ExceptionEscapeCheck: small refactoring

2019-03-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: baloghadamsoftware, JonasToth, gribozavr.
lebedev.ri added a project: clang-tools-extra.
Herald added a subscriber: rnkovacs.
Herald added a project: clang.

D59466  wants to analyse the `Stmt`, and 
`ExceptionEscapeCheck` does not
have that as a possible entry point.
This simplifies addition of `Stmt` analysis entry point.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D59650

Files:
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h


Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -128,7 +128,7 @@
 IgnoredExceptions = std::move(ExceptionNames);
   }
 
-  ExceptionInfo analyze(const FunctionDecl *Func);
+  template  ExceptionInfo analyze(const T *Node);
 
 private:
   ExceptionInfo
@@ -138,10 +138,17 @@
   throwsException(const Stmt *St, const ExceptionInfo::Throwables ,
   llvm::SmallSet );
 
+  template 
+  void analyze(const T *Node, ExceptionInfo );
+
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
   std::map FunctionCache;
 };
+
+extern template ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func);
+
 } // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -204,10 +204,9 @@
   return Results;
 }
 
-ExceptionAnalyzer::ExceptionInfo
-ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
-  ExceptionInfo ExceptionList;
-
+template <>
+void ExceptionAnalyzer::analyze(const FunctionDecl *Func,
+ExceptionInfo ) {
   // Check if the function has already been analyzed and reuse that result.
   if (FunctionCache.count(Func) == 0) {
 llvm::SmallSet CallStack;
@@ -220,6 +219,13 @@
 FunctionCache.insert(std::make_pair(Func, ExceptionList));
   } else
 ExceptionList = FunctionCache[Func];
+}
+
+template 
+ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::analyze(const T *Node) {
+  ExceptionInfo ExceptionList;
+
+  analyze(Node, ExceptionList);
 
   if (ExceptionList.getBehaviour() == State::NotThrowing ||
   ExceptionList.getBehaviour() == State::Unknown)
@@ -231,6 +237,10 @@
 
   return ExceptionList;
 }
+
+template ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func);
+
 } // namespace utils
 } // namespace tidy
 


Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -128,7 +128,7 @@
 IgnoredExceptions = std::move(ExceptionNames);
   }
 
-  ExceptionInfo analyze(const FunctionDecl *Func);
+  template  ExceptionInfo analyze(const T *Node);
 
 private:
   ExceptionInfo
@@ -138,10 +138,17 @@
   throwsException(const Stmt *St, const ExceptionInfo::Throwables ,
   llvm::SmallSet );
 
+  template 
+  void analyze(const T *Node, ExceptionInfo );
+
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
   std::map FunctionCache;
 };
+
+extern template ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func);
+
 } // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -204,10 +204,9 @@
   return Results;
 }
 
-ExceptionAnalyzer::ExceptionInfo
-ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
-  ExceptionInfo ExceptionList;
-
+template <>
+void ExceptionAnalyzer::analyze(const FunctionDecl *Func,
+ExceptionInfo ) {
   // Check if the function has already been analyzed and reuse that result.
   if (FunctionCache.count(Func) == 0) {
 llvm::SmallSet CallStack;
@@ -220,6 +219,13 @@
 FunctionCache.insert(std::make_pair(Func, ExceptionList));
   } else
 ExceptionList = FunctionCache[Func];
+}
+
+template 
+ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::analyze(const T *Node) {
+  ExceptionInfo ExceptionList;
+
+  analyze(Node, ExceptionList);
 
   if (ExceptionList.getBehaviour() == State::NotThrowing ||
   ExceptionList.getBehaviour() == State::Unknown)
@@ -231,6 +237,10 @@
 
   return ExceptionList;
 }
+
+template ExceptionAnalyzer::ExceptionInfo
+ExceptionAnalyzer::analyze(const FunctionDecl *Func);
+
 } // namespace utils
 } // namespace tidy
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D59440: add steps to preprocess file and reduce command line args

2019-03-21 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

@arichardson Will add you next time, sorry I didn't do so on this one!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59440/new/

https://reviews.llvm.org/D59440



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356679 - [AST] OMPStructuredBlockTest: two matchers were promoted into ASTMatchers.h

2019-03-21 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Mar 21 08:50:54 2019
New Revision: 356679

URL: http://llvm.org/viewvc/llvm-project?rev=356679=rev
Log:
[AST] OMPStructuredBlockTest: two matchers were promoted into ASTMatchers.h

Modified:
cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp

Modified: cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp?rev=356679=356678=356679=diff
==
--- cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp (original)
+++ cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp Thu Mar 21 08:50:54 2019
@@ -14,6 +14,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gmock/gmock.h"
@@ -25,8 +26,6 @@ using namespace tooling;
 
 namespace {
 
-AST_MATCHER(Stmt, isOMPStructuredBlock) { return Node.isOMPStructuredBlock(); }
-
 const ast_matchers::internal::VariadicDynCastAllOfMatcher<
 OMPExecutableDirective, OMPTargetDirective>
 ompTargetDirective;
@@ -37,10 +36,6 @@ StatementMatcher OMPInnermostStructuredB
   .bind("id");
 }
 
-AST_MATCHER(OMPExecutableDirective, isStandaloneDirective) {
-  return Node.isStandaloneDirective();
-}
-
 StatementMatcher OMPStandaloneDirectiveMatcher() {
   return stmt(ompExecutableDirective(isStandaloneDirective())).bind("id");
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59647: [CUDA][HIP] Warn shared var initialization

2019-03-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a project: clang.

In many cases the default constructor of a class contains initializer of data
members, which allows concise code. The class may be instantiated as
global or automatic variables in device code, which is totally legal. However
when such a class is instantiated as a shared variable in device code, clang
will emit an error saying shared variables cannot be initialized.

Usually, users would like to just add explicit initialization for the shared 
variable,
instead of remove the initializer of data members from the default constructor,
since that would requires adding explicit initialization to all instances of 
the class,
even as global or automatic variables.

This requires the diagnostic of initialization of shared variable to be a 
warning,
instead of an error.

nvcc emits an warning for such situation, e.g.

  $ cat a.cu
  
  struct A {
int a;
__device__ A():a(0){}
  };
  
  
  __global__ void foo() {
__shared__ A a;
  }
  
  $nvcc -c a.cu
  a.cu(10): warning: __shared__ memory variable with non-empty constructor or 
destructor (potential race between threads)

This patch turns the diagnostic of initialization of shared varibles into a 
warning.
By default it is still treated as error, therefore no behavior change of clang. 
However,
user can turn it into a warning by -Wno-error=cuda-shared-init.


Repository:
  rC Clang

https://reviews.llvm.org/D59647

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCUDA.cpp


Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -499,7 +499,7 @@
 
 if (!AllowedInit) {
   Diag(VD->getLocation(), VD->hasAttr()
-  ? diag::err_shared_var_init
+  ? diag::warn_shared_var_init
   : diag::err_dynamic_var_init)
   << Init->getSourceRange();
   VD->setInvalidDecl();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7194,8 +7194,9 @@
 def err_dynamic_var_init : Error<
 "dynamic initialization is not supported for "
 "__device__, __constant__, and __shared__ variables.">;
-def err_shared_var_init : Error<
-"initialization is not supported for __shared__ variables.">;
+def warn_shared_var_init : Warning<
+"initialization is not supported for __shared__ variables.">,
+InGroup>, DefaultError;
 def err_device_static_local_var : Error<
 "within a %select{__device__|__global__|__host__|__host__ __device__}0 "
 "function, only __shared__ variables or const variables without device "


Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -499,7 +499,7 @@
 
 if (!AllowedInit) {
   Diag(VD->getLocation(), VD->hasAttr()
-  ? diag::err_shared_var_init
+  ? diag::warn_shared_var_init
   : diag::err_dynamic_var_init)
   << Init->getSourceRange();
   VD->setInvalidDecl();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7194,8 +7194,9 @@
 def err_dynamic_var_init : Error<
 "dynamic initialization is not supported for "
 "__device__, __constant__, and __shared__ variables.">;
-def err_shared_var_init : Error<
-"initialization is not supported for __shared__ variables.">;
+def warn_shared_var_init : Warning<
+"initialization is not supported for __shared__ variables.">,
+InGroup>, DefaultError;
 def err_device_static_local_var : Error<
 "within a %select{__device__|__global__|__host__|__host__ __device__}0 "
 "function, only __shared__ variables or const variables without device "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59639: [clangd] Print template arguments helper

2019-03-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clangd/AST.cpp:26
+llvm::Optional>
+getTemplateSpecializationArgLocs(const NamedDecl ) {
+  if (auto *Func = llvm::dyn_cast()) {

Functions should be static, not in anonymous namespace. See LLVM Coding 
Guidelines.



Comment at: clang-tools-extra/clangd/AST.cpp:28
+  if (auto *Func = llvm::dyn_cast()) {
+if (auto *Args = Func->getTemplateSpecializationArgsAsWritten())
+  return Args->arguments();

Return type is not obvious, so auto should not be used.



Comment at: clang-tools-extra/clangd/AST.cpp:131
+  PrintingPolicy Policy(ND.getASTContext().getLangOpts());
+  if (auto Args = getTemplateSpecializationArgLocs(ND))
+printTemplateArgumentList(OS, *Args, Policy);

Return type is not obvious, so auto should not be used.



Comment at: clang/lib/AST/TypePrinter.cpp:1642
+  const PrintingPolicy , llvm::raw_ostream ) {
+  const auto  = A.getArgument().getKind();
+  assert(Kind != TemplateArgument::Null &&

Return type is not obvious, so auto should not be used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59639/new/

https://reviews.llvm.org/D59639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59463: [ASTMatchers][OpenMP] OpenMP Structured-block-related matchers

2019-03-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356676: [ASTMatchers][OpenMP] OpenMP 
Structured-block-related matchers (authored by lebedevri, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59463?vs=191701=191707#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59463/new/

https://reviews.llvm.org/D59463

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -3497,6 +3497,21 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectiveisStandaloneDirective
+Matches standalone OpenMP directives,
+i.e., directives that can't have a structured block.
+
+Given
+
+  #pragma omp parallel
+  {}
+  #pragma omp taskyield
+
+``ompExecutableDirective(isStandaloneDirective()))`` matches
+``omp taskyield``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprargumentCountIsunsigned N
 Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -3867,6 +3882,19 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtisOMPStructuredBlock
+Matches the Stmt AST node that is marked as being the structured-block
+of an OpenMP executable directive.
+
+Given
+
+   #pragma omp parallel
+   {}
+
+``stmt(isOMPStructuredBlock()))`` matches ``{}``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html;>StringLiteralhasSizeunsigned N
 Matches nodes that have the specified size.
 
@@ -6234,6 +6262,23 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectivehasStructuredBlockMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>Stmt InnerMatcher
+Matches the structured-block of the OpenMP executable directive
+
+Prerequisite: the executable directive must not be standalone directive.
+If it is, it will never match.
+
+Given
+
+   #pragma omp parallel
+   ;
+   #pragma omp parallel
+   {}
+
+``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprhasAnyArgumentMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr InnerMatcher
 Matches any argument of a call expression or a constructor call
 expression, or an ObjC-message-send expression.
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -6390,6 +6390,58 @@
 extern const internal::VariadicDynCastAllOfMatcher
 ompExecutableDirective;
 
+/// Matches standalone OpenMP directives,
+/// i.e., directives that can't have a structured block.
+///
+/// Given
+///
+/// \code
+///   #pragma omp parallel
+///   {}
+///   #pragma omp taskyield
+/// \endcode
+///
+/// ``ompExecutableDirective(isStandaloneDirective()))`` matches
+/// ``omp taskyield``.
+AST_MATCHER(OMPExecutableDirective, isStandaloneDirective) {
+  return Node.isStandaloneDirective();
+}
+
+/// Matches the Stmt AST node that is marked as being the structured-block
+/// of an OpenMP executable directive.
+///
+/// Given
+///
+/// \code
+///#pragma omp parallel
+///{}
+/// \endcode
+///
+/// ``stmt(isOMPStructuredBlock()))`` matches ``{}``.
+AST_MATCHER(Stmt, isOMPStructuredBlock) { return Node.isOMPStructuredBlock(); }
+
+/// Matches the structured-block of the OpenMP executable directive
+///
+/// Prerequisite: the executable directive must not be standalone directive.
+/// If it is, it will never match.
+///
+/// Given
+///
+/// \code
+///#pragma omp parallel
+///;
+///#pragma omp parallel
+///{}
+/// \endcode
+///
+/// ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
+AST_MATCHER_P(OMPExecutableDirective, hasStructuredBlock,
+  internal::Matcher, InnerMatcher) {
+  if (Node.isStandaloneDirective())
+return false; // Standalone directives have no structured blocks.
+  return InnerMatcher.matches(*Node.getStructuredBlock(), Finder, Builder);
+}
+
 /// Matches any clause in an OpenMP directive.
 ///
 /// Given
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp

[PATCH] D57112: [ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handling

2019-03-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356675: [ASTTypeTraits][ASTMatchers][OpenMP] OMPClause 
handling (authored by lebedevri, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57112?vs=191697=191706#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57112/new/

https://reviews.llvm.org/D57112

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/AST/ASTTypeTraits.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/AST/ASTTypeTraits.cpp
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -645,6 +645,19 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPClause.html;>OMPClauseompDefaultClauseMatcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html;>OMPDefaultClause...
+Matches OpenMP ``default`` clause.
+
+Given
+
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+  #pragma omp parallel
+
+``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypequalTypeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType...
 Matches QualTypes in the clang AST.
 
@@ -3439,6 +3452,51 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html;>OMPDefaultClauseisNoneKind
+Matches if the OpenMP ``default`` clause has ``none`` kind specified.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+
+``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
+
+
+
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html;>OMPDefaultClauseisSharedKind
+Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+
+``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
+
+
+
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectiveisAllowedToContainClauseKindOpenMPClauseKind CKind
+Matches if the OpenMP directive is allowed to contain the specified OpenMP
+clause kind.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel for
+  #pragma omp  for
+
+`ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
+``omp parallel`` and ``omp parallel for``.
+
+If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
+should be passed as a quoted string. e.g.,
+``isAllowedToContainClauseKind("OMPC_default").``
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprargumentCountIsunsigned N
 Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -6163,6 +6221,19 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectivehasAnyClauseMatcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPClause.html;>OMPClause InnerMatcher
+Matches any clause in an OpenMP directive.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+
+``ompExecutableDirective(hasAnyClause(anything()))`` matches
+``omp parallel default(none)``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprhasAnyArgumentMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr InnerMatcher
 Matches any argument of a call expression or a constructor call
 expression, or an ObjC-message-send expression.
Index: cfe/trunk/include/clang/AST/ASTTypeTraits.h
===
--- cfe/trunk/include/clang/AST/ASTTypeTraits.h
+++ cfe/trunk/include/clang/AST/ASTTypeTraits.h
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
@@ -58,6 +59,7 @@
   static ASTNodeKind getFromNode(const Decl );
   static ASTNodeKind getFromNode(const Stmt );
   static ASTNodeKind getFromNode(const Type );
+  static ASTNodeKind getFromNode(const OMPClause );
   /// \}
 
   /// Returns \c true if \c this and \c Other represent the same kind.
@@ -136,6 +138,9 @@

[PATCH] D59453: [ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.

2019-03-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356674: [ASTMatchers][OpenMP] Add base 
ompExecutableDirective() matcher. (authored by lebedevri, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59453?vs=191674=191705#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59453/new/

https://reviews.llvm.org/D59453

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -60,6 +60,7 @@
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
+#include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -6369,6 +6370,29 @@
   return false;
 }
 
+////
+// OpenMP handling.
+////
+
+/// Matches any ``#pragma omp`` executable directive.
+///
+/// Given
+///
+/// \code
+///   #pragma omp parallel
+///   #pragma omp parallel default(none)
+///   #pragma omp taskyield
+/// \endcode
+///
+/// ``ompExecutableDirective()`` matches ``omp parallel``,
+/// ``omp parallel default(none)`` and ``omp taskyield``.
+extern const internal::VariadicDynCastAllOfMatcher
+ompExecutableDirective;
+
+////
+// End OpenMP handling.
+////
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -845,5 +845,8 @@
 AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
 PointerType, ReferenceType));
 
+const internal::VariadicDynCastAllOfMatcher
+ompExecutableDirective;
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -434,6 +434,7 @@
   REGISTER_MATCHER(objcThrowStmt);
   REGISTER_MATCHER(objcTryStmt);
   REGISTER_MATCHER(ofClass);
+  REGISTER_MATCHER(ompExecutableDirective);
   REGISTER_MATCHER(on);
   REGISTER_MATCHER(onImplicitObjectArgument);
   REGISTER_MATCHER(opaqueValueExpr);
Index: cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp
===
--- cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp
+++ cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp
@@ -28,10 +28,6 @@
 AST_MATCHER(Stmt, isOMPStructuredBlock) { return Node.isOMPStructuredBlock(); }
 
 const ast_matchers::internal::VariadicDynCastAllOfMatcher<
-Stmt, OMPExecutableDirective>
-ompExecutableDirective;
-
-const ast_matchers::internal::VariadicDynCastAllOfMatcher<
 OMPExecutableDirective, OMPTargetDirective>
 ompTargetDirective;
 
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1765,5 +1765,29 @@
   EXPECT_FALSE(matchesObjC(ObjCStringNoPool, autoreleasePoolStmt()));
 }
 
+TEST(OMPExecutableDirective, Matches) {
+  auto Matcher = stmt(ompExecutableDirective());
+
+  const std::string Source0 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source0, Matcher));
+
+  const std::string Source1 = R"(
+void x() {
+#pragma omp taskyield
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP(Source1, Matcher));
+
+  const std::string Source2 = R"(
+void x() {
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source2, Matcher));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
@@ -235,6 +235,18 @@
 }
 
 template 

r356676 - [ASTMatchers][OpenMP] OpenMP Structured-block-related matchers

2019-03-21 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Mar 21 08:33:35 2019
New Revision: 356676

URL: http://llvm.org/viewvc/llvm-project?rev=356676=rev
Log:
[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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=356676=356675=356676=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Mar 21 08:33:35 2019
@@ -3497,6 +3497,21 @@ should be passed as a quoted string. e.g
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectiveisStandaloneDirective
+Matches 
standalone OpenMP directives,
+i.e., directives that can't have a structured block.
+
+Given
+
+  #pragma omp parallel
+  {}
+  #pragma omp taskyield
+
+``ompExecutableDirective(isStandaloneDirective()))`` matches
+``omp taskyield``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprargumentCountIsunsigned N
 Checks that a call 
expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -3867,6 +3882,19 @@ Usable as: Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtisOMPStructuredBlock
+Matches the 
Stmt AST node that is marked as being the structured-block
+of an OpenMP executable directive.
+
+Given
+
+   #pragma omp parallel
+   {}
+
+``stmt(isOMPStructuredBlock()))`` matches ``{}``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html;>StringLiteralhasSizeunsigned N
 Matches nodes that have the 
specified size.
 
@@ -6234,6 +6262,23 @@ Given
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectivehasStructuredBlockMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>Stmt 
InnerMatcher
+Matches the 
structured-block of the OpenMP executable directive
+
+Prerequisite: the executable directive must not be standalone directive.
+If it is, it will never match.
+
+Given
+
+   #pragma omp parallel
+   ;
+   #pragma omp parallel
+   {}
+
+``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprhasAnyArgumentMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr 
InnerMatcher
 Matches any argument 
of a call expression or a constructor call
 expression, or an ObjC-message-send expression.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=356676=356675=356676=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Mar 21 08:33:35 2019
@@ -6390,6 +6390,58 @@ AST_MATCHER(FunctionDecl, hasTrailingRet
 extern const internal::VariadicDynCastAllOfMatcher
 ompExecutableDirective;
 
+/// Matches standalone OpenMP directives,
+/// i.e., directives that can't have a structured block.
+///
+/// Given
+///
+/// \code
+///   #pragma omp parallel
+///   {}
+///   #pragma omp taskyield
+/// \endcode
+///
+/// ``ompExecutableDirective(isStandaloneDirective()))`` matches
+/// ``omp taskyield``.
+AST_MATCHER(OMPExecutableDirective, isStandaloneDirective) {
+  return Node.isStandaloneDirective();
+}
+
+/// Matches the Stmt AST node that is marked as being the structured-block
+/// of an OpenMP executable directive.
+///
+/// Given
+///
+/// \code
+///#pragma omp parallel
+///{}
+/// \endcode
+///
+/// ``stmt(isOMPStructuredBlock()))`` matches ``{}``.
+AST_MATCHER(Stmt, isOMPStructuredBlock) { return Node.isOMPStructuredBlock(); }
+
+/// Matches the structured-block of the OpenMP executable directive
+///
+/// Prerequisite: the executable directive must not be standalone directive.
+/// If it is, it will never match.
+///
+/// Given
+///
+/// \code
+///#pragma omp parallel
+///;
+///#pragma omp parallel
+///{}
+/// \endcode
+///
+/// ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
+AST_MATCHER_P(OMPExecutableDirective, hasStructuredBlock,
+  internal::Matcher, 

r356677 - [ASTMatcher] Add clang-query disclaimer to two more matchers that take enum

2019-03-21 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Mar 21 08:33:43 2019
New Revision: 356677

URL: http://llvm.org/viewvc/llvm-project?rev=356677=rev
Log:
[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.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=356677=356676=356677=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Mar 21 08:33:43 2019
@@ -2640,6 +2640,9 @@ Example matches y(x) but not y(42) or NS
 Example: matches the implicit cast around 0
 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
   int *p = 0;
+
+If the matcher is use from clang-query, CastKind parameter
+should be passed as a quoted string. e.g., ofKind("CK_NullToPointer").
 
 
 
@@ -4086,6 +4089,9 @@ Given
   int s = sizeof(x) + alignof(x)
 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
   matches sizeof(x)
+
+If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
+should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
 
 
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=356677=356676=356677=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Mar 21 08:33:43 2019
@@ -2492,6 +2492,9 @@ AST_MATCHER_P(UnaryExprOrTypeTraitExpr,
 /// \endcode
 /// unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
 ///   matches \c sizeof(x)
+///
+/// If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
+/// should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
 AST_MATCHER_P(UnaryExprOrTypeTraitExpr, ofKind, UnaryExprOrTypeTrait, Kind) {
   return Node.getKind() == Kind;
 }
@@ -4483,6 +4486,9 @@ AST_POLYMORPHIC_MATCHER_P(hasSourceExpre
 /// \code
 ///   int *p = 0;
 /// \endcode
+///
+/// If the matcher is use from clang-query, CastKind parameter
+/// should be passed as a quoted string. e.g., ofKind("CK_NullToPointer").
 AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
   return Node.getCastKind() == Kind;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356675 - [ASTTypeTraits][ASTMatchers][OpenMP] OMPClause handling

2019-03-21 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Mar 21 08:33:24 2019
New Revision: 356675

URL: http://llvm.org/viewvc/llvm-project?rev=356675=rev
Log:
[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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/AST/ASTTypeTraits.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTTypeTraits.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Marshallers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=356675=356674=356675=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Mar 21 08:33:24 2019
@@ -645,6 +645,19 @@ nestedNameSpecifier()
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPClause.html;>OMPClauseompDefaultClauseMatcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html;>OMPDefaultClause...
+Matches OpenMP 
``default`` clause.
+
+Given
+
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+  #pragma omp parallel
+
+``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypequalTypeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType...
 Matches QualTypes in the 
clang AST.
 
@@ -3439,6 +3452,51 @@ namespaceDecl(isInline()) will match n::
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html;>OMPDefaultClauseisNoneKind
+Matches if the OpenMP 
``default`` clause has ``none`` kind specified.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+
+``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
+
+
+
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html;>OMPDefaultClauseisSharedKind
+Matches if the OpenMP 
``default`` clause has ``shared`` kind specified.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+
+``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
+
+
+
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectiveisAllowedToContainClauseKindOpenMPClauseKind
 CKind
+Matches if the OpenMP directive is 
allowed to contain the specified OpenMP
+clause kind.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel for
+  #pragma omp  for
+
+`ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
+``omp parallel`` and ``omp parallel for``.
+
+If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
+should be passed as a quoted string. e.g.,
+``isAllowedToContainClauseKind("OMPC_default").``
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprargumentCountIsunsigned N
 Checks that a call 
expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -6163,6 +6221,19 @@ nestedNameSpecifier(specifiesType(
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirectivehasAnyClauseMatcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPClause.html;>OMPClause
 InnerMatcher
+Matches any clause in 
an OpenMP directive.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+
+``ompExecutableDirective(hasAnyClause(anything()))`` matches
+``omp parallel default(none)``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprhasAnyArgumentMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr 
InnerMatcher
 Matches any argument 
of a call expression or a constructor call
 expression, or an ObjC-message-send expression.

Modified: cfe/trunk/include/clang/AST/ASTTypeTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTTypeTraits.h?rev=356675=356674=356675=diff
==
--- cfe/trunk/include/clang/AST/ASTTypeTraits.h (original)
+++ 

r356674 - [ASTMatchers][OpenMP] Add base ompExecutableDirective() matcher.

2019-03-21 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Thu Mar 21 08:33:10 2019
New Revision: 356674

URL: http://llvm.org/viewvc/llvm-project?rev=356674=rev
Log:
[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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/AST/OMPStructuredBlockTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=356674=356673=356674=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Mar 21 08:33:10 2019
@@ -1375,6 +1375,20 @@ Example matches @try
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtompExecutableDirectiveMatcherhttps://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html;>OMPExecutableDirective...
+Matches any 
``#pragma omp`` executable directive.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp taskyield
+
+``ompExecutableDirective()`` matches ``omp parallel``,
+``omp parallel default(none)`` and ``omp taskyield``.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtopaqueValueExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html;>OpaqueValueExpr...
 Matches opaque 
value expressions. They are used as helpers
 to reference another expressions and can be met

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=356674=356673=356674=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Mar 21 08:33:10 2019
@@ -60,6 +60,7 @@
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
+#include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -6369,6 +6370,29 @@ AST_MATCHER(FunctionDecl, hasTrailingRet
   return false;
 }
 
+////
+// OpenMP handling.
+////
+
+/// Matches any ``#pragma omp`` executable directive.
+///
+/// Given
+///
+/// \code
+///   #pragma omp parallel
+///   #pragma omp parallel default(none)
+///   #pragma omp taskyield
+/// \endcode
+///
+/// ``ompExecutableDirective()`` matches ``omp parallel``,
+/// ``omp parallel default(none)`` and ``omp taskyield``.
+extern const internal::VariadicDynCastAllOfMatcher
+ompExecutableDirective;
+
+////
+// End OpenMP handling.
+////
+
 } // namespace ast_matchers
 } // namespace clang
 

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=356674=356673=356674=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Thu Mar 21 08:33:10 2019
@@ -845,5 +845,8 @@ AST_TYPELOC_TRAVERSE_MATCHER_DEF(
 AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
 PointerType, ReferenceType));
 
+const internal::VariadicDynCastAllOfMatcher
+ompExecutableDirective;
+
 } // end namespace ast_matchers
 } // end namespace clang

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=356674=356673=356674=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Thu Mar 21 08:33:10 2019
@@ -434,6 +434,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(objcThrowStmt);
   REGISTER_MATCHER(objcTryStmt);
   REGISTER_MATCHER(ofClass);
+  REGISTER_MATCHER(ompExecutableDirective);
   

[PATCH] D59528: [clang-tidy] Expand modular headers for PPCallbacks

2019-03-21 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thank you for the review! I hope I covered all the points.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59528/new/

https://reviews.llvm.org/D59528



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >