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

2018-11-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 175011.
Quuxplusone added a comment.

Change `1 <<` to `size_t(1) <<` in one last place. @EricWF ping.


Repository:
  rCXX libc++

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
@@ -211,6 +211,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);
+successful_allocations.emplace_back(bytes, align);
+return result;
+}
+void do_deallocate(void *p, size_t bytes, size_t align) override {
+

[PATCH] D54784: Use --push/pop-state with XRay link deps

2018-11-21 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D54784



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


[PATCH] D52160: [Driver] Support XRay on Fuchsia

2018-11-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347444: [Driver] Support XRay on Fuchsia (authored by 
phosek, committed by ).
Herald added a subscriber: mgorny.

Changed prior to commit:
  https://reviews.llvm.org/D52160?vs=165706&id=175009#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52160

Files:
  cmake/caches/Fuchsia-stage2.cmake
  lib/Driver/ToolChains/Fuchsia.cpp
  lib/Driver/XRayArgs.cpp
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray-basic.a
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray.a
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray-basic.a
  
test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray.a
  test/Driver/fuchsia.c


Index: lib/Driver/XRayArgs.cpp
===
--- lib/Driver/XRayArgs.cpp
+++ lib/Driver/XRayArgs.cpp
@@ -58,6 +58,15 @@
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
+} else if (Triple.getOS() == llvm::Triple::Fuchsia) {
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+  case llvm::Triple::aarch64:
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
 } else {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -109,7 +109,8 @@
   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
@@ -133,9 +134,12 @@
   }
 }
 
-if (NeedSanitizerDeps)
+if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 
+if (NeedsXRayDeps)
+  linkXRayRuntimeDeps(ToolChain, CmdArgs);
+
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
 if (Args.hasArg(options::OPT_pthread) ||
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -147,6 +147,7 @@
   llvm-size
   llvm-strip
   llvm-symbolizer
+  llvm-xray
   opt
   sancov
   CACHE STRING "")
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -149,6 +149,26 @@
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-SHARED: 
"[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}libclang_rt.scudo.so"
 
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fxray-instrument -fxray-modes=xray-basic \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-XRAY-X86
+// CHECK-XRAY-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-XRAY-X86: "-fxray-instrument"
+// CHECK-XRAY-X86: 
"[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}libclang_rt.xray.a"
+// CHECK-XRAY-X86: 
"[[RESOURCE_DIR]]{{/|}}x86_64-fuchsia{{/|}}lib{{/|}}libclang_rt.xray-basic.a"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fxray-instrument -fxray-modes=xray-basic \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-XRAY-AARCH64
+// CHECK-XRAY-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-XRAY-AARCH64: "-fxray-instrument"
+// CHECK-XRAY-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}aarch64-fuchsia{{/|}}lib{{/|}}libclang_rt.xray.a"
+// CHECK-XRAY-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}aarch64-fuchsia{{/|}}lib{{/|}}libclang_rt.xray-basic.a"
+
 // RUN: %clang %s -### --target=aarch64-fuchsia \
 // RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \
 // RUN: -fuse-ld=lld \


Index: lib/Driver/XRayArgs.cpp
===
--- lib/Driver/XRayArgs.cpp
+++ lib/Driver/XRayArgs.cpp
@@ -58,6 +58,15 @@
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
+} else if (Triple.getOS() == llvm::Triple::Fuchsia) {
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+  case llvm::Triple::aar

r347444 - [Driver] Support XRay on Fuchsia

2018-11-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Nov 21 18:36:47 2018
New Revision: 347444

URL: http://llvm.org/viewvc/llvm-project?rev=347444&view=rev
Log:
[Driver] Support XRay on Fuchsia

This enables support for XRay in Fuchsia Clang driver.

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

Added:

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray-basic.a

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray.a

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray-basic.a

cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray.a
Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=347444&r1=347443&r2=347444&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Wed Nov 21 18:36:47 2018
@@ -147,6 +147,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-size
   llvm-strip
   llvm-symbolizer
+  llvm-xray
   opt
   sancov
   CACHE STRING "")

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=347444&r1=347443&r2=347444&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Wed Nov 21 18:36:47 2018
@@ -109,7 +109,8 @@ void fuchsia::Linker::ConstructJob(Compi
   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
@@ -133,9 +134,12 @@ void fuchsia::Linker::ConstructJob(Compi
   }
 }
 
-if (NeedSanitizerDeps)
+if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 
+if (NeedsXRayDeps)
+  linkXRayRuntimeDeps(ToolChain, CmdArgs);
+
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
 if (Args.hasArg(options::OPT_pthread) ||

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=347444&r1=347443&r2=347444&view=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Wed Nov 21 18:36:47 2018
@@ -58,6 +58,15 @@ XRayArgs::XRayArgs(const ToolChain &TC,
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
   }
+} else if (Triple.getOS() == llvm::Triple::Fuchsia) {
+  switch (Triple.getArch()) {
+  case llvm::Triple::x86_64:
+  case llvm::Triple::aarch64:
+break;
+  default:
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
 } else {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray-basic.a
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray-basic.a?rev=347444&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray.a
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray.a?rev=347444&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray-basic.a
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray-basic.a?rev=347444&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray.a
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_per_

[PATCH] D53696: [Haiku] Support __float128 for Haiku x86 and x86_64

2018-11-21 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 added a comment.

Indeed. I agree the _GLIBCXX_USE_FLOAT128 is misplaced there.   That comes from 
config.h in libstdc++.  That's working around an issue in Haiku's build 
(libstdc++ is built by gcc, but then we try and use it with clang later)
I can remove that.

Is the __FLOAT128__ desireable?


Repository:
  rC Clang

https://reviews.llvm.org/D53696



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


[PATCH] D54823: [analyzer][MallocChecker][NFC] Document and reorganize some functions

2018-11-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

I also have some very neat ideas how the split up should go, but I'd like to 
mature the idea in my head for just a bit longer.




Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:24-27
+//   It also has a boolean "Optimistic" checker option, which if set to 
true
+//   will cause the checker to model user defined memory management related
+//   functions annotated via the attribute ownership_takes, ownership_holds
+//   and ownership_returns.

Source: https://reviews.llvm.org/D7905



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:242-245
+/// This is important because realloc may fail, and that needs special 
modeling.
+/// Whether reallocation failed or not will not be known until later, so we'll
+/// store whether upon failure 'fromPtr' will be freed, or needs to be freed
+/// later, etc.

Source: http://lists.llvm.org/pipermail/cfe-dev/2018-November/060216.html



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:435-443
+  /// User-defined function may have the ownership_returns attribute, which
+  /// annotates that the function returns with an object that was allocated on
+  /// the heap, and passes the ownertship to the callee.
+  ///
+  ///   void __attribute((ownership_returns(malloc, 1))) *my_malloc(size_t);
+  ///
+  /// It has two parameters:

Source:
http://lists.llvm.org/pipermail/cfe-dev/2010-June/009600.html
https://github.com/llvm-mirror/clang/commit/dd0e490c24aeade2c59ca4cae171199f6af9f02e



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1359-1363
+  /// Non-trivial constructors have a chance to escape 'this', but marking all
+  /// invocations of trivial constructors as escaped would cause too great of
+  /// reduction of true positives, so let's just do that for constructor that
+  /// have an argument of a pointer-to-record type.
+  if (!PM.isConsumedExpr(NE) && hasNonTrivialConstructorCall(NE))

Source:
https://bugs.llvm.org/show_bug.cgi?id=19102
https://reviews.llvm.org/D4025


Repository:
  rC Clang

https://reviews.llvm.org/D54823



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


[PATCH] D54823: [analyzer][MallocChecker][NFC] Document and reorganize some functions

2018-11-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, rnkovacs.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, whisperity.

I'm in the process of splitting this checker into multiple other ones, and 
while I was there, I provided documentation to most functions, and made some 
static, and in some cases moved them out of class.

This patch merely reorganizes some things, and features no functional change.

In detail:

- Provided documentation, or moved existing documentation in more obvious 
places.
- Added dividers. (the `//===--===//` thing).
- Moved `getAllocationFamily`, `printAllocDeallocName`, 
`printExpectedAllocName` and `printExpectedDeallocName` in the global namespace 
on top of the file where `AllocationFamily` is declared, as they are very 
strongly related.
- Realloc modeling was very poor in terms of variable and structure naming, as 
well as documentation, so I renamed some of them and added much needed docs.
- Moved function `IdentifierInfo`s to a separate struct, and moved 
`isMemFunction`, `isCMemFunction` adn `isStandardNewDelete` inside it. This 
makes the patch affect quite a lot of lines, should I extract it to a separate 
one?
- Moved `MallocBugVisitor` out of `MallocChecker`.
- Preferred switches to long else-if branches in some places.
- Neatly organized some `RUN:` lines.


Repository:
  rC Clang

https://reviews.llvm.org/D54823

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/malloc.c

Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-store=region -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.deadcode.UnreachableCode \
+// RUN:   -analyzer-checker=alpha.core.CastSize \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=debug.ExprInspection
 
 #include "Inputs/system-header-simulator.h"
 
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -7,8 +7,41 @@
 //
 //===--===//
 //
-// This file defines malloc/free checker, which checks for potential memory
-// leaks, double free, and use-after-free problems.
+// This file defines a variety of memory management related checkers, such as
+// leak, double free, and use-after-free.
+//
+// The following checkers are defined here:
+//
+//   * MallocChecker
+//   Despite it's name, it models all sorts of memory allocations and
+//   de- or reallocation, including but not limited to malloc, free,
+//   relloc, new, delete. It also reports on a variety of memory misuse
+//   errors.
+//   Many other checkers interact very closely with this checker, in fact,
+//   most are merely options to this one. Other checkers may register
+//   MallocChecker, but do not enable MallocChecker's reports (more details
+//   to follow around it's field, ChecksEnabled).
+//   It also has a boolean "Optimistic" checker option, which if set to true
+//   will cause the checker to model user defined memory management related
+//   functions annotated via the attribute ownership_takes, ownership_holds
+//   and ownership_returns.
+//
+//   * NewDeleteChecker
+//   Enables the modeling of new, new[], delete, delete[] in MallocChecker,
+//   and checks for related double-free and use-after-free errors.
+//
+//   * NewDeleteLeaksChecker
+//   Checks for leaks related to new, new[], delete, delete[].
+//   Depends on NewDeleteChecker.
+//
+//   * MismatchedDeallocatorChecker
+//   Enables checking whether memory is deallocated with the correspending
+//   allocation function in MallocChecker, such as malloc() allocated
+//   regions are only freed by free(), new by delete, new[] by delete[].
+//
+//  InnerPointerChecker interacts very closely with MallocChecker, but unlike
+//  the above checkers, it has it's own file, hence the many InnerPointerChecker
+//  related headers and non-static functions.
 //
 //===--===//
 
@@ -37,6 +70,10 @@
 using namespace clang;
 using namespace ento;
 
+//===--===//
+// The types of allocation we're modeling.
+//===--===//
+
 namespace {
 
 // Used to check correspondence between allocators and dealloc

[PATCH] D53696: [Haiku] Support __float128 for Haiku x86 and x86_64

2018-11-21 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Linux, Solaris and OpenBSD also define it where appropriate, it depends on the 
target. This is why it's much easier to review when full context (diff with `-U 
9`) is provided, and means that it has a much lower change of `patch` doing 
something unexpected.


Repository:
  rC Clang

https://reviews.llvm.org/D53696



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


[PATCH] D53696: [Haiku] Support __float128 for Haiku x86 and x86_64

2018-11-21 Thread Jonathan Schleifer via Phabricator via cfe-commits
js requested changes to this revision.
js added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Basic/Targets/OSTargets.h:262
+  Builder.defineMacro("__FLOAT128__");
+  Builder.defineMacro("_GLIBCXX_USE_FLOAT128");
+}

js wrote:
> This seems weird. Shouldn't by stdlibc++ and not by the compiler?
+be defined


Repository:
  rC Clang

https://reviews.llvm.org/D53696



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


[PATCH] D53696: [Haiku] Support __float128 for Haiku x86 and x86_64

2018-11-21 Thread Jonathan Schleifer via Phabricator via cfe-commits
js added inline comments.



Comment at: lib/Basic/Targets/OSTargets.h:262
+  Builder.defineMacro("__FLOAT128__");
+  Builder.defineMacro("_GLIBCXX_USE_FLOAT128");
+}

This seems weird. Shouldn't by stdlibc++ and not by the compiler?


Repository:
  rC Clang

https://reviews.llvm.org/D53696



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


[PATCH] D53696: [Haiku] Support __float128 for Haiku x86 and x86_64

2018-11-21 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a reviewer: kristina.
kristina added a comment.

Do you mind resubmitting those with context? Also I would suggest asking Tom 
Stellard as he's in charge of handling cherrypicking patches to go into 
releases once the major rolls over and I think we're pretty close (?) to 7.0.1.


Repository:
  rC Clang

https://reviews.llvm.org/D53696



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


[PATCH] D53696: [Haiku] Support __float128 for Haiku x86 and x86_64

2018-11-21 Thread Alexander von Gluck IV via Phabricator via cfe-commits
kallisti5 added a comment.

Thanks smeenai!   Any chance of this one getting into 7.x.x?   It's technically 
a bug fix... I think it's the last major hurdle to Haiku compiling (easily) 
with clang vs gcc.


Repository:
  rC Clang

https://reviews.llvm.org/D53696



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


Re: r338941 - [constexpr] Support for constant evaluation of __builtin_memcpy and

2018-11-21 Thread Shoaib Meenai via cfe-commits
If it's not too late, could we have this as part of 7.0.1? (You'll also
need to cherry-pick the initial reversion in r338602.) 7.0 hits assertion
failures for pretty basic memcpy cases on windows-msvc targets, and this
patch fixes that.

% cat /tmp/reduced.c
void *memcpy(void *, const void *, __SIZE_TYPE__);
void f(int i) {
  struct { int i } s;
  memcpy((char *)&s.i, &i, sizeof(i));
}

% clang -cc1 -triple x86_64-windows-msvc -emit-llvm -fms-compatibility -o
/dev/null /tmp/reduced.c
llvm::SmallVectorTemplateCommon::const_reference
llvm::SmallVectorTemplateCommon::back() const [T = clang::APValue::LValuePathEntry]: Assertion
`!empty()' failed.

On Fri, Aug 3, 2018 at 5:57 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri Aug  3 17:57:17 2018
> New Revision: 338941
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338941&view=rev
> Log:
> [constexpr] Support for constant evaluation of __builtin_memcpy and
> __builtin_memmove (in non-type-punning cases).
>
> This is intended to permit libc++ to make std::copy etc constexpr
> without sacrificing the optimization that uses memcpy on
> trivially-copyable types.
>
> __builtin_strcpy and __builtin_wcscpy are not handled by this change.
> They'd be straightforward to add, but we haven't encountered a need for
> them just yet.
>
> This reinstates r338455, reverted in r338602, with a fix to avoid trying
> to constant-evaluate a memcpy call if either pointer operand has an
> invalid designator.
>
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/CodeGen/builtin-memfns.c
> cfe/trunk/test/SemaCXX/constexpr-string.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=338941&r1=338940&r2=338941&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Fri Aug  3 17:57:17 2018
> @@ -471,6 +471,8 @@ BUILTIN(__builtin_wcslen, "zwC*", "nF")
>  BUILTIN(__builtin_wcsncmp, "iwC*wC*z", "nF")
>  BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF")
>  BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF")
> +BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF")
> +BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF")
>  BUILTIN(__builtin_return_address, "v*IUi", "n")
>  BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
>  BUILTIN(__builtin_frame_address, "v*IUi", "n")
> @@ -908,6 +910,8 @@ LIBBUILTIN(wcslen,  "zwC*", "f", "wc
>  LIBBUILTIN(wcsncmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES)
>  LIBBUILTIN(wmemchr, "w*wC*wz",  "f", "wchar.h", ALL_LANGUAGES)
>  LIBBUILTIN(wmemcmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES)
> +LIBBUILTIN(wmemcpy, "w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES)
> +LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES)
>
>  // C99
>  // In some systems setjmp is a macro that expands to _setjmp. We undefine
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=338941&r1=338940&r2=338941&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri Aug  3
> 17:57:17 2018
> @@ -163,6 +163,20 @@ def note_constexpr_unsupported_unsized_a
>  def note_constexpr_unsized_array_indexed : Note<
>"indexing of array without known bound is not allowed "
>"in a constant expression">;
> +def note_constexpr_memcpy_type_pun : Note<
> +  "cannot constant evaluate '%select{memcpy|memmove}0' from object of "
> +  "type %1 to object of type %2">;
> +def note_constexpr_memcpy_nontrivial : Note<
> +  "cannot constant evaluate '%select{memcpy|memmove}0' between objects of
> "
> +  "non-trivially-copyable type %1">;
> +def note_constexpr_memcpy_overlap : Note<
> +  "'%select{memcpy|wmemcpy}0' between overlapping memory regions">;
> +def note_constexpr_memcpy_unsupported : Note<
> +  "'%select{%select{memcpy|wmemcpy}1|%select{memmove|wmemmove}1}0' "
> +  "not supported: %select{"
> +  "size to copy (%4) is not a multiple of size of element type %3 (%5)|"
> +  "source is not a contiguous array of at least %4 elements of type %3|"
> +  "destination is not a contiguous array of at least %4 elements of type
> %3}2">;
>
>  def warn_integer_constant_overflow : Warning<
>"overflow in expression; result is %0 with type %1">,
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=338941&r1=338940&r2=338941&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (

[PATCH] D54817: [clangd] Put direct headers into srcs section.

2018-11-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.

Currently, there's no way of knowing about header files
using compilation database, since it doesn't contain header files as entries.

Using this information, restoring from cache using compile commands becomes
possible instead of doing directory traversal. Also, we can issue indexing
actions for out-of-date headers even if source files depending on them haven't
changed.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54817

Files:
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/Serialization.cpp
  clangd/index/Serialization.h
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/SerializationTests.cpp

Index: unittests/clangd/SerializationTests.cpp
===
--- unittests/clangd/SerializationTests.cpp
+++ unittests/clangd/SerializationTests.cpp
@@ -173,7 +173,7 @@
   UnorderedElementsAreArray(YAMLFromRefs(*In->Refs)));
 }
 
-TEST(SerializationTest, HashTest) {
+TEST(SerializationTest, SrcsTest) {
   auto In = readIndexFile(YAML);
   EXPECT_TRUE(bool(In)) << In.takeError();
 
@@ -185,19 +185,39 @@
   IndexFileOut Out(*In);
   Out.Format = IndexFileFormat::RIFF;
   Out.Digest = &Digest;
-  std::string Serialized = to_string(Out);
-
-  auto In2 = readIndexFile(Serialized);
-  ASSERT_TRUE(bool(In2)) << In.takeError();
-  ASSERT_EQ(In2->Digest, Digest);
-  ASSERT_TRUE(In2->Symbols);
-  ASSERT_TRUE(In2->Refs);
-
-  // Assert the YAML serializations match, for nice comparisons and diffs.
-  EXPECT_THAT(YAMLFromSymbols(*In2->Symbols),
-  UnorderedElementsAreArray(YAMLFromSymbols(*In->Symbols)));
-  EXPECT_THAT(YAMLFromRefs(*In2->Refs),
-  UnorderedElementsAreArray(YAMLFromRefs(*In->Refs)));
+  {
+std::string Serialized = to_string(Out);
+
+auto In = readIndexFile(Serialized);
+ASSERT_TRUE(bool(In)) << In.takeError();
+ASSERT_EQ(*In->Digest, Digest);
+ASSERT_TRUE(In->Symbols);
+ASSERT_TRUE(In->Refs);
+// Assert the YAML serializations match, for nice comparisons and diffs.
+EXPECT_THAT(YAMLFromSymbols(*In->Symbols),
+UnorderedElementsAreArray(YAMLFromSymbols(*In->Symbols)));
+EXPECT_THAT(YAMLFromRefs(*In->Refs),
+UnorderedElementsAreArray(YAMLFromRefs(*In->Refs)));
+  }
+
+  std::vector DirectIncludes = {"inc1", "inc2"};
+  Out.DirectIncludes = &DirectIncludes;
+  {
+std::string Serialized = to_string(Out);
+
+auto In = readIndexFile(Serialized);
+ASSERT_TRUE(bool(In)) << In.takeError();
+ASSERT_EQ(*In->Digest, Digest);
+ASSERT_TRUE(In->Symbols);
+ASSERT_TRUE(In->Refs);
+EXPECT_THAT(*In->DirectIncludes, UnorderedElementsAreArray(DirectIncludes));
+
+// Assert the YAML serializations match, for nice comparisons and diffs.
+EXPECT_THAT(YAMLFromSymbols(*In->Symbols),
+UnorderedElementsAreArray(YAMLFromSymbols(*In->Symbols)));
+EXPECT_THAT(YAMLFromRefs(*In->Refs),
+UnorderedElementsAreArray(YAMLFromRefs(*In->Refs)));
+  }
 }
 
 } // namespace
Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -161,5 +161,37 @@
   EXPECT_EQ(*ShardSource->Digest, Digest);
 }
 
+TEST(BackgroundIndexTest, DirectIncludesTest) {
+  MockFSProvider FS;
+  FS.Files[testPath("root/B.h")] = "";
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  #include "B.h"
+  void common();
+  void f_b();
+  class A_CC {};
+  )cpp";
+  std::string A_CC = "#include \"A.h\"\nvoid g() { (void)common; }";
+  FS.Files[testPath("root/A.cc")] = A_CC;
+
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  {
+BackgroundIndex Idx(Context::empty(), "", FS, /*URISchemes=*/{"unittest"},
+[&](llvm::StringRef) { return &MSS; });
+Idx.enqueue(testPath("root"), Cmd);
+Idx.blockUntilIdleForTest();
+  }
+
+  auto ShardSource = MSS.loadShard(testPath("root/A.cc"));
+  EXPECT_THAT(*ShardSource->DirectIncludes,
+  UnorderedElementsAre("unittest:///root/A.h"));
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/index/Serialization.h
===
--- clangd/index/Serialization.h
+++ clangd/index/Serialization.h
@@ -42,6 +42,8 @@
   llvm::Optional Refs;
   // Digest of the source file that generated the contents.
   llvm::Optional Digest;
+  // URIs of headers directly included in the source file.
+  llvm::Optional> DirectIncludes;
 };
 // Par

[PATCH] D54816: [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-11-21 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
mgrang added reviewers: asb, apazos.
Herald added subscribers: jocewei, PkmX, rkruppe, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, 
niosHD, sabuasal, simoncook, johnrusso, rbar.

Some of these tests break if the RISCV backend has not been built.


Repository:
  rC Clang

https://reviews.llvm.org/D54816

Files:
  Driver/riscv-abi.c
  Driver/riscv-arch.c
  Driver/riscv-features.c
  Driver/riscv-gnutools.c
  Driver/riscv32-toolchain.c
  Driver/riscv64-toolchain.c


Index: Driver/riscv64-toolchain.c
===
--- Driver/riscv64-toolchain.c
+++ Driver/riscv64-toolchain.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck 
-check-prefix=CC1 %s
Index: Driver/riscv32-toolchain.c
===
--- Driver/riscv32-toolchain.c
+++ Driver/riscv32-toolchain.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s
Index: Driver/riscv-gnutools.c
===
--- Driver/riscv-gnutools.c
+++ Driver/riscv-gnutools.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // Check gnutools are invoked with propagated values for -mabi and -march.
 
 // RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \
Index: Driver/riscv-features.c
===
--- Driver/riscv-features.c
+++ Driver/riscv-features.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 
Index: Driver/riscv-arch.c
===
--- Driver/riscv-arch.c
+++ Driver/riscv-arch.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
Index: Driver/riscv-abi.c
===
--- Driver/riscv-abi.c
+++ Driver/riscv-abi.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \


Index: Driver/riscv64-toolchain.c
===
--- Driver/riscv64-toolchain.c
+++ Driver/riscv64-toolchain.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
Index: Driver/riscv32-toolchain.c
===
--- Driver/riscv32-toolchain.c
+++ Driver/riscv32-toolchain.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
Index: Driver/riscv-gnutools.c
===
--- Driver/riscv-gnutools.c
+++ Driver/riscv-gnutools.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // Check gnutools are invoked with propagated values for -mabi and -march.
 
 // RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \
Index: Driver/riscv-features.c
===
--- Driver/riscv-features.c
+++ Driver/riscv-features.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
 
Index: Driver/riscv-arch.c
===
--- Driver/riscv-arch.c
+++ Driver/riscv-arch.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
Index: Driver/riscv-abi.c
===
--- Driver/riscv-abi.c
+++ Driver/riscv-abi.c
@@ -1,3 +1,5 @@
+// REQUIRES: riscv-registered-target
+
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o 

[PATCH] D54436: [analyzer][NFC] Move CheckerRegistry from the Core directory to Frontend

2018-11-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.
Herald added subscribers: gamesh411, baloghadamsoftware.

Polite ping :)


Repository:
  rC Clang

https://reviews.llvm.org/D54436



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


[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I have already reverted the change as r347430 after seeing the failure on 
sanitizer bots.


Repository:
  rC Clang

https://reviews.llvm.org/D54805



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


[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In https://reviews.llvm.org/D54805#1305749, @pcc wrote:

> Unfortunately it looks like the Android NDK uses some ancient version of gold 
> that doesn't support `--push-state`, so we probably can't rely on being able 
> to use it.
>  
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/17287/steps/run%20lit%20tests%20%5Bi686%2Ffugu-userdebug%2FN2G48C%5D/logs/stdio
>  As an alternative solution, could we add these flags at the start of the 
> linker command line? That way, we're guaranteed that the linker will be in 
> the `--no-as-needed` state.


`gold --push-state` seems a new thing. It is available since Dec 2016 (version 
1.14)

I'm also interested in the history of

  // Force linking against the system libraries sanitizers depends on
  // (see PR15823 why this is necessary).
  CmdArgs.push_back("--no-as-needed");

PR15823 leans slightly to the user-error side to me. Shouldn't the user ensure 
the use of `-Wl,--as-needed` is eventually closed so that system libraries 
start with the `-Wl--no-as-needed` state?


Repository:
  rC Clang

https://reviews.llvm.org/D54805



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


[PATCH] D53207: Fix bug 26547 - alignof should return ABI alignment, not preferred alignment

2018-11-21 Thread Nicole Mazzuca via Phabricator via cfe-commits
ubsan added a comment.

The ABI breakage was already there, in the difference between GCC and Clang

- if one compiles against libc++ with gcc, it is not compatible with things

that are compiled with clang. I frankly think that being ABI compatible
with gcc (and correct according to the standard) is far more important than
being ABI compatible with previous versions of clang - if people need the
ABI compatibility, they can and should use `-fclang-abi-compat`


Repository:
  rL LLVM

https://reviews.llvm.org/D53207



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


[PATCH] D53207: Fix bug 26547 - alignof should return ABI alignment, not preferred alignment

2018-11-21 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added subscribers: dexonsmith, ldionne.
ldionne added a comment.

I'm surprised that nobody discussed the potential for ABI breakage of this 
change, which changes the result of the `alignof` operator. I'm trying to 
evaluate what to do in libc++ as a result of this change (now 
`std::alignment_of` does not match `alignof`) for PR39713 
, and I'm wondering whether this 
issue was considered here. I'm not saying this is a bad change, by the way, I'd 
simply like to understand what the implications are and find good arguments to 
convince me to follow the lead in libc++. Pinging @dexonsmith for awareness.


Repository:
  rL LLVM

https://reviews.llvm.org/D53207



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


r347430 - Revert "[Driver] Use --push/pop-state with Sanitizer link deps"

2018-11-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Nov 21 13:59:39 2018
New Revision: 347430

URL: http://llvm.org/viewvc/llvm-project?rev=347430&view=rev
Log:
Revert "[Driver] Use --push/pop-state with Sanitizer link deps"

This reverts commit r347413: older versions of ld.gold that are used
by Android don't support --push/pop-state which broke sanitizer bots.

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=347430&r1=347429&r2=347430&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Nov 21 13:59:39 2018
@@ -598,7 +598,6 @@ void tools::linkSanitizerRuntimeDeps(con
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
-  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -618,7 +617,6 @@ void tools::linkSanitizerRuntimeDeps(con
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
-  CmdArgs.push_back("--pop-state");
 }
 
 static void

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=347430&r1=347429&r2=347430&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Wed Nov 21 13:59:39 2018
@@ -220,20 +220,6 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
-// RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
-//
-// CHECK-ASAN-LINUX-STATIC: "--push-state"
-// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
-// CHECK-ASAN-LINUX-STATIC: "-lpthread"
-// CHECK-ASAN-LINUX-STATIC: "-lrt"
-// CHECK-ASAN-LINUX-STATIC: "-lm"
-// CHECK-ASAN-LINUX-STATIC: "-ldl"
-// CHECK-ASAN-LINUX-STATIC: "--pop-state"
-
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ 
\
 // RUN: -fsanitize=thread \


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


[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Unfortunately it looks like the Android NDK uses some ancient version of gold 
that doesn't support `--push-state`, so we probably can't rely on being able to 
use it.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/17287/steps/run%20lit%20tests%20%5Bi686%2Ffugu-userdebug%2FN2G48C%5D/logs/stdio
As an alternative solution, could we add these flags at the start of the linker 
command line? That way, we're guaranteed that the linker will be in the 
`--no-as-needed` state.


Repository:
  rC Clang

https://reviews.llvm.org/D54805



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


[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2018-11-21 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In https://reviews.llvm.org/D53076#1305209, @Szelethus wrote:

> In the meanwhile we managed to figure out where the problem lays, so if 
> you're interested, I'm going to document it here.
>
> The patch attempts to solve this by inspecting the actual condition, and 
> tries to find out whether the symbols inside that condition has changed in 
> between the states, but this is overkill solution, as comparing the two 
> `ConstraintManager` objects would achieve the same thing.


I tried to investigate what is happening after we entered into a condition, 
which is working well with 'Knowing...' pieces, but with too much overhead. 
Because this patch is all about write out more information, rather than 
removing the GDM-checking I will move forward with 'Knowing...' pieces. The 
current questions are real for that project, just let me simplify the code and 
create that feature.


https://reviews.llvm.org/D53076



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


r347425 - [OPENMP][NVPTX]Emit default locations as constant with undefined mode.

2018-11-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 21 13:04:34 2018
New Revision: 347425

URL: http://llvm.org/viewvc/llvm-project?rev=347425&view=rev
Log:
[OPENMP][NVPTX]Emit default locations as constant with undefined mode.

For the NVPTX target default locations should be emitted as constants +
additional info must be emitted in the reserved_2 field of the ident_t
structure. The 1st bit controls the execution mode and the 2nd bit
controls use of the lightweight runtime. The combination of the bits for
Non-SPMD mode + lightweight runtime represents special undefined mode,
used outside of the target regions for orphaned directives or functions.
Should allow and additional optimization inside of the target regions.

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/test/OpenMP/nvptx_SPMD_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=347425&r1=347424&r2=347425&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Nov 21 13:04:34 2018
@@ -1467,7 +1467,9 @@ createConstantGlobalStructAndAddToParent
 
 Address CGOpenMPRuntime::getOrCreateDefaultLocation(unsigned Flags) {
   CharUnits Align = CGM.getContext().getTypeAlignInChars(IdentQTy);
-  llvm::Value *Entry = OpenMPDefaultLocMap.lookup(Flags);
+  unsigned Reserved2Flags = getDefaultLocationReserved2Flags();
+  FlagsTy FlagsKey(Flags, Reserved2Flags);
+  llvm::Value *Entry = OpenMPDefaultLocMap.lookup(FlagsKey);
   if (!Entry) {
 if (!DefaultOpenMPPSource) {
   // Initialize default location for psource field of ident_t structure of
@@ -1480,18 +1482,18 @@ Address CGOpenMPRuntime::getOrCreateDefa
   llvm::ConstantExpr::getBitCast(DefaultOpenMPPSource, CGM.Int8PtrTy);
 }
 
-llvm::Constant *Data[] = {llvm::ConstantInt::getNullValue(CGM.Int32Ty),
-  llvm::ConstantInt::get(CGM.Int32Ty, Flags),
-  llvm::ConstantInt::getNullValue(CGM.Int32Ty),
-  llvm::ConstantInt::getNullValue(CGM.Int32Ty),
-  DefaultOpenMPPSource};
+llvm::Constant *Data[] = {
+llvm::ConstantInt::getNullValue(CGM.Int32Ty),
+llvm::ConstantInt::get(CGM.Int32Ty, Flags),
+llvm::ConstantInt::get(CGM.Int32Ty, Reserved2Flags),
+llvm::ConstantInt::getNullValue(CGM.Int32Ty), DefaultOpenMPPSource};
 llvm::GlobalValue *DefaultOpenMPLocation =
-createGlobalStruct(CGM, IdentQTy, /*IsConstant=*/false, Data, "",
+createGlobalStruct(CGM, IdentQTy, isDefaultLocationConstant(), Data, 
"",
llvm::GlobalValue::PrivateLinkage);
 DefaultOpenMPLocation->setUnnamedAddr(
 llvm::GlobalValue::UnnamedAddr::Global);
 
-OpenMPDefaultLocMap[Flags] = Entry = DefaultOpenMPLocation;
+OpenMPDefaultLocMap[FlagsKey] = Entry = DefaultOpenMPLocation;
   }
   return Address(Entry, Align);
 }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=347425&r1=347424&r2=347425&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed Nov 21 13:04:34 2018
@@ -282,12 +282,21 @@ protected:
   bool AtCurrentPoint = false);
   void clearLocThreadIdInsertPt(CodeGenFunction &CGF);
 
+  /// Check if the default location must be constant.
+  /// Default is false to support OMPT/OMPD.
+  virtual bool isDefaultLocationConstant() const { return false; }
+
+  /// Returns additional flags that can be stored in reserved_2 field of the
+  /// default location.
+  virtual unsigned getDefaultLocationReserved2Flags() const { return 0; }
+
 private:
   /// Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource = nullptr;
+  using FlagsTy = std::pair;
   /// Map of flags and corresponding default locations.
-  typedef llvm::DenseMap OpenMPDefaultLocMapTy;
+  using OpenMPDefaultLocMapTy = llvm::DenseMap;
   OpenMPDefaultLocMapTy OpenMPDefaultLocMap;
   Address getOrCreateDefaultLocation(unsigned Flags);
 

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=347425&r1=347424&r2=347425&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.c

[clang-tools-extra] r347419 - Update call to EvaluateAsInt() to the new syntax.

2018-11-21 Thread Bill Wendling via cfe-commits
Author: void
Date: Wed Nov 21 12:45:00 2018
New Revision: 347419

URL: http://llvm.org/viewvc/llvm-project?rev=347419&view=rev
Log:
Update call to EvaluateAsInt() to the new syntax.

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp

clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp?rev=347419&r1=347418&r2=347419&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp 
Wed Nov 21 12:45:00 2018
@@ -65,16 +65,16 @@ static unsigned getMaxCalculationWidth(c
 if (Bop->getOpcode() == BO_Add)
   return std::max(LHSWidth, RHSWidth) + 1;
 if (Bop->getOpcode() == BO_Rem) {
-  llvm::APSInt Val;
-  if (Bop->getRHS()->EvaluateAsInt(Val, Context))
-return Val.getActiveBits();
+  Expr::EvalResult Result;
+  if (Bop->getRHS()->EvaluateAsInt(Result, Context))
+return Result.Val.getInt().getActiveBits();
 } else if (Bop->getOpcode() == BO_Shl) {
-  llvm::APSInt Bits;
-  if (Bop->getRHS()->EvaluateAsInt(Bits, Context)) {
+  Expr::EvalResult Result;
+  if (Bop->getRHS()->EvaluateAsInt(Result, Context)) {
 // We don't handle negative values and large values well. It is assumed
 // that compiler warnings are written for such values so the user will
 // fix that.
-return LHSWidth + Bits.getExtValue();
+return LHSWidth + Result.Val.getInt().getExtValue();
   }
 
   // Unknown bitcount, assume there is truncation.

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp?rev=347419&r1=347418&r2=347419&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp 
Wed Nov 21 12:45:00 2018
@@ -76,10 +76,13 @@ void SuspiciousMemsetUsageCheck::check(c
 // Case 2: fill_char of memset() is larger in size than an unsigned char
 // so it gets truncated during conversion.
 
-llvm::APSInt NumValue;
 const auto UCharMax = (1 << Result.Context->getCharWidth()) - 1;
-if (!NumFill->EvaluateAsInt(NumValue, *Result.Context) ||
-(NumValue >= 0 && NumValue <= UCharMax))
+Expr::EvalResult EVResult;
+if (!NumFill->EvaluateAsInt(EVResult, *Result.Context))
+  return;
+
+llvm::APSInt NumValue = EVResult.Val.getInt();
+if (NumValue >= 0 && NumValue <= UCharMax)
   return;
 
 diag(NumFill->getBeginLoc(), "memset fill value is out of unsigned "
@@ -94,18 +97,22 @@ void SuspiciousMemsetUsageCheck::check(c
 const Expr *ByteCount = Call->getArg(2);
 
 // Return if `byte_count` is not zero at compile time.
-llvm::APSInt Value1, Value2;
+Expr::EvalResult Value2;
 if (ByteCount->isValueDependent() ||
-!ByteCount->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0)
+!ByteCount->EvaluateAsInt(Value2, *Result.Context) ||
+Value2.Val.getInt() != 0)
   return;
 
 // Return if `fill_char` is known to be zero or negative at compile
 // time. In these cases, swapping the args would be a nop, or
 // introduce a definite bug. The code is likely correct.
+Expr::EvalResult EVResult;
 if (!FillChar->isValueDependent() &&
-FillChar->EvaluateAsInt(Value1, *Result.Context) &&
-(Value1 == 0 || Value1.isNegative()))
-  return;
+FillChar->EvaluateAsInt(EVResult, *Result.Context)) {
+  llvm::APSInt Value1 = EVResult.Val.getInt();
+  if (Value1 == 0 || Value1.isNegative())
+return;
+}
 
 // `byte_count` is known to be zero at compile time, and `fill_char` is
 // either not known or known to be a positive integer. Emit a warning

Modified: 
clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp?rev=347419&r1=347418&r2=347419&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp 
Wed Nov 21 12:45:00 2018
@@ -101,8 +101,8 @@ void ProperlySeededRandomGenerator

r347417 - Re-Reinstate 347294 with a fix for the failures.

2018-11-21 Thread Bill Wendling via cfe-commits
Author: void
Date: Wed Nov 21 12:44:18 2018
New Revision: 347417

URL: http://llvm.org/viewvc/llvm-project?rev=347417&view=rev
Log:
Re-Reinstate 347294 with a fix for the failures.

Don't try to emit a scalar expression for a non-scalar argument to
__builtin_constant_p().

Third time's a charm!

Added:
cfe/trunk/test/CodeGenCXX/builtin-constant-p.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/Analysis/builtin-functions.cpp
cfe/trunk/test/Sema/builtins.c
cfe/trunk/test/SemaCXX/compound-literal.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=347417&r1=347416&r2=347417&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Nov 21 12:44:18 2018
@@ -600,7 +600,7 @@ public:
 
   /// EvaluateAsInt - Return true if this is a constant which we can fold and
   /// convert to an integer, using any crazy technique that we want to.
-  bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
+  bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx,
  SideEffectsKind AllowSideEffects = SE_NoSideEffects) 
const;
 
   /// EvaluateAsFloat - Return true if this is a constant which we can fold and
@@ -901,10 +901,15 @@ public:
 
 /// ConstantExpr - An expression that occurs in a constant context.
 class ConstantExpr : public FullExpr {
-public:
   ConstantExpr(Expr *subexpr)
 : FullExpr(ConstantExprClass, subexpr) {}
 
+public:
+  static ConstantExpr *Create(const ASTContext &Context, Expr *E) {
+assert(!isa(E));
+return new (Context) ConstantExpr(E);
+  }
+
   /// Build an empty constant expression wrapper.
   explicit ConstantExpr(EmptyShell Empty)
 : FullExpr(ConstantExprClass, Empty) {}
@@ -3087,8 +3092,8 @@ inline Expr *Expr::IgnoreImpCasts() {
   while (true)
 if (ImplicitCastExpr *ice = dyn_cast(e))
   e = ice->getSubExpr();
-else if (ConstantExpr *ce = dyn_cast(e))
-  e = ce->getSubExpr();
+else if (FullExpr *fe = dyn_cast(e))
+  e = fe->getSubExpr();
 else
   break;
   return e;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=347417&r1=347416&r2=347417&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Nov 21 12:44:18 2018
@@ -6380,7 +6380,7 @@ ExpectedStmt ASTNodeImporter::VisitConst
   Expr *ToSubExpr;
   std::tie(ToSubExpr) = *Imp;
 
-  return new (Importer.getToContext()) ConstantExpr(ToSubExpr);
+  return ConstantExpr::Create(Importer.getToContext(), ToSubExpr);
 }
 
 ExpectedStmt ASTNodeImporter::VisitParenExpr(ParenExpr *E) {

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=347417&r1=347416&r2=347417&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Nov 21 12:44:18 2018
@@ -2594,8 +2594,8 @@ Expr *Expr::IgnoreParenCasts() {
   E = NTTP->getReplacement();
   continue;
 }
-if (ConstantExpr *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
+if (FullExpr *FE = dyn_cast(E)) {
+  E = FE->getSubExpr();
   continue;
 }
 return E;
@@ -2619,8 +2619,8 @@ Expr *Expr::IgnoreCasts() {
   E = NTTP->getReplacemen

[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347413: [Driver] Use --push/pop-state with Sanitizer link 
deps (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54805?vs=174952&id=174966#toc

Repository:
  rC Clang

https://reviews.llvm.org/D54805

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -220,6 +220,20 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
+//
+// CHECK-ASAN-LINUX-STATIC: "--push-state"
+// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
+// CHECK-ASAN-LINUX-STATIC: "-lpthread"
+// CHECK-ASAN-LINUX-STATIC: "-lrt"
+// CHECK-ASAN-LINUX-STATIC: "-lm"
+// CHECK-ASAN-LINUX-STATIC: "-ldl"
+// CHECK-ASAN-LINUX-STATIC: "--pop-state"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ 
\
 // RUN: -fsanitize=thread \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -598,6 +598,7 @@
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -617,6 +618,7 @@
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
+  CmdArgs.push_back("--pop-state");
 }
 
 static void


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -220,6 +220,20 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
+//
+// CHECK-ASAN-LINUX-STATIC: "--push-state"
+// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
+// CHECK-ASAN-LINUX-STATIC: "-lpthread"
+// CHECK-ASAN-LINUX-STATIC: "-lrt"
+// CHECK-ASAN-LINUX-STATIC: "-lm"
+// CHECK-ASAN-LINUX-STATIC: "-ldl"
+// CHECK-ASAN-LINUX-STATIC: "--pop-state"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=thread \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -598,6 +598,7 @@
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -617,6 +618,7 @@
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
+  CmdArgs.push_back("--pop-state");
 }
 
 static void
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r347413 - [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Nov 21 12:33:12 2018
New Revision: 347413

URL: http://llvm.org/viewvc/llvm-project?rev=347413&view=rev
Log:
[Driver] Use --push/pop-state with Sanitizer link deps

Sanitizer runtime link deps handling passes --no-as-needed because of
PR15823, but it never undoes it and this flag may affect other libraries
that come later on the link line. To avoid this, wrap Sanitizer link
deps in --push/pop-state.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=347413&r1=347412&r2=347413&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Nov 21 12:33:12 2018
@@ -598,6 +598,7 @@ void tools::linkSanitizerRuntimeDeps(con
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -617,6 +618,7 @@ void tools::linkSanitizerRuntimeDeps(con
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
+  CmdArgs.push_back("--pop-state");
 }
 
 static void

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=347413&r1=347412&r2=347413&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Wed Nov 21 12:33:12 2018
@@ -220,6 +220,20 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
+//
+// CHECK-ASAN-LINUX-STATIC: "--push-state"
+// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
+// CHECK-ASAN-LINUX-STATIC: "-lpthread"
+// CHECK-ASAN-LINUX-STATIC: "-lrt"
+// CHECK-ASAN-LINUX-STATIC: "-lm"
+// CHECK-ASAN-LINUX-STATIC: "-ldl"
+// CHECK-ASAN-LINUX-STATIC: "--pop-state"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ 
\
 // RUN: -fsanitize=thread \


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


[PATCH] D54708: [OPENMP] NFC: Refactor code for parsing omp declare target directive and its clauses

2018-11-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347411: [OPENMP] Refactor code for parsing omp declare 
target directive and its clauses… (authored by kli, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54708?vs=174627&id=174963#toc

Repository:
  rC Clang

https://reviews.llvm.org/D54708

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseOpenMP.cpp

Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -2775,6 +2775,11 @@
   DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
 CachedTokens &Toks,
 SourceLocation Loc);
+  /// Parse clauses for '#pragma omp declare target'.
+  DeclGroupPtrTy ParseOMPDeclareTargetClauses();
+  /// Parse '#pragma omp end declare target'.
+  void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind DKind,
+ SourceLocation Loc);
   /// Parses declarative OpenMP directives.
   DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
   AccessSpecifier &AS, ParsedAttributesWithRange &Attrs,
Index: lib/Parse/ParseOpenMP.cpp
===
--- lib/Parse/ParseOpenMP.cpp
+++ lib/Parse/ParseOpenMP.cpp
@@ -644,6 +644,60 @@
   LinModifiers, Steps, SourceRange(Loc, EndLoc));
 }
 
+Parser::DeclGroupPtrTy Parser::ParseOMPDeclareTargetClauses() {
+  // OpenMP 4.5 syntax with list of entities.
+  Sema::NamedDeclSetType SameDirectiveDecls;
+  while (Tok.isNot(tok::annot_pragma_openmp_end)) {
+OMPDeclareTargetDeclAttr::MapTypeTy MT = OMPDeclareTargetDeclAttr::MT_To;
+if (Tok.is(tok::identifier)) {
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  StringRef ClauseName = II->getName();
+  // Parse 'to|link' clauses.
+  if (!OMPDeclareTargetDeclAttr::ConvertStrToMapTypeTy(ClauseName, MT)) {
+Diag(Tok, diag::err_omp_declare_target_unexpected_clause) << ClauseName;
+break;
+  }
+  ConsumeToken();
+}
+auto &&Callback = [this, MT, &SameDirectiveDecls](
+CXXScopeSpec &SS, DeclarationNameInfo NameInfo) {
+  Actions.ActOnOpenMPDeclareTargetName(getCurScope(), SS, NameInfo, MT,
+   SameDirectiveDecls);
+};
+if (ParseOpenMPSimpleVarList(OMPD_declare_target, Callback,
+ /*AllowScopeSpecifier=*/true))
+  break;
+
+// Consume optional ','.
+if (Tok.is(tok::comma))
+  ConsumeToken();
+  }
+  SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
+  ConsumeAnyToken();
+  SmallVector Decls(SameDirectiveDecls.begin(),
+   SameDirectiveDecls.end());
+  if (Decls.empty())
+return DeclGroupPtrTy();
+  return Actions.BuildDeclaratorGroup(Decls);
+}
+
+void Parser::ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind DKind,
+   SourceLocation DTLoc) {
+  if (DKind != OMPD_end_declare_target) {
+Diag(Tok, diag::err_expected_end_declare_target);
+Diag(DTLoc, diag::note_matching) << "'#pragma omp declare target'";
+return;
+  }
+  ConsumeAnyToken();
+  if (Tok.isNot(tok::annot_pragma_openmp_end)) {
+Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
+<< getOpenMPDirectiveName(OMPD_end_declare_target);
+SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
+  }
+  // Skip the last annot_pragma_openmp_end.
+  ConsumeAnyToken();
+}
+
 /// Parsing of declarative OpenMP directives.
 ///
 ///   threadprivate-directive:
@@ -785,43 +839,7 @@
   case OMPD_declare_target: {
 SourceLocation DTLoc = ConsumeAnyToken();
 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
-  // OpenMP 4.5 syntax with list of entities.
-  Sema::NamedDeclSetType SameDirectiveDecls;
-  while (Tok.isNot(tok::annot_pragma_openmp_end)) {
-OMPDeclareTargetDeclAttr::MapTypeTy MT =
-OMPDeclareTargetDeclAttr::MT_To;
-if (Tok.is(tok::identifier)) {
-  IdentifierInfo *II = Tok.getIdentifierInfo();
-  StringRef ClauseName = II->getName();
-  // Parse 'to|link' clauses.
-  if (!OMPDeclareTargetDeclAttr::ConvertStrToMapTypeTy(ClauseName,
-   MT)) {
-Diag(Tok, diag::err_omp_declare_target_unexpected_clause)
-<< ClauseName;
-break;
-  }
-  ConsumeToken();
-}
-auto &&Callback = [this, MT, &SameDirectiveDecls](
-  CXXScopeSpec &SS, DeclarationNameInfo NameInfo) {
-  Actions.ActOnOpenMPDeclareTargetName(getCurScope(), SS, NameInfo, MT,
-   SameDirectiveDecls);
-};
-if (ParseOpenMPSimpleVarList(OMPD_declare_target, 

r347411 - [OPENMP] Refactor code for parsing omp declare target directive and its clauses (NFC)

2018-11-21 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Nov 21 12:15:57 2018
New Revision: 347411

URL: http://llvm.org/viewvc/llvm-project?rev=347411&view=rev
Log:
[OPENMP] Refactor code for parsing omp declare target directive and its clauses 
(NFC)

This patch refactor the code for parsing omp declare target directive and
its clauses.

Patch by pjeeva01 (Jeeva P.)

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

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=347411&r1=347410&r2=347411&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Nov 21 12:15:57 2018
@@ -2775,6 +2775,11 @@ private:
   DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
 CachedTokens &Toks,
 SourceLocation Loc);
+  /// Parse clauses for '#pragma omp declare target'.
+  DeclGroupPtrTy ParseOMPDeclareTargetClauses();
+  /// Parse '#pragma omp end declare target'.
+  void ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind DKind,
+ SourceLocation Loc);
   /// Parses declarative OpenMP directives.
   DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
   AccessSpecifier &AS, ParsedAttributesWithRange &Attrs,

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=347411&r1=347410&r2=347411&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Nov 21 12:15:57 2018
@@ -644,6 +644,60 @@ Parser::ParseOMPDeclareSimdClauses(Parse
   LinModifiers, Steps, SourceRange(Loc, EndLoc));
 }
 
+Parser::DeclGroupPtrTy Parser::ParseOMPDeclareTargetClauses() {
+  // OpenMP 4.5 syntax with list of entities.
+  Sema::NamedDeclSetType SameDirectiveDecls;
+  while (Tok.isNot(tok::annot_pragma_openmp_end)) {
+OMPDeclareTargetDeclAttr::MapTypeTy MT = OMPDeclareTargetDeclAttr::MT_To;
+if (Tok.is(tok::identifier)) {
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  StringRef ClauseName = II->getName();
+  // Parse 'to|link' clauses.
+  if (!OMPDeclareTargetDeclAttr::ConvertStrToMapTypeTy(ClauseName, MT)) {
+Diag(Tok, diag::err_omp_declare_target_unexpected_clause) << 
ClauseName;
+break;
+  }
+  ConsumeToken();
+}
+auto &&Callback = [this, MT, &SameDirectiveDecls](
+CXXScopeSpec &SS, DeclarationNameInfo NameInfo) {
+  Actions.ActOnOpenMPDeclareTargetName(getCurScope(), SS, NameInfo, MT,
+   SameDirectiveDecls);
+};
+if (ParseOpenMPSimpleVarList(OMPD_declare_target, Callback,
+ /*AllowScopeSpecifier=*/true))
+  break;
+
+// Consume optional ','.
+if (Tok.is(tok::comma))
+  ConsumeToken();
+  }
+  SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
+  ConsumeAnyToken();
+  SmallVector Decls(SameDirectiveDecls.begin(),
+   SameDirectiveDecls.end());
+  if (Decls.empty())
+return DeclGroupPtrTy();
+  return Actions.BuildDeclaratorGroup(Decls);
+}
+
+void Parser::ParseOMPEndDeclareTargetDirective(OpenMPDirectiveKind DKind,
+   SourceLocation DTLoc) {
+  if (DKind != OMPD_end_declare_target) {
+Diag(Tok, diag::err_expected_end_declare_target);
+Diag(DTLoc, diag::note_matching) << "'#pragma omp declare target'";
+return;
+  }
+  ConsumeAnyToken();
+  if (Tok.isNot(tok::annot_pragma_openmp_end)) {
+Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
+<< getOpenMPDirectiveName(OMPD_end_declare_target);
+SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
+  }
+  // Skip the last annot_pragma_openmp_end.
+  ConsumeAnyToken();
+}
+
 /// Parsing of declarative OpenMP directives.
 ///
 ///   threadprivate-directive:
@@ -785,43 +839,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen
   case OMPD_declare_target: {
 SourceLocation DTLoc = ConsumeAnyToken();
 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
-  // OpenMP 4.5 syntax with list of entities.
-  Sema::NamedDeclSetType SameDirectiveDecls;
-  while (Tok.isNot(tok::annot_pragma_openmp_end)) {
-OMPDeclareTargetDeclAttr::MapTypeTy MT =
-OMPDeclareTargetDeclAttr::MT_To;
-if (Tok.is(tok::identifier)) {
-  IdentifierInfo *II = Tok.getIdentifierInfo();
-  StringRef ClauseName = II->getName();
-  // Parse 'to|link' clauses.
-  if (!OMPDeclareTargetDeclAttr::ConvertStrToMapTypeTy(ClauseName,
-   

[PATCH] D54565: Introduce `-Wc++14-compat-ctad` as a subgroup of `-Wc++14-compat`

2018-11-21 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(From a user point of view, I have no idea what "CTAD" means, and I sometimes 
work on a C++ compiler.)


Repository:
  rC Clang

https://reviews.llvm.org/D54565



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


[PATCH] D53210: Revert 344389 "Revert r344375 "[Driver] check for exit code from SIGPIPE""

2018-11-21 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added a comment.

Hi @nickdesaulniers - thanks for the clarification. I was suffering from some 
PEBCAK of my own when I thought the commits were not on master. Thanks for 
these patches - a great help.


Repository:
  rC Clang

https://reviews.llvm.org/D53210



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


[PATCH] D52311: [clangd] Add support for hierarchical documentSymbol

2018-11-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 174960.
ilya-biryukov added a comment.

- Remove accidentally added qualifiers


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52311

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/clients/clangd-vscode/package.json
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -47,7 +47,7 @@
 llvm::Expected>
 runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit);
 
-llvm::Expected>
+Expected>
 runDocumentSymbols(ClangdServer &Server, PathRef File);
 
 SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query);
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -120,9 +120,9 @@
   return std::move(*Result);
 }
 
-Expected>
+Expected>
 runDocumentSymbols(ClangdServer &Server, PathRef File) {
-  Optional>> Result;
+  Optional>> Result;
   Server.documentSymbols(File, capture(Result));
   return std::move(*Result);
 }
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -23,6 +23,7 @@
 using ::testing::AnyOf;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
+using ::testing::Field;
 using ::testing::IsEmpty;
 using ::testing::UnorderedElementsAre;
 
@@ -37,9 +38,17 @@
 return arg.name == Name;
   return (arg.containerName + "::" + arg.name) == Name;
 }
+MATCHER_P(WithName, N, "") { return arg.name == N; }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
 MATCHER_P(SymRange, Range, "") { return arg.location.range == Range; }
 
+// GMock helpers for matching DocumentSymbol.
+MATCHER_P(SymNameRange, Range, "") { return arg.selectionRange == Range; }
+template 
+testing::Matcher Children(ChildMatchers... ChildrenM) {
+  return Field(&DocumentSymbol::children, ElementsAre(ChildrenM...));
+}
+
 ClangdServer::Options optsForTests() {
   auto ServerOpts = ClangdServer::optsForTest();
   ServerOpts.WorkspaceRoot = testRoot();
@@ -301,7 +310,7 @@
   IgnoreDiagnostics DiagConsumer;
   ClangdServer Server;
 
-  std::vector getSymbols(PathRef File) {
+  std::vector getSymbols(PathRef File) {
 EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
 auto SymbolInfos = runDocumentSymbols(Server, File);
 EXPECT_TRUE(bool(SymbolInfos)) << "documentSymbols returned an error";
@@ -364,31 +373,46 @@
 )");
 
   addFile(FilePath, Main.code());
-  EXPECT_THAT(getSymbols(FilePath),
-  ElementsAreArray(
-  {AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
-   AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
-   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::f"), WithKind(SymbolKind::Method)),
-   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
-   AllOf(QName("Foo::operator="), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::~Foo"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::Nested"), WithKind(SymbolKind::Class)),
-   AllOf(QName("Foo::Nested::f"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Friend"), WithKind(SymbolKind::Class)),
-   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
-   AllOf(QName("f2"), WithKind(SymbolKind::Function)),
-   AllOf(QName("KInt"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("kStr"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
-   AllOf(QName("foo"), WithKind(SymbolKind::Namespace)),
-   AllOf(QName("foo::int32"), WithKind(SymbolKind::Class)),
-   AllOf(QName("foo::int32_t"), WithKind(SymbolKind::Class)),
-   AllOf(QName("foo::v1"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("foo::bar"), WithKind(SymbolKind::Namespace)),
-   AllOf(QName("foo::bar::v2"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("foo::baz"), WithKind(SymbolKind::Namespace))}));
+  EXPECT_THAT(
+  getSymbols(FilePath),
+  ElementsAreArray(
+  {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
+   AllOf(WithName("Foo"), WithKind(SymbolKind::Clas

r347409 - [OPENMP]Fix handling of the LCVs in loop-based directives.

2018-11-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 21 11:41:10 2018
New Revision: 347409

URL: http://llvm.org/viewvc/llvm-project?rev=347409&view=rev
Log:
[OPENMP]Fix handling of the LCVs in loop-based directives.

Loop-control variables with the default data-sharing attributes should
not be captured in the OpenMP region as they are private by default.
Also, default attributes should be emitted for such variables in the
inner OpenMP regions for the correct data sharing during codegen.

Added:
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=347409&r1=347408&r2=347409&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Nov 21 11:41:10 2018
@@ -1275,10 +1275,16 @@ bool DSAStackTy::hasExplicitDSA(
 return false;
   std::advance(StartI, Level);
   auto I = StartI->SharingMap.find(D);
-  return (I != StartI->SharingMap.end()) &&
+  if ((I != StartI->SharingMap.end()) &&
  I->getSecond().RefExpr.getPointer() &&
  CPred(I->getSecond().Attributes) &&
- (!NotLastprivate || !I->getSecond().RefExpr.getInt());
+ (!NotLastprivate || !I->getSecond().RefExpr.getInt()))
+return true;
+  // Check predetermined rules for the loop control variables.
+  auto LI = StartI->LCVMap.find(D);
+  if (LI != StartI->LCVMap.end())
+return CPred(OMPC_private);
+  return false;
 }
 
 bool DSAStackTy::hasExplicitDirective(

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=347409&r1=347408&r2=347409&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Nov 21 11:41:10 2018
@@ -6770,6 +6770,9 @@ TreeTransform::TransformDoStmt(
 template
 StmtResult
 TreeTransform::TransformForStmt(ForStmt *S) {
+  if (getSema().getLangOpts().OpenMP)
+getSema().startOpenMPLoop();
+
   // Transform the initialization statement
   StmtResult Init = getDerived().TransformStmt(S->getInit());
   if (Init.isInvalid())

Added: cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp?rev=347409&view=auto
==
--- cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp Wed Nov 21 
11:41:10 2018
@@ -0,0 +1,90 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix 
CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ 
-triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck 
%s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK: [[MEM_TY:%.+]] = type { [4 x i8] }
+// CHECK-DAG: {{@__omp_offloading_.+}}_l19_exec_mode = weak constant i8 1
+// CHECK-DAG: internal unnamed_addr constant i{{64|32}} 4
+
+template
+tx ftemplate(int n) {
+  int i;
+
+  #pragma omp target teams distribute
+  for (i = 0; i < 10; ++i)
+  {
+#pragma omp parallel
+++i;
+  }
+
+  return i;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-LABEL: define {{.*}}void 
{{@__omp_offloading_.+template.+l19}}_worker()
+  // CHECK: ret void
+
+  // CHECK: define {{.*}}void {{@__omp_offloading_.+template.+l19}}()
+
+  // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-DAG: [[TH_LIMIT:%.+]] = sub nuw i32 [[NTH]], [[WS]]
+  // CHECK: [[IS_WORKER:%.+]] = icmp u

[PATCH] D52311: [clangd] Add support for hierarchical documentSymbol

2018-11-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/FindSymbols.cpp:190
+  index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
+  SymbolKind SK = indexSymbolKindToSymbolKind(SymInfo.Kind);
 

sammccall wrote:
> may want to add a FIXME here: per the tests, it's not classifying 
> constructor/destructor/operator correctly (they're all "methods").
> 
> cons/dest is just indexSymbolKindToSymbolKind needing an update, but operator 
> isn't represented in index::SymbolKind.
> Maybe we should stop using index::SymbolKind entirely, it doesn't appear to 
> be great.
Added a FIXME.
From what I can tell, writing our own classification function shouldn't be too 
much work and would clearly fix those cases. We should do this!



Comment at: clangd/FindSymbols.cpp:208
+std::vector collectDocSymbols(ParsedAST &AST) {
+  struct CollectSymbols {
+CollectSymbols(ParsedAST &AST, std::vector &Results)

sammccall wrote:
> sammccall wrote:
> > sammccall wrote:
> > > this class seems maybe too long to live inside this function. (I wouldn't 
> > > worry about it being visible to other stuff, the file is small and 
> > > focused)
> > (this looks more like a class than a struct?)
> should this be a RecursiveASTVisitor?
> I guess not, but please explain why (there's no documentation on the 
> implementation strategy, and it's complicated)
Added a comment.



Comment at: clangd/FindSymbols.cpp:264
+// ignored.
+if (auto *Info = Func->getTemplateSpecializationInfo()) {
+  if (!Info->isExplicitInstantiationOrSpecialization())

sammccall wrote:
> isn't this covered by D->isImplicit?
Nope, IIUC things are only marked "implicit" in clangd if they were generated 
by the compiler from the start.
For this case, the **initial** template code was written by the user, so 
`isImplicit()` returns false for both the template and its instantiations.



Comment at: clangd/FindSymbols.cpp:276
+  // children.
+  //   - implicit instantiations, i.e. not written by the user.
+  // Do not visit at all, they are not present in the code.

sammccall wrote:
> isn't this covered by D->isImplicit() above?
See the other comment.



Comment at: clangd/Protocol.h:43
   InvalidParams = -32602,
+
   InternalError = -32603,

sammccall wrote:
> why?
Sorry, accidental change. Reverted.



Comment at: unittests/clangd/FindSymbolsTests.cpp:442
+SymNameRange(Main.range("decl"),
+  AllOf(WithName("f"), WithKind(SymbolKind::Method),
+SymNameRange(Main.range("def");

sammccall wrote:
> this one is to be fixed, right?
Why? The outline view gives both the declaration and the definition, since both 
were written in the code.
That seems to be in line with what I'd expect from the outline view.



Comment at: unittests/clangd/FindSymbolsTests.cpp:521
+ChildrenAre(AllOf(WithName("x"), 
WithKind(SymbolKind::Field,
+  AllOf(WithName("Tmpl"), WithKind(SymbolKind::Struct),
+ChildrenAre(WithName("y"))),

sammccall wrote:
> hmm, this seems pretty confusing - I think `Tmpl` would be a clearer 
> name for a specialization, even if we just have `Tmpl` for the primary 
> template.
> Partial specializations are confusing, though :-/
Done. Now prints as `Tmpl`.
This may also include some arguments not written by the users (e.g. some 
default args), but added a FIXME to fix this, it's not entirely trivial



Comment at: unittests/clangd/FindSymbolsTests.cpp:523
+ChildrenAre(WithName("y"))),
+  AllOf(WithName("Tmpl"), WithKind(SymbolKind::Struct), NoChildren()),
+  AllOf(WithName("Tmpl"), WithKind(SymbolKind::Struct), 
NoChildren(;

sammccall wrote:
> why the change in policy with this patch? (one of these previously was 
> deliberately not indexed, now is)
We might have different goals in mind here.
From my perspective, the purpose of the outline is to cover all things written 
in the code: there are 4 decls that the user wrote: one primary template, one 
template  specialization and two template instantiations.

What is your model here?



Comment at: unittests/clangd/FindSymbolsTests.cpp:571
   addFile(FilePath, R"(
   enum {
 Red

sammccall wrote:
> hmm, our handling of anonymous enums seems different than anonymous 
> namespaces - why?
No rigorous reasons. The namespaces tend to group more things together, so it's 
arguably more useful to have an option of folding their subitems in the tree.
Anonymous enums are typically used only in the classes (and on the top-level in 
C to define constants?) and I feel having an extra node there merely produces 
noise.
Happy

[PATCH] D52311: [clangd] Add support for hierarchical documentSymbol

2018-11-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 174958.
ilya-biryukov marked 15 inline comments as done.
ilya-biryukov added a comment.

- Address comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52311

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/clients/clangd-vscode/package.json
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -47,7 +47,7 @@
 llvm::Expected>
 runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit);
 
-llvm::Expected>
+llvm::Expected>
 runDocumentSymbols(ClangdServer &Server, PathRef File);
 
 SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query);
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -120,9 +120,9 @@
   return std::move(*Result);
 }
 
-Expected>
+llvm::Expected>
 runDocumentSymbols(ClangdServer &Server, PathRef File) {
-  Optional>> Result;
+  llvm::Optional>> Result;
   Server.documentSymbols(File, capture(Result));
   return std::move(*Result);
 }
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -23,6 +23,7 @@
 using ::testing::AnyOf;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
+using ::testing::Field;
 using ::testing::IsEmpty;
 using ::testing::UnorderedElementsAre;
 
@@ -37,9 +38,17 @@
 return arg.name == Name;
   return (arg.containerName + "::" + arg.name) == Name;
 }
+MATCHER_P(WithName, N, "") { return arg.name == N; }
 MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
 MATCHER_P(SymRange, Range, "") { return arg.location.range == Range; }
 
+// GMock helpers for matching DocumentSymbol.
+MATCHER_P(SymNameRange, Range, "") { return arg.selectionRange == Range; }
+template 
+testing::Matcher Children(ChildMatchers... ChildrenM) {
+  return Field(&DocumentSymbol::children, ElementsAre(ChildrenM...));
+}
+
 ClangdServer::Options optsForTests() {
   auto ServerOpts = ClangdServer::optsForTest();
   ServerOpts.WorkspaceRoot = testRoot();
@@ -301,7 +310,7 @@
   IgnoreDiagnostics DiagConsumer;
   ClangdServer Server;
 
-  std::vector getSymbols(PathRef File) {
+  std::vector getSymbols(PathRef File) {
 EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
 auto SymbolInfos = runDocumentSymbols(Server, File);
 EXPECT_TRUE(bool(SymbolInfos)) << "documentSymbols returned an error";
@@ -364,31 +373,46 @@
 )");
 
   addFile(FilePath, Main.code());
-  EXPECT_THAT(getSymbols(FilePath),
-  ElementsAreArray(
-  {AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
-   AllOf(QName("Foo"), WithKind(SymbolKind::Class)),
-   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::Foo"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::f"), WithKind(SymbolKind::Method)),
-   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
-   AllOf(QName("Foo::operator="), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::~Foo"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Foo::Nested"), WithKind(SymbolKind::Class)),
-   AllOf(QName("Foo::Nested::f"), WithKind(SymbolKind::Method)),
-   AllOf(QName("Friend"), WithKind(SymbolKind::Class)),
-   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
-   AllOf(QName("f2"), WithKind(SymbolKind::Function)),
-   AllOf(QName("KInt"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("kStr"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("f1"), WithKind(SymbolKind::Function)),
-   AllOf(QName("foo"), WithKind(SymbolKind::Namespace)),
-   AllOf(QName("foo::int32"), WithKind(SymbolKind::Class)),
-   AllOf(QName("foo::int32_t"), WithKind(SymbolKind::Class)),
-   AllOf(QName("foo::v1"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("foo::bar"), WithKind(SymbolKind::Namespace)),
-   AllOf(QName("foo::bar::v2"), WithKind(SymbolKind::Variable)),
-   AllOf(QName("foo::baz"), WithKind(SymbolKind::Namespace))}));
+  EXPECT_THAT(
+  getSymbols(FilePath),
+  ElementsAreArray(
+  {AllOf(WithName("Foo"), WithKind(SymbolKind::Class), Children()),
+   A

[PATCH] D54638: [OpenMP] remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp (NFC)

2018-11-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347408: [OPENMP] remove redundant MapTypeModifierSpecified 
flag in ParseOpenMP.cpp (NFC) (authored by kli, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54638?vs=174396&id=174957#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54638

Files:
  cfe/trunk/lib/Parse/ParseOpenMP.cpp


Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -1775,7 +1775,6 @@
 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, 
tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1904,8 +1901,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1942,9 +1937,7 @@
   (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
   (Kind == OMPC_reduction && !InvalidReductionId) ||
-  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-   (!MapTypeModifierSpecified ||
-Data.MapTypeModifier == OMPC_MAP_always)) ||
+  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
   (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&


Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -1775,7 +1775,6 @@
 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1904,8 +1901,6 @@
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1942,9 +1937,7 @@
   (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
   (Kind == OMPC_reduction && !InvalidReductionId) ||
-  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-   (!MapTypeModifierSpecified ||
-Data.MapTypeModifier == OMPC_MAP_always)) ||
+  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
   (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r347408 - [OPENMP] remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp (NFC)

2018-11-21 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Nov 21 11:38:53 2018
New Revision: 347408

URL: http://llvm.org/viewvc/llvm-project?rev=347408&view=rev
Log:
[OPENMP] remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp (NFC)

Whether the map type modifier is specified or not, the flag 
MapTypeModifierSpecified is always set to true.

Patch by Ahsan Saghir

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

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=347408&r1=347407&r2=347408&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Nov 21 11:38:53 2018
@@ -1775,7 +1775,6 @@ bool Parser::ParseOpenMPVarList(OpenMPDi
 OpenMPVarListDataTy &Data) {
   UnqualifiedId UnqualifiedReductionId;
   bool InvalidReductionId = false;
-  bool MapTypeModifierSpecified = false;
 
   // Parse '('.
   BalancedDelimiterTracker T(*this, tok::l_paren, 
tok::annot_pragma_openmp_end);
@@ -1878,8 +1877,6 @@ bool Parser::ParseOpenMPVarList(OpenMPDi
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1904,8 +1901,6 @@ bool Parser::ParseOpenMPVarList(OpenMPDi
   if (Data.MapTypeModifier != OMPC_MAP_always) {
 Diag(Tok, diag::err_omp_unknown_map_type_modifier);
 Data.MapTypeModifier = OMPC_MAP_unknown;
-  } else {
-MapTypeModifierSpecified = true;
   }
 
   ConsumeToken();
@@ -1942,9 +1937,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDi
   (Kind != OMPC_reduction && Kind != OMPC_task_reduction &&
Kind != OMPC_in_reduction && Kind != OMPC_depend && Kind != OMPC_map) ||
   (Kind == OMPC_reduction && !InvalidReductionId) ||
-  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown &&
-   (!MapTypeModifierSpecified ||
-Data.MapTypeModifier == OMPC_MAP_always)) ||
+  (Kind == OMPC_map && Data.MapType != OMPC_MAP_unknown) ||
   (Kind == OMPC_depend && Data.DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&


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


[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D54805



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


[PATCH] D54441: [OPENMP] Support relational-op !- (not-equal) as one of the canonical forms of random access iterator

2018-11-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347405: [OPENMP] Support relational-op != (not-equal) as one 
of the canonical  (authored by kli, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54441?vs=174394&id=174954#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54441

Files:
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/for_loop_messages.cpp
  cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
  cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
  cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp
  cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_loop_messages.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
  
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp
  cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  cfe/trunk/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -3905,7 +3905,8 @@
   ///   Var <= UB
   ///   UB  >  Var
   ///   UB  >= Var
-  bool TestIsLessOp = false;
+  /// This will have no value when the condition is !=
+  llvm::Optional TestIsLessOp;
   /// This flag is true when condition is strict ( < or > ).
   bool TestIsStrictOp = false;
   /// This flag is true when step is subtracted on each iteration.
@@ -3971,8 +3972,8 @@
   /// Helper to set loop counter variable and its initializer.
   bool setLCDeclAndLB(ValueDecl *NewLCDecl, Expr *NewDeclRefExpr, Expr *NewLB);
   /// Helper to set upper bound.
-  bool setUB(Expr *NewUB, bool LessOp, bool StrictOp, SourceRange SR,
- SourceLocation SL);
+  bool setUB(Expr *NewUB, llvm::Optional LessOp, bool StrictOp,
+ SourceRange SR, SourceLocation SL);
   /// Helper to set loop increment.
   bool setStep(Expr *NewStep, bool Subtract);
 };
@@ -4007,15 +4008,17 @@
   return false;
 }
 
-bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB, bool LessOp, bool StrictOp,
-SourceRange SR, SourceLocation SL) {
+bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB, llvm::Optional LessOp,
+bool StrictOp, SourceRange SR,
+SourceLocation SL) {
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && UB == nullptr &&
  Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
   if (!NewUB)
 return true;
   UB = NewUB;
-  TestIsLessOp = LessOp;
+  if (LessOp)
+TestIsLessOp = LessOp;
   TestIsStrictOp = StrictOp;
   ConditionSrcRange = SR;
   ConditionLoc = SL;
@@ -4055,18 +4058,23 @@
 bool IsConstPos =
 IsConstant && Result.isSigned() && (Subtract == Result.isNegative());
 bool IsConstZero = IsConstant && !Result.getBoolValue();
+
+// != with increment is treated as <; != with decrement is treated as >
+if (!TestIsLessOp.hasValue())
+  TestIsLessOp = IsConstPos || (IsUnsigned && !Subtract);
 if (UB && (IsConstZero ||
-   (TestIsLessOp ? (IsConstNeg || (IsUnsigned && Subtract))
- : (IsConstPos || (IsUnsigned && !Subtract) {
+   (TestIsLessOp.getValue() ? 
+  (IsConstNeg || (IsUnsigned && Subtract)) :
+  (IsConstPos || (IsUnsigned && !Subtract) {
   SemaRef.Diag(NewStep->getExprLoc(),
diag::err_omp_loop_incr_not_compatible)
-  << LCDecl << TestIsLessOp << NewStep->getSourceRange();
+  << LCDecl << TestIsLessOp.getValue() << NewStep->getSourceRange();
   SemaRef.Diag(ConditionLoc,
diag::note_omp_loop_cond_requres_compatible_incr)
-  << TestIsLessOp << ConditionSrcRange;
+  << TestIsLessOp.getValue() << ConditionSrcRange;
   return true;
 }
-if (TestIsLessOp == Subtract) {
+if (TestIsLessOp.getValue() == Subtract) {
   NewStep =
   SemaRef.CreateBuiltinUnaryOp(NewStep->g

r347405 - [OPENMP] Support relational-op != (not-equal) as one of the canonical

2018-11-21 Thread Kelvin Li via cfe-commits
Author: kli
Date: Wed Nov 21 11:10:48 2018
New Revision: 347405

URL: http://llvm.org/viewvc/llvm-project?rev=347405&view=rev
Log:
[OPENMP] Support relational-op != (not-equal) as one of the canonical 
forms of random access iterator

In OpenMP 4.5, only 4 relational operators are supported: <, <=, >, 
and >=.  This work is to enable support for relational operator 
!= (not-equal) as one of the canonical forms.

Patch by Anh Tuyen Tran

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp
cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=347405&r1=347404&r2=347405&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Nov 21 11:10:48 2018
@@ -3905,7 +3905,8 @@ class OpenMPIterationSpaceChecker {
   ///   Var <= UB
   ///   UB  >  Var
   ///   UB  >= Var
-  bool TestIsLessOp = false;
+  /// This will have no value when the condition is !=
+  llvm::Optional TestIsLessOp;
   /// This flag is true when condition is strict ( < or > ).
   bool TestIsStrictOp = false;
   /// This flag is true when step is subtracted on each iteration.
@@ -3971,8 +3972,8 @@ private:
   /// Helper to set loop counter variable and its initializer.
   bool setLCDeclAndLB(ValueDecl *NewLCDecl, Expr *NewDeclRefExpr, Expr *NewLB);
   /// Helper to set upper bound.
-  bool setUB(Expr *NewUB, bool LessOp, bool StrictOp, SourceRange SR,
- SourceLocation SL);
+  bool setUB(Expr *NewUB, llvm::Optional LessOp, bool StrictOp,
+ SourceRange SR, SourceLocation SL);
   /// Helper to set loop increment.
   bool setStep(Expr *NewStep, bool Subtract);
 };
@@ -4007,15 +4008,17 @@ bool OpenMPIterationSpaceChecker::setLCD
   return false;
 }
 
-bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB, bool LessOp, bool 
StrictOp,
-SourceRange SR, SourceLocation SL) {
+bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB, llvm::Optional 
LessOp,
+bool StrictOp, SourceRange SR,
+SourceLocation SL) {
   // State consistency checking to ensure correct usage.
   assert(LCDecl != nullptr && LB != nullptr && UB == nullptr &&
  Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
   if (!NewUB)
 return true;
   UB = NewUB;
-  TestIsLessOp = LessOp;
+  if (LessOp)
+TestIsLessOp = LessOp;
   TestIsStrictOp = StrictOp;
   ConditionSrcRange = SR;
   ConditionLoc = SL;
@@ -4055,18 +4058,23 @@ bool OpenMPIterationSpaceChecker::setSte
 bool IsConstPos =
 IsConstant && Result.isSigned() && (Subtract == Result.isNegative());
 bool IsConstZero = IsConstant && !Result.getBoolValue();
+
+// != with increment is treated as <; != with decrement is treated as >
+if (!TestIsLessOp.hasValue())
+  TestIsLessOp = IsConstPos || (IsUnsigned && !Subtract);
 if (UB && (IsConstZero ||
-   (TestIsLessOp ? (IsConstNeg || (IsUnsigned && Subtract))
- : (IsConstPos || (IsUnsigned && !Subtract) {
+   (TestIsLessOp.getValue() ? 
+  (IsConstNeg || (IsUnsigned && Subtract)) :
+  (IsConstPos || (IsUnsigned && !Subtract) {
   SemaRef.Diag(NewStep->getExprLoc(),
diag::err_omp_loop_incr_not_compatible)
-  << LCDecl << TestIsLessOp << NewStep->getSourceRange();
+

[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded

2018-11-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Ping, @xazax.hun, any objections?


https://reviews.llvm.org/D52795



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


[PATCH] D54805: [Driver] Use --push/pop-state with Sanitizer link deps

2018-11-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: vitalybuka, morehouse.
Herald added subscribers: cfe-commits, jfb.

Sanitizer runtime link deps handling passes --no-as-needed because of
PR15823, but it never undoes it and this flag may affect other libraries
that come later on the link line. To avoid this, wrap Sanitizer link
deps in --push/pop-state.


Repository:
  rC Clang

https://reviews.llvm.org/D54805

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -220,6 +220,20 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
+//
+// CHECK-ASAN-LINUX-STATIC: "--push-state"
+// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
+// CHECK-ASAN-LINUX-STATIC: "-lpthread"
+// CHECK-ASAN-LINUX-STATIC: "-lrt"
+// CHECK-ASAN-LINUX-STATIC: "-lm"
+// CHECK-ASAN-LINUX-STATIC: "-ldl"
+// CHECK-ASAN-LINUX-STATIC: "--pop-state"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ 
\
 // RUN: -fsanitize=thread \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -598,6 +598,7 @@
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -617,6 +618,7 @@
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
+  CmdArgs.push_back("--pop-state");
 }
 
 static void


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -220,6 +220,20 @@
 // CHECK-ASAN-MYRIAD-NOT: "-lc"
 // CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -static \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-STATIC %s
+//
+// CHECK-ASAN-LINUX-STATIC: "--push-state"
+// CHECK-ASAN-LINUX-STATIC: "--no-as-needed"
+// CHECK-ASAN-LINUX-STATIC: "-lpthread"
+// CHECK-ASAN-LINUX-STATIC: "-lrt"
+// CHECK-ASAN-LINUX-STATIC: "-lm"
+// CHECK-ASAN-LINUX-STATIC: "-ldl"
+// CHECK-ASAN-LINUX-STATIC: "--pop-state"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=thread \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -598,6 +598,7 @@
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   // There's no libpthread or librt on RTEMS & Android.
   if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
@@ -617,6 +618,7 @@
   if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
   TC.getTriple().getOS() == llvm::Triple::FreeBSD)
 CmdArgs.push_back("-lexecinfo");
+  CmdArgs.push_back("--pop-state");
 }
 
 static void
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51650: Implement target_clones multiversioning

2018-11-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 174950.
erichkeane added a subscriber: grooverdan.
erichkeane added a comment.

Fix @rsmith s comments, rebase on the big CPUDispatch refactor.


https://reviews.llvm.org/D51650

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-target-clones.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-cpuspecific.c
  test/Sema/attr-target-clones.c

Index: test/Sema/attr-target-clones.c
===
--- /dev/null
+++ test/Sema/attr-target-clones.c
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+
+// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
+void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
+no_default(void);
+
+// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
+ignored_attr(void);
+// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
+ignored_attr2(void);
+
+int redecl(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
+int redecl3(void);
+
+int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
+// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
+redecl4(void) { return 1; }
+
+int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef3'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef4'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+
+// Duplicates are allowed, however they alter name mangling.
+// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted}}
+// expected-warning@+1 2 {{version list contains duplicate entries}}
+int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
+dupes(void) { return 1; }
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("")))
+empty_target_1(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones(",default")))
+empty_target_2(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,")))
+empty_target_3(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default, ,avx2")))
+empty_target_4(void);
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,avx2", "")))
+empty_target_5(void);
+
+// expected-warning@+1 {{version list contains duplicate entries}}
+void __attribute__((target_clones("default", "default")))
+dupe_default(void);
+
+// expected-warning@+1 {{version list contains duplicate entries}}
+void __attribute__((target_clones("avx2,avx2,default")))
+dupe_normal(void);
+
+// expected-error@+2 {{'target_clones' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("avx2,default"), target_clones("arch=atom,default")))
+dupe_normal2(void);
+
+int mv_after_use(void);
+int useage() {
+  return mv_after_use();
+}
+// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
+int __attribute__((target_clones("sse4.2", "default"))) mv

[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-11-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In https://reviews.llvm.org/D50119#1303720, @rjmccall wrote:

> In https://reviews.llvm.org/D50119#1303662, @Quuxplusone wrote:
>
> > >> I still believe it is impossible to implement `std::optional` with only 
> > >> `[[maybe_trivially_relocatable]]`.
> > > 
> > > This might also need elaboration.
> >
> > Because `__optional_destruct_base` contains an anonymous union member, and 
> > that union type is not destructible; therefore that union type is not 
> > trivially relocatable; therefore `__optional_destruct_base` contains a 
> > member of non-trivially-destructible type. However, I'm working on changing 
> > my patch to make anonymous unions "see-through" in this respect, so that 
> > that union's non-destructibility doesn't interfere with the 
> > `[[maybe_trivially_relocatable]]`ity of its enclosing class type, as long 
> > as all the members of the //union// are trivially relocatable. This might 
> > fix `optional`. I'm not sure yet.
>
>
> Ah, that makes sense.  And yeah, that seems like the right rule for unions.  
> I really appreciate you putting the effort into exploring this part of the 
> design space.


I think it's part of the right rule, but it's not enough, either. Consider:

  struct [[clang::maybe_trivially_relocatable]] DestroyBase {
  int i;
  DestroyBase(DestroyBase&&) = delete;
  ~DestroyBase();
  };
  struct [[clang::maybe_trivially_relocatable]] MoveBase : DestroyBase {
  MoveBase(MoveBase&&);
  };
  
  static_assert(not std::is_move_constructible_v); //, therefore
  static_assert(not std::is_relocatable_v); //, therefore
  static_assert(not std::is_trivially_relocatable_v); //; and 
since MoveBase now has a base class of non-trivially-relocatable type,
  static_assert(not std::is_trivially_relocatable_v);

So maybe you need a notion like "a class is BlahBlah if all of its direct 
members are BlahBlah, //and// either it is annotated 
`[[maybe_trivially_relocatable]]` or else it has no non-defaulted move or 
destroy operations." And then "a move-constructible, destructible class is 
trivially relocatable if it is BlahBlah, //or// if it is annotated 
`[[trivially_relocatable]]`." And then a class like `DestroyBase` can be 
"BlahBlah but not move-constructible," and if it's placed inside `MoveBase`, 
and `MoveBase` is //both// annotated and move-constructible, then `MoveBase` 
becomes trivially relocatable.

This does feel like it would be twice as hard to specify in the Standard, 
because I think I'd have to specify both the rules for BlahBlah //and// the 
rules for "trivially relocatable."

I'm also extremely concerned about the philosophical correctness of separating 
BlahBlahness from actual physical relocatability. What does it mean, 
abstractly, to say that "`DestroyBase` is not even moveable at all, but //if it 
were//, I'm confident that its relocation operation would be trivial"?  That's 
some weird counterfactual logic that forces the writer of the class 
(`DestroyBase` in this case, but also e.g. `lock_guard`) to think about how 
their class might get used downstream, and what the class's hypothetical 
invariants might be, under an operation (move+destroy) that it itself does not 
claim to support.

The benefit of my original "second-level" `[[trivially_relocatable]]` attribute 
is that it puts all the responsibility in a single very high-level place. 
`optional` is the thing that knows exactly when it's trivially relocatable (or 
at least can make a conservative guess, which might boil down to "I'm never 
trivially relocatable"), so `optional` is the thing that should get the 
attribute.

If I get time today I'll try adding the boolean argument to the attribute, and 
do the libc++ patches that way for comparison.


Repository:
  rC Clang

https://reviews.llvm.org/D50119



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


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-11-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

@ebevhan Any more comments on this patch?


Repository:
  rC Clang

https://reviews.llvm.org/D53738



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


r347402 - Mark lambda decl as invalid if a captured variable has an invalid type.

2018-11-21 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Wed Nov 21 09:49:37 2018
New Revision: 347402

URL: http://llvm.org/viewvc/llvm-project?rev=347402&view=rev
Log:
Mark lambda decl as invalid if a captured variable has an invalid type.

This causes the compiler to crash when trying to compute a layout for
the lambda closure type (see included test).

Added:
cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=347402&r1=347401&r2=347402&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Nov 21 09:49:37 2018
@@ -14966,6 +14966,21 @@ static void addAsFieldToClosureType(Sema
 = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType,
 S.Context.getTrivialTypeSourceInfo(FieldType, Loc),
 nullptr, false, ICIS_NoInit);
+  // If the variable being captured has an invalid type, mark the lambda class
+  // as invalid as well.
+  if (!FieldType->isDependentType()) {
+if (S.RequireCompleteType(Loc, FieldType, diag::err_field_incomplete)) {
+  Lambda->setInvalidDecl();
+  Field->setInvalidDecl();
+} else {
+  NamedDecl *Def;
+  FieldType->isIncompleteType(&Def);
+  if (Def && Def->isInvalidDecl()) {
+Lambda->setInvalidDecl();
+Field->setInvalidDecl();
+  }
+}
+  }
   Field->setImplicit(true);
   Field->setAccess(AS_private);
   Lambda->addDecl(Field);

Added: cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp?rev=347402&view=auto
==
--- cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp (added)
+++ cfe/trunk/test/SemaCXX/lambda-invalid-capture.cpp Wed Nov 21 09:49:37 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash.
+
+struct g {
+  j; // expected-error {{C++ requires a type specifier for all declarations}}
+};
+
+void captures_invalid_type() {
+  g child;
+  auto q = [child]{};
+  const int n = sizeof(q);
+}
+
+void captures_invalid_array_type() {
+  g child[100];
+  auto q = [child]{};
+  const int n = sizeof(q);
+}


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


[PATCH] D54799: [clangd][WIP] textDocument/CursorInfo method

2018-11-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for sending this! Broadly looks good, a few details to work out. I think 
the biggest one is multiple symbols which you've flagged.

> I'd like to ask for early feedback - what's still missing is relevant client 
> capability.

I'm actually not 100% sure that's necessary for custom LSP methods.

- a server capability would suffice at least, unless we're worried clients are 
going to call it "by mistake"?
- even that doesn't seem much better than just allowing the call where other 
servers would return an error. Keep it simple?

I'd suggest leaving it out unless others feel strongly.

> Couple things that I'd love to hear opinions about are:
> 
> - conditional return in `getCursorInfo` - Should we return for example data 
> with empty `USR`?

Please return a symbol unless it has no SymbolID (we don't treat those as 
symbols in clangd).
In practice this amounts to the same thing for now (SymbolID is derived from 
USR). May change in the future though.

> - `containerName` of local variables - It's currently empty even if semantic 
> parent has a name (say it's a function). (Please search for local.cpp in the 
> test.) Is that what we want?

good question, no idea.

> - For now I used `getSymbolAtPosition()` as it's simpler and fits the context 
> better. However I assume I could use this optimization from 
> `tooling::getNamedDeclAt()` (in a separate patch): 
> https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Refactoring/Rename/#L82

Yes, though at least for C++ this optimization won't usually buy anything, as 
the top-level decl will just be a namespace decl I think.
We could plumb this deeper if we want to win more here.

- One thing I am wondering about is whether we could use (and whether it's a 
significant improvement) some early return in `indexTopLevelDecls` (using 
`DeclarationAndMacrosFinder`) also for hover and definition use-cases. Is it 
correct to assume that at a given `Location` there can be maximum of one 
declaration and one definition?

There can be multiple and we should return them all. (Not sure what we do for 
hover, but defs handles this correctly).
I can't remember which are the important cases, but one we handle like this is 
implicit constructor calls:

  class Foo { Foo(const char*); }
  void g(Foo);
  const char* str = "abc";
  g(str);

completion on the `s` in the last line finds both the Foo constructor and the 
definition of `str`.

Maybe it's worth revisiting this if we can't find any really important 
examples. That would involve digging up the historical context (I don't 
remember it right now).

> P. S. Alex and Ben have thanksgiving break now so they'll probably add any 
> feedback next week.

Hope they're having a good break!




Comment at: ClangdLSPServer.cpp:728
   MsgHandler->bind("workspace/didChangeConfiguration", 
&ClangdLSPServer::onChangeConfiguration);
+  MsgHandler->bind("textDocument/cursorInfo", &ClangdLSPServer::onCursorInfo);
   // clang-format on

I'd suggest `textDocument/symbolInfo` for consistency with LSP (and similar 
with internal names).
The term "symbol" is used throughout LSP to describe roughly what we're using 
it to mean here.

Conversely I guess "cursor" refers to the editor cursor, but LSP seems to 
prefer just talking about positions.



Comment at: ClangdServer.h:205
+  /// Get cursor info for given position.
+  void getCursorInfo(PathRef File, Position Pos,
+ Callback> CB);

nit: just `cursorInfo` (or `symbolInfo` etc) for consistency with other where 
there isn't a specific verb.



Comment at: Protocol.cpp:436
+  const IdentifierData &SUCI) {
+  O << SUCI.containerName << "::" << SUCI.name << " - " << toJSON(SUCI);
+  return O;

(you only want containername if non-empty, right?)



Comment at: Protocol.h:676
 
+/// Represents information about identifier.
+struct IdentifierData {

Unless I'm misunderstanding, this is about a symbol, not an identifier. (e.g. 
overloads of C++ functions are distinct symbols). Maybe `SymbolDetails` would 
be a useful name.

There's a question of scope here: `getCursorInfo` seems to return a single 
instance of these, but there can be 0, 1, or many symbols at a given location. 
These could be `vector` or so, or if this struct is intended to 
encapsulate them all, it could be named `SymbolsAtLocation` or so.



Comment at: Protocol.h:676
 
+/// Represents information about identifier.
+struct IdentifierData {

sammccall wrote:
> Unless I'm misunderstanding, this is about a symbol, not an identifier. (e.g. 
> overloads of C++ functions are distinct symbols). Maybe `SymbolDetails` would 
> be a useful name.
> 
> There's a question of scope here: `getCursorInfo` seems to return a single 
> instance of these, but there can be 0, 1, or many symbols at a given 
> 

[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-21 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy marked 6 inline comments as done.
donat.nagy added a comment.

An example of duplicated code in Clang (it appears in 
llvm/tools/clang/lib/Frontend/Rewrite/RewriteMacros.cpp starting from line 128):

  // If this is a #warning directive or #pragma mark (GNU extensions),
  // comment the line out.
  if (RawTokens[CurRawTok].is(tok::identifier)) {
const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo();
if (II->getName() == "warning") {
  // Comment out #warning.
  RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");   
// THIS IS...
} else if (II->getName() == "pragma" &&
   RawTokens[CurRawTok+1].is(tok::identifier) &&
   (RawTokens[CurRawTok+1].getIdentifierInfo()->getName() ==
"mark")) {
  // Comment out #pragma mark.
  RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");   
// IDENTICAL TO THIS
}
  }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54757



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


[PATCH] D54550: Mark lambda decl as invalid if a captured variable has an invalid type.

2018-11-21 Thread Jorge Gorbe Moya via Phabricator via cfe-commits
jgorbe updated this revision to Diff 174944.
jgorbe added a comment.

Folded the two test cases (capturing an invalid type and capturing an invalid 
array type) into a single file.


https://reviews.llvm.org/D54550

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/lambda-invalid-capture.cpp


Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash.
+
+struct g {
+  j; // expected-error {{C++ requires a type specifier for all declarations}}
+};
+
+void captures_invalid_type() {
+  g child;
+  auto q = [child]{};
+  const int n = sizeof(q);
+}
+
+void captures_invalid_array_type() {
+  g child[100];
+  auto q = [child]{};
+  const int n = sizeof(q);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14967,6 +14967,21 @@
 = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType,
 S.Context.getTrivialTypeSourceInfo(FieldType, Loc),
 nullptr, false, ICIS_NoInit);
+  // If the variable being captured has an invalid type, mark the lambda class
+  // as invalid as well.
+  if (!FieldType->isDependentType()) {
+if (S.RequireCompleteType(Loc, FieldType, diag::err_field_incomplete)) {
+  Lambda->setInvalidDecl();
+  Field->setInvalidDecl();
+} else {
+  NamedDecl *Def;
+  FieldType->isIncompleteType(&Def);
+  if (Def && Def->isInvalidDecl()) {
+Lambda->setInvalidDecl();
+Field->setInvalidDecl();
+  }
+}
+  }
   Field->setImplicit(true);
   Field->setAccess(AS_private);
   Lambda->addDecl(Field);


Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash.
+
+struct g {
+  j; // expected-error {{C++ requires a type specifier for all declarations}}
+};
+
+void captures_invalid_type() {
+  g child;
+  auto q = [child]{};
+  const int n = sizeof(q);
+}
+
+void captures_invalid_array_type() {
+  g child[100];
+  auto q = [child]{};
+  const int n = sizeof(q);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14967,6 +14967,21 @@
 = FieldDecl::Create(S.Context, Lambda, Loc, Loc, nullptr, FieldType,
 S.Context.getTrivialTypeSourceInfo(FieldType, Loc),
 nullptr, false, ICIS_NoInit);
+  // If the variable being captured has an invalid type, mark the lambda class
+  // as invalid as well.
+  if (!FieldType->isDependentType()) {
+if (S.RequireCompleteType(Loc, FieldType, diag::err_field_incomplete)) {
+  Lambda->setInvalidDecl();
+  Field->setInvalidDecl();
+} else {
+  NamedDecl *Def;
+  FieldType->isIncompleteType(&Def);
+  if (Def && Def->isInvalidDecl()) {
+Lambda->setInvalidDecl();
+Field->setInvalidDecl();
+  }
+}
+  }
   Field->setImplicit(true);
   Field->setAccess(AS_private);
   Lambda->addDecl(Field);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-21 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy updated this revision to Diff 174943.
donat.nagy added a comment.

Implement suggested improvements


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54757

Files:
  clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tidy/bugprone/BranchCloneCheck.h
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-branch-clone.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-branch-clone.cpp

Index: test/clang-tidy/bugprone-branch-clone.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-branch-clone.cpp
@@ -0,0 +1,751 @@
+// RUN: %check_clang_tidy %s bugprone-branch-clone %t
+
+void test_basic1(int in, int &out) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  else
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+
+  out++;
+}
+
+void test_basic2(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  }
+  else {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+  }
+
+  out++;
+}
+
+void test_basic3(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  }
+  else
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+
+  out++;
+}
+
+void test_basic4(int in, int &out) {
+  if (in > 77) {
+out--;
+  }
+  else {
+out++;
+  }
+}
+
+void test_basic5(int in, int &out) {
+  if (in > 77) {
+out++;
+  }
+  else {
+out++;
+out++;
+  }
+}
+
+void test_basic6(int in, int &out) {
+  if (in > 77) {
+out++;
+  }
+  else {
+out++, out++;
+  }
+}
+
+void test_basic7(int in, int &out) {
+  if (in > 77) {
+out++;
+out++;
+  }
+  else
+out++;
+
+  out++;
+}
+
+void test_basic8(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+out++;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+out++;
+out++;
+  }
+
+  if (in % 2)
+out++;
+}
+
+void test_basic9(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+if (in % 2)
+  out++;
+else
+  out--;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+if (in % 2)
+  out++;
+else
+  out--;
+  }
+}
+
+// If we remove the braces from the previous example, the check recognizes it
+// as an `else if`.
+void test_basic10(int in, int &out) {
+  if (in > 77)
+if (in % 2)
+  out++;
+else
+  out--;
+  else
+if (in % 2)
+  out++;
+else
+  out--;
+
+}
+
+void test_basic11(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+if (in % 2)
+  out++;
+else
+  out--;
+if (in % 3)
+  out++;
+else
+  out--;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+if (in % 2)
+  out++;
+else
+  out--;
+if (in % 3)
+  out++;
+else
+  out--;
+  }
+}
+
+void test_basic12(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+  }
+}
+
+void test_basic13(int in, int &out) {
+  if (in > 77) {
+// Empty compound statement is not identical to null statement.
+  } else;
+}
+
+
+void test_chain1(int in, int &out) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: repeated branch in conditional chain [bugprone-branch-clone]
+out++;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: note: end of the original
+  else if (in > 55)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: clone 1 starts here
+out++;
+
+  out++;
+}
+
+void test_chain2(int in, int &out) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: repeated branch in conditional chain [bugprone-branch-clone]
+out++;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: note: end of the original
+  else if (in > 55)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: clone 1 starts here
+out++;
+  else if (in > 42)
+out--;
+  else if (in > 28)
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: clone 2 starts here
+out++;
+  else if (in > 12) {
+out++;
+out *= 7;
+  } else if (in > 7) {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: note: clone 3 starts here
+out++;
+  }
+}
+
+void test_chain3(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: repeate

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-11-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 174942.
JonasToth added a comment.

- Merge branch 'master' into check_const


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,563 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  const int *const p0_p_local1 = &p_local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared 'const'
+  function_in_pointer(&p_local2);
+}
+
+void function_inout_ref(int &inout);
+void function_in_ref(const int &in);
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int &r0_np_local0 = np_local0;
+  int &r1_np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int &r2_np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  const int &r0_p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be d

[PATCH] D54798: Move the llvm lit test dependencies to clang-tools-extra.

2018-11-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/CMakeLists.txt:76
+# Add lit test dependencies.
+set(llvm_utils_deps
+  FileCheck count not

Nitpicking a bit but I think it would be better to uppercase it for consistency.



Comment at: test/CMakeLists.txt:80
+foreach(dep ${llvm_utils_deps})
+  if (TARGET ${dep})
+list(APPEND CLANGD_TEST_DEPS ${dep})

…and remove the space after `if`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54798



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


[PATCH] D54796: [clangd] **Prototype**: C++ API for emitting file status

2018-11-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

The code is not polished yet, I'd like to get some high-level comments before 
moving further.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54796



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


[PATCH] D54795: [clang-format] Do not treat asm clobber [ as ObjCExpr, refined

2018-11-21 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Does this also work for _asm and __asm?


Repository:
  rC Clang

https://reviews.llvm.org/D54795



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


[PATCH] D53830: [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-11-21 Thread Alex Strelnikov via Phabricator via cfe-commits
astrelni marked 5 inline comments as done.
astrelni added a comment.

Sorry for the long delay.

I've reworked the template instantiation stuff a little bit yet again. Going to 
still come back and comment with results of profiling but I think now this 
shouldn't be much slower than if the template instantiations were filtered out 
with the matchers.




Comment at: clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp:153
+  // required so we provide only a warning.
+  std::sort(MatchedTemplateLocations.begin(), MatchedTemplateLocations.end());
+  for (SourceLocation Loc : MatchedInstantiationLocations) {

alexfh wrote:
> MatchedTemplateLocations can be a std::set or a 
> std::unordered_set filled with SourceLocation::getRawEncoding(). 
> Same for MatchedInstantiationLocations, I suppose.
Ah thank you, I didn't look hard enough after not seeing a std::hash 
specialization for SourceLocation. In that case we don't need the 
onEndOfTranslationUnit or MatchedInstantiationLocations so those are now gone. 
I added a test case for when a template is used in source before the body since 
I wasn't 100% sure that the template would be traversed before the 
instantiation.


https://reviews.llvm.org/D53830



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


[PATCH] D53830: [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-11-21 Thread Alex Strelnikov via Phabricator via cfe-commits
astrelni updated this revision to Diff 174931.

https://reviews.llvm.org/D53830

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
  clang-tidy/abseil/UpgradeDurationConversionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-upgrade-duration-conversions.cpp

Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -12,6 +12,7 @@
abseil-redundant-strcat-calls
abseil-string-find-startswith
abseil-str-cat-append
+   abseil-upgrade-duration-conversions
android-cloexec-accept
android-cloexec-accept4
android-cloexec-creat
Index: docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
===
--- docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
+++ docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
@@ -0,0 +1,43 @@
+.. title:: clang-tidy - abseil-upgrade-duration-conversions
+
+abseil-upgrade-duration-conversions
+===
+
+Finds calls to ``absl::Duration`` arithmetic operators and factories whose
+argument needs an explicit cast to continue compiling after upcoming API
+changes.
+
+The operators ``*=``, ``/=``, ``*``, and ``/`` for ``absl::Duration`` currently
+accept an argument of class type that is convertible to an arithmetic type. Such
+a call currently converts the value to an ``int64_t``, even in a case such as
+``std::atomic`` that would result in lossy conversion.
+
+Additionally, the ``absl::Duration`` factory functions (``absl::Hours``,
+``absl::Minutes``, etc) currently accept an ``int64_t`` or a floating-point
+type. Similar to the arithmetic operators, calls with an argument of class type
+that is convertible to an arithmetic type go through the ``int64_t`` path.
+
+These operators and factories will be changed to only accept arithmetic types to
+prevent unintended behavior. After these changes are released, passing an
+argument of class type will no longer compile, even if the type is implicitly
+convertible to an arithmetic type.
+
+Here are example fixes created by this check:
+
+.. code-block:: c++
+
+  std::atomic a;
+  absl::Duration d = absl::Milliseconds(a);
+  d *= a;
+
+becomes
+
+.. code-block:: c++
+
+  std::atomic a;
+  absl::Duration d = absl::Milliseconds(static_cast(a));
+  d *= static_cast(a);
+
+Note that this check always adds a cast to ``int64_t`` in order to preserve the
+current behavior of user code. It is possible that this uncovers unintended
+behavior due to types implicitly convertible to a floating-point type.
Index: test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===
--- test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -0,0 +1,473 @@
+// RUN: %check_clang_tidy %s abseil-upgrade-duration-conversions %t
+
+using int64_t = long long;
+
+// Partial implementation of relevant APIs from
+// https://github.com/abseil/abseil-cpp/blob/master/absl/time/time.h
+namespace absl {
+
+class Duration {
+public:
+  Duration &operator*=(int64_t r);
+  Duration &operator*=(float r);
+  Duration &operator*=(double r);
+  template  Duration &operator*=(T r);
+
+  Duration &operator/=(int64_t r);
+  Duration &operator/=(float r);
+  Duration &operator/=(double r);
+  template  Duration &operator/=(T r);
+};
+
+template  Duration operator*(Duration lhs, T rhs);
+template  Duration operator*(T lhs, Duration rhs);
+template  Duration operator/(Duration lhs, T rhs);
+
+constexpr Duration Nanoseconds(int64_t n);
+constexpr Duration Microseconds(int64_t n);
+constexpr Duration Milliseconds(int64_t n);
+constexpr Duration Seconds(int64_t n);
+constexpr Duration Minutes(int64_t n);
+constexpr Duration Hours(int64_t n);
+
+template  struct EnableIfFloatImpl {};
+template <> struct EnableIfFloatImpl { typedef int Type; };
+template <> struct EnableIfFloatImpl { typedef int Type; };
+template <> struct EnableIfFloatImpl { typedef int Type; };
+template  using EnableIfFloat = typename EnableIfFloatImpl::Type;
+
+template  = 0> Duration Nanoseconds(T n);
+template  = 0> Duration Microseconds(T n);
+template  = 0> Duration Milliseconds(T n);
+template  = 0> Duration Seconds(T n);
+template  = 0> Duration Minutes(T n);
+template  = 0> Duration Hours(T n);
+
+} // namespace absl
+
+template  struct ConvertibleTo {
+  operator T() const;
+};
+
+template 
+ConvertibleTo operator+(ConvertibleTo, ConvertibleTo);
+
+template 
+ConvertibleTo operator*(ConvertibleTo, ConvertibleTo);
+
+void arithmeticOperatorBasicPositive() {
+  absl::Duration d;
+  d *= ConvertibleTo();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning:

[PATCH] D54565: Introduce `-Wc++14-compat-ctad` as a subgroup of `-Wc++14-compat`

2018-11-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In https://reviews.llvm.org/D54565#1304740, @rsmith wrote:

> In the past, we've been resistant to adding more fine-grained compat 
> warnings, because we don't want to encourage subsetting the language (which 
> sounds like exactly what you're trying to do here). We generally don't think 
> it's Clang's business to enforce coding style conventions (such as "don't use 
> CTAD because it makes your code less readable"), but we do consider it to be 
> in-scope for Clang to warn on constructs that are error-prone or that have a 
> negative impact on portability or compatibility, and so on. On that basis, I 
> think there is a case to be made for warning on this specific language 
> feature, because using CTAD on class templates that weren't designed for it 
> is dangerous and creates source compatibility problems for future changes to 
> that library.


Yes, that's a good way to put it.
Personally I would go stronger: using CTAD on class templates that //were// 
designed for it (1) is dangerous and (2) may create source compatibility 
problems for future changes to that library! The Standard Library itself deals 
with (2) by simply promising not to make future changes to the library... and 
deals with (1) by making changes to the library. For example, CTAD has in the 
"past/present" had problems distinguishing `std::vector{"hello", "world"}` 
(`vector`, or UB?) from `std::vector{set.begin(), set.end()}` 
(`vector`, or `vector::iterator>`?). The guides for std::pair, 
and the guides around uses-allocator construction, seem particularly in flux, 
to my outside-observer eyes.

> However, if we consider the goal to be to warn only on using CTAD in places 
> where the class template author didn't design for it, then:

Unfortunately, I don't think the diagnostic will ever be able to detect 
"design"; the best it could do would be to detect "coding", which I don't think 
is good enough, in this case. ;)

> - this should be a separate warning, not a subgroup of `-Wc++14-compat`
> - the warning should be suppressed by any explicitly-declared deduction 
> guides for the class
> - there should be some fairly obvious way to suppress the warning in the case 
> where the deduction guides implied by the constructors already do the right 
> thing (maybe an attribute?)
> 
>   What do you think? Would that cover the use case you're trying to address 
> here, or are you really trying to enforce a style rule of "don't use CTAD 
> ever"?

Essentially the latter.

- I would be quite happy to move the diagnostic outside of `-Wc++14-compat`.
- I specifically do //not// want the diagnostic to become suppressed on 
explicitly-declared deduction guides; that would have the effect of suppressing 
it for e.g. `std::vector` and `std::pair`. That would also have the effect of 
nerfing it for user-defined types: if Alice is relying on the diagnostic to 
avoid accidental CTAD, and then Bob adds a deduction guide that solves //his// 
case without perfectly solving Alice's case, then the diagnostic will go silent 
for Alice even though the consequences of Alice's slip-up are still just as 
severe.
- I think I don't understand your third bullet. My use-case requires a 
diagnostic about the //call site//, opted into by the writer of the call-site 
(Alice). IIUC, you ask for a way that the //callee// (the author of the class 
type, or perhaps Bob) could unilaterally suppress that diagnostic. But only the 
caller is able to make the judgment call that says "I don't trust these 
deduction guides (either they're incorrect, or I think they're prone to change 
in the next release, or both); I want a diagnostic every time I 
//accidentally// rely on one of them." The callee can't tell whether any 
particular use was accidental or intentional.


Repository:
  rC Clang

https://reviews.llvm.org/D54565



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


[PATCH] D54800: [clangd] Cleanup: stop passing around list of supported URI schemes.

2018-11-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 174929.
ioeric added a comment.

- remove unused include


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54800

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/URI.cpp
  clangd/URI.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  clangd/index/Serialization.cpp
  clangd/index/Serialization.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/dex/Dex.cpp
  clangd/index/dex/Dex.h
  clangd/index/dex/dexp/Dexp.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/did-change-configuration-params.test
  test/clangd/protocol.test
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DexTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/TestTU.cpp

Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -59,8 +59,7 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = llvm::make_unique(
-  /*URISchemes=*/std::vector{}, /*UseDex=*/true);
+  auto Idx = llvm::make_unique(/*UseDex=*/true);
   Idx->updatePreamble(Filename, AST.getASTContext(), AST.getPreprocessorPtr());
   Idx->updateMain(Filename, AST);
   return std::move(Idx);
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -227,8 +227,8 @@
   : InMemoryFileSystem(new vfs::InMemoryFileSystem),
 TestHeaderName(testPath("symbol.h")),
 TestFileName(testPath("symbol.cc")) {
-TestHeaderURI = URI::createFile(TestHeaderName).toString();
-TestFileURI = URI::createFile(TestFileName).toString();
+TestHeaderURI = URI::create(TestHeaderName).toString();
+TestFileURI = URI::create(TestFileName).toString();
   }
 
   bool runSymbolCollector(StringRef HeaderCode, StringRef MainCode,
@@ -391,7 +391,7 @@
 - (void)someMethodName3:(void*)name3;
 @end
   )";
-  TestFileName = "test.m";
+  TestFileName = testPath("test.m");
   runSymbolCollector(Header, /*Main=*/"", {"-fblocks", "-xobjective-c++"});
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(
@@ -534,38 +534,22 @@
 TEST_F(SymbolCollectorTest, SymbolRelativeWithFallback) {
   TestHeaderName = "x.h";
   TestFileName = "x.cpp";
-  TestHeaderURI = URI::createFile(testPath(TestHeaderName)).toString();
+  TestHeaderURI = URI::create(testPath(TestHeaderName)).toString();
   CollectorOpts.FallbackDir = testRoot();
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(AllOf(QName("Foo"), DeclURI(TestHeaderURI;
 }
 
-TEST_F(SymbolCollectorTest, CustomURIScheme) {
+TEST_F(SymbolCollectorTest, UnittestURIScheme) {
   // Use test URI scheme from URITests.cpp
-  CollectorOpts.URISchemes.insert(CollectorOpts.URISchemes.begin(), "unittest");
   TestHeaderName = testPath("x.h");
   TestFileName = testPath("x.cpp");
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
AllOf(QName("Foo"), DeclURI("unittest:///x.h";
 }
 
-TEST_F(SymbolCollectorTest, InvalidURIScheme) {
-  // Use test URI scheme from URITests.cpp
-  CollectorOpts.URISchemes = {"invalid"};
-  runSymbolCollector("class Foo {};", /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(AllOf(QName("Foo"), DeclURI("";
-}
-
-TEST_F(SymbolCollectorTest, FallbackToFileURI) {
-  // Use test URI scheme from URITests.cpp
-  CollectorOpts.URISchemes = {"invalid", "file"};
-  runSymbolCollector("class Foo {};", /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(
-   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
-}
-
 TEST_F(SymbolCollectorTest, IncludeEnums) {
   const std::string Header = R"(
 enum {
@@ -606,7 +590,7 @@
 QName("(anonymous struct)::a")));
 }
 
-TEST_F(SymbolCollectorTest, SymbolFormedFromMacro) {
+TEST_F(SymbolCollectorTest, SymbolFormedFromRegisteredSchemeFromMacro) {
 
   Annotations Header(R"(
 #define FF(name) \
@@ -765,7 +749,7 @@
   // bits/basic_string.h$ should be mapped to 
   TestHeaderName = "/nasty/bits/basic_string.h";
   TestFileName = "/nasty/bits/basic_string.cpp";
-  TestHeaderURI = URI::createFile(TestHeaderName).toString();
+  TestHeaderURI = URI::create(TestHeaderName).toString();
   runSymbolCollector("class string {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(AllOf(QName("string"),
   DeclURI(TestHeaderURI),
@@ -835,7 +819,7 @@
   Inc

[PATCH] D54800: [clangd] Cleanup: stop passing around list of supported URI schemes.

2018-11-21 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Instead of passing around a list of supported URI schemes in clangd, we
expose an interface to convert a path to URI using any compatible scheme
that has been registered. It favors customized schemes and falls
back to "file" when no other scheme works.

Changes in this patch are:

- URI::create(AbsPath, URISchemes) -> URI::create(AbsPath). The new API finds a

compatible scheme from the registry.

- Remove URISchemes option everywhere (ClangdServer, SymbolCollecter, FileIndex 
etc).
- Unit tests will use "unittest" by default.
- Move "test" scheme from ClangdLSPServer to ClangdMain.cpp, and only

register the test scheme when lit-test or enable-lit-scheme is set.
(The new flag is added to make lit protocol.test work; I wonder if there
is alternative here.)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54800

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/URI.cpp
  clangd/URI.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  clangd/index/Serialization.cpp
  clangd/index/Serialization.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/dex/Dex.cpp
  clangd/index/dex/Dex.h
  clangd/index/dex/dexp/Dexp.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/did-change-configuration-params.test
  test/clangd/protocol.test
  unittests/clangd/BackgroundIndexTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DexTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/TestTU.cpp

Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -59,8 +59,7 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = llvm::make_unique(
-  /*URISchemes=*/std::vector{}, /*UseDex=*/true);
+  auto Idx = llvm::make_unique(/*UseDex=*/true);
   Idx->updatePreamble(Filename, AST.getASTContext(), AST.getPreprocessorPtr());
   Idx->updateMain(Filename, AST);
   return std::move(Idx);
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -227,8 +227,8 @@
   : InMemoryFileSystem(new vfs::InMemoryFileSystem),
 TestHeaderName(testPath("symbol.h")),
 TestFileName(testPath("symbol.cc")) {
-TestHeaderURI = URI::createFile(TestHeaderName).toString();
-TestFileURI = URI::createFile(TestFileName).toString();
+TestHeaderURI = URI::create(TestHeaderName).toString();
+TestFileURI = URI::create(TestFileName).toString();
   }
 
   bool runSymbolCollector(StringRef HeaderCode, StringRef MainCode,
@@ -391,7 +391,7 @@
 - (void)someMethodName3:(void*)name3;
 @end
   )";
-  TestFileName = "test.m";
+  TestFileName = testPath("test.m");
   runSymbolCollector(Header, /*Main=*/"", {"-fblocks", "-xobjective-c++"});
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(
@@ -534,38 +534,22 @@
 TEST_F(SymbolCollectorTest, SymbolRelativeWithFallback) {
   TestHeaderName = "x.h";
   TestFileName = "x.cpp";
-  TestHeaderURI = URI::createFile(testPath(TestHeaderName)).toString();
+  TestHeaderURI = URI::create(testPath(TestHeaderName)).toString();
   CollectorOpts.FallbackDir = testRoot();
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(AllOf(QName("Foo"), DeclURI(TestHeaderURI;
 }
 
-TEST_F(SymbolCollectorTest, CustomURIScheme) {
+TEST_F(SymbolCollectorTest, UnittestURIScheme) {
   // Use test URI scheme from URITests.cpp
-  CollectorOpts.URISchemes.insert(CollectorOpts.URISchemes.begin(), "unittest");
   TestHeaderName = testPath("x.h");
   TestFileName = testPath("x.cpp");
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(
AllOf(QName("Foo"), DeclURI("unittest:///x.h";
 }
 
-TEST_F(SymbolCollectorTest, InvalidURIScheme) {
-  // Use test URI scheme from URITests.cpp
-  CollectorOpts.URISchemes = {"invalid"};
-  runSymbolCollector("class Foo {};", /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(AllOf(QName("Foo"), DeclURI("";
-}
-
-TEST_F(SymbolCollectorTest, FallbackToFileURI) {
-  // Use test URI scheme from URITests.cpp
-  CollectorOpts.URISchemes = {"invalid", "file"};
-  runSymbolCollector("class Foo {};", /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(
-   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
-}
-
 TEST_F(SymbolCollectorTest, IncludeEnums) {
   const std

[PATCH] D54799: [clangd][WIP] textDocument/CursorInfo method

2018-11-21 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: sammccall, arphaman, benlangmuir.
Herald added subscribers: cfe-commits, kadircet, dexonsmith, MaskRay, ioeric, 
ilya-biryukov.

Hi,

I implemented `textDocument/cursorInfo` method based on consensus in 
https://reviews.llvm.org/D54529.
I'd like to ask for early feedback - what's still missing is relevant client 
capability.

Couple things that I'd love to hear opinions about are:

- conditional return in `getCursorInfo` - Should we return for example data 
with empty `USR`?
- `containerName` of local variables - It's currently empty even if semantic 
parent has a name (say it's a function). (Please search for local.cpp in the 
test.) Is that what we want?
- For now I used `getSymbolAtPosition()` as it's simpler and fits the context 
better. However I assume I could use this optimization from 
`tooling::getNamedDeclAt()` (in a separate patch): 
https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Refactoring/Rename/USRFinder.cpp#L82
- One thing I am wondering about is whether we could use (and whether it's a 
significant improvement) some early return in `indexTopLevelDecls` (using 
`DeclarationAndMacrosFinder`) also for hover and definition use-cases. Is it 
correct to assume that at a given `Location` there can be maximum of one 
declaration and one definition?

P. S. Alex and Ben have thanksgiving break now so they'll probably add any 
feedback next week.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54799

Files:
  ClangdLSPServer.cpp
  ClangdLSPServer.h
  ClangdServer.cpp
  ClangdServer.h
  Protocol.cpp
  Protocol.h
  XRefs.cpp
  XRefs.h
  clangd/cursor-info.test

Index: clangd/cursor-info.test
===
--- /dev/null
+++ clangd/cursor-info.test
@@ -0,0 +1,46 @@
+# RUN: clangd -lit-test < %s | FileCheck %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///simple.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/cursorInfo","params":{"textDocument":{"uri":"test:///simple.cpp"},"position":{"line":0,"character":27}}}
+#  CHECK:"containerName": "",
+# CHECK-NEXT:"id": "CA2EBE44A1D76D2A1547D47BC6D51EBF",
+# CHECK-NEXT:"name": "foo",
+# CHECK-NEXT:"usr": "c:@F@foo#"
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///nested-decl.cpp","languageId":"cpp","version":1,"text":"namespace nnn { struct aaa {}; void foo() { aaa a; }; }"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/cursorInfo","params":{"textDocument":{"uri":"test:///nested-decl.cpp"},"position":{"line":0,"character":46}}}
+#  CHECK:"containerName": "nnn::",
+# CHECK-NEXT:"id": "20237FF18EB405D842456DC5D578426D",
+# CHECK-NEXT:"name": "aaa",
+# CHECK-NEXT:"usr": "c:@N@nnn@S@aaa"
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///reference.cpp","languageId":"cpp","version":1,"text":"int value; void foo(int) {} void bar() { foo(value); }"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/cursorInfo","params":{"textDocument":{"uri":"test:///reference.cpp"},"position":{"line":0,"character":48}}}
+#  CHECK:"containerName": "",
+# CHECK-NEXT:"id": "844613FB2393C9D40A2AFF25D5D316A1",
+# CHECK-NEXT:"name": "value",
+# CHECK-NEXT:"usr": "c:@value"
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///local.cpp","languageId":"cpp","version":1,"text":"void foo() { int aaa; int bbb = aaa; }"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/cursorInfo","params":{"textDocument":{"uri":"test:///local.cpp"},"position":{"line":0,"character":33}}}
+#  CHECK:"containerName": "",
+# CHECK-NEXT:"id": "C05589F2664B06F392C2C438568E55E0",
+# CHECK-NEXT:"name": "aaa",
+# CHECK-NEXT:"usr": "c:local.cpp@13@F@foo#@aaa"
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///macro.cpp","languageId":"cpp","version":1,"text":"#define MACRO 5\nint i = MACRO;"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/cursorInfo","params":{"textDocument":{"uri":"test:///macro.cpp"},"position":{"line":1,"character":11}}}
+#  CHECK:"containerName": "",
+# CHECK-NEXT:"id": "29EB506CBDF1BA6D1B6EC203FF03B384",
+# CHECK-NEXT:"name": "MACRO",
+# CHECK-NEXT:"usr": "c:macro.cpp@24@macro@MACRO"
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: XRefs.h
===
--- XRefs.h
+++ XRefs.h
@@ -38,6 +38,9 @@
 std::vector findReferences(ParsedAST &AST, Position Pos,
  const Symbo

[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-21 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In https://reviews.llvm.org/D54757#1305306, @Eugene.Zelenko wrote:

> In https://reviews.llvm.org/D54757#1305114, @whisperity wrote:
>
> > Bar the previous comments, I really like this. The test suite is massive 
> > and well-constructed. Do we know of any real-world findings, maybe even 
> > from LLVM?
>
>
> GCC 7 introduced -Wduplicated-branches, so will be good idea to run this 
> check on associated regression(s).


Compared to Donát's checker, GCC's warning seems much more underperforming. See 
https://godbolt.org/z/Iq3FC9.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54757



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


[PATCH] D52713: Move llvm util dependencies from clang-tools-extra to add_lit_target.

2018-11-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D52713#1305291, @mgorny wrote:

> This particular build method uses system-wide installation of these tools.


Sounds fair enough. I sent you two patches to move this back to 
clang-tools-extra.


Repository:
  rL LLVM

https://reviews.llvm.org/D52713



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


[PATCH] D54798: Move the llvm lit test dependencies to clang-tools-extra.

2018-11-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: mgorny.

Part of revert r343473


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54798

Files:
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -71,6 +71,17 @@
   clangd-indexer
   dexp
   )
+
+# Add lit test dependencies.
+set(llvm_utils_deps
+  FileCheck count not
+)
+foreach(dep ${llvm_utils_deps})
+  if (TARGET ${dep})
+list(APPEND CLANGD_TEST_DEPS ${dep})
+  endif()
+endforeach()
+
 foreach(clangd_dep ${CLANGD_TEST_DEPS})
   list(APPEND CLANG_TOOLS_TEST_DEPS
${clangd_dep})


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -71,6 +71,17 @@
   clangd-indexer
   dexp
   )
+
+# Add lit test dependencies.
+set(llvm_utils_deps
+  FileCheck count not
+)
+foreach(dep ${llvm_utils_deps})
+  if (TARGET ${dep})
+list(APPEND CLANGD_TEST_DEPS ${dep})
+  endif()
+endforeach()
+
 foreach(clangd_dep ${CLANGD_TEST_DEPS})
   list(APPEND CLANG_TOOLS_TEST_DEPS
${clangd_dep})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In https://reviews.llvm.org/D54757#1305114, @whisperity wrote:

> Bar the previous comments, I really like this. The test suite is massive and 
> well-constructed. Do we know of any real-world findings, maybe even from LLVM?


GCC 7 introduced -Wduplicated-branches, so will be good idea to run this check 
on associated regression(s).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54757



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


[PATCH] D54466: [Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators stored in a region

2018-11-21 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D54466#1297887, @NoQ wrote:

> > I marked this patch as WIP because I could not create a test-case for it. 
> > However in real projects this patch seems to reduce false positives 
> > significantly.
>
> False positives are hard to reduce via delta-debugging because they can be 
> accidentally reduced into true positives, because the distinction between 
> true positives and false positives cannot be tested automatically. But once 
> you fix the false positive, `creduce` can be used to reduce them by writing 
> down the condition as "the positive is there on the original clang but not on 
> the modified clang". Strongly recommended :)


`creduce` did not work (continous `clang_delta` crash) but somehow I managed to 
create tests.

>> Hmmm, shouldn't we add this to `MemRegion`'s interface instead?

This:

> I wouldn't insist, but this does indeed sound useful. I suggest 
> `MemRegion::getMostDerivedObjectRegion()` or something like that.

vs

> Also, ugh, that nomenclature: the base region of `CXXBaseObjectRegion` in 
> fact represents the //derived// object.

So if `CXXBaseObjectRegion` is the derived object, then 
`MemRegion::getMostDerivedObjectRegion()` gets the least derived object region 
now?


https://reviews.llvm.org/D54466



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


[PATCH] D54253: [OpenCL] Launch opencl-types.cl test only on x86

2018-11-21 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov updated this revision to Diff 174919.
AlexeySachkov retitled this revision from "[OpenCL][NFC] Improve test coverage 
of test/Index/opencl-types.cl" to "[OpenCL] Launch opencl-types.cl test only on 
x86".
AlexeySachkov edited the summary of this revision.
AlexeySachkov added a comment.

Simplified patch. Updated title and description


https://reviews.llvm.org/D54253

Files:
  test/Index/opencl-types.cl


Index: test/Index/opencl-types.cl
===
--- test/Index/opencl-types.cl
+++ test/Index/opencl-types.cl
@@ -1,4 +1,5 @@
 // RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// REQUIRES: x86
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable


Index: test/Index/opencl-types.cl
===
--- test/Index/opencl-types.cl
+++ test/Index/opencl-types.cl
@@ -1,4 +1,5 @@
 // RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// REQUIRES: x86
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54466: [Analyzer] Iterator Checkers - Use the region of the topmost base class for iterators stored in a region

2018-11-21 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 174917.
baloghadamsoftware retitled this revision from "[Analyzer] [WIP] Iterator 
Checkers - Use the base region of C++ Base Object Regions (recursively) for 
iterators stored in a region" to "[Analyzer] Iterator Checkers - Use the region 
of the topmost base class for iterators stored in a region".
baloghadamsoftware edited the summary of this revision.

https://reviews.llvm.org/D54466

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Core/MemRegion.cpp
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -200,3 +200,38 @@
   ++i0;
   *++i0; // expected-warning{{Iterator accessed outside of its range}}
 }
+
+struct simple_iterator_base {
+  simple_iterator_base();
+  simple_iterator_base(const simple_iterator_base& rhs);
+  simple_iterator_base &operator=(const simple_iterator_base& rhs);
+  virtual ~simple_iterator_base();
+  bool friend operator==(const simple_iterator_base &lhs,
+ const simple_iterator_base &rhs);
+  bool friend operator!=(const simple_iterator_base &lhs,
+ const simple_iterator_base &rhs);
+private:
+  int *ptr;
+};
+
+struct simple_derived_iterator: public simple_iterator_base {
+  int& operator*();
+  int* operator->();
+  simple_iterator_base &operator++();
+  simple_iterator_base operator++(int);
+  simple_iterator_base &operator--();
+  simple_iterator_base operator--(int);
+};
+
+struct simple_container {
+  simple_derived_iterator begin();
+  simple_derived_iterator end();
+};
+
+void good_derived(simple_container c) {
+  auto i0 = c.end();
+  if (i0 != c.end()) {
+clang_analyzer_warnIfReached();
+*i0; // no-warning
+  }
+}
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1175,6 +1175,20 @@
   return R;
 }
 
+// getgetMostDerivedObjectRegion gets the region of the root class of a C++
+// class hierarchy.
+const MemRegion *MemRegion::getMostDerivedObjectRegion() const {
+  const MemRegion *R = this;
+  while (true) {
+if (R->getKind() == MemRegion::CXXBaseObjectRegionKind) {
+R = cast(R)->getSuperRegion();
+continue;
+}
+break;
+  }
+  return R;
+}
+
 bool MemRegion::isSubRegionOf(const MemRegion *) const {
   return false;
 }
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -1089,9 +1089,7 @@
 void IteratorChecker::verifyMatch(CheckerContext &C, const SVal &Iter,
   const MemRegion *Cont) const {
   // Verify match between a container and the container of an iterator
-  while (const auto *CBOR = Cont->getAs()) {
-Cont = CBOR->getSuperRegion();
-  }
+  Cont = Cont->getMostDerivedObjectRegion();
 
   auto State = C.getState();
   const auto *Pos = getIteratorPosition(State, Iter);
@@ -1125,9 +1123,7 @@
   if (!ContReg)
 return;
 
-  while (const auto *CBOR = ContReg->getAs()) {
-ContReg = CBOR->getSuperRegion();
-  }
+  ContReg = ContReg->getMostDerivedObjectRegion();
 
   // If the container already has a begin symbol then use it. Otherwise first
   // create a new one.
@@ -1151,9 +1147,7 @@
   if (!ContReg)
 return;
 
-  while (const auto *CBOR = ContReg->getAs()) {
-ContReg = CBOR->getSuperRegion();
-  }
+  ContReg = ContReg->getMostDerivedObjectRegion();
 
   // If the container already has an end symbol then use it. Otherwise first
   // create a new one.
@@ -1174,9 +1168,7 @@
 void IteratorChecker::assignToContainer(CheckerContext &C, const Expr *CE,
 const SVal &RetVal,
 const MemRegion *Cont) const {
-  while (const auto *CBOR = Cont->getAs()) {
-Cont = CBOR->getSuperRegion();
-  }
+  Cont = Cont->getMostDerivedObjectRegion();
 
   auto State = C.getState();
   auto &SymMgr = C.getSymbolManager();
@@ -1194,9 +1186,7 @@
   if (!ContReg)
 return;
 
-  while (const auto *CBOR = ContReg->getAs()) {
-ContReg = CBOR->getSuperRegion();
-  }
+  ContReg = ContReg->getMostDerivedObjectRegion();
 
   // Assignment of a new value to a container always invalidates all its
   // iterators
@@ -1211,9 +1201,7 @@
   if (!OldCont.isUndef()) {
 const auto *OldContReg = OldCont.getAsRegion();
 if (OldContReg) {
-  while (const auto *CBOR = OldContReg->getAs()) {
-OldContReg = CBOR->getSuperRegion();
-  }
+  OldContReg = OldContReg->getMostDerivedObjectRegion();
   const auto OldCData = getContainerData(Stat

[PATCH] D52713: Move llvm util dependencies from clang-tools-extra to add_lit_target.

2018-11-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This particular build method uses system-wide installation of these tools.


Repository:
  rL LLVM

https://reviews.llvm.org/D52713



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-21 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In https://reviews.llvm.org/D53157#1305233, @kpn wrote:

> In https://reviews.llvm.org/D53157#1304347, @uweigand wrote:
>
> > But given that there is still infrastructure missing in the IR optimizers, 
> > I also think that at least in the first implementation, we probably should 
> > go with the original approach and just use constrained intrinsics 
> > everywhere in the function, and possibly add some function attribute that 
> > prevent any cross-inlining of functions built with constrained intrinsics 
> > with functions built with regular floating-point operations.
>
>
> Subtle. This last sentence seems to imply that cross-inlining should be 
> allowed when there are no regular floating point operations in the function 
> to be inlined. This makes sense due to, for example, the common use of tiny 
> functions just to retrieve a value. Do I interpret your statement correctly?


Sure, that would be an optimization.  Another potential optimization would be 
to **allow** inlining, but have the inliner automatically replace regular 
floating-point operations with constrained intrinsics in the target routine ... 
  But all of that is probably "stage2" after an initial implementation that 
just disables inlining.


https://reviews.llvm.org/D53157



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


[PATCH] D54796: [clangd] **Prototype**: C++ API for emitting file status

2018-11-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric, javed.absar, ilya-biryukov.

This is a quick prototype (with hacky implementation).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54796

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h

Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -52,6 +52,27 @@
   unsigned MaxRetainedASTs = 3;
 };
 
+/// Indicates the current status of the file in ClangdServer.
+/// FIXME: should we add error code (e.g. severity)?
+struct FileStatus {
+  enum class State {
+Unknown,
+Preparing, // Build system is preparing for the file.
+Wait,  // The file is waiting in the queue to be processed.
+Building,  // The file is being built.
+Ready, // The file is ready.
+
+// FIXME: others?
+  };
+
+
+  State S;
+  // A detailed message of the status, which can be shown in the status bar.
+  // This can contain details, e.g. the compile command used to build the file;
+  // whether the preamble/AST is reused.
+  std::string Message;
+};
+
 class ParsingCallbacks {
 public:
   virtual ~ParsingCallbacks() = default;
@@ -101,8 +122,9 @@
   /// Schedule an update for \p File. Adds \p File to a list of tracked files if
   /// \p File was not part of it before.
   /// FIXME(ibiryukov): remove the callback from this function.
-  void update(PathRef File, ParseInputs Inputs, WantDiagnostics WD,
-  llvm::unique_function)> OnUpdated);
+  void update(
+  PathRef File, ParseInputs Inputs, WantDiagnostics WD,
+  llvm::unique_function)> OnUpdated);
 
   /// Remove \p File from the list of tracked files and schedule removal of its
   /// resources.
Index: clangd/TUScheduler.cpp
===
--- clangd/TUScheduler.cpp
+++ clangd/TUScheduler.cpp
@@ -176,7 +176,7 @@
   ~ASTWorker();
 
   void update(ParseInputs Inputs, WantDiagnostics,
-  llvm::unique_function)> OnUpdated);
+  llvm::unique_function)> OnUpdated);
   void runWithAST(StringRef Name,
   unique_function)> Action);
   bool blockUntilIdle(Deadline Timeout) const;
@@ -333,8 +333,9 @@
 }
 
 void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags,
-   unique_function)> OnUpdated) {
+   unique_function)> OnUpdated) {
   auto Task = [=](decltype(OnUpdated) OnUpdated) mutable {
+OnUpdated(FileStatus{FileStatus::State::Building, "Building"}, {});
 // Will be used to check if we can avoid rebuilding the AST.
 bool InputsAreTheSame =
 std::tie(FileInputs.CompileCommand, FileInputs.Contents) ==
@@ -397,6 +398,7 @@
 // current file at this point?
 log("Skipping rebuild of the AST for {0}, inputs are the same.",
 FileName);
+OnUpdated({FileStatus::State::Ready, "Ready"}, {});
 return;
   }
 }
@@ -417,15 +419,15 @@
 // spam us with updates.
 // Note *AST can still be null if buildAST fails.
 if (*AST) {
-  OnUpdated((*AST)->getDiagnostics());
+  OnUpdated({FileStatus::State::Ready, "Ready"}, (*AST)->getDiagnostics());
   trace::Span Span("Running main AST callback");
   Callbacks.onMainAST(FileName, **AST);
   DiagsWereReported = true;
 }
 // Stash the AST in the cache for further use.
 IdleASTs.put(this, std::move(*AST));
   };
-
+  OnUpdated({FileStatus::State::Wait, "Wait"}, {});
   startTask("Update", Bind(Task, std::move(OnUpdated)), WantDiags);
 }
 
@@ -697,7 +699,7 @@
 
 void TUScheduler::update(PathRef File, ParseInputs Inputs,
  WantDiagnostics WantDiags,
- unique_function)> OnUpdated) {
+ unique_function)> OnUpdated) {
   std::unique_ptr &FD = Files[File];
   if (!FD) {
 // Create a new worker to process the AST-related tasks.
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -43,6 +43,9 @@
   /// Called by ClangdServer when \p Diagnostics for \p File are ready.
   virtual void onDiagnosticsReady(PathRef File,
   std::vector Diagnostics) = 0;
+
+  /// Called by ClangdServer when the status of file is updated.
+  virtual void onFileUpdated(PathRef File, FileStatus Status) = 0;
 };
 
 /// Manages a collection of source files and derived data (ASTs, indexes),
@@ -229,6 +232,7 @@
   typedef uint64_t DocVersion;
 
   void consumeDiagnostics(PathRef File, DocVersion Version,
+  FileStatus FS,
   std::vector Diags);
 
   tooling::CompileCommand getCompileCommand(PathRef File);
Index: clangd/ClangdServ

[PATCH] D54760: [clangd] Cleanup: make the diags callback global in TUScheduler

2018-11-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.h:232
+  /// addDocument. Used to avoid races when sending diagnostics to the clients.
+  static Key DocVersionKey;
 

sammccall wrote:
> I'm not sure using context here buys much: there aren't many layers, they're 
> fairly coupled, and this information would look pretty natural in the 
> interfaces.
> 
> What about:
>  - move the definition of DocVersion to TUScheduler
>  - make DocVersion a member of ParseInputs
>  - pass (PathRef, DocVersion, vector) to the TUScheduler's diag callback
I'd keep it separate: `ParseInputs` is defined in `ClangdUnit.cpp` and it 
serves the purpose of defining everything we need to run the compiler.
Adding `DocVersion` there would make no sense: it's of no use to the actual 
code doing preamble builds or parsing.

I would rather aim to get rid of `DocVersion` (for this particular purpose, 
there are other ways to fix the raciness that the DocVersions workaround).
WDYT?



Comment at: clangd/TUScheduler.h:92
+  ASTRetentionPolicy RetentionPolicy,
+  DiagsCallback OnDiags = nullptr);
   ~TUScheduler();

sammccall wrote:
> ISTM the callback would fit nicely on the ASTCallbacks?
> It even gets plumbed through to ASTWorker correctly by reference.
Done. This is definitely less plumbing, but IMO the public interface looks a 
bit worse now.
Consuming ASTs and diagnostics are two independent concerns and it's a bit 
awkward to combine them in the same struct.

But we don't have too many callers, updating those is easy.



Comment at: unittests/clangd/TUSchedulerTests.cpp:32
 
-void ignoreUpdate(Optional>) {}
 void ignoreError(Error Err) {
   handleAllErrors(std::move(Err), [](const ErrorInfoBase &) {});

sammccall wrote:
> (up to you if you feel like fixing while here)
> this is just llvm::consumeError
Will fix in a separate commit, like it more when cleanups are the only thing in 
the commit.



Comment at: unittests/clangd/TUSchedulerTests.cpp:38
+/// cancelled.
+void updateWithCallback(TUScheduler &S, PathRef File, ParseInputs Inputs,
+WantDiagnostics WD, llvm::unique_function CB) {

sammccall wrote:
> ParseInputs is always getInputs(File), you could do that here (similarly for 
> `updateWithDiags`) to avoid repetition.
It's actually a bit more complicated: `getInputs(File, Contents)`, note the 
second parameter. 
Done anyway, definitely looks better (and less prone to mistakes!).

The calls are now `updateWith(S, File, Contents...)`, there's one place that 
still relies on the `Inputs` though (checks the VFS does not change in the 
following read).




Comment at: unittests/clangd/TUSchedulerTests.cpp:495
   /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
-  ASTRetentionPolicy());
+  ASTRetentionPolicy(), captureDiags);
 

sammccall wrote:
> can we just increment a counter in the callback, and have DoUpdate look for a 
> delta?
Maybe... I haven't looked closely into the test, would prefer to keep this 
change mostly mechanical and avoid digging into the test logic.
Happy to take a look into simplifying the test separately, of course.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54760



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


[PATCH] D54760: [clangd] Cleanup: make the diags callback global in TUScheduler

2018-11-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 174914.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Merge the diagnostics callback into ParsingCallbacks
- updateWithDiags(File, getInputs(File...)) -> updateWithDiags(File, ...)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54760

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -10,6 +10,7 @@
 #include "Context.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -28,7 +29,6 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-void ignoreUpdate(Optional>) {}
 void ignoreError(Error Err) {
   handleAllErrors(std::move(Err), [](const ErrorInfoBase &) {});
 }
@@ -40,11 +40,62 @@
buildTestFS(Files, Timestamps), std::move(Contents)};
   }
 
+void updateWithCallback(TUScheduler &S, PathRef File, StringRef Contents,
+WantDiagnostics WD, llvm::unique_function CB) {
+  WithContextValue Ctx(llvm::make_scope_exit(std::move(CB)));
+  S.update(File, getInputs(File, Contents), WD);
+}
+
+static Key)>>
+DiagsCallbackKey;
+
+/// A diagnostics callback that should be passed to TUScheduler when it's used
+/// in updateWithDiags.
+static std::unique_ptr captureDiags() {
+  class CaptureDiags : public ParsingCallbacks {
+void onDiagnostics(PathRef File, std::vector Diags) override {
+  auto D = Context::current().get(DiagsCallbackKey);
+  if (!D)
+return;
+  const_cast)> &> (
+  *D)(File, Diags);
+}
+  };
+  return llvm::make_unique();
+}
+
+/// Schedule an update and call \p CB with the diagnostics it produces, if any.
+/// The TUScheduler should be created with captureDiags as a DiagsCallback for
+/// this to work.
+void updateWithDiags(TUScheduler &S, PathRef File, ParseInputs Inputs,
+ WantDiagnostics WD,
+ llvm::unique_function)> CB) {
+  Path OrigFile = File.str();
+  WithContextValue Ctx(
+  DiagsCallbackKey,
+  Bind(
+  [OrigFile](decltype(CB) CB, PathRef File, std::vector Diags) {
+assert(File == OrigFile);
+CB(std::move(Diags));
+  },
+  std::move(CB)));
+  S.update(File, std::move(Inputs), WD);
+}
+
+  void updateWithDiags(TUScheduler &S, PathRef File, llvm::StringRef Contents,
+  WantDiagnostics WD,
+  llvm::unique_function)> CB) {
+return updateWithDiags(S, File, getInputs(File, Contents), WD, std::move(CB));
+  }
+
   StringMap Files;
   StringMap Timestamps;
   MockCompilationDatabase CDB;
 };
 
+Key)>>
+TUSchedulerTests::DiagsCallbackKey;
+
 TEST_F(TUSchedulerTests, MissingFiles) {
   TUScheduler S(getDefaultAsyncThreadsCount(),
 /*StorePreamblesInMemory=*/true, /*ASTCallbacks=*/nullptr,
@@ -57,7 +108,7 @@
   auto Missing = testPath("missing.cpp");
   Files[Missing] = "";
 
-  S.update(Added, getInputs(Added, ""), WantDiagnostics::No, ignoreUpdate);
+  S.update(Added, getInputs(Added, ""), WantDiagnostics::No);
 
   // Assert each operation for missing file is an error (even if it's available
   // in VFS).
@@ -104,25 +155,25 @@
 Notification Ready;
 TUScheduler S(
 getDefaultAsyncThreadsCount(),
-/*StorePreamblesInMemory=*/true, /*ASTCallbacks=*/nullptr,
+/*StorePreamblesInMemory=*/true, captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
 auto Path = testPath("foo.cpp");
-S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
- [&](std::vector) { Ready.wait(); });
-
-S.update(Path, getInputs(Path, "request diags"), WantDiagnostics::Yes,
- [&](std::vector Diags) { ++CallbackCount; });
-S.update(Path, getInputs(Path, "auto (clobbered)"), WantDiagnostics::Auto,
- [&](std::vector Diags) {
-   ADD_FAILURE() << "auto should have been cancelled by auto";
- });
-S.update(Path, getInputs(Path, "request no diags"), WantDiagnostics::No,
- [&](std::vector Diags) {
-   ADD_FAILURE() << "no diags should not be called back";
- });
-S.update(Path, getInputs(Path, "auto (produces)"), WantDiagnostics::Auto,
- [&](std::vector Diags) { ++CallbackCount; });
+updateWithDiags(S, Path, "", WantDiagnostics::Yes,
+[&](std::vector) { Ready.wait(); });
+updateWithDiags(S, Path, "request diags", WantDiagnostics::Yes,
+[&](std::vector) { ++CallbackCount; });
+updateWithDiags(S, Path, "auto (clobbered)",
+

[PATCH] D54795: [clang-format] Do not treat asm clobber [ as ObjCExpr, refined

2018-11-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: cfe-commits.

r346756 refined clang-format to not treat the `[` in `asm (...: [] ..)` as an
ObjCExpr. However that's not enough, as we might have a comma-separated list of
such clobbers as in the newly added test.
This updates the detection to instead look at the Line's first token being `asm`
and not mark `[`-s as ObjCExprs in this case.


Repository:
  rC Clang

https://reviews.llvm.org/D54795

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12762,6 +12762,12 @@
" : [d] \"=rm\" (d)\n"
"   [e] \"rm\" (*e));\n"
"}"));
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h",
+   "void f() {\n"
+   "  asm (\"mov %[e], %[d]\"\n"
+   " : [d] \"=rm\" (d),\n"
+   "   [e] \"rm\" (*e));\n"
+   "}"));
   EXPECT_EQ(FormatStyle::LK_Cpp,
 guessLanguage("foo.h", "void f() {\n"
"  asm volatile (\"mov %[e], %[d]\"\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -399,14 +399,15 @@
 bool IsCpp11AttributeSpecifier = isCpp11AttributeSpecifier(*Left) ||
  Contexts.back().InCpp11AttributeSpecifier;
 
+bool InsideInlineASM = Line.startsWith(tok::kw_asm);
 bool StartsObjCMethodExpr =
-!CppArrayTemplates && Style.isCpp() && !IsCpp11AttributeSpecifier &&
-Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
+!InsideInlineASM && !CppArrayTemplates && Style.isCpp() &&
+!IsCpp11AttributeSpecifier && Contexts.back().CanBeExpression &&
+Left->isNot(TT_LambdaLSquare) &&
 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
 (!Parent ||
- (Parent->is(tok::colon) && Parent->isNot(TT_InlineASMColon)) ||
- Parent->isOneOf(tok::l_square, tok::l_paren, tok::kw_return,
- tok::kw_throw) ||
+ Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
+ tok::kw_return, tok::kw_throw) ||
  Parent->isUnaryOperator() ||
  // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12762,6 +12762,12 @@
" : [d] \"=rm\" (d)\n"
"   [e] \"rm\" (*e));\n"
"}"));
+  EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h",
+   "void f() {\n"
+   "  asm (\"mov %[e], %[d]\"\n"
+   " : [d] \"=rm\" (d),\n"
+   "   [e] \"rm\" (*e));\n"
+   "}"));
   EXPECT_EQ(FormatStyle::LK_Cpp,
 guessLanguage("foo.h", "void f() {\n"
"  asm volatile (\"mov %[e], %[d]\"\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -399,14 +399,15 @@
 bool IsCpp11AttributeSpecifier = isCpp11AttributeSpecifier(*Left) ||
  Contexts.back().InCpp11AttributeSpecifier;
 
+bool InsideInlineASM = Line.startsWith(tok::kw_asm);
 bool StartsObjCMethodExpr =
-!CppArrayTemplates && Style.isCpp() && !IsCpp11AttributeSpecifier &&
-Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
+!InsideInlineASM && !CppArrayTemplates && Style.isCpp() &&
+!IsCpp11AttributeSpecifier && Contexts.back().CanBeExpression &&
+Left->isNot(TT_LambdaLSquare) &&
 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
 (!Parent ||
- (Parent->is(tok::colon) && Parent->isNot(TT_InlineASMColon)) ||
- Parent->isOneOf(tok::l_square, tok::l_paren, tok::kw_return,
- tok::kw_throw) ||
+ Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
+ to

[PATCH] D53699: [ASTImporter] Fix inequality of functions with different attributes

2018-11-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.
Herald added a subscriber: gamesh411.

That's a good point. I agree, we should check some bits (calling convention 
bits) but not all (e.g. noreturn bit). I am going to create another patch which 
replaces this.


Repository:
  rC Clang

https://reviews.llvm.org/D53699



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In https://reviews.llvm.org/D53157#1304347, @uweigand wrote:

> But given that there is still infrastructure missing in the IR optimizers, I 
> also think that at least in the first implementation, we probably should go 
> with the original approach and just use constrained intrinsics everywhere in 
> the function, and possibly add some function attribute that prevent any 
> cross-inlining of functions built with constrained intrinsics with functions 
> built with regular floating-point operations.


Subtle. This last sentence seems to imply that cross-inlining should be allowed 
when there are no regular floating point operations in the function to be 
inlined. This makes sense due to, for example, the common use of tiny functions 
just to retrieve a value. Do I interpret your statement correctly?


https://reviews.llvm.org/D53157



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


[PATCH] D52713: Move llvm util dependencies from clang-tools-extra to add_lit_target.

2018-11-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a subscriber: chapuni.
hokein added a comment.

Hi @mgorny, sorry for the trouble it might cause.

In https://reviews.llvm.org/D52713#1305164, @mgorny wrote:

> I would like to request reverting this. It's established standard within LLVM 
> to explicitly specify the dependencies the particular test suite relies on.
>  This change causes the `-DLLVM_OCAML_OUT_OF_TREE=1` to start wrongly 
> depending on additional test utility targets, causing building an unnecessary 
> second copy of LLVMSupport.


I'm not an expert on this. It seems to me that `FileCheck, count, not` are 
reasonable dependencies to `lit` tests, and from what I se, lit tests of 
`llvm`, `clang` and `clang-tools-extra` are using these dep tools.
+ @chapuni, maybe you have ideas here? since you are the original author of the 
code r301762 
.


Repository:
  rL LLVM

https://reviews.llvm.org/D52713



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


[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2018-11-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

In the meanwhile we managed to figure out where the problem lays, so if you're 
interested, I'm going to document it here.

The problem this patch attempts to solve is that `ConditionBRVisitor` adds 
event pieces to the bugpath when the state has changed from the previous state, 
not only when the `ConstraintManager` differs in between the changes [1]. The 
patch attempts to solve this by inspecting the actual condition, and tries to 
find out whether the symbols inside that condition has changed in between the 
states, but this is overkill solution, as comparing the two `ConstraintManager` 
objects would achieve the same thing. This should probably be executed by 
extending the interface of `ConstraintManager` with a comparison method.

[1] 
https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp#L1808


https://reviews.llvm.org/D53076



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


[PATCH] D54746: [clangd] Respect task cancellation in TUScheduler.

2018-11-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clangd/TUScheduler.cpp:598
+if (!isCancelled(I->Ctx))
+  continue;
+// Cancelled reads are moved to the front of the queue and run immediately.

NIT: maybe also break on non-cancelled reads? Going past this point does not 
seem particularly useful, as we won't be able to cancel any pending updates 
before them anyway. And it does not seem like responding for a cancelled task 
fast is higher priority than delivering the results of that non-cancelled read.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54746



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


[clang-tools-extra] r347390 - Revert 347366, its prerequisite 347364 got reverted.

2018-11-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Nov 21 04:49:22 2018
New Revision: 347390

URL: http://llvm.org/viewvc/llvm-project?rev=347390&view=rev
Log:
Revert 347366, its prerequisite 347364 got reverted.

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp

clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp?rev=347390&r1=347389&r2=347390&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp 
Wed Nov 21 04:49:22 2018
@@ -65,16 +65,16 @@ static unsigned getMaxCalculationWidth(c
 if (Bop->getOpcode() == BO_Add)
   return std::max(LHSWidth, RHSWidth) + 1;
 if (Bop->getOpcode() == BO_Rem) {
-  Expr::EvalResult Result;
-  if (Bop->getRHS()->EvaluateAsInt(Result, Context))
-return Result.Val.getInt().getActiveBits();
+  llvm::APSInt Val;
+  if (Bop->getRHS()->EvaluateAsInt(Val, Context))
+return Val.getActiveBits();
 } else if (Bop->getOpcode() == BO_Shl) {
-  Expr::EvalResult Result;
-  if (Bop->getRHS()->EvaluateAsInt(Result, Context)) {
+  llvm::APSInt Bits;
+  if (Bop->getRHS()->EvaluateAsInt(Bits, Context)) {
 // We don't handle negative values and large values well. It is assumed
 // that compiler warnings are written for such values so the user will
 // fix that.
-return LHSWidth + Result.Val.getInt().getExtValue();
+return LHSWidth + Bits.getExtValue();
   }
 
   // Unknown bitcount, assume there is truncation.

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp?rev=347390&r1=347389&r2=347390&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp 
Wed Nov 21 04:49:22 2018
@@ -76,13 +76,10 @@ void SuspiciousMemsetUsageCheck::check(c
 // Case 2: fill_char of memset() is larger in size than an unsigned char
 // so it gets truncated during conversion.
 
+llvm::APSInt NumValue;
 const auto UCharMax = (1 << Result.Context->getCharWidth()) - 1;
-Expr::EvalResult EVResult;
-if (!NumFill->EvaluateAsInt(EVResult, *Result.Context))
-  return;
-
-llvm::APSInt NumValue = EVResult.Val.getInt();
-if (NumValue >= 0 && NumValue <= UCharMax)
+if (!NumFill->EvaluateAsInt(NumValue, *Result.Context) ||
+(NumValue >= 0 && NumValue <= UCharMax))
   return;
 
 diag(NumFill->getBeginLoc(), "memset fill value is out of unsigned "
@@ -97,22 +94,18 @@ void SuspiciousMemsetUsageCheck::check(c
 const Expr *ByteCount = Call->getArg(2);
 
 // Return if `byte_count` is not zero at compile time.
-Expr::EvalResult Value2;
+llvm::APSInt Value1, Value2;
 if (ByteCount->isValueDependent() ||
-!ByteCount->EvaluateAsInt(Value2, *Result.Context) ||
-Value2.Val.getInt() != 0)
+!ByteCount->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0)
   return;
 
 // Return if `fill_char` is known to be zero or negative at compile
 // time. In these cases, swapping the args would be a nop, or
 // introduce a definite bug. The code is likely correct.
-Expr::EvalResult EVResult;
 if (!FillChar->isValueDependent() &&
-FillChar->EvaluateAsInt(EVResult, *Result.Context)) {
-  llvm::APSInt Value1 = EVResult.Val.getInt();
-  if (Value1 == 0 || Value1.isNegative())
-return;
-}
+FillChar->EvaluateAsInt(Value1, *Result.Context) &&
+(Value1 == 0 || Value1.isNegative()))
+  return;
 
 // `byte_count` is known to be zero at compile time, and `fill_char` is
 // either not known or known to be a positive integer. Emit a warning

Modified: 
clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp?rev=347390&r1=347389&r2=347390&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp 
Wed Nov 21 04:49:22 2018
@@ -101,8 +101,8 @@ void ProperlySeededRandomGenera

r347389 - Revert r347364 again, the fix was incomplete.

2018-11-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Nov 21 04:47:43 2018
New Revision: 347389

URL: http://llvm.org/viewvc/llvm-project?rev=347389&view=rev
Log:
Revert r347364 again, the fix was incomplete.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/Analysis/builtin-functions.cpp
cfe/trunk/test/Sema/builtins.c
cfe/trunk/test/SemaCXX/compound-literal.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=347389&r1=347388&r2=347389&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Nov 21 04:47:43 2018
@@ -600,7 +600,7 @@ public:
 
   /// EvaluateAsInt - Return true if this is a constant which we can fold and
   /// convert to an integer, using any crazy technique that we want to.
-  bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx,
+  bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
  SideEffectsKind AllowSideEffects = SE_NoSideEffects) 
const;
 
   /// EvaluateAsFloat - Return true if this is a constant which we can fold and
@@ -901,15 +901,10 @@ public:
 
 /// ConstantExpr - An expression that occurs in a constant context.
 class ConstantExpr : public FullExpr {
+public:
   ConstantExpr(Expr *subexpr)
 : FullExpr(ConstantExprClass, subexpr) {}
 
-public:
-  static ConstantExpr *Create(const ASTContext &Context, Expr *E) {
-assert(!isa(E));
-return new (Context) ConstantExpr(E);
-  }
-
   /// Build an empty constant expression wrapper.
   explicit ConstantExpr(EmptyShell Empty)
 : FullExpr(ConstantExprClass, Empty) {}
@@ -3092,8 +3087,8 @@ inline Expr *Expr::IgnoreImpCasts() {
   while (true)
 if (ImplicitCastExpr *ice = dyn_cast(e))
   e = ice->getSubExpr();
-else if (FullExpr *fe = dyn_cast(e))
-  e = fe->getSubExpr();
+else if (ConstantExpr *ce = dyn_cast(e))
+  e = ce->getSubExpr();
 else
   break;
   return e;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=347389&r1=347388&r2=347389&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Nov 21 04:47:43 2018
@@ -6380,7 +6380,7 @@ ExpectedStmt ASTNodeImporter::VisitConst
   Expr *ToSubExpr;
   std::tie(ToSubExpr) = *Imp;
 
-  return ConstantExpr::Create(Importer.getToContext(), ToSubExpr);
+  return new (Importer.getToContext()) ConstantExpr(ToSubExpr);
 }
 
 ExpectedStmt ASTNodeImporter::VisitParenExpr(ParenExpr *E) {

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=347389&r1=347388&r2=347389&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Nov 21 04:47:43 2018
@@ -2594,8 +2594,8 @@ Expr *Expr::IgnoreParenCasts() {
   E = NTTP->getReplacement();
   continue;
 }
-if (FullExpr *FE = dyn_cast(E)) {
-  E = FE->getSubExpr();
+if (ConstantExpr *CE = dyn_cast(E)) {
+  E = CE->getSubExpr();
   continue;
 }
 return E;
@@ -2619,8 +2619,8 @@ Expr *Expr::IgnoreCasts() {
   E = NTTP->getReplacement();
   continue;
 }
-if (FullExpr *FE = dyn_cast(E)) {
-  E = FE->getSubExpr();
+if (ConstantExpr *CE = dyn_cast(E)) {
+  E = CE->getSubExpr();
   co

[PATCH] D54787: [PowerPC] Vector load/store builtins overstate alignment of pointers

2018-11-21 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: hfinkel, jsji, wuzish.
Herald added subscribers: kristina, kbarton.

A number of builtins in altivec.h load/store vectors from pointers to scalar 
types. Currently they just cast the pointer to a vector pointer, but 
expressions like that have the alignment of the target type. Of course, the 
input pointer did not have that alignment so this triggers UBSan (and rightly 
so).

This resolves https://bugs.llvm.org/show_bug.cgi?id=39704


Repository:
  rC Clang

https://reviews.llvm.org/D54787

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -1638,51 +1638,51 @@
 // CHECK-LE: @llvm.ppc.altivec.vsro
 
 res_vsll = vec_xl(sll, asll);
-// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 1
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 1
 
 res_vull = vec_xl(sll, aull);
-// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 1
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 1
 
 res_vd = vec_xl(sll, ad);
-// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
-// CHECK-LE: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 1
+// CHECK-LE: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 1
 
 vec_xst(vsll, sll, asll);
-// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
 
 vec_xst(vull, sll, aull);
-// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
 
 vec_xst(vd, sll, ad);
-// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
-// CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 1
+// CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 1
 
 res_vsll = vec_xl_be(sll, asll);
-// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 1
 // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
 
 res_vull = vec_xl_be(sll, aull);
-// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 1
 // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
 
 res_vd = vec_xl_be(sll, ad);
-// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 1
 // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
 
 vec_xst_be(vsll, sll, asll);
-// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
 // CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
 
 vec_xst_be(vull, sll, aull);
-// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
 // CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
 
 vec_xst_be(vd, sll, ad);
-// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 1
 // CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
 
   res_vf = vec_neg(vf);
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -9362,137 +9362,137 @@
   // CHECK-LABEL: define void @test9
   // CHECK-LE-LABEL: define void @test9
   res_vsc = vec_xl(param_sll, ¶m_sc);
-  // CHECK: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 16
-  // CHECK-LE: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 16
+  // CHECK: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 1
+  // CHECK-LE: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 1
 
   res_vuc = vec_xl(param_sll, ¶m_uc);
-  // CHECK: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 16
-  // CHECK-LE: load <16 x i8>,

[PATCH] D52713: Move llvm util dependencies from clang-tools-extra to add_lit_target.

2018-11-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I would like to request reverting this. It's established standard within LLVM 
to explicitly specify the dependencies the particular test suite relies on.

This change causes the `-DLLVM_OCAML_OUT_OF_TREE=1` to start wrongly depending 
on additional test utility targets, causing building an unnecessary second copy 
of LLVMSupport.


Repository:
  rL LLVM

https://reviews.llvm.org/D52713



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


[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-11-21 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.
Herald added a reviewer: shafik.
Herald added a subscriber: gamesh411.



Comment at: lib/AST/ASTImporter.cpp:7716
   }
 }
 

balazske wrote:
> This can be simplified by removing brace characters and removing `ToD`.
Good catch, changed it.


Repository:
  rC Clang

https://reviews.llvm.org/D53755



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


[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-11-21 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 174897.
martong marked an inline comment as done.
martong removed a reviewer: shafik.
martong removed a subscriber: gamesh411.
martong added a comment.
Herald added a reviewer: shafik.

- Better style without braces


Repository:
  rC Clang

https://reviews.llvm.org/D53755

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExternalASTMerger.cpp


Index: lib/AST/ExternalASTMerger.cpp
===
--- lib/AST/ExternalASTMerger.cpp
+++ lib/AST/ExternalASTMerger.cpp
@@ -144,14 +144,14 @@
 }
 if (auto *ToTag = dyn_cast(To)) {
   ToTag->setHasExternalLexicalStorage();
-  ToTag->setMustBuildLookupTable();
+  ToTag->getPrimaryContext()->setMustBuildLookupTable();
   assert(Parent.CanComplete(ToTag));
 } else if (auto *ToNamespace = dyn_cast(To)) {
   ToNamespace->setHasExternalVisibleStorage();
   assert(Parent.CanComplete(ToNamespace));
 } else if (auto *ToContainer = dyn_cast(To)) {
   ToContainer->setHasExternalLexicalStorage();
-  ToContainer->setMustBuildLookupTable();
+  ToContainer->getPrimaryContext()->setMustBuildLookupTable();
   assert(Parent.CanComplete(ToContainer));
 }
 return To;
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1580,6 +1580,9 @@
 return Err;
 
   ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
 
   return Error::success();
 }
@@ -7721,17 +7724,12 @@
   return ToAttr;
 }
 
-Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
-  llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
-  if (Pos != ImportedDecls.end()) {
-Decl *ToD = Pos->second;
-// FIXME: move this call to ImportDeclParts().
-if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, 
ToD))
-  llvm::consumeError(std::move(Err));
-return ToD;
-  } else {
+Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
+  auto Pos = ImportedDecls.find(FromD);
+  if (Pos != ImportedDecls.end())
+return Pos->second;
+  else
 return nullptr;
-  }
 }
 
 Decl *ASTImporter::Import(Decl *FromD) {
Index: include/clang/AST/ASTImporter.h
===
--- include/clang/AST/ASTImporter.h
+++ include/clang/AST/ASTImporter.h
@@ -198,7 +198,7 @@
 /// Return the copy of the given declaration in the "to" context if
 /// it has already been imported from the "from" context.  Otherwise return
 /// NULL.
-Decl *GetAlreadyImportedOrNull(Decl *FromD);
+Decl *GetAlreadyImportedOrNull(const Decl *FromD) const;
 
 /// Import the given declaration context from the "from"
 /// AST context into the "to" AST context.


Index: lib/AST/ExternalASTMerger.cpp
===
--- lib/AST/ExternalASTMerger.cpp
+++ lib/AST/ExternalASTMerger.cpp
@@ -144,14 +144,14 @@
 }
 if (auto *ToTag = dyn_cast(To)) {
   ToTag->setHasExternalLexicalStorage();
-  ToTag->setMustBuildLookupTable();
+  ToTag->getPrimaryContext()->setMustBuildLookupTable();
   assert(Parent.CanComplete(ToTag));
 } else if (auto *ToNamespace = dyn_cast(To)) {
   ToNamespace->setHasExternalVisibleStorage();
   assert(Parent.CanComplete(ToNamespace));
 } else if (auto *ToContainer = dyn_cast(To)) {
   ToContainer->setHasExternalLexicalStorage();
-  ToContainer->setMustBuildLookupTable();
+  ToContainer->getPrimaryContext()->setMustBuildLookupTable();
   assert(Parent.CanComplete(ToContainer));
 }
 return To;
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -1580,6 +1580,9 @@
 return Err;
 
   ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(D));
+  if (ToD)
+if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
+  return Err;
 
   return Error::success();
 }
@@ -7721,17 +7724,12 @@
   return ToAttr;
 }
 
-Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
-  llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
-  if (Pos != ImportedDecls.end()) {
-Decl *ToD = Pos->second;
-// FIXME: move this call to ImportDeclParts().
-if (Error Err = ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, ToD))
-  llvm::consumeError(std::move(Err));
-return ToD;
-  } else {
+Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
+  auto Pos = ImportedDecls.find(FromD);
+  if (Pos != ImportedDecls.end())
+return Pos->second;
+  else
 return nullptr;
-  }
 }
 
 Decl *ASTImporter::Import(Decl *FromD) {
Index: include/clang/AST/ASTImporter.h
===

[PATCH] D53655: [ASTImporter] Fix redecl chain of classes and class templates

2018-11-21 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 174893.
martong marked 4 inline comments as done.
martong added a comment.
Herald added a reviewer: shafik.
Herald added a subscriber: gamesh411.

- Minor style changes and rename a function


Repository:
  rC Clang

https://reviews.llvm.org/D53655

Files:
  include/clang/AST/DeclContextInternals.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclBase.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/StructuralEquivalenceTest.cpp

Index: unittests/AST/StructuralEquivalenceTest.cpp
===
--- unittests/AST/StructuralEquivalenceTest.cpp
+++ unittests/AST/StructuralEquivalenceTest.cpp
@@ -597,6 +597,77 @@
   EXPECT_FALSE(testStructuralMatch(R0, R1));
 }
 
+TEST_F(StructuralEquivalenceRecordTest, AnonymousRecordsShouldBeInequivalent) {
+  auto t = makeTuDecls(
+  R"(
+  struct X {
+struct {
+  int a;
+};
+struct {
+  int b;
+};
+  };
+  )",
+  "", Lang_C);
+  auto *TU = get<0>(t);
+  auto *A = FirstDeclMatcher().match(
+  TU, indirectFieldDecl(hasName("a")));
+  auto *FA = cast(A->chain().front());
+  RecordDecl *RA = cast(FA->getType().getTypePtr())->getDecl();
+  auto *B = FirstDeclMatcher().match(
+  TU, indirectFieldDecl(hasName("b")));
+  auto *FB = cast(B->chain().front());
+  RecordDecl *RB = cast(FB->getType().getTypePtr())->getDecl();
+
+  ASSERT_NE(RA, RB);
+  EXPECT_TRUE(testStructuralMatch(RA, RA));
+  EXPECT_TRUE(testStructuralMatch(RB, RB));
+  EXPECT_FALSE(testStructuralMatch(RA, RB));
+}
+
+TEST_F(StructuralEquivalenceRecordTest,
+   RecordsAreInequivalentIfOrderOfAnonRecordsIsDifferent) {
+  auto t = makeTuDecls(
+  R"(
+  struct X {
+struct { int a; };
+struct { int b; };
+  };
+  )",
+  R"(
+  struct X { // The order is reversed.
+struct { int b; };
+struct { int a; };
+  };
+  )",
+  Lang_C);
+
+  auto *TU = get<0>(t);
+  auto *A = FirstDeclMatcher().match(
+  TU, indirectFieldDecl(hasName("a")));
+  auto *FA = cast(A->chain().front());
+  RecordDecl *RA = cast(FA->getType().getTypePtr())->getDecl();
+
+  auto *TU1 = get<1>(t);
+  auto *A1 = FirstDeclMatcher().match(
+  TU1, indirectFieldDecl(hasName("a")));
+  auto *FA1 = cast(A1->chain().front());
+  RecordDecl *RA1 = cast(FA1->getType().getTypePtr())->getDecl();
+
+  RecordDecl *X =
+  FirstDeclMatcher().match(TU, recordDecl(hasName("X")));
+  RecordDecl *X1 =
+  FirstDeclMatcher().match(TU1, recordDecl(hasName("X")));
+  ASSERT_NE(X, X1);
+  EXPECT_FALSE(testStructuralMatch(X, X1));
+
+  ASSERT_NE(RA, RA1);
+  EXPECT_TRUE(testStructuralMatch(RA, RA));
+  EXPECT_TRUE(testStructuralMatch(RA1, RA1));
+  EXPECT_FALSE(testStructuralMatch(RA1, RA));
+}
+
 TEST_F(StructuralEquivalenceRecordTest,
UnnamedRecordsShouldBeInequivalentEvenIfTheSecondIsBeingDefined) {
   auto Code =
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -11,9 +11,10 @@
 //
 //===--===//
 
+#include "clang/AST/ASTImporter.h"
 #include "MatchVerifier.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTImporter.h"
+#include "clang/AST/DeclContextInternals.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
@@ -1808,6 +1809,65 @@
   EXPECT_NE(To0->getCanonicalDecl(), To1->getCanonicalDecl());
 }
 
+TEST_P(ASTImporterTestBase, AnonymousRecords) {
+  auto *Code =
+  R"(
+  struct X {
+struct { int a; };
+struct { int b; };
+  };
+  )";
+  Decl *FromTU0 = getTuDecl(Code, Lang_C, "input0.c");
+
+  Decl *FromTU1 = getTuDecl(Code, Lang_C, "input1.c");
+
+  auto *X0 =
+  FirstDeclMatcher().match(FromTU0, recordDecl(hasName("X")));
+  auto *X1 =
+  FirstDeclMatcher().match(FromTU1, recordDecl(hasName("X")));
+  Import(X0, Lang_C);
+  Import(X1, Lang_C);
+
+  auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  // We expect no (ODR) warning during the import.
+  EXPECT_EQ(0u, ToTU->getASTContext().getDiagnostics().getNumWarnings());
+  EXPECT_EQ(1u,
+DeclCounter().match(ToTU, recordDecl(hasName("X";
+}
+
+TEST_P(ASTImporterTestBase, AnonymousRecordsReversed) {
+  Decl *FromTU0 = getTuDecl(
+  R"(
+  struct X {
+struct { int a; };
+struct { int b; };
+  };
+  )",
+  Lang_C, "input0.c");
+
+  Decl *FromTU1 = getTuDecl(
+  R"(
+  struct X { // reversed order
+struct { int b; };
+struct { int a; };
+  };
+  )",
+  Lang_C, "input1.c");
+
+  auto *X0 =
+  FirstDeclMatcher().match(FromTU0, recordDecl(hasName("X")));

[PATCH] D53655: [ASTImporter] Fix redecl chain of classes and class templates

2018-11-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/DeclBase.cpp:1469
 assert(Pos != Map->end() && "no lookup entry for decl");
-if (Pos->second.getAsVector() || Pos->second.getAsDecl() == ND)
+// Remove the decl only if it is contained.
+if ((Pos->second.getAsVector() && Pos->second.containsInVector(ND)) ||

Szelethus wrote:
> Contained in?
Indeed, `containedInVector` sounds better, so I renamed.


Repository:
  rC Clang

https://reviews.llvm.org/D53655



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


[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2018-11-21 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Bar the previous comments, I really like this. The test suite is massive and 
well-constructed. Do we know of any real-world findings, maybe even from LLVM?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54757



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


[PATCH] D54784: Use --push/pop-state with XRay link deps

2018-11-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: dberris.
Herald added a subscriber: cfe-commits.

XRay runtime link deps handling passes --no-as-needed, but it never
undoes it and this flag may affect other libraries that come later on
the link line. To avoid this, wrap XRay link deps in --push/pop-state.


Repository:
  rC Clang

https://reviews.llvm.org/D54784

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/XRay/xray-shared-noxray.cpp


Index: clang/test/Driver/XRay/xray-shared-noxray.cpp
===
--- clang/test/Driver/XRay/xray-shared-noxray.cpp
+++ clang/test/Driver/XRay/xray-shared-noxray.cpp
@@ -7,6 +7,9 @@
 //
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}
+// STATIC: "--push-state"
+// STATIC: "--no-as-needed"
+// STATIC: "--pop-state"
 //
 // REQUIRES: linux, enable_shared
 int foo() { return 42; }
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -788,6 +788,7 @@
 }
 
 void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   CmdArgs.push_back("-lpthread");
   if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
@@ -798,6 +799,7 @@
   TC.getTriple().getOS() != llvm::Triple::NetBSD &&
   TC.getTriple().getOS() != llvm::Triple::OpenBSD)
 CmdArgs.push_back("-ldl");
+  CmdArgs.push_back("--pop-state");
 }
 
 bool tools::areOptimizationsEnabled(const ArgList &Args) {


Index: clang/test/Driver/XRay/xray-shared-noxray.cpp
===
--- clang/test/Driver/XRay/xray-shared-noxray.cpp
+++ clang/test/Driver/XRay/xray-shared-noxray.cpp
@@ -7,6 +7,9 @@
 //
 // SHARED-NOT: {{clang_rt\.xray-}}
 // STATIC: {{clang_rt\.xray-}}
+// STATIC: "--push-state"
+// STATIC: "--no-as-needed"
+// STATIC: "--pop-state"
 //
 // REQUIRES: linux, enable_shared
 int foo() { return 42; }
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -788,6 +788,7 @@
 }
 
 void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
+  CmdArgs.push_back("--push-state");
   CmdArgs.push_back("--no-as-needed");
   CmdArgs.push_back("-lpthread");
   if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
@@ -798,6 +799,7 @@
   TC.getTriple().getOS() != llvm::Triple::NetBSD &&
   TC.getTriple().getOS() != llvm::Triple::OpenBSD)
 CmdArgs.push_back("-ldl");
+  CmdArgs.push_back("--pop-state");
 }
 
 bool tools::areOptimizationsEnabled(const ArgList &Args) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits