r353922 - [test] Fix the test from SVN r353917 when running without lld available

2019-02-12 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Feb 12 23:50:21 2019
New Revision: 353922

URL: http://llvm.org/viewvc/llvm-project?rev=353922=rev
Log:
[test] Fix the test from SVN r353917 when running without lld available

These tests still relies on the default linker not to be overridden
via e.g. CLANG_DEFAULT_LINKER in cmake.

Modified:
cfe/trunk/test/Driver/instrprof-ld.c

Modified: cfe/trunk/test/Driver/instrprof-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/instrprof-ld.c?rev=353922=353921=353922=diff
==
--- cfe/trunk/test/Driver/instrprof-ld.c (original)
+++ cfe/trunk/test/Driver/instrprof-ld.c Tue Feb 12 23:50:21 2019
@@ -122,10 +122,10 @@
 // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
 // CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
 //
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fuse-ld=lld \
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-mingw32 -fprofile-instr-generate \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64 %s
 //
-// CHECK-MINGW-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
+// CHECK-MINGW-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-MINGW-X86-64: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}windows{{/|}}libclang_rt.profile-x86_64.a"


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


[PATCH] D58107: [MinGW] Add the profiling library when necessary

2019-02-12 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353917: [MinGW] Add the profiling library when necessary 
(authored by mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58107?vs=186411=186588#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58107

Files:
  cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
  cfe/trunk/test/Driver/instrprof-ld.c


Index: cfe/trunk/test/Driver/instrprof-ld.c
===
--- cfe/trunk/test/Driver/instrprof-ld.c
+++ cfe/trunk/test/Driver/instrprof-ld.c
@@ -121,3 +121,11 @@
 //
 // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
 // CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fuse-ld=lld \
+// RUN: -target x86_64-mingw32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64 %s
+//
+// CHECK-MINGW-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
+// CHECK-MINGW-X86-64: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}windows{{/|}}libclang_rt.profile-x86_64.a"
Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -264,6 +264,8 @@
 CmdArgs.push_back(Args.MakeArgString("--no-whole-archive"));
   }
 
+  TC.addProfileRTLibs(Args, CmdArgs);
+
   if (!HasWindowsApp) {
 // Add system libraries. If linking to libwindowsapp.a, that import
 // library replaces all these and we shouldn't accidentally try to


Index: cfe/trunk/test/Driver/instrprof-ld.c
===
--- cfe/trunk/test/Driver/instrprof-ld.c
+++ cfe/trunk/test/Driver/instrprof-ld.c
@@ -121,3 +121,11 @@
 //
 // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
 // CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fuse-ld=lld \
+// RUN: -target x86_64-mingw32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64 %s
+//
+// CHECK-MINGW-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
+// CHECK-MINGW-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}windows{{/|}}libclang_rt.profile-x86_64.a"
Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -264,6 +264,8 @@
 CmdArgs.push_back(Args.MakeArgString("--no-whole-archive"));
   }
 
+  TC.addProfileRTLibs(Args, CmdArgs);
+
   if (!HasWindowsApp) {
 // Add system libraries. If linking to libwindowsapp.a, that import
 // library replaces all these and we shouldn't accidentally try to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353917 - [MinGW] Add the profiling library when necessary

2019-02-12 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Feb 12 23:26:54 2019
New Revision: 353917

URL: http://llvm.org/viewvc/llvm-project?rev=353917=rev
Log:
[MinGW] Add the profiling library when necessary

Profiling still doesn't seem to work properly, but this at least
hooks up the library and eases completing whatever is missing.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/test/Driver/instrprof-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=353917=353916=353917=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Feb 12 23:26:54 2019
@@ -264,6 +264,8 @@ void tools::MinGW::Linker::ConstructJob(
 CmdArgs.push_back(Args.MakeArgString("--no-whole-archive"));
   }
 
+  TC.addProfileRTLibs(Args, CmdArgs);
+
   if (!HasWindowsApp) {
 // Add system libraries. If linking to libwindowsapp.a, that import
 // library replaces all these and we shouldn't accidentally try to

Modified: cfe/trunk/test/Driver/instrprof-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/instrprof-ld.c?rev=353917=353916=353917=diff
==
--- cfe/trunk/test/Driver/instrprof-ld.c (original)
+++ cfe/trunk/test/Driver/instrprof-ld.c Tue Feb 12 23:26:54 2019
@@ -121,3 +121,11 @@
 //
 // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
 // CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fuse-ld=lld \
+// RUN: -target x86_64-mingw32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64 %s
+//
+// CHECK-MINGW-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
+// CHECK-MINGW-X86-64: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}windows{{/|}}libclang_rt.profile-x86_64.a"


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


[PATCH] D58106: [compiler-rt] [profile] Provide lprofGetHostName for all windows environments

2019-02-12 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353918: [profile] Provide lprofGetHostName for all windows 
environments (authored by mstorsjo, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D58106?vs=186410=186589#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58106

Files:
  compiler-rt/trunk/lib/profile/InstrProfilingUtil.c


Index: compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
===
--- compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
@@ -80,7 +80,7 @@
 
 #endif
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 COMPILER_RT_VISIBILITY int lprofGetHostName(char *Name, int Len) {
   WCHAR Buffer[COMPILER_RT_MAX_HOSTLEN];
   DWORD BufferSize = sizeof(Buffer);


Index: compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
===
--- compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/trunk/lib/profile/InstrProfilingUtil.c
@@ -80,7 +80,7 @@
 
 #endif
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 COMPILER_RT_VISIBILITY int lprofGetHostName(char *Name, int Len) {
   WCHAR Buffer[COMPILER_RT_MAX_HOSTLEN];
   DWORD BufferSize = sizeof(Buffer);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58157: Stop enabling clang-tools-extra automatically when clang is in LLVM_ENABLE_PROJECTS

2019-02-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added subscribers: cfe-commits, lebedev.ri.
lebedev.ri added a comment.

cfe-commits (if cfe-dev proper) should probably also be part of this 
disscussion.


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

https://reviews.llvm.org/D58157



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


[PATCH] D58165: [Headers][mips] Add `__attribute__((__mode__(__unwind_word__)))` to the _Unwind_Word / _Unwind_SWord definitions

2019-02-12 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
atanasyan added reviewers: rnk, thakis, craig.topper.
Herald added subscribers: jrtc27, arichardson, sdardis.
Herald added a project: clang.

The rationale of this change is to fix _Unwind_Word / _Unwind_SWord definitions 
for MIPS N32 ABI. This ABI uses 32-bit pointers, but _Unwind_Word and 
_Unwind_SWord types are eight bytes long.

1. The __attribute__((__mode__(__unwind_word__))) is added to the type 
definitions. It makes them equal to the corresponding definitions used by GCC 
and allows to override types using `getUnwindWordWidth` function.
2. The `getUnwindWordWidth` virtual function override in the `MipsTargetInfo` 
class and provides correct type size values.


Repository:
  rC Clang

https://reviews.llvm.org/D58165

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/lib/Basic/Targets/Mips.h
  clang/lib/Headers/unwind.h
  clang/test/Sema/attr-mode.c


Index: clang/test/Sema/attr-mode.c
===
--- clang/test/Sema/attr-mode.c
+++ clang/test/Sema/attr-mode.c
@@ -6,6 +6,12 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 
-fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
+// RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -DTEST_MIPS_N32 
-fsyntax-only \
+// RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -DTEST_MIPS_64 -fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -33,7 +39,7 @@
 int c32_test[sizeof(c32) == 8 ? 1 : -1];
 typedef _Complex float c64 __attribute((mode(DC)));
 
-#ifndef TEST_64BIT_PPC64 // Note, 'XC' mode is illegal for PPC64 machines.
+#if !defined(__ppc__) && !defined(__mips__) // Note, 'XC' mode is illegal for 
PPC64 and MIPS machines.
 typedef _Complex float c80 __attribute((mode(XC)));
 #endif
 
@@ -84,6 +90,15 @@
 void f_ft128_complex_arg(_Complex long double *x);
 void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
 void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
+#elif TEST_MIPS_32
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 4 ? 1 : -1];
+#elif TEST_MIPS_N32
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+#elif TEST_MIPS_64
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
 #else
 #error Unknown test architecture.
 #endif
Index: clang/lib/Headers/unwind.h
===
--- clang/lib/Headers/unwind.h
+++ clang/lib/Headers/unwind.h
@@ -66,8 +66,8 @@
 #pragma GCC visibility push(default)
 #endif
 
-typedef uintptr_t _Unwind_Word;
-typedef intptr_t _Unwind_Sword;
+typedef uintptr_t _Unwind_Word __attribute__((__mode__(__unwind_word__)));
+typedef intptr_t _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
 typedef uintptr_t _Unwind_Ptr;
 typedef uintptr_t _Unwind_Internal_Ptr;
 typedef uint64_t _Unwind_Exception_Class;
Index: clang/lib/Basic/Targets/Mips.h
===
--- clang/lib/Basic/Targets/Mips.h
+++ clang/lib/Basic/Targets/Mips.h
@@ -401,6 +401,8 @@
 return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
   }
 
+  unsigned getUnwindWordWidth() const override;
+
   bool validateTarget(DiagnosticsEngine ) const override;
 };
 } // namespace targets
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -215,6 +215,14 @@
  Builtin::FirstTSBuiltin);
 }
 
+unsigned MipsTargetInfo::getUnwindWordWidth() const {
+  return llvm::StringSwitch(ABI)
+  .Case("o32", 32)
+  .Case("n32", 64)
+  .Case("n64", 64)
+  .Default(getPointerWidth(0));
+}
+
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine ) const {
   // microMIPS64R6 backend was removed.
   if (getTriple().isMIPS64() && IsMicromips && (ABI == "n32" || ABI == "n64")) 
{


Index: clang/test/Sema/attr-mode.c
===
--- clang/test/Sema/attr-mode.c
+++ clang/test/Sema/attr-mode.c
@@ -6,6 +6,12 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
+// RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -DTEST_MIPS_N32 -fsyntax-only \
+// RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -DTEST_MIPS_64 -fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ 

[libunwind] r353915 - [CMake] Don't cache LLVM_MAIN_SRC_DIR

2019-02-12 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Feb 12 23:09:26 2019
New Revision: 353915

URL: http://llvm.org/viewvc/llvm-project?rev=353915=rev
Log:
[CMake] Don't cache LLVM_MAIN_SRC_DIR

If we're not in a standalone build, this variable should be already
set, so there's no need to set it again or to cache it.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=353915=353914=353915=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Feb 12 23:09:26 2019
@@ -115,7 +115,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
 else()
-  set(LLVM_MAIN_SRC_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "Path to LLVM source 
tree")
   set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
 endif()
 


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


[PATCH] D56305: [AArch64] Support reserving arbitrary general purpose registers

2019-02-12 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:318
 
+  if (Args.hasArg(options::OPT_ffixed_x0))
+Features.push_back("+reserve-x0");

efriedma wrote:
> trong wrote:
> > trong wrote:
> > > phosek wrote:
> > > > trong wrote:
> > > > > What happens (should happen) if we reserve x0 and compile a function 
> > > > > with a return value?
> > > > Clang throws `error: AArch64 doesn't support function calls if any of 
> > > > the argument registers is reserved.` as for any other argument register.
> > > Yes, if x0 is reserved, it can't be used to pass arguments. But what 
> > > happens if x0 is used to return a value? For example:
> > > ```
> > > int foo() {
> > > return 1;
> > > }
> > > ```
> > > It would be helpful if compiling `foo()` with x0 reserved threw an error.
> > OTOH, [[ https://godbolt.org/z/jWW09Y | gcc ]] doesn't complain, so maybe 
> > we're OK here.
> IIRC gcc never reports any errors for its version of these flags; that 
> doesn't mean we should accept constructs which don't have defined behavior.  
> I'd prefer to print an error in any situation where we would implicitly use a 
> reserved register.
I've looked into it, but there are several places where LLVM assumes and uses 
x0, so I think it's safer for now to disallow reserving x0 just like we do with 
x19.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56305



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


[PATCH] D58164: Block+lambda: allow reference capture

2019-02-12 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added reviewers: rjmccall, ahatanak.
Herald added subscribers: cfe-commits, dexonsmith, jkorous.
Herald added a project: clang.

Capturing a C++ object by reference wasn't quite working when mixing block and 
lambda.


Repository:
  rC Clang

https://reviews.llvm.org/D58164

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenCXX/lambda-capturing-block.cpp


Index: test/CodeGenCXX/lambda-capturing-block.cpp
===
--- /dev/null
+++ test/CodeGenCXX/lambda-capturing-block.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -S -emit-llvm -std=c++17 
-fblocks -fcxx-exceptions -o - %s | FileCheck %s
+
+extern "C" {
+
+struct derp {
+derp() {}
+derp(const derp& _Src) {}
+derp(derp&& _Src) {}
+~derp() {}
+void cancel() const{}
+};
+
+// CHECK-LABEL: test(
+void test() {
+  derp c;  
+  auto b = [&](auto const& func) noexcept {
+auto block = ^() {
+  try {
+func();
+  } catch (...) {
+c.cancel();
+  }
+};
+block();
+  };
+   
+  b([](){});
+}
+
+}
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -625,8 +625,13 @@
 } else if (CI.hasCopyExpr()) {
   info.NeedsCopyDispose = true;
   info.HasCXXObject = true;
-  if (!VT->getAsCXXRecordDecl()->isExternallyVisible())
-info.CapturesNonExternalType = true;
+  if (auto *T = VT->getAsTagDecl()) {
+if (T->isExternallyVisible())
+  info.CapturesNonExternalType = true;
+  } else if (auto *P = VT->getPointeeCXXRecordDecl()) {
+if (P->isExternallyVisible())
+  info.CapturesNonExternalType = true;
+  }
 
 // So do C structs that require non-trivial copy construction or
 // destruction.


Index: test/CodeGenCXX/lambda-capturing-block.cpp
===
--- /dev/null
+++ test/CodeGenCXX/lambda-capturing-block.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -S -emit-llvm -std=c++17 -fblocks -fcxx-exceptions -o - %s | FileCheck %s
+
+extern "C" {
+
+struct derp {
+derp() {}
+derp(const derp& _Src) {}
+derp(derp&& _Src) {}
+~derp() {}
+void cancel() const{}
+};
+
+// CHECK-LABEL: test(
+void test() {
+  derp c;	
+  auto b = [&](auto const& func) noexcept {
+auto block = ^() {
+  try {
+func();
+  } catch (...) {
+c.cancel();
+  }
+};
+block();
+  };
+	
+  b([](){});
+}
+
+}
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -625,8 +625,13 @@
 } else if (CI.hasCopyExpr()) {
   info.NeedsCopyDispose = true;
   info.HasCXXObject = true;
-  if (!VT->getAsCXXRecordDecl()->isExternallyVisible())
-info.CapturesNonExternalType = true;
+  if (auto *T = VT->getAsTagDecl()) {
+if (T->isExternallyVisible())
+  info.CapturesNonExternalType = true;
+  } else if (auto *P = VT->getPointeeCXXRecordDecl()) {
+if (P->isExternallyVisible())
+  info.CapturesNonExternalType = true;
+  }
 
 // So do C structs that require non-trivial copy construction or
 // destruction.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 2 inline comments as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:543
+  return CB(InpAST.takeError());
+CB(clangd::getTypeHierarchy(InpAST->AST, Item.range.start, Resolve,
+Direction));

sammccall wrote:
> nridge wrote:
> > sammccall wrote:
> > > relying on the item range to resolve the actual symbol isn't reliable:
> > >  - the source code may have changed
> > >  - the range may not be within the TU, and might be e.g. in an indexed 
> > > header we don't have a compile command for.
> > Good point. I appreciate a bit better now why you suggested trying to avoid 
> > `resolve` for now :)
> > 
> > What do you think of the following implementation approach:
> > 
> >  * Use the `data` field of `TypeHierarchyItem` (which the client will send 
> > back to the server for `resolve` queries) to send the `SymbolID` of the 
> > item to the client.
> >  * When the client sends back the `SymbolID` in the `resolve` request, look 
> > up the symbol in the index, and use the source range from the symbol.
> > 
> > (Later, when we start storing base <--> derived relationships in the index 
> > for subtype support, we could just answer the entire `resolve` query using 
> > the index.)
> Thanks for exploring all the options here!
> 
> Generally we've tried to avoid relying on the index unless it's needed, using 
> the AST where possible. There are failure modes here:
>  - the base type is in the current file, which is actively edited. The ranges 
> in the index may be off due to staleness.
>  - the base type is not indexed, because it is e.g. a member class inside a 
> class template
>  - there's no index (`-index=0`, though I'm not sure why we still support 
> this) or the index is stale and the type is missing (we're working on making 
> index updates more async)
>  - the base type is not encodable.
> 
> There are just more moving pieces here, I think. Is there a clear reason to 
> support resolve for parents?
> Is there a clear reason to support resolve for parents?

Just what I said earlier about a hypothetical client that relies on it.

However, given the complications involved in implementing it, I'm happy with 
only being concerned with actual clients, not hypothetical ones. The only 
client implementation I currently know of is Theia, and I checked that it works 
fine without `resolve`, so I'm happy with deferring work on `resolve` for now.

If another client comes along that relies on `resolve`, we can revisit this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370



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


[PATCH] D56305: [AArch64] Support reserving arbitrary general purpose registers

2019-02-12 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 186583.
phosek marked 5 inline comments as done.
phosek edited the summary of this revision.

Repository:
  rC Clang

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

https://reviews.llvm.org/D56305

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-fixed-x-register.c
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.td
  llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
  llvm/test/CodeGen/AArch64/arm64-reserve-call-saved-reg.ll

Index: llvm/test/CodeGen/AArch64/arm64-reserve-call-saved-reg.ll
===
--- llvm/test/CodeGen/AArch64/arm64-reserve-call-saved-reg.ll
+++ llvm/test/CodeGen/AArch64/arm64-reserve-call-saved-reg.ll
@@ -1,13 +1,34 @@
-; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x18 -mattr=+call-saved-x18 \
-; RUN: -o - %s | FileCheck %s
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x9 -mattr=+call-saved-x9 -o - %s | FileCheck %s --check-prefixes=CHECK-X9
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x9 -mattr=+call-saved-x9 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X9
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x9 -mattr=+call-saved-x9 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X9
 
-; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x18 -mattr=+call-saved-x18 \
-; RUN: -global-isel \
-; RUN: -o - %s | FileCheck %s
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x10 -mattr=+call-saved-x10 -o - %s | FileCheck %s --check-prefixes=CHECK-X10
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x10 -mattr=+call-saved-x10 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X10
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x10 -mattr=+call-saved-x10 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X10
 
-; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x18 -mattr=+call-saved-x18 \
-; RUN: -fast-isel \
-; RUN: -o - %s | FileCheck %s
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x11 -mattr=+call-saved-x11 -o - %s | FileCheck %s --check-prefixes=CHECK-X11
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x11 -mattr=+call-saved-x11 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X11
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x11 -mattr=+call-saved-x11 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X11
+
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x12 -mattr=+call-saved-x12 -o - %s | FileCheck %s --check-prefixes=CHECK-X12
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x12 -mattr=+call-saved-x12 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X12
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x12 -mattr=+call-saved-x12 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X12
+
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x13 -mattr=+call-saved-x13 -o - %s | FileCheck %s --check-prefixes=CHECK-X13
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x13 -mattr=+call-saved-x13 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X13
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x13 -mattr=+call-saved-x13 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X13
+
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x14 -mattr=+call-saved-x14 -o - %s | FileCheck %s --check-prefixes=CHECK-X14
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x14 -mattr=+call-saved-x14 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X14
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x14 -mattr=+call-saved-x14 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X14
+
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x15 -mattr=+call-saved-x15 -o - %s | FileCheck %s --check-prefixes=CHECK-X15
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x15 -mattr=+call-saved-x15 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X15
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x15 -mattr=+call-saved-x15 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X15
+
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x18 -mattr=+call-saved-x18 -o - %s | FileCheck %s --check-prefixes=CHECK-X18
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x18 -mattr=+call-saved-x18 -global-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X18
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x18 -mattr=+call-saved-x18 -fast-isel -o - %s | FileCheck %s --check-prefixes=CHECK-X18
 
 ; Used to exhaust the supply of GPRs.
 @var = global [30 x i64] zeroinitializer
@@ -15,14 +36,42 @@
 ; If a register is specified to be both reserved and callee-saved, then it
 ; should not be allocated and should not be spilled onto the stack.
 define void @foo() {
-; 

[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

In D54978#1395425 , @brzycki wrote:

> This works for everything I could throw at it. If you think it's reasonable I 
> can open another ticket and have the code reviewed as a separate fix.


Sounds good to me, although I think it'd be good to emit a warning or at least 
a message about assuming the version due to a missing executable.

In D54978#1395561 , @brzycki wrote:

> I looked at the Z3 source and they do have a `z3_version.h` file now and was 
> added in version 4.4.2.0. You may be able to use the header directly, but I'm 
> not sure how `find_package()` parses for library versions and if this is 
> useful or not.  The generated header is named `src/util/version.h` in this 
> initial commit:
>  
> https://github.com/Z3Prover/z3/commit/251527603df01904f70ed884f8695fedab5caed9


You're right, it looks like it was originally internal-only, but them became 
exposed as part of the interface with the second commit, starting around the 
release of z3 4.8.1. It's been a while since I've used CMake, but perhaps 
something like this:

  if(Z3_INCLUDE_DIR AND EXISTS "${Z3_INCLUDE_DIR }/z3_version.h")
file(STRINGS "${Z3_INCLUDE_DIR }/z3_version.h" z3_version_str REGEX 
"^#define[\t ]+Z3_FULL_VERSION[\t ]+\".*\"")
  
string(REGEX REPLACE "^.*Z3_FULL_VERSION[\t ]+\"Z3 ([0-9\.]+)\".*$" "\\1" 
Z3_VERSION_STRING "${z3_version_str}")
unset(z3_version_str)
  endif()



In D54978#1395476 , @mikhail.ramalho 
wrote:

> I'm wondering if we can remove the binary requirement all together: is it 
> possible to run a small program that would return EXIT_SUCCESS if the library 
> is the correct version?


I see other projects do something similar; e.g. 
https://github.com/SRI-CSL/sally/blob/master/cmake/FindZ3.cmake#L20 . I'm less 
fond of that approach because it involves even more moving parts, but then 
again, parsing C header files with regular expressions isn't particularly 
robust either.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D58163: [CUDA][HIP] Use device side kernel and variable names when registering them

2019-02-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, tra.
Herald added subscribers: jdoerfert, tpr.

`__hipRegisterFunction` and `__hipRegisterVar` need to accept device side 
kernel and variable names
so that HIP runtime can associate kernel stub functions in host code with 
kernel symbols in fat binaries,
and associate shadow variables in host code with device variables in fat 
binaries.

Currently, clang assumes kernel functions and device variables have the same 
name as the kernel
stub functions and shadow variables. However, when host is compiled in windows 
with MSVC C++
ABI and device is compiled with Itanium C++ ABI (e.g. AMDGPU), kernels and 
device symbols in fat
binary are mangled differently than host.

This patch gets the device side kernel and variable name by mangling them in 
the mangle context
of aux target.


https://reviews.llvm.org/D58163

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGCUDANV.cpp
  lib/CodeGen/CGCUDARuntime.h
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=8.0 -fcuda-include-gpubinary %t -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s \
-// RUN:   --check-prefixes=ALL,NORDC,CUDA,CUDANORDC,CUDA-OLD
+// RUN:   --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-OLD
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=8.0  -fcuda-include-gpubinary %t \
 // RUN: -o - -DNOGLOBALS \
@@ -12,7 +12,7 @@
 // RUN: -target-sdk-version=8.0 -fgpu-rdc -fcuda-include-gpubinary %t \
 // RUN: -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s \
-// RUN:   --check-prefixes=ALL,RDC,CUDA,CUDARDC,CUDA-OLD
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-OLD
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=8.0 -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN
@@ -20,7 +20,7 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s   \
 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - \
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
-// RUN:   --check-prefixes=ALL,NORDC,CUDA,CUDANORDC,CUDA-NEW
+// RUN:   --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-NEW
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s \
@@ -28,56 +28,70 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
-// RUN:   --check-prefixes=ALL,RDC,CUDA,CUDARDC,CUDA_NEW
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
-// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,NORDC,HIP,HIPEF
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,LNX,NORDC,HIP,HIPEF
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS -x hip \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fgpu-rdc -fcuda-include-gpubinary %t -o - -x hip \
-// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,NORDC,HIP,HIPEF
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,LNX,NORDC,HIP,HIPEF
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - -x hip\
-// RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=ALL,NORDC,HIP,HIPNEF
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=ALL,LNX,NORDC,HIP,HIPNEF
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -aux-triple amdgcn -emit-llvm %s \
+// RUN: -fcuda-include-gpubinary %t -o - -x hip\
+// RUN:   | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,WIN
 
 #include "Inputs/cuda.h"
 
 #ifndef NOGLOBALS
-// ALL-DAG: @device_var = internal global i32
+// LNX-DAG: @device_var = internal global i32
+// WIN-DAG: @"?device_var@@3HA" = internal global i32
 __device__ int device_var;
 
-// ALL-DAG: @constant_var = internal global i32
+// LNX-DAG: @constant_var = internal global i32
+// 

[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 

2019-02-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore marked an inline comment as done.
stephanemoore added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h:1
+#ifndef _STDIO_H_
+#define _STDIO_H_

stephanemoore wrote:
> I noticed that some of the other example headers don't have `#ifdef` guards 
> at all. I decided to still include them—perhaps mostly for my own sanity. I 
> figured that it wasn't necessary to use the full 
> `LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_INPUTS_HEADER_STDIO_H` for this 
> header that is mimicking a system header so I went with the shorter 
> `_STDIO_H_` which I think better represents what actual stdio.h headers would 
> have. Let me know if you think something else makes more sense.
Do I need the licensing preamble on this test input header?



Comment at: clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h:1-9
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+// A header intended to contain C standard input and output library
+// declarations.
+
+int printf(const char *, ...);

I noticed that some of the other example headers don't have `#ifdef` guards at 
all. I decided to still include them—perhaps mostly for my own sanity. I 
figured that it wasn't necessary to use the full 
`LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_INPUTS_HEADER_STDIO_H` for this header 
that is mimicking a system header so I went with the shorter `_STDIO_H_` which 
I think better represents what actual stdio.h headers would have. Let me know 
if you think something else makes more sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58095



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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:543
+  return CB(InpAST.takeError());
+CB(clangd::getTypeHierarchy(InpAST->AST, Item.range.start, Resolve,
+Direction));

nridge wrote:
> sammccall wrote:
> > relying on the item range to resolve the actual symbol isn't reliable:
> >  - the source code may have changed
> >  - the range may not be within the TU, and might be e.g. in an indexed 
> > header we don't have a compile command for.
> Good point. I appreciate a bit better now why you suggested trying to avoid 
> `resolve` for now :)
> 
> What do you think of the following implementation approach:
> 
>  * Use the `data` field of `TypeHierarchyItem` (which the client will send 
> back to the server for `resolve` queries) to send the `SymbolID` of the item 
> to the client.
>  * When the client sends back the `SymbolID` in the `resolve` request, look 
> up the symbol in the index, and use the source range from the symbol.
> 
> (Later, when we start storing base <--> derived relationships in the index 
> for subtype support, we could just answer the entire `resolve` query using 
> the index.)
Thanks for exploring all the options here!

Generally we've tried to avoid relying on the index unless it's needed, using 
the AST where possible. There are failure modes here:
 - the base type is in the current file, which is actively edited. The ranges 
in the index may be off due to staleness.
 - the base type is not indexed, because it is e.g. a member class inside a 
class template
 - there's no index (`-index=0`, though I'm not sure why we still support this) 
or the index is stale and the type is missing (we're working on making index 
updates more async)
 - the base type is not encodable.

There are just more moving pieces here, I think. Is there a clear reason to 
support resolve for parents?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370



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


[PATCH] D58161: Print a note to the called macro when diagnosing err_embedded_directive

2019-02-12 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:497
+
 Args = ReadMacroCallArgumentList(Identifier, MI, ExpansionEnd);
 

rnk wrote:
> Can this re-enter, something like:
>   MACRO1(MACRO2(a1), MACRO3(
>   #include "asdf"
>   )
> In this case, I think your diagnostic might do a null-deref. Maybe just add 
> this test case and add a null test for it.
This works fine:

```
#define MACRO1(a, b, c)
#define MACRO2(a, b, c)
#define MACRO3(a, b, c)

MACRO1(MACRO2(a1), MACRO3(
#include "asdf"
)

$ out/gn/bin/clang -c test.cc
test.cc:30:2: error: embedding a #include directive within macro arguments is 
not supported
#include "asdf"
 ^
test.cc:29:1: note: expansion of macro 'MACRO1' requested here
MACRO1(MACRO2(a1), MACRO3(
^
test.cc:29:1: error: unterminated function-like macro invocation
MACRO1(MACRO2(a1), MACRO3(
^
test.cc:25:9: note: macro 'MACRO1' defined here
#define MACRO1(a, b, c)
^
2 errors generated.
```

Note that the diag is only emitted if inMacroArgs is true, and ArgMacro is 
always set to non-nullptr exactly when that's true.




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

https://reviews.llvm.org/D58161



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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.
Herald added a subscriber: jdoerfert.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:543
+  return CB(InpAST.takeError());
+CB(clangd::getTypeHierarchy(InpAST->AST, Item.range.start, Resolve,
+Direction));

sammccall wrote:
> relying on the item range to resolve the actual symbol isn't reliable:
>  - the source code may have changed
>  - the range may not be within the TU, and might be e.g. in an indexed header 
> we don't have a compile command for.
Good point. I appreciate a bit better now why you suggested trying to avoid 
`resolve` for now :)

What do you think of the following implementation approach:

 * Use the `data` field of `TypeHierarchyItem` (which the client will send back 
to the server for `resolve` queries) to send the `SymbolID` of the item to the 
client.
 * When the client sends back the `SymbolID` in the `resolve` request, look up 
the symbol in the index, and use the source range from the symbol.

(Later, when we start storing base <--> derived relationships in the index for 
subtype support, we could just answer the entire `resolve` query using the 
index.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370



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


[PATCH] D57984: PR40642: Fix determination of whether the final statement of a statementexpression is a discarded-value expression.

2019-02-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 186578.
rsmith added a comment.

Combine WithinStmtExpr flag with AllowedStmtKinds into a more general statement
context. In doing so, fix some bugs where the OpenMP context was not being
propagated properly through labels and expression-statements starting with @.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57984

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/Basic/StmtNodes.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/Stmt.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCXX/stmtexpr.cpp
  test/CodeGenCXX/volatile.cpp
  test/OpenMP/barrier_messages.cpp
  test/OpenMP/cancel_messages.cpp
  test/OpenMP/cancellation_point_messages.cpp
  test/OpenMP/flush_messages.cpp
  test/OpenMP/taskwait_messages.cpp
  test/OpenMP/taskyield_messages.cpp

Index: test/OpenMP/taskyield_messages.cpp
===
--- test/OpenMP/taskyield_messages.cpp
+++ test/OpenMP/taskyield_messages.cpp
@@ -29,7 +29,7 @@
 #pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
 switch (argc)
 case 1:
-#pragma omp taskyield
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
 #pragma omp taskyield
@@ -49,10 +49,13 @@
 #pragma omp taskyield
 }
 label:
-#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+#pragma omp taskyield
 label1 : {
 #pragma omp taskyield
 }
+if (1)
+  label2:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
 
   return T();
 }
@@ -83,7 +86,7 @@
 #pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
 switch (argc)
 case 1:
-#pragma omp taskyield
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
 #pragma omp taskyield
@@ -103,10 +106,13 @@
 #pragma omp taskyield
 }
 label:
-#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+#pragma omp taskyield
 label1 : {
 #pragma omp taskyield
 }
+if (1)
+  label2:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
 
   return tmain(argc);
 }
Index: test/OpenMP/taskwait_messages.cpp
===
--- test/OpenMP/taskwait_messages.cpp
+++ test/OpenMP/taskwait_messages.cpp
@@ -29,7 +29,7 @@
 #pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
 switch (argc)
 case 1:
-#pragma omp taskwait
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
 #pragma omp taskwait
@@ -49,7 +49,7 @@
 #pragma omp taskwait
 }
 label:
-#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+#pragma omp taskwait
 label1 : {
 #pragma omp taskwait
 }
@@ -83,7 +83,7 @@
 #pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
 switch (argc)
 case 1:
-#pragma omp taskwait
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
 #pragma omp taskwait
@@ -103,7 +103,7 @@
 #pragma omp taskwait
 }
 label:
-#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+#pragma omp taskwait
 label1 : {
 #pragma omp taskwait
 }
Index: test/OpenMP/flush_messages.cpp
===
--- test/OpenMP/flush_messages.cpp
+++ test/OpenMP/flush_messages.cpp
@@ -33,7 +33,7 @@
 #pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
 switch (argc)
 case 1:
-#pragma omp flush
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
 #pragma omp flush
@@ -53,7 +53,7 @@
 #pragma omp flush
 }
 label:
-#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+#pragma omp flush
 label1 : {
 #pragma omp flush
 }
@@ -97,7 +97,7 @@
 #pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
 switch (argc)
 case 1:
-#pragma omp flush
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
 #pragma omp flush
@@ -117,7 +117,7 @@
 #pragma omp flush
 

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-12 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 186577.
jyu2 added a comment.

Cleanup CFG code, remove obj-lifetime code when build CFE for asm-goto.


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

https://reviews.llvm.org/D56571

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/asm-goto.cpp
  test/CodeGen/asm-goto.c
  test/CodeGen/asm.c
  test/CodeGen/inline-asm-mixed-style.c
  test/Coverage/c-language-features.inc
  test/PCH/asm.h
  test/Parser/asm.c
  test/Parser/asm.cpp
  test/Sema/asm-goto.cpp
  test/Sema/asm.c
  test/Sema/inline-asm-validate-tmpl.cpp
  test/Sema/scope-check.c

Index: test/Sema/scope-check.c
===
--- test/Sema/scope-check.c
+++ test/Sema/scope-check.c
@@ -232,3 +232,19 @@
 
 // rdar://9024687
 int test16(int [sizeof &]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+//Asm goto:
+int test16(int n)
+{
+  // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
+  // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
+  // expected-note@+2 {{jump bypasses initialization of variable length array}}
+  // expected-note@+1 {{possible target of asm goto statement}}
+  return ({int a[n];label_true: 2;});
+  // expected-note@+1 {{jump bypasses initialization of variable length array}}
+  int b[n];
+// expected-note@+1 {{possible target of asm goto statement}}
+loop:
+  return 0;
+}
Index: test/Sema/inline-asm-validate-tmpl.cpp
===
--- test/Sema/inline-asm-validate-tmpl.cpp
+++ test/Sema/inline-asm-validate-tmpl.cpp
@@ -23,3 +23,13 @@
 	asm("rol %1, %0" :"=r"(value): "I"(N + 1));
 }
 int	foo() { testc<2>(10); }
+
+// these should compile without error
+template  bool testd()
+{
+  __asm goto ("" : : : : lab);
+  return true;
+lab:
+  return false;
+}
+bool foox() { return testd<0> (); }
Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -295,3 +295,24 @@
   return r0 + r1;
 }
 
+void test18()
+{
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("" : : : : lab, lab, lab2, lab);
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("xorw %[lab], %[lab]; je %l[lab]" : : [lab] "i" (0) : : lab);
+lab:;
+lab2:;
+  int x,x1;
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x),[lab] "+r" (x) : [lab1] "r" (x));
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x1) : [lab] "r" (x));
+  // expected-error@+1 {{invalid operand number in inline asm string}}
+  asm ("jne %l0":::);
+  asm goto ("jne %l0"lab);
+}
Index: test/Sema/asm-goto.cpp
===
--- /dev/null
+++ test/Sema/asm-goto.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
+
+struct NonTrivial {
+  ~NonTrivial();
+  int f(int);
+private:
+  int k;
+};
+void JumpDiagnostics(int n) {
+// expected-error@+1 {{cannot jump from this goto statement to its label}}
+  goto DirectJump;
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp1;
+
+DirectJump:
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" Later);
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp2;
+// expected-note@+1 {{possible target of asm goto statement}}
+Later:
+  return;
+}
+
+struct S { ~S(); };
+void foo(int a) {
+  if (a) {
+FOO:
+// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
+// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
+S s;
+void *p = &
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" BAR);
+// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible 

[PATCH] D58161: Print a note to the called macro when diagnosing err_embedded_directive

2019-02-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:497
+
 Args = ReadMacroCallArgumentList(Identifier, MI, ExpansionEnd);
 

Can this re-enter, something like:
  MACRO1(MACRO2(a1), MACRO3(
  #include "asdf"
  )
In this case, I think your diagnostic might do a null-deref. Maybe just add 
this test case and add a null test for it.


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

https://reviews.llvm.org/D58161



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


[PATCH] D57736: [WebAssembly] Bulk memory intrinsics and builtins

2019-02-12 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13477
+if (!SegArg->isIntegerConstantExpr(SegConst, getContext()))
+  llvm_unreachable("Constant arg isn't actually constant?");
+llvm::Type *SegType = ConvertType(SegArg->getType());

tlively wrote:
> aheejin wrote:
> > Not sure if we can use `llvm_unreachable` here, because we can certainly 
> > reach here if a user uses this builtin with a non-const variable. In this 
> > file people often just used `assert` for user errors, which is not ideal 
> > either.
> > 
> > I haven't used it myself, but looking at the code, the recommended way to 
> > signal an error looks like to use [[ 
> > https://github.com/llvm/llvm-project/blob/db7fbcb038f095622a3e6847ecd6ff80bdc2483a/clang/lib/CodeGen/CodeGenFunction.h#L2092-L2094
> >  | `CodeGenFunction::ErrorUnsupported` ]] function, as in [[ 
> > https://github.com/llvm/llvm-project/blob/0e04ebdcda44ef90e25abd0a2e65cc755ae8bc37/clang/lib/CodeGen/CGBuiltin.cpp#L2458-L2460
> >  | here ]]. We used `llvm_unreachable` for SIMD builtins too, but maybe we 
> > can fix it later.
> `llvm_unreachable` is appropriate here because non-constant expressions will 
> have been caught earlier by the type checking.
> 
> A follow-up PR updating SIMD intrinsics to use `Ui` and appropriate error 
> handling sounds good.
> `llvm_unreachable` is appropriate here because non-constant expressions will 
> have been caught earlier by the type checking.
Oh, does `Ii` ensures that? That's cool...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57736



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


[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D54978#1395136 , @brzycki wrote:

> The following patch:
>
>   diff --git a/llvm/cmake/modules/CrossCompile.cmake 
> b/llvm/cmake/modules/CrossCompile.cmake
>   index bc3b210f018..0c30b88f80f 100644
>   --- a/llvm/cmake/modules/CrossCompile.cmake
>   +++ b/llvm/cmake/modules/CrossCompile.cmake
>   @@ -53,6 +53,7 @@ function(llvm_create_cross_target_internal target_name 
> toolchain buildtype)
>-DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}"
>-DLLVM_TARGET_ARCH="${LLVM_TARGET_ARCH}"
>
> -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="${LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN}"
>   +-DLLVM_ENABLE_Z3_SOLVER="${LLVM_ENABLE_Z3_SOLVER}"
>${build_type_flags} ${linker_flag} ${external_clang_dir}
>WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
>DEPENDS CREATE_LLVM_${target_name}
>


Independent of the rest of the discussion, this patch should be part of the 
reland, to make sure that explicitly turning off Z3 works reliably. Thanks for 
coming up with that, and thanks everyone for the good discussion here :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D58161: Print a note to the called macro when diagnosing err_embedded_directive

2019-02-12 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

Fixes PR40713, see there for the motivation for this.


https://reviews.llvm.org/D58161

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Preprocessor/macro_arg_directive.c


Index: clang/test/Preprocessor/macro_arg_directive.c
===
--- clang/test/Preprocessor/macro_arg_directive.c
+++ clang/test/Preprocessor/macro_arg_directive.c
@@ -8,7 +8,7 @@
 _Static_assert(n == 5, "");
 
 #define M(A)
-M(
+M( // expected-note {{expansion of macro 'M' requested here}}
 #pragma pack(pop) // expected-error {{embedding a #pragma directive within 
macro arguments is not supported}}
 )
 
@@ -18,7 +18,7 @@
  ({ int result = 0; __VA_ARGS__; if (!result) { fail(#__VA_ARGS__); }; result 
})
 
 static inline int f(int k) {
-  return MUNCH( // expected-error {{expected ')'}} expected-note {{to match 
this '('}} expected-error {{returning 'void'}}
+  return MUNCH( // expected-error {{expected ')'}} expected-note {{to match 
this '('}} expected-error {{returning 'void'}} expected-note {{expansion of 
macro 'MUNCH' requested here}}
 if (k < 3)
   result = 24;
 else if (k > 4)
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -102,6 +102,7 @@
   DisableMacroExpansion = false;
   MacroExpansionInDirectivesOverride = false;
   InMacroArgs = false;
+  ArgMacro = nullptr;
   InMacroArgPreExpansion = false;
   NumCachedTokenLexers = 0;
   PragmasEnabled = true;
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -492,10 +492,13 @@
 // Preprocessor directives used inside macro arguments are not portable, 
and
 // this enables the warning.
 InMacroArgs = true;
+ArgMacro = 
+
 Args = ReadMacroCallArgumentList(Identifier, MI, ExpansionEnd);
 
 // Finished parsing args.
 InMacroArgs = false;
+ArgMacro = nullptr;
 
 // If there was an error parsing the arguments, bail out.
 if (!Args) return true;
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -886,6 +886,8 @@
   case tok::pp___include_macros:
   case tok::pp_pragma:
 Diag(Result, diag::err_embedded_directive) << II->getName();
+Diag(*ArgMacro, diag::note_macro_expansion_here)
+<< ArgMacro->getIdentifierInfo();
 DiscardUntilEndOfDirective();
 return;
   default:
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -173,6 +173,9 @@
   IdentifierInfo *Ident__is_target_os; // __is_target_os
   IdentifierInfo *Ident__is_target_environment;// __is_target_environment
 
+  // Weak, only valid (and set) while InMacroArgs is true.
+  Token* ArgMacro;
+
   SourceLocation DATELoc, TIMELoc;
 
   // Next __COUNTER__ value, starts at 0.
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -391,6 +391,7 @@
   "empty macro arguments are incompatible with C++98">,
   InGroup, DefaultIgnore;
 def note_macro_here : Note<"macro %0 defined here">;
+def note_macro_expansion_here : Note<"expansion of macro %0 requested here">;
 
 def err_pp_opencl_variadic_macros :
   Error<"variadic macros not supported in OpenCL">;


Index: clang/test/Preprocessor/macro_arg_directive.c
===
--- clang/test/Preprocessor/macro_arg_directive.c
+++ clang/test/Preprocessor/macro_arg_directive.c
@@ -8,7 +8,7 @@
 _Static_assert(n == 5, "");
 
 #define M(A)
-M(
+M( // expected-note {{expansion of macro 'M' requested here}}
 #pragma pack(pop) // expected-error {{embedding a #pragma directive within macro arguments is not supported}}
 )
 
@@ -18,7 +18,7 @@
  ({ int result = 0; __VA_ARGS__; if (!result) { fail(#__VA_ARGS__); }; result })
 
 static inline int f(int k) {
-  return MUNCH( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{returning 'void'}}
+  return MUNCH( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{returning 'void'}} expected-note {{expansion of macro 'MUNCH' requested here}}
 if (k < 3)
   result = 24;
 else if (k > 4)
Index: 

[PATCH] D57080: [clang-tidy] Delete obsolete objc-property-declaration options ✂️

2019-02-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 186572.
stephanemoore added a comment.
Herald added a project: clang.

Migrated patch to LLVM monorepo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57080

Files:
  clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst


Index: clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst
+++ clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst
@@ -40,15 +40,3 @@
@property(nonatomic, assign) int abc_lowerCamelCase;
 
 The corresponding style rule: 
https://developer.apple.com/library/content/qa/qa1908/_index.html
-
-
-Options

-
-.. option:: Acronyms
-
-   This option is deprecated and ignored.
-
-.. option:: IncludeDefaultAcronyms
-
-   This option is deprecated and ignored.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,10 @@
   `CommentUserDefiniedLiterals`, `CommentStringLiterals`,
   `CommentCharacterLiterals` & `CommentNullPtrs` options.
 
+- The `Acronyms` and `IncludeDefaultAcronyms` options for the
+  :doc:`objc-property-declaration 
`
+  check have been removed.
+
 Improvements to include-fixer
 -
 
Index: clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.h
===
--- clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.h
+++ clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.h
@@ -10,8 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_PROPERTY_DECLARATION_H
 
 #include "../ClangTidy.h"
-#include 
-#include 
 
 namespace clang {
 namespace tidy {
@@ -27,15 +25,10 @@
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/objc-property-declaration.html
 class PropertyDeclarationCheck : public ClangTidyCheck {
 public:
-  PropertyDeclarationCheck(StringRef Name, ClangTidyContext *Context);
+  PropertyDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
-  void storeOptions(ClangTidyOptions::OptionMap ) override;
-
-private:
-  const std::vector SpecialAcronyms;
-  const bool IncludeDefaultAcronyms;
-  std::vector EscapedAcronyms;
 };
 
 } // namespace objc
Index: clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -97,14 +97,6 @@
 }
 }  // namespace
 
-PropertyDeclarationCheck::PropertyDeclarationCheck(StringRef Name,
-   ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  SpecialAcronyms(
-  utils::options::parseStringList(Options.get("Acronyms", ""))),
-  IncludeDefaultAcronyms(Options.get("IncludeDefaultAcronyms", true)),
-  EscapedAcronyms() {}
-
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
@@ -145,12 +137,6 @@
   << generateFixItHint(MatchedDecl, StandardProperty);
 }
 
-void PropertyDeclarationCheck::storeOptions(ClangTidyOptions::OptionMap ) 
{
-  Options.store(Opts, "Acronyms",
-utils::options::serializeStringList(SpecialAcronyms));
-  Options.store(Opts, "IncludeDefaultAcronyms", IncludeDefaultAcronyms);
-}
-
 }  // namespace objc
 }  // namespace tidy
 }  // namespace clang


Index: clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst
+++ clang-tools-extra/docs/clang-tidy/checks/objc-property-declaration.rst
@@ -40,15 +40,3 @@
@property(nonatomic, assign) int abc_lowerCamelCase;
 
 The corresponding style rule: https://developer.apple.com/library/content/qa/qa1908/_index.html
-
-
-Options

-
-.. option:: Acronyms
-
-   This option is deprecated and ignored.
-
-.. option:: IncludeDefaultAcronyms
-
-   This option is deprecated and ignored.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ 

[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-12 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 186569.
hwright marked 3 inline comments as done.

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

https://reviews.llvm.org/D58137

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tidy/abseil/TimeSubtractionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-time-subtraction.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-time-subtraction.cpp

Index: test/clang-tidy/abseil-time-subtraction.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-time-subtraction.cpp
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s abseil-time-subtraction %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void g(absl::Duration d);
+
+void f() {
+  absl::Time t;
+  int x, y;
+  absl::Duration d;
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(x));
+  d = absl::Minutes(absl::ToUnixMinutes(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMinutes(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x));
+  d = absl::Milliseconds(absl::ToUnixMillis(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMillis(x));
+  d = absl::Microseconds(absl::ToUnixMicros(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMicros(x));
+  d = absl::Nanoseconds(absl::ToUnixNanos(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixNanos(x));
+
+  y = x - absl::ToUnixHours(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Hours(absl::FromUnixHours(x) - t);
+  y = x - absl::ToUnixMinutes(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Minutes(absl::FromUnixMinutes(x) - t);
+  y = x - absl::ToUnixSeconds(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t);
+  y = x - absl::ToUnixMillis(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Milliseconds(absl::FromUnixMillis(x) - t);
+  y = x - absl::ToUnixMicros(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Microseconds(absl::FromUnixMicros(x) - t);
+  y = x - absl::ToUnixNanos(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Nanoseconds(absl::FromUnixNanos(x) - t);
+
+  // Check parenthesis placement
+  d = 5 * absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = 5 * (t - absl::FromUnixSeconds(x));
+
+  // No extra parens around arguments
+  g(absl::Seconds(absl::ToUnixSeconds(t) - x));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(t - absl::FromUnixSeconds(x));
+  g(absl::Seconds(x - absl::ToUnixSeconds(t)));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(absl::FromUnixSeconds(x) - t);
+
+  // These should not trigger; they are likely bugs
+  d = absl::Milliseconds(absl::ToUnixSeconds(t) - x);
+  d = absl::Seconds(absl::ToUnixMicros(t) - x);
+}
+
+absl::Duration parens_in_return() {
+  absl::Time t;
+  int x;
+
+  return absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: return t - absl::FromUnixSeconds(x);
+  return absl::Seconds(x - absl::ToUnixSeconds(t));
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: return 

[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 

2019-02-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/google-objc-function-naming.m:10
+// function would be declared in a system header.
+int printf(const char *, ...);  // NOLINT(google-objc-function-naming)
+

aaron.ballman wrote:
> stephanemoore wrote:
> > Thus far I have been unsuccessful in using line markers to simulate this 
> > declaration being in a system header but I did discover precedence for 
> > using NOLINT to suppress diagnostics in some of the clang-tidy tests:
> > https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/test/clang-tidy/google-runtime-int-std.cpp#L11
> > https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/test/clang-tidy/google-runtime-int.cpp#L6
> > 
> > I think it should be reasonable to suppress the diagnostic here with a 
> > comment explaining why. Let me know if you don't think that's an 
> > appropriate solution and I can continue investigating for a potential 
> > solution using line markers.
> Personally, I would recommend adding stdio.h to 
> extra\test\clang-tidy\Inputs\Headers and adding a `-isystem` to this test's 
> RUN line. You could also add `#pragma clang system_header` to the file to be 
> really sure it's treated as a system header. This gives us a place to add 
> more stdio.h declarations in the future as well.
> 
That sounds like a better idea. Thanks for the suggestion!

Things seem to work without needing `#pragma clang system_header` so I left it 
out. If you want me to include that, I can do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58095



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


[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 

2019-02-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 186567.
stephanemoore marked 2 inline comments as done.
stephanemoore added a comment.

Add a comment to the new stdio.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58095

Files:
  clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
  clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
  clang-tools-extra/test/clang-tidy/google-objc-function-naming.m


Index: clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
+++ clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem 
%S/Inputs/Headers
+
+#include 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
 
 typedef _Bool bool;
 
Index: clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,10 @@
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+// A header intended to contain C standard input and output library
+// declarations.
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+
Index: clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))


Index: clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
+++ clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem %S/Inputs/Headers
+
+#include 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
 
 typedef _Bool bool;
 
Index: clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,10 @@
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+// A header intended to contain C standard input and output library
+// declarations.
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+
Index: clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D58160: Fix runtime problem from //bugs.llvm.org/show_bug.cgi?id=40323

2019-02-12 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: cfe-commits, rnk, majnemer, erichkeane.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.

A MS only run time problem, because the init function for template static 
member is not getting called when the template static member is not reference.  
To be able to evoke the init function, MS put the template static member in the 
linker directive section, that cause init function gets call.   As Rick 
suggest;  add template static data member to llvm.used that cause compiler to 
emit a similar -include directive into the linker directive section.

//bugs.llvm.org/show_bug.cgi?id=40323


Repository:
  rL LLVM

https://reviews.llvm.org/D58160

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/microsoft-abi-template-static-init.cpp


Index: test/CodeGenCXX/microsoft-abi-template-static-init.cpp
===
--- /dev/null
+++ test/CodeGenCXX/microsoft-abi-template-static-init.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -fms-extensions 
-emit-llvm -o - | FileCheck %s
+
+struct S {
+  S();
+  ~S();
+};
+
+template  struct __declspec(dllexport) ExportedTemplate {
+  static S s;
+};
+template  S ExportedTemplate::s;
+void useExportedTemplate(ExportedTemplate x) {
+  (void)x.s;
+}
+int f();
+namespace selectany_init {
+// MS don't put selectany static var in the linker directive, init routine
+// f() is not getting called if x is not referenced.
+int __declspec(selectany) x = f();
+}
+
+namespace explicit_template_instantiation {
+template  struct A { static  int x; };
+template  int A::x = f();
+template struct A;
+}
+
+namespace implicit_template_instantiation {
+template  struct A { static  int x; };
+template   int A::x = f();
+int g() { return A::x; }
+}
+
+
+template 
+struct X_ {
+  static T ioo;
+  static T init();
+};
+template  T X_::ioo = X_::init();
+template struct X_;
+
+template 
+struct X {
+  static T ioo;
+  static T init();
+};
+// template specialized static data don't need in llvm.used,
+// the static init routine get call from _GLOBAL__sub_I_ routines.
+template <> int X::ioo = X::init();
+template struct X;
+// CHECK: @llvm.global_ctors = appending global [6 x { i32, void ()*, i8* }] 
[{ i32, void ()*, i8* } { i32 65535, void ()* @"??__Ex@selectany_init@@YAXXZ", 
i8* bitcast (i32* @"?x@selectany_init@@3HA" to i8*) }, { i32, void ()*, i8* } { 
i32 65535, void ()* 
@"??__E?x@?$A@H@explicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* @"??__E?ioo@?$X_@H@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*) }, { i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?s@?$ExportedTemplate@H@@2US@@A@@YAXXZ", i8* getelementptr inbounds 
(%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0) }, { 
i32, void ()*, i8* } { i32 65535, void ()* 
@"??__E?x@?$A@H@implicit_template_instantiation@@2HA@@YAXXZ", i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*) }, { i32, void ()*, 
i8* } { i32 65535, void ()* 
@_GLOBAL__sub_I_microsoft_abi_template_static_init.cpp, i8* null }]
+// CHECK: @llvm.used = appending global [4 x i8*] [i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds (%struct.S, %struct.S* 
@"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section 
"llvm.metadata"
+
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -481,6 +481,12 @@
 // minor startup time optimization.  In the MS C++ ABI, there are no guard
 // variables, so this COMDAT key is required for correctness.
 AddGlobalCtor(Fn, 65535, COMDATKey);
+if (getTarget().getCXXABI().isMicrosoft()) {
+  // In The MS C++, MS add template static data member in the linker
+  // drective.
+  assert(COMDATKey);
+  addUsedGlobal(COMDATKey);
+}
   } else if (D->hasAttr()) {
 // SelectAny globals will be comdat-folded. Put the initializer into a
 // COMDAT group associated with the global, so the initializers get folded


Index: test/CodeGenCXX/microsoft-abi-template-static-init.cpp
===
--- /dev/null
+++ test/CodeGenCXX/microsoft-abi-template-static-init.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | 

[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 

2019-02-12 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 186566.
stephanemoore added a comment.

Create a new header stdio.h under //test/clang-tidy/Inputs/Headers/ to contain 
declaration of
`printf` and import the new header to `google-objc-function-naming.m`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58095

Files:
  clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
  clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
  clang-tools-extra/test/clang-tidy/google-objc-function-naming.m


Index: clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
+++ clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem 
%S/Inputs/Headers
+
+#include 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
 
 typedef _Bool bool;
 
Index: clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,7 @@
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+
Index: clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))


Index: clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
+++ clang-tools-extra/test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem %S/Inputs/Headers
+
+#include 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
 
 typedef _Bool bool;
 
Index: clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,7 @@
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+
Index: clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58145: [Sema] Fix a bogus -Wconversion warning

2019-02-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this regression (sorry, I caused it).  Doesn't regress the 
tests I added.  You'll probably want to request to Hans that this gets picked 
up for the 8.0 release.  Not sure if @rsmith has comments on the added `fixme`?




Comment at: clang/test/SemaObjC/conversion.m:23
+  double local = 42;
+  dp.d += local;
+}

does this need a `// no-warning` comment?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58145



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


[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The official documentation still says "Your app must perform runtime detection 
to confirm that NEON-capable machine code can be run on the target device" 
(https://developer.android.com/ndk/guides/cpu-arm-neon#runtime_detection).  Is 
that wrong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58153



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


[PATCH] D58089: Add missing library dependencies in CMakeLists.txt

2019-02-12 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added a comment.

Oh, forgot to mention in the initial submission: I don't have commit access so 
I'll need someone else to commit this.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58089



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


[PATCH] D58122: Restore Check for Unreachable Exit Block in -Winfinite-recursion

2019-02-12 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu accepted this revision.
rtrieu added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D58122



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


[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

In D54978#1395561 , @brzycki wrote:

> In D54978#1395476 , @mikhail.ramalho 
> wrote:
>
> > I'm wondering if we can remove the binary requirement all together: is it 
> > possible to run a small program that would return EXIT_SUCCESS if the 
> > library is the correct version?
>
>
> Hi @mikhail.ramalho, I don't think this is feasible unfortunately. If we're 
> using a cross-compiler the emitted binary won't be native to the platform. In 
> other words, you cannot test for Z3 as a run-time property.


Hi @brzycki, but isn't it exactly what we want? I mean, if we try to 
cross-compile and it fails for any reason (non-native library, wrong version), 
then Z3_FOUND shouldn't be set.

I just finished a small patch that checks the version as a run-time property. 
Please, let me know your thoughts.

If you agree with this approach I'll create a separate revision for it (it 
seems to work on ubuntu and fedora for me).


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Brian Rzycki via Phabricator via cfe-commits
brzycki added a comment.

In D54978#1395476 , @mikhail.ramalho 
wrote:

> I'm wondering if we can remove the binary requirement all together: is it 
> possible to run a small program that would return EXIT_SUCCESS if the library 
> is the correct version?


Hi @mikhail.ramalho, I don't think this is feasible unfortunately. If we're 
using a cross-compiler the emitted binary won't be native to the platform. In 
other words, you cannot test for Z3 as a run-time property.

I looked at the Z3 source and they do have a `z3_version.h` file now and was 
added in version 4.4.2.0. You may be able to use the header directly, but I'm 
not sure how `find_package()` parses for library versions and if this is useful 
or not.  The generated header is named `src/util/version.h` in this initial 
commit:
https://github.com/Z3Prover/z3/commit/251527603df01904f70ed884f8695fedab5caed9

and was renamed last September to `src/util/z3_version.h` in this commit:
https://github.com/Z3Prover/z3/commit/0c4754d94bdfaf07077120f5cbff780d8fb0971d


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D58154: Add support for -fpermissive.

2019-02-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: jyknight.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

The intent is to provide similar functionality to GCC's -fpermissive.
For Clang's approach to diagnostics, this means that we remap all
extension diagnostics to no higher than a warning. As with GCC, the
warnings can then be suppressed with -w.


Repository:
  rC Clang

https://reviews.llvm.org/D58154

Files:
  docs/UsersManual.rst
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/DiagnosticOptions.def
  include/clang/Basic/DiagnosticOptions.h
  include/clang/Driver/Options.td
  lib/ARCMigrate/ARCMT.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/Basic/DiagnosticOptions.cpp
  lib/Basic/Warnings.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Serialization/ASTReader.cpp
  test/Driver/warning-options_pedantic.cpp
  test/Frontend/warning-mapping-2.c

Index: test/Frontend/warning-mapping-2.c
===
--- test/Frontend/warning-mapping-2.c
+++ test/Frontend/warning-mapping-2.c
@@ -1,7 +1,31 @@
+// Check that -pedantic-errors promotes extensions to errors
+// RUN: %clang_cc1 -verify -pedantic-errors %s -DMODE=0
+
 // Check that -w takes precedence over -pedantic-errors.
-// RUN: %clang_cc1 -verify -pedantic-errors -w %s
+// RUN: %clang_cc1 -verify -pedantic-errors -w %s -DMODE=1
 
-// Expect *not* to see a diagnostic for "implicit declaration of function"
-// expected-no-diagnostics
+// Check that -fpermissive demotes errors to warnings.
+// RUN: %clang_cc1 -verify -fpermissive %s -DMODE=2
+
+// Check that -w suppresses diagnostics demoted by -fpermissive.
+// RUN: %clang_cc1 -verify -fpermissive -w %s -DMODE=3
 
 void f0() { f1(); }
+#if MODE == 0
+  // expected-error@-2 {{implicit declaration of function}}
+#elif MODE == 1
+  // no diagnostic
+#elif MODE == 2
+  // expected-warning@-6 {{implicit declaration of function}}
+#else
+  // expected-no-diagnostics
+#endif
+
+void f2() {
+  return 123;
+#if MODE <= 1
+  // expected-error@-2 {{should not return a value}}
+#elif MODE == 2
+  // expected-warning@-4 {{should not return a value}}
+#endif
+}
Index: test/Driver/warning-options_pedantic.cpp
===
--- test/Driver/warning-options_pedantic.cpp
+++ test/Driver/warning-options_pedantic.cpp
@@ -2,12 +2,37 @@
 // Delimiters match the start of the cc1 and the start of the linker lines
 // DELIMITERS: {{^ *"}}
 
+// RUN: %clang -### -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic-errors %s 2>&1 | FileCheck -check-prefix=PEDANTIC_ERRORS -check-prefix=DELIMITERS %s
+// RUN: %clang -### -Wpedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC -check-prefix=DELIMITERS %s
 // RUN: %clang -### -pedantic -no-pedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC -check-prefix=DELIMITERS %s
 // RUN: %clang -### -pedantic -Wno-pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic -no-pedantic -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic -no-pedantic -pedantic-errors %s 2>&1 | FileCheck -check-prefix=PEDANTIC_ERRORS -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic-errors -no-pedantic -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic -no-pedantic -pedantic-errors -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC_ERRORS -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic -no-pedantic -Wpedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic-errors -no-pedantic -Wpedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC -check-prefix=DELIMITERS %s
+
+// RUN: %clang -### -fpermissive %s 2>&1 | FileCheck -check-prefix=PERMISSIVE -check-prefix=DELIMITERS %s
+// RUN: %clang -### -fpermissive -fno-permissive -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -fpermissive -fno-permissive -pedantic-errors %s 2>&1 | FileCheck -check-prefix=PEDANTIC_ERRORS -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic -fpermissive -fno-permissive %s 2>&1 | FileCheck -check-prefix=PEDANTIC -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic-errors -fpermissive -fno-permissive %s 2>&1 | FileCheck -check-prefix=PEDANTIC_ERRORS -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic -no-pedantic -fpermissive %s 2>&1 | FileCheck -check-prefix=PERMISSIVE -check-prefix=DELIMITERS %s
+// RUN: %clang -### -pedantic-errors -no-pedantic -fpermissive %s 2>&1 | FileCheck -check-prefix=PERMISSIVE -check-prefix=DELIMITERS %s
+
+// RUN: %clang -### -pedantic -fpermissive %s 2>&1 | FileCheck -check-prefix=PEDANTIC_PERMISSIVE %s
+// RUN: %clang -### -pedantic-errors 

[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-12 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama, kristof.beyls.
danalbert added a project: clang.
Herald added a subscriber: javed.absar.

There are an insignificant number of ARM Android devices that don't
support NEON. Default to using NEON since that will improve
performance on the majority of devices. Users that need to target
non-NEON devices can still explicitly disable NEON.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58153

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-mfpu.c


Index: clang/test/Driver/arm-mfpu.c
===
--- clang/test/Driver/arm-mfpu.c
+++ clang/test/Driver/arm-mfpu.c
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-D16 %s
+// CHECK-ARM7-ANDROID-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+d16"
+// 

[PATCH] D58152: [Sema] Delay checking whether objc_designated_initializer is being applied to an init method

2019-02-12 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: aaron.ballman, arphaman, erichkeane.
Herald added subscribers: jdoerfert, dexonsmith, jkorous.
Herald added a project: clang.

We ran into some source breaking changes to do with the attribute reordering 
changes that recently landed. The problem is that the order that 
`objc_designated_initializer` and `objc_method_family` are processed matters, 
because `objc_method_family` can make a method an init method, which is a 
prerequisite for `objc_designated_initializer`. When the attribute order 
flipped, the arrangement of these attributes that lead to an error and the 
arrangement that worked fine also flipped. This patch fixes this by delaying 
the check until both attributes have been processed.

rdar://47829358

Thanks!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D58152

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-designated-init.m

Index: clang/test/SemaObjC/attr-designated-init.m
===
--- clang/test/SemaObjC/attr-designated-init.m
+++ clang/test/SemaObjC/attr-designated-init.m
@@ -3,7 +3,7 @@
 #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
 #define NS_UNAVAILABLE __attribute__((unavailable))
 
-void fnfoo(void) NS_DESIGNATED_INITIALIZER; // expected-error {{only applies to init methods of interface or class extension declarations}}
+void fnfoo(void) NS_DESIGNATED_INITIALIZER; // expected-error {{'objc_designated_initializer' attribute only applies to Objective-C methods}}
 
 @protocol P1
 -(id)init NS_DESIGNATED_INITIALIZER; // expected-error {{only applies to init methods of interface or class extension declarations}}
@@ -428,3 +428,12 @@
 @interface CategoryForMissingInterface(Cat) // expected-error{{cannot find interface declaration}}
 - (instancetype)init NS_DESIGNATED_INITIALIZER; // expected-error{{only applies to init methods of interface or class extension declarations}}
 @end
+
+@interface TwoAttrs
+- (instancetype)foo
+__attribute__((objc_designated_initializer))
+__attribute__((objc_method_family(init)));
+- (instancetype)bar
+__attribute__((objc_method_family(init)))
+__attribute__((objc_designated_initializer));
+@end
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -97,6 +97,7 @@
 // CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
 // CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCBridgeRelated (SubjectMatchRule_record)
+// CHECK-NEXT: ObjCDesignatedInitializer (SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCException (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCExplicitProtocolImpl (SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5249,11 +5249,22 @@
 
 static void handleObjCDesignatedInitializer(Sema , Decl *D,
 const ParsedAttr ) {
+  auto *Ctx = D->getDeclContext();
+
+  // This attribute can only be applied to methods in interfaces or class
+  // extensions.
+  if (!isa(Ctx) &&
+  !(isa(Ctx) &&
+cast(Ctx)->IsClassExtension())) {
+S.Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
+return;
+  }
+
   ObjCInterfaceDecl *IFace;
-  if (auto *CatDecl = dyn_cast(D->getDeclContext()))
+  if (auto *CatDecl = dyn_cast(Ctx))
 IFace = CatDecl->getClassInterface();
   else
-IFace = cast(D->getDeclContext());
+IFace = cast(Ctx);
 
   if (!IFace)
 return;
@@ -7243,6 +7254,17 @@
   }
 }
   }
+
+  // Do this check after processing D's attributes because the attribute
+  // objc_method_family can change whether the given method is in the init
+  // family, and it can be applied after objc_designated_initializer. This is a
+  // bit of a hack, but we need it to be compatible with versions of clang that
+  // processed the attribute list in the wrong order.
+  if (D->hasAttr() &&
+  cast(D)->getMethodFamily() != OMF_init) {
+Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
+D->dropAttr();
+  }
 }
 
 // Helper for delayed processing TransparentUnion attribute.
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- 

[PATCH] D58120: [Builtins] Treat `bcmp` as a builtin.

2019-02-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

This looks essentially fine, but I'd like to see some basic test coverage for 
the changes to warnings and constant evaluation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58120



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-12 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Reviving this now that I have some cycles to work on this.

So I tried running this on csa-testbench projects but I didn't have much 
success. I always run into a bunch of build/env related errors:

  15:05:20 [libcxx] Checking out project... 
  [ERROR] Unknown option: json
  
  15:05:22 [libcxx] LOC: ?.
  15:05:22 [libcxx] Generating build log... 
  15:05:22 [libcxx_master] Analyzing project... 
  [ERROR] Traceback (most recent call last):
File 
"/local/mnt/workspace/mgrang/comm_analyzer/CodeChecker/cc_bin/CodeChecker.py", 
line 20, in 
  from shared.ttypes import RequestFailed
  ImportError: No module named shared.ttypes

I installed CodeChecker and various other dependencies mentioned in the README. 
Here's what my input json looks like:

  {
"projects": [
  {
"url": "git://github.com/chapuni/libcxx.git",
"name": "libcxx",
"clang_sa_args": "--analyze -Xanalyzer 
-analyzer-checker=alpha.nondeterminism.PointerSorting",
"clang_path": "path/to/llvm/install/bin",
"binary_dir": "build"
  },
  {
"name": "bitcoin",
"url": "https://github.com/bitcoin/bitcoin.git;,
"tag": "v0.15.1",
"clang_sa_args": "--analyze -Xanalyzer 
-analyzer-checker=alpha.nondeterminism.PointerSorting",
"clang_path": "path/to/llvm/install/bin",
"binary_dir": "build"
  },
  {
"name": "xerces-c",
"url": "https://github.com/apache/xerces-c.git;,
"prepared": true,
"clang_sa_args": "--analyze -Xanalyzer 
-analyzer-checker=alpha.nondeterminism.PointerSorting",
"clang_path": "path/to/llvm/install/bin",
"binary_dir": "build"
  }
],
  
"CodeChecker": {
  "url": "http://localhost:8001/Default;,
  "analyze_args": "",
  "store_args": ""
}
  }


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

https://reviews.llvm.org/D50488



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-12 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 186549.
Herald added subscribers: jdoerfert, baloghadamsoftware.

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

https://reviews.llvm.org/D50488

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
  test/Analysis/ptr-sort.cpp

Index: test/Analysis/ptr-sort.cpp
===
--- /dev/null
+++ test/Analysis/ptr-sort.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.nondeterminism.PointerSorting %s -analyzer-output=text -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+namespace std {
+  template
+  bool is_sorted(ForwardIt first, ForwardIt last);
+
+  template 
+  void nth_element(RandomIt first, RandomIt nth, RandomIt last);
+
+  template
+  void partial_sort(RandomIt first, RandomIt middle, RandomIt last);
+
+  template
+  void sort (RandomIt first, RandomIt last);
+
+  template
+  void stable_sort(RandomIt first, RandomIt last);
+
+  template
+  BidirIt partition(BidirIt first, BidirIt last, UnaryPredicate p);
+
+  template
+  BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);
+}
+
+bool f (int x) { return true; }
+bool g (int *x) { return true; }
+
+void PointerSorting() {
+  int a = 1, b = 2, c = 3;
+  std::vector V1 = {a, b};
+  std::vector V2 = {, };
+
+  std::is_sorted(V1.begin(), V1.end());// no-warning
+  std::nth_element(V1.begin(), V1.begin() + 1, V1.end());  // no-warning
+  std::partial_sort(V1.begin(), V1.begin() + 1, V1.end()); // no-warning
+  std::sort(V1.begin(), V1.end()); // no-warning
+  std::stable_sort(V1.begin(), V1.end());  // no-warning
+  std::partition(V1.begin(), V1.end(), f); // no-warning
+  std::stable_partition(V1.begin(), V1.end(), g);  // no-warning
+
+  std::is_sorted(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::nth_element(V2.begin(), V2.begin() + 1, V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::partial_sort(V2.begin(), V2.begin() + 1, V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::sort(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::stable_sort(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::partition(V2.begin(), V2.end(), f); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::stable_partition(V2.begin(), V2.end(), g); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+}
Index: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
@@ -0,0 +1,119 @@
+//===-- PointerSortingChecker.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines PointerSortingChecker which checks for non-determinism
+// caused due to sorting containers with pointer-like elements.
+//
+//===--===//
+

[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

Looks like my last email got lost:

I'm wondering if we can remove the binary requirement all together: is it 
possible to run a small program that would return EXIT_SUCCESS if the library 
is the correct version?

Something like:

  #include 
  
  int main()
  {
unsigned int major, minor, build, revision;
Z3_get_version(, , , );

if(major >= 4 && minor >= 7 && build >= 1)
  return EXIT_SUCCESS;
  
return EXIT_FAILURE;
  }

This would be part of FindZ3.cmake and would set Z3_FOUND.

Do you guys think it's possible? I'm almost certain it can be done with 
autotools, but I'm clueless when it comes to cmake.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

I found a `CHECK_CXX_SOURCE_COMPILES`, which seems to be used in a number of 
places in LLVM. I'll give it a try.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I reverted this in rC353893  because it was 
still causing test failures.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57977



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


r353893 - Revert r353880 "[HIP] Handle compile -m options and propagate into LLC"

2019-02-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Feb 12 14:51:54 2019
New Revision: 353893

URL: http://llvm.org/viewvc/llvm-project?rev=353893=rev
Log:
Revert r353880 "[HIP] Handle compile -m options and propagate into LLC"

This was still causing test failures in the clang test suite.

Removed:
cfe/trunk/test/Driver/hip-toolchain-features.hip
Modified:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=353893=353892=353893=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Tue Feb 12 14:51:54 2019
@@ -159,25 +159,8 @@ const char *AMDGCN::Linker::constructLlc
 llvm::StringRef OutputFilePrefix, const char *InputFileName) const {
   // Construct llc command.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-"-filetype=obj",
-Args.MakeArgString("-mcpu=" + SubArchName)};
-
-  // Extract all the -m options
-  std::vector Features;
-  handleTargetFeaturesGroup(
-Args, Features, options::OPT_m_amdgpu_Features_Group);
-
-  // Add features to mattr such as code-object-v3 and xnack
-  std::string MAttrString = "-mattr=";
-  for(auto OneFeature : Features) {
-MAttrString.append(Args.MakeArgString(OneFeature));
-if (OneFeature != Features.back())
-  MAttrString.append(",");
-  }
-  LlcArgs.push_back(Args.MakeArgString(MAttrString));
-
-  // Add output filename
-  LlcArgs.push_back("-o");
+"-filetype=obj", "-mattr=-code-object-v3",
+Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
   std::string LlcOutputFileName =
   C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
   const char *LlcOutputFile =

Removed: cfe/trunk/test/Driver/hip-toolchain-features.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-features.hip?rev=353892=auto
==
--- cfe/trunk/test/Driver/hip-toolchain-features.hip (original)
+++ cfe/trunk/test/Driver/hip-toolchain-features.hip (removed)
@@ -1,49 +0,0 @@
-// REQUIRES: clang-driver
-// REQUIRES: x86-registered-target
-// REQUIRES: amdgpu-registered-target
-
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mcode-object-v3 2>&1 | FileCheck %s -check-prefix=COV3
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mno-code-object-v3 2>&1 | FileCheck %s -check-prefix=NOCOV3
-
-// COV3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3"
-// NOCOV3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3"
-
-
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mxnack 2>&1 | FileCheck %s -check-prefix=XNACK
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mno-xnack 2>&1 | FileCheck %s -check-prefix=NOXNACK
-
-// XNACK: {{.*}}clang{{.*}}"-target-feature" "+xnack"
-// NOXNACK: {{.*}}clang{{.*}}"-target-feature" "-xnack"
-
-
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -msram-ecc 2>&1 | FileCheck %s -check-prefix=SRAM
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mno-sram-ecc 2>&1 | FileCheck %s -check-prefix=NOSRAM
-
-// SRAM: {{.*}}clang{{.*}}"-target-feature" "+sram-ecc"
-// NOSRAM: {{.*}}clang{{.*}}"-target-feature" "-sram-ecc"
-
-
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mcode-object-v3 -mxnack -msram-ecc \
-// RUN:   2>&1 | FileCheck %s -check-prefix=ALL3
-// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
-// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
-// RUN:   -mno-code-object-v3 -mno-xnack -mno-sram-ecc \
-// RUN:   2>&1 | FileCheck %s -check-prefix=NOALL3
-
-// ALL3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3" 
"-target-feature" "+xnack" "-target-feature" "+sram-ecc"
-// NOALL3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3" 
"-target-feature" "-xnack" "-target-feature" "-sram-ecc"
-


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


Re: [PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Mikhail Ramalho via cfe-commits
Hi,

Thank you for the discussion, I was finally able to reproduce the error.


> Hello @ddcc.
> I agree with your reasoning here and developed a patch based on this line
> of thought:
>
>   diff --git a/llvm/cmake/modules/FindZ3.cmake
> b/llvm/cmake/modules/FindZ3.cmake
>   index 5c6d3f0b427..b213342df37 100644
>   --- a/llvm/cmake/modules/FindZ3.cmake
>   +++ b/llvm/cmake/modules/FindZ3.cmake
>   @@ -39,6 +39,11 @@ if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE)
>string(REGEX REPLACE "^Z3 version ([0-9.]+)" "\\1"
>   Z3_VERSION_STRING "${libz3_version_str}")
>unset(libz3_version_str)
>   +else()
>   +# The version could not be determined from running Z3_EXECUTABLE.
> Set the
>   +# version Z3 to the lowest possible value such that all checks for a
>   +# minimum version will fail.
>   +set(Z3_VERSION_STRING "0.0.0")
>endif()
>
># handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if
>
> This works for everything I could throw at it. If you think it's
> reasonable I can open another ticket and have the code reviewed as a
> separate fix.
>
>
This seems fine but I'm wondering if we can remove the binary requirement
all together: is it possible to run a small program that would return
EXIT_SUCCESS if the library is the correct version?

Something like:
```
#include 

int main()
{
  unsigned int major, minor, build, revision;
  Z3_get_version(, , , );

  if(major >= 4 && minor >= 7 && build >= 1)
return EXIT_SUCCESS;

  return EXIT_FAILURE;
}
```

This would be part of FindZ3.cmake and would set Z3_FOUND.

Do you guys think it's possible? I'm almost certain it can be done with
autotools, but I'm clueless when it comes to cmake.

-- 

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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I think this breaks the attributes already listed in the functions on the IR 
since -mattr overrides those. I think we need to stop using subtarget features 
to communicate this


Repository:
  rC Clang

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

https://reviews.llvm.org/D57977



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


r353890 - docs: Update the ShadowCallStack documentation.

2019-02-12 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue Feb 12 14:45:23 2019
New Revision: 353890

URL: http://llvm.org/viewvc/llvm-project?rev=353890=rev
Log:
docs: Update the ShadowCallStack documentation.

- Remove most of the discussion of the x86_64 implementation;
  link to an older version of the documentation for details of
  that implementation.
- Add description of the compatibility and security issues discovered
  during the development of the aarch64 implementation for Android.

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

Modified:
cfe/trunk/docs/ShadowCallStack.rst

Modified: cfe/trunk/docs/ShadowCallStack.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ShadowCallStack.rst?rev=353890=353889=353890=diff
==
--- cfe/trunk/docs/ShadowCallStack.rst (original)
+++ cfe/trunk/docs/ShadowCallStack.rst Tue Feb 12 14:45:23 2019
@@ -8,28 +8,45 @@ ShadowCallStack
 Introduction
 
 
-ShadowCallStack is an **experimental** instrumentation pass, currently only
-implemented for x86_64 and aarch64, that protects programs against return
-address overwrites (e.g. stack buffer overflows.) It works by saving a
-function's return address to a separately allocated 'shadow call stack'
-in the function prolog and checking the return address on the stack against
-the shadow call stack in the function epilog.
+ShadowCallStack is an instrumentation pass, currently only implemented for
+aarch64 and x86_64, that protects programs against return address overwrites
+(e.g. stack buffer overflows.) It works by saving a function's return address
+to a separately allocated 'shadow call stack' in the function prolog in
+non-leaf functions and loading the return address from the shadow call stack
+in the function epilog. The return address is also stored on the regular stack
+for compatibility with unwinders, but is otherwise unused.
+
+The aarch64 implementation is considered production ready, and
+an `implementation of the runtime`_ has been added to Android's libc
+(bionic). The x86_64 implementation was evaluated using Chromium and was
+found to have critical performance and security deficiencies, and may be
+removed in a future release of the compiler. This document only describes
+the aarch64 implementation; details on the x86_64 implementation are found
+in the `Clang 7.0.1 documentation`_.
+
+.. _`implementation of the runtime`: 
https://android.googlesource.com/platform/bionic/+/808d176e7e0dd727c7f929622ec017f6e065c582/libc/bionic/pthread_create.cpp#128
+.. _`Clang 7.0.1 documentation`: 
https://releases.llvm.org/7.0.1/tools/clang/docs/ShadowCallStack.html
 
 Comparison
 --
 
-To optimize for memory consumption and cache locality, the shadow call stack
-stores an index followed by an array of return addresses. This is in contrast
-to other schemes, like :doc:`SafeStack`, that mirror the entire stack and
-trade-off consuming more memory for shorter function prologs and epilogs with
-fewer memory accesses. Similarly, `Return Flow Guard`_ consumes more memory 
with
-shorter function prologs and epilogs than ShadowCallStack but suffers from the
-same race conditions (see `Security`_). Intel `Control-flow Enforcement 
Technology`_
-(CET) is a proposed hardware extension that would add native support to
-use a shadow stack to store/check return addresses at call/return time. It
-would not suffer from race conditions at calls and returns and not incur the
-overhead of function instrumentation, but it does require operating system
-support.
+To optimize for memory consumption and cache locality, the shadow call
+stack stores only an array of return addresses. This is in contrast to other
+schemes, like :doc:`SafeStack`, that mirror the entire stack and trade-off
+consuming more memory for shorter function prologs and epilogs with fewer
+memory accesses.
+
+`Return Flow Guard`_ is a pure software implementation of shadow call stacks
+on x86_64. It is similar to the ShadowCallStack x86_64 implementation but
+trades off higher memory usage for a shorter prologue and epilogue. Like
+x86_64 ShadowCallStack, it is inherently racy due to the architecture's use
+of the stack for calls and returns.
+
+Intel `Control-flow Enforcement Technology`_ (CET) is a proposed hardware
+extension that would add native support to use a shadow stack to store/check
+return addresses at call/return time. Being a hardware implementation, it
+would not suffer from race conditions and would not incur the overhead of
+function instrumentation, but it does require operating system support.
 
 .. _`Return Flow Guard`: 
https://xlab.tencent.com/en/2016/11/02/return-flow-guard/
 .. _`Control-flow Enforcement Technology`: 
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf
@@ -37,57 +54,96 @@ support.
 Compatibility
 -
 
-ShadowCallStack currently only supports x86_64 and aarch64. A runtime is not

[PATCH] D56305: [AArch64] Support reserving arbitrary general purpose registers

2019-02-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:318
 
+  if (Args.hasArg(options::OPT_ffixed_x0))
+Features.push_back("+reserve-x0");

trong wrote:
> trong wrote:
> > phosek wrote:
> > > trong wrote:
> > > > What happens (should happen) if we reserve x0 and compile a function 
> > > > with a return value?
> > > Clang throws `error: AArch64 doesn't support function calls if any of the 
> > > argument registers is reserved.` as for any other argument register.
> > Yes, if x0 is reserved, it can't be used to pass arguments. But what 
> > happens if x0 is used to return a value? For example:
> > ```
> > int foo() {
> > return 1;
> > }
> > ```
> > It would be helpful if compiling `foo()` with x0 reserved threw an error.
> OTOH, [[ https://godbolt.org/z/jWW09Y | gcc ]] doesn't complain, so maybe 
> we're OK here.
IIRC gcc never reports any errors for its version of these flags; that doesn't 
mean we should accept constructs which don't have defined behavior.  I'd prefer 
to print an error in any situation where we would implicitly use a reserved 
register.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56305



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


[PATCH] D58149: [clang] Make sure C99/C11 features in are provided in C++11

2019-02-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added reviewers: jfb, eli.friedman.
Herald added subscribers: cfe-commits, dexonsmith, jkorous.
Herald added a project: clang.

Previously, those #defines were only provided in C or when GNU extensions were
enabled. We need those #defines in C++11 and above, too.


Repository:
  rC Clang

https://reviews.llvm.org/D58149

Files:
  clang/lib/Headers/float.h
  clang/test/Headers/float.c


Index: clang/test/Headers/float.c
===
--- clang/test/Headers/float.c
+++ clang/test/Headers/float.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++14 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++17 -ffreestanding %s
 // expected-no-diagnostics
 
 /* Basic floating point conformance checks against:
@@ -11,7 +14,7 @@
 /*
 C11,5.2.4.2.2p11,   pp. 30
 C99,5.2.4.2.2p9,pp. 25
-C89,2.2.4.2 
+C89,2.2.4.2
 */
 #include 
 
@@ -42,7 +45,7 @@
 #endif
 
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
 #ifndef FLT_DECIMAL_DIG
 #error "Mandatory macro FLT_DECIMAL_DIG is missing."
 #elif   FLT_DECIMAL_DIG < 6
@@ -98,7 +101,7 @@
 #endif
 
 
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
 #ifndef DECIMAL_DIG
 #error "Mandatory macro DECIMAL_DIG is missing."
 #elif   DECIMAL_DIG < 10
@@ -212,13 +215,13 @@
 _Static_assert(DBL_MANT_DIG == __DBL_MANT_DIG__, "");
 _Static_assert(LDBL_MANT_DIG == __LDBL_MANT_DIG__, "");
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
 _Static_assert(FLT_DECIMAL_DIG == __FLT_DECIMAL_DIG__, "");
 _Static_assert(DBL_DECIMAL_DIG == __DBL_DECIMAL_DIG__, "");
 _Static_assert(LDBL_DECIMAL_DIG == __LDBL_DECIMAL_DIG__, "");
 #endif
 
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
 _Static_assert(DECIMAL_DIG == __DECIMAL_DIG__, "");
 #endif
 
Index: clang/lib/Headers/float.h
===
--- clang/lib/Headers/float.h
+++ clang/lib/Headers/float.h
@@ -51,7 +51,7 @@
 #  undef FLT_MANT_DIG
 #  undef DBL_MANT_DIG
 #  undef LDBL_MANT_DIG
-#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+#  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201103L
 #undef DECIMAL_DIG
 #  endif
 #  undef FLT_DIG
@@ -78,7 +78,7 @@
 #  undef FLT_MIN
 #  undef DBL_MIN
 #  undef LDBL_MIN
-#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus 
>= 201103L
 #undef FLT_TRUE_MIN
 #undef DBL_TRUE_MIN
 #undef LDBL_TRUE_MIN
@@ -101,7 +101,7 @@
 #define DBL_MANT_DIG __DBL_MANT_DIG__
 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
 
-#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
 #  define DECIMAL_DIG __DECIMAL_DIG__
 #endif
 
@@ -137,7 +137,7 @@
 #define DBL_MIN __DBL_MIN__
 #define LDBL_MIN __LDBL_MIN__
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 
201103L
 #  define FLT_TRUE_MIN __FLT_DENORM_MIN__
 #  define DBL_TRUE_MIN __DBL_DENORM_MIN__
 #  define LDBL_TRUE_MIN __LDBL_DENORM_MIN__


Index: clang/test/Headers/float.c
===
--- clang/test/Headers/float.c
+++ clang/test/Headers/float.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++14 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++17 -ffreestanding %s
 // expected-no-diagnostics
 
 /* Basic floating point conformance checks against:
@@ -11,7 +14,7 @@
 /*
 C11,5.2.4.2.2p11,   pp. 30
 C99,5.2.4.2.2p9,pp. 25
-C89,2.2.4.2 
+C89,2.2.4.2
 */
 #include 
 
@@ -42,7 +45,7 @@
 #endif
 
 
-#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
+#if __STDC_VERSION__ >= 201112L || 

[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Brian Rzycki via Phabricator via cfe-commits
brzycki added a comment.

In D54978#1395288 , @ddcc wrote:

> In D54978#1395268 , @brzycki wrote:
>
> > I think I found why others are struggling to recreate this issue. I did not 
> > have the package `z3/bionic` installed. This provides the `/usr/bin/z3` 
> > executable which `llvm/cmake/modules/FindZ3.cmake` relies upon to determine 
> > the correct `Z3_VERSION_STRING`.
>
>
> Yeah, that's what I meant by best-effort only. Due to upstream Z3's design, 
> without the binary, there is no easy way to retrieve the current installed 
> version, so when I originally wrote the Z3 integration, it seemed fine to let 
> the version check pass. Given the issues that have come up, it might make 
> more sense to at least emit a warning, or explicitly fail if the version 
> can't be determined, and prompt the user to install the binary.


Hello @ddcc.
I agree with your reasoning here and developed a patch based on this line of 
thought:

  diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake
  index 5c6d3f0b427..b213342df37 100644
  --- a/llvm/cmake/modules/FindZ3.cmake
  +++ b/llvm/cmake/modules/FindZ3.cmake
  @@ -39,6 +39,11 @@ if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE)
   string(REGEX REPLACE "^Z3 version ([0-9.]+)" "\\1"
  Z3_VERSION_STRING "${libz3_version_str}")
   unset(libz3_version_str)
  +else()
  +# The version could not be determined from running Z3_EXECUTABLE. Set the
  +# version Z3 to the lowest possible value such that all checks for a
  +# minimum version will fail.
  +set(Z3_VERSION_STRING "0.0.0")
   endif()
  
   # handle the QUIETLY and REQUIRED arguments and set Z3_FOUND to TRUE if

This works for everything I could throw at it. If you think it's reasonable I 
can open another ticket and have the code reviewed as a separate fix.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D57961: [X86] Add explicit alignment to __m128/__m128i/__m128d/etc. to allow matching of MSVC behavior with #pragma pack.

2019-02-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Thanks for the fix @rnk, I've added some MSVC command lines to some of the 
other test files too.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57961



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


r353887 - [X86] Follow up to r353878, add MSVC compatibility command lines to other intrinsic tests that uses packed structs to control alignment.

2019-02-12 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Feb 12 14:12:19 2019
New Revision: 353887

URL: http://llvm.org/viewvc/llvm-project?rev=353887=rev
Log:
[X86] Follow up to r353878, add MSVC compatibility command lines to other 
intrinsic tests that uses packed structs to control alignment.

r353878 fixed a bug in _mm_loadu_ps and added a command line to catch it. 
Adding additional command lines to prevent breaking other intrinsics in the 
future.

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=353887=353886=353887=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Tue Feb 12 14:12:19 2019
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx -emit-llvm -o - -Wall -Werror | FileCheck %s
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck 
%s
+// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s 
-triple=x86_64-windows-msvc -target-feature +avx -emit-llvm -o - -Wall -Werror 
| FileCheck %s
 
 
 #include 

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=353887=353886=353887=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue Feb 12 14:12:19 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512f -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s 
-triple=x86_64-windows-msvc -target-feature +avx512f -emit-llvm -o - -Wall 
-Werror | FileCheck %s
 
 #include 
 
@@ -10139,70 +10140,70 @@ __m512i test_mm512_set_epi8(char e63, ch
 char e1, char e0) {
 
   //CHECK-LABEL: @test_mm512_set_epi8
-  //CHECK: load i8, i8* %e63.addr, align 1
-   //CHECK: load i8, i8* %e62.addr, align 1
-   //CHECK: load i8, i8* %e61.addr, align 1
-   //CHECK: load i8, i8* %e60.addr, align 1
-   //CHECK: load i8, i8* %e59.addr, align 1
-   //CHECK: load i8, i8* %e58.addr, align 1
-   //CHECK: load i8, i8* %e57.addr, align 1
-   //CHECK: load i8, i8* %e56.addr, align 1
-   //CHECK: load i8, i8* %e55.addr, align 1
-   //CHECK: load i8, i8* %e54.addr, align 1
-   //CHECK: load i8, i8* %e53.addr, align 1
-   //CHECK: load i8, i8* %e52.addr, align 1
-   //CHECK: load i8, i8* %e51.addr, align 1
-   //CHECK: load i8, i8* %e50.addr, align 1
-   //CHECK: load i8, i8* %e49.addr, align 1
-   //CHECK: load i8, i8* %e48.addr, align 1
-   //CHECK: load i8, i8* %e47.addr, align 1
-   //CHECK: load i8, i8* %e46.addr, align 1
-   //CHECK: load i8, i8* %e45.addr, align 1
-   //CHECK: load i8, i8* %e44.addr, align 1
-   //CHECK: load i8, i8* %e43.addr, align 1
-   //CHECK: load i8, i8* %e42.addr, align 1
-   //CHECK: load i8, i8* %e41.addr, align 1
-   //CHECK: load i8, i8* %e40.addr, align 1
-   //CHECK: load i8, i8* %e39.addr, align 1
-   //CHECK: load i8, i8* %e38.addr, align 1
-   //CHECK: load i8, i8* %e37.addr, align 1
-   //CHECK: load i8, i8* %e36.addr, align 1
-   //CHECK: load i8, i8* %e35.addr, align 1
-   //CHECK: load i8, i8* %e34.addr, align 1
-   //CHECK: load i8, i8* %e33.addr, align 1
-   //CHECK: load i8, i8* %e32.addr, align 1
-   //CHECK: load i8, i8* %e31.addr, align 1
-   //CHECK: load i8, i8* %e30.addr, align 1
-   //CHECK: load i8, i8* %e29.addr, align 1
-   //CHECK: load i8, i8* %e28.addr, align 1
-   //CHECK: load i8, i8* %e27.addr, align 1
-   //CHECK: load i8, i8* %e26.addr, align 1
-   //CHECK: load i8, i8* %e25.addr, align 1
-   //CHECK: load i8, i8* %e24.addr, align 1
-   //CHECK: load i8, i8* %e23.addr, align 1
-   //CHECK: load i8, i8* %e22.addr, align 1
-   //CHECK: load i8, i8* %e21.addr, align 1
-   //CHECK: load i8, i8* %e20.addr, align 1
-   //CHECK: load i8, i8* %e19.addr, align 1
-   //CHECK: load i8, i8* %e18.addr, align 1
-   //CHECK: load i8, i8* %e17.addr, align 1
-   //CHECK: load i8, i8* %e16.addr, align 1
-   //CHECK: load i8, i8* %e15.addr, align 1
-   //CHECK: load i8, i8* %e14.addr, align 1
-   //CHECK: load i8, i8* %e13.addr, align 1
-   //CHECK: load i8, i8* %e12.addr, align 1
-   //CHECK: load i8, i8* %e11.addr, align 1
-   //CHECK: load i8, i8* %e10.addr, align 1
-   //CHECK: load i8, i8* %e9.addr, align 1
-   //CHECK: load i8, i8* %e8.addr, align 1
-   //CHECK: load i8, i8* %e7.addr, align 1
-   //CHECK: load i8, i8* %e6.addr, align 1
-   //CHECK: load i8, i8* %e5.addr, align 1
-   //CHECK: load i8, i8* %e4.addr, align 1
-   //CHECK: load i8, i8* %e3.addr, align 1

[PATCH] D58147: [CodeGen] Fix calling llvm.var.annotation outside of a basic block.

2019-02-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I've checked and seems like other places where we `EmitAnnotationCall` should 
be safe. We do that for globals, function parameters, fields (`FieldDecl`) and 
early return isn't applicable in those cases. We can do that for any 
expressions with `__builtin_annotation` but that was already working correctly 
and I've just added a test.


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

https://reviews.llvm.org/D58147



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


[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-02-12 Thread John McCall via Phabricator via cfe-commits
rjmccall resigned from this revision.
rjmccall added a comment.
Herald added a subscriber: jdoerfert.

Sorry, this is deep in the loop analysis code, and I don't remember anything 
about this stuff, so I'm not sure I'm going to be a useful reviewer.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57978



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


[PATCH] D58147: [CodeGen] Fix calling llvm.var.annotation outside of a basic block.

2019-02-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added a reviewer: rjmccall.
Herald added subscribers: dexonsmith, jkorous, aprantl.

When we have an annotated local variable after a function returns, we
generate IR that fails verification with the error

> Instruction referencing instruction not embedded in a basic block!

And it means that bitcast referencing alloca doesn't have a parent basic
block.

Fix by checking if we are at an unreachable point and skip emitting
annotations. This approach is similar to the way we emit variable
initializer and debug info.

rdar://problem/46200420


https://reviews.llvm.org/D58147

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGen/annotations-builtin.c
  clang/test/CodeGen/annotations-var.c


Index: clang/test/CodeGen/annotations-var.c
===
--- clang/test/CodeGen/annotations-var.c
+++ clang/test/CodeGen/annotations-var.c
@@ -39,10 +39,19 @@
 // LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr 
inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), 
i32 33)
 }
 
+void local_after_return(void) {
+return;
+int localvar __attribute__((annotate("localvar_after_return"))) = 3;
+// Test we are not emitting instructions like bitcast or call outside of a 
basic block.
+// LOCAL-LABEL: define void @local_after_return()
+// LOCAL:  [[LOCALVAR:%.*]] = alloca i32,
+// LOCAL-NEXT: ret void
+}
+
 void undef(void) {
 int undefvar __attribute__((annotate("undefvar_ann_0")));
 // UNDEF-LABEL: define void @undef()
 // UNDEF:  [[UNDEFVAR:%.*]] = alloca i32,
 // UNDEF-NEXT: [[T0:%.*]] = bitcast i32* [[UNDEFVAR]] to i8*
-// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr 
inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), 
i32 43)
+// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr 
inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), 
i32 52)
 }
Index: clang/test/CodeGen/annotations-builtin.c
===
--- clang/test/CodeGen/annotations-builtin.c
+++ clang/test/CodeGen/annotations-builtin.c
@@ -43,4 +43,7 @@
 // CHECK: call i32 @llvm.annotation.i32
 // CHECK: inttoptr {{.*}} to i8**
 return 0;
+
+int after_return = __builtin_annotation(argc, "annotation_a");
+// CHECK-NOT: call i32 @llvm.annotation.i32
 }
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1487,7 +1487,7 @@
 (void)DI->EmitDeclareOfAutoVariable(, address.getPointer(), Builder);
   }
 
-  if (D.hasAttr())
+  if (D.hasAttr() && HaveInsertPoint())
 EmitVarAnnotations(, address.getPointer());
 
   // Make sure we call @llvm.lifetime.end.


Index: clang/test/CodeGen/annotations-var.c
===
--- clang/test/CodeGen/annotations-var.c
+++ clang/test/CodeGen/annotations-var.c
@@ -39,10 +39,19 @@
 // LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33)
 }
 
+void local_after_return(void) {
+return;
+int localvar __attribute__((annotate("localvar_after_return"))) = 3;
+// Test we are not emitting instructions like bitcast or call outside of a basic block.
+// LOCAL-LABEL: define void @local_after_return()
+// LOCAL:  [[LOCALVAR:%.*]] = alloca i32,
+// LOCAL-NEXT: ret void
+}
+
 void undef(void) {
 int undefvar __attribute__((annotate("undefvar_ann_0")));
 // UNDEF-LABEL: define void @undef()
 // UNDEF:  [[UNDEFVAR:%.*]] = alloca i32,
 // UNDEF-NEXT: [[T0:%.*]] = bitcast i32* [[UNDEFVAR]] to i8*
-// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 43)
+// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 52)
 }
Index: clang/test/CodeGen/annotations-builtin.c
===
--- clang/test/CodeGen/annotations-builtin.c
+++ clang/test/CodeGen/annotations-builtin.c
@@ -43,4 +43,7 @@
 // CHECK: call i32 @llvm.annotation.i32
 // CHECK: inttoptr {{.*}} to i8**
 return 0;
+
+int after_return = __builtin_annotation(argc, "annotation_a");
+// CHECK-NOT: call i32 @llvm.annotation.i32
 }
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1487,7 +1487,7 @@
 (void)DI->EmitDeclareOfAutoVariable(, address.getPointer(), Builder);
   }
 
-  if (D.hasAttr())
+  if (D.hasAttr() && HaveInsertPoint())
 EmitVarAnnotations(, address.getPointer());
 
   

[PATCH] D58060: Fix diagnostic for addr spaces in static_cast

2019-02-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1830
+  "binding value %diff{of type $ to reference to type $|to reference}0,1 "
+  "changes address space">;
 def err_reference_bind_failed : Error<

We say that references are bound to objects, not that objects are bound to 
references.



Comment at: lib/Sema/SemaInit.cpp:4601
+  // addr space must be a superset.
+  T1Quals.isAddressSpaceSupersetOf(T2Quals))) {
 if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy)

I think the comment should go after the quote in the main comment above, i.e. 
something like "For address spaces, we interpret this to mean..."

Also, this clause is part of the parenthesized group and should be indented 
consistently.


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

https://reviews.llvm.org/D58060



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


[PATCH] D58057: Allow bundle size to be 0 in clang-offload-bundler

2019-02-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I really don't understand this well enough to review.


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

https://reviews.llvm.org/D58057



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


r353885 - [HIP] Fix hip-toolchain-rdc tests

2019-02-12 Thread Aaron Enye Shi via cfe-commits
Author: aaronenyeshi
Date: Tue Feb 12 14:01:19 2019
New Revision: 353885

URL: http://llvm.org/viewvc/llvm-project?rev=353885=rev
Log:
[HIP] Fix hip-toolchain-rdc tests

Since we removed changed the way HIP Toolchain will propagate -m options into 
LLC, we need to remove from these older tests.

This is related to rC353880.

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


Modified:
cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip
cfe/trunk/test/Driver/hip-toolchain-rdc.hip

Modified: cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip?rev=353885=353884=353885=diff
==
--- cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip (original)
+++ cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip Tue Feb 12 14:01:19 2019
@@ -34,7 +34,6 @@
 
 // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa"
 // CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-mattr=-code-object-v3"
 // CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]]
 
 // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
@@ -62,7 +61,6 @@
 
 // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa"
 // CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-mattr=-code-object-v3"
 // CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]]
 
 // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
@@ -105,7 +103,6 @@
 
 // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_803]] "-mtriple=amdgcn-amd-amdhsa"
 // CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-mattr=-code-object-v3"
 // CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV_B_803:".*-gfx803-.*o"]]
 
 // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
@@ -133,7 +130,6 @@
 
 // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_B_900]] "-mtriple=amdgcn-amd-amdhsa"
 // CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-mattr=-code-object-v3"
 // CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV_B_900:".*-gfx900-.*o"]]
 
 // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"

Modified: cfe/trunk/test/Driver/hip-toolchain-rdc.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-rdc.hip?rev=353885=353884=353885=diff
==
--- cfe/trunk/test/Driver/hip-toolchain-rdc.hip (original)
+++ cfe/trunk/test/Driver/hip-toolchain-rdc.hip Tue Feb 12 14:01:19 2019
@@ -38,7 +38,6 @@
 
 // CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV1]] "-mtriple=amdgcn-amd-amdhsa"
 // CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-mattr=-code-object-v3"
 // CHECK-SAME: "-mcpu=gfx803" "-o" [[OBJ_DEV1:".*-gfx803-.*o"]]
 
 // CHECK: [[LLD: ".*lld"]] "-flavor" "gnu" "--no-undefined" "-shared"
@@ -66,7 +65,6 @@
 
 // CHECK: [[LLC]] [[OPT_BC_DEV2]] "-mtriple=amdgcn-amd-amdhsa"
 // CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-mattr=-code-object-v3"
 // CHECK-SAME: "-mcpu=gfx900" "-o" [[OBJ_DEV2:".*-gfx900-.*o"]]
 
 // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"


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


[PATCH] D56924: Handle ObjCCategoryDecl class extensions for print

2019-02-12 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D57965: Clean up ObjCPropertyDecl printing

2019-02-12 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

> @property(attr, attr2) instead of @property ( attr,attr2 ).

The style I see most often is `@property (attr, attr2)`, which is in between 
those two.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57965



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


[PATCH] D57965: Clean up ObjCPropertyDecl printing

2019-02-12 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added subscribers: akyrtzi, benlangmuir.
benlangmuir added a comment.

@arphaman @akyrtzi could you take a look at this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57965



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


r353882 - Make ModuleDependencyCollector's method virtual (NFC)

2019-02-12 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Feb 12 13:45:14 2019
New Revision: 353882

URL: http://llvm.org/viewvc/llvm-project?rev=353882=rev
Log:
Make ModuleDependencyCollector's method virtual (NFC)

For reproducers in LLDB we want to hook up into the existing clang
infrastructure. To make that happen we need to be able to override the
ModuleDependencyCollector's methods.

The alternative was to inherit from the DependencyCollector directly,
but that would mean re-implementing the ModuleDependencyListener and the
ModuleDependencyPPCallbacks and ModuleDependencyMMCallbacks.

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

Modified:
cfe/trunk/include/clang/Frontend/Utils.h

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=353882=353881=353882=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Tue Feb 12 13:45:14 2019
@@ -145,18 +145,18 @@ public:
   ~ModuleDependencyCollector() override { writeFileMap(); }
 
   StringRef getDest() { return DestDir; }
-  bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void addFile(StringRef Filename, StringRef FileDst = {});
+  virtual bool insertSeen(StringRef Filename) { return 
Seen.insert(Filename).second; }
+  virtual void addFile(StringRef Filename, StringRef FileDst = {});
 
-  void addFileMapping(StringRef VPath, StringRef RPath) {
+  virtual void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }
 
   void attachToPreprocessor(Preprocessor ) override;
   void attachToASTReader(ASTReader ) override;
 
-  void writeFileMap();
-  bool hasErrors() { return HasErrors; }
+  virtual void writeFileMap();
+  virtual bool hasErrors() { return HasErrors; }
 };
 
 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach


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


[PATCH] D58072: Make ModuleDependencyCollector's method virtual (NFC)

2019-02-12 Thread Jonas Devlieghere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353882: Make ModuleDependencyCollectors method virtual 
(NFC) (authored by JDevlieghere, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58072?vs=186320=186538#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58072

Files:
  cfe/trunk/include/clang/Frontend/Utils.h


Index: cfe/trunk/include/clang/Frontend/Utils.h
===
--- cfe/trunk/include/clang/Frontend/Utils.h
+++ cfe/trunk/include/clang/Frontend/Utils.h
@@ -145,18 +145,18 @@
   ~ModuleDependencyCollector() override { writeFileMap(); }
 
   StringRef getDest() { return DestDir; }
-  bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void addFile(StringRef Filename, StringRef FileDst = {});
+  virtual bool insertSeen(StringRef Filename) { return 
Seen.insert(Filename).second; }
+  virtual void addFile(StringRef Filename, StringRef FileDst = {});
 
-  void addFileMapping(StringRef VPath, StringRef RPath) {
+  virtual void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }
 
   void attachToPreprocessor(Preprocessor ) override;
   void attachToASTReader(ASTReader ) override;
 
-  void writeFileMap();
-  bool hasErrors() { return HasErrors; }
+  virtual void writeFileMap();
+  virtual bool hasErrors() { return HasErrors; }
 };
 
 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach


Index: cfe/trunk/include/clang/Frontend/Utils.h
===
--- cfe/trunk/include/clang/Frontend/Utils.h
+++ cfe/trunk/include/clang/Frontend/Utils.h
@@ -145,18 +145,18 @@
   ~ModuleDependencyCollector() override { writeFileMap(); }
 
   StringRef getDest() { return DestDir; }
-  bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void addFile(StringRef Filename, StringRef FileDst = {});
+  virtual bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
+  virtual void addFile(StringRef Filename, StringRef FileDst = {});
 
-  void addFileMapping(StringRef VPath, StringRef RPath) {
+  virtual void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }
 
   void attachToPreprocessor(Preprocessor ) override;
   void attachToASTReader(ASTReader ) override;
 
-  void writeFileMap();
-  bool hasErrors() { return HasErrors; }
+  virtual void writeFileMap();
+  virtual bool hasErrors() { return HasErrors; }
 };
 
 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58145: [Sema] Fix a bogus -Wconversion warning

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

DiagnoseFloatingImpCast expects an integer type, but the changes introduced in 
D50467  caused us to warn on any builtin type, 
even pseudo-object type. This lead to us warning in this property expression's 
syntactic form. Its not clear to me that we should even be analyzing the 
syntactic form here, but this patch fixes the regression.

rdar://47644670

Thanks!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D58145

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/conversion.m


Index: clang/test/SemaObjC/conversion.m
===
--- clang/test/SemaObjC/conversion.m
+++ clang/test/SemaObjC/conversion.m
@@ -14,4 +14,11 @@
   x = y; // expected-warning {{implicit conversion loses integer precision: 
'int' to 'char'}}
 }
 
+__attribute__((objc_root_class)) @interface DoubleProp
+@property double d;
+@end
 
+void use_double_prop(DoubleProp *dp) {
+  double local = 42;
+  dp.d += local;
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10624,16 +10624,15 @@
   // The below checks assume source is floating point.
   if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
 
-  // If source is floating point but target is not.
-  if (!ResultBT->isFloatingPoint())
-return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
-   E->getExprLoc());
-
-  // If both source and target are floating points.
-  // Builtin FP kinds are ordered by increasing FP rank.
-  if (ResultBT->getKind() < RBT->getKind() &&
-  // We don't want to warn for system macro.
-  !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+  // If source is floating point but target is an integer.
+  if (ResultBT->isInteger())
+DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(), E->getExprLoc());
+  // If both source and target are floating points. Builtin FP kinds are 
ordered
+  // by increasing FP rank. FIXME: except _Float16, we currently emit a bogus
+  // warning.
+  else if (ResultBT->isFloatingType() && ResultBT->getKind() < RBT->getKind() 
&&
+   // We don't want to warn for system macro.
+   !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
 // warn about dropping FP rank.
 DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), 
E->getOperatorLoc(),
 diag::warn_impcast_float_result_precision);


Index: clang/test/SemaObjC/conversion.m
===
--- clang/test/SemaObjC/conversion.m
+++ clang/test/SemaObjC/conversion.m
@@ -14,4 +14,11 @@
   x = y; // expected-warning {{implicit conversion loses integer precision: 'int' to 'char'}}
 }
 
+__attribute__((objc_root_class)) @interface DoubleProp
+@property double d;
+@end
 
+void use_double_prop(DoubleProp *dp) {
+  double local = 42;
+  dp.d += local;
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10624,16 +10624,15 @@
   // The below checks assume source is floating point.
   if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
 
-  // If source is floating point but target is not.
-  if (!ResultBT->isFloatingPoint())
-return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
-   E->getExprLoc());
-
-  // If both source and target are floating points.
-  // Builtin FP kinds are ordered by increasing FP rank.
-  if (ResultBT->getKind() < RBT->getKind() &&
-  // We don't want to warn for system macro.
-  !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+  // If source is floating point but target is an integer.
+  if (ResultBT->isInteger())
+DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(), E->getExprLoc());
+  // If both source and target are floating points. Builtin FP kinds are ordered
+  // by increasing FP rank. FIXME: except _Float16, we currently emit a bogus
+  // warning.
+  else if (ResultBT->isFloatingType() && ResultBT->getKind() < RBT->getKind() &&
+   // We don't want to warn for system macro.
+   !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
 // warn about dropping FP rank.
 DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), E->getOperatorLoc(),
 diag::warn_impcast_float_result_precision);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58072: Make ModuleDependencyCollector's method virtual (NFC)

2019-02-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D58072



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


[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57948



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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353880: [HIP] Handle compile -m options and propagate into 
LLC (authored by aaronenyeshi, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57977?vs=186528=186534#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57977

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-toolchain-features.hip


Index: test/Driver/hip-toolchain-features.hip
===
--- test/Driver/hip-toolchain-features.hip
+++ test/Driver/hip-toolchain-features.hip
@@ -0,0 +1,49 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 2>&1 | FileCheck %s -check-prefix=COV3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 2>&1 | FileCheck %s -check-prefix=NOCOV3
+
+// COV3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3"
+// NOCOV3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mxnack 2>&1 | FileCheck %s -check-prefix=XNACK
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-xnack 2>&1 | FileCheck %s -check-prefix=NOXNACK
+
+// XNACK: {{.*}}clang{{.*}}"-target-feature" "+xnack"
+// NOXNACK: {{.*}}clang{{.*}}"-target-feature" "-xnack"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -msram-ecc 2>&1 | FileCheck %s -check-prefix=SRAM
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-sram-ecc 2>&1 | FileCheck %s -check-prefix=NOSRAM
+
+// SRAM: {{.*}}clang{{.*}}"-target-feature" "+sram-ecc"
+// NOSRAM: {{.*}}clang{{.*}}"-target-feature" "-sram-ecc"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 -mxnack -msram-ecc \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ALL3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 -mno-xnack -mno-sram-ecc \
+// RUN:   2>&1 | FileCheck %s -check-prefix=NOALL3
+
+// ALL3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3" 
"-target-feature" "+xnack" "-target-feature" "+sram-ecc"
+// NOALL3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3" 
"-target-feature" "-xnack" "-target-feature" "-sram-ecc"
+
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -159,8 +159,25 @@
 llvm::StringRef OutputFilePrefix, const char *InputFileName) const {
   // Construct llc command.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-"-filetype=obj", "-mattr=-code-object-v3",
-Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
+"-filetype=obj",
+Args.MakeArgString("-mcpu=" + SubArchName)};
+
+  // Extract all the -m options
+  std::vector Features;
+  handleTargetFeaturesGroup(
+Args, Features, options::OPT_m_amdgpu_Features_Group);
+
+  // Add features to mattr such as code-object-v3 and xnack
+  std::string MAttrString = "-mattr=";
+  for(auto OneFeature : Features) {
+MAttrString.append(Args.MakeArgString(OneFeature));
+if (OneFeature != Features.back())
+  MAttrString.append(",");
+  }
+  LlcArgs.push_back(Args.MakeArgString(MAttrString));
+
+  // Add output filename
+  LlcArgs.push_back("-o");
   std::string LlcOutputFileName =
   C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
   const char *LlcOutputFile =


Index: test/Driver/hip-toolchain-features.hip
===
--- test/Driver/hip-toolchain-features.hip
+++ test/Driver/hip-toolchain-features.hip
@@ -0,0 +1,49 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 2>&1 | FileCheck %s -check-prefix=COV3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 

r353880 - [HIP] Handle compile -m options and propagate into LLC

2019-02-12 Thread Aaron Enye Shi via cfe-commits
Author: aaronenyeshi
Date: Tue Feb 12 13:21:06 2019
New Revision: 353880

URL: http://llvm.org/viewvc/llvm-project?rev=353880=rev
Log:
[HIP] Handle compile -m options and propagate into LLC

Allow the compile options for -m such as -mxnack/-mno-xnack, 
-msram-ecc/-mno-sram-ecc, -mcode-object-v3/-mno-code-object-v3 to propagate 
into LLC args.

Also add lit tests to verify features are properly passed.

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

Reviewers: yaxunl, kzhuravl


Added:
cfe/trunk/test/Driver/hip-toolchain-features.hip
Modified:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=353880=353879=353880=diff
==
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Tue Feb 12 13:21:06 2019
@@ -159,8 +159,25 @@ const char *AMDGCN::Linker::constructLlc
 llvm::StringRef OutputFilePrefix, const char *InputFileName) const {
   // Construct llc command.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-"-filetype=obj", "-mattr=-code-object-v3",
-Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
+"-filetype=obj",
+Args.MakeArgString("-mcpu=" + SubArchName)};
+
+  // Extract all the -m options
+  std::vector Features;
+  handleTargetFeaturesGroup(
+Args, Features, options::OPT_m_amdgpu_Features_Group);
+
+  // Add features to mattr such as code-object-v3 and xnack
+  std::string MAttrString = "-mattr=";
+  for(auto OneFeature : Features) {
+MAttrString.append(Args.MakeArgString(OneFeature));
+if (OneFeature != Features.back())
+  MAttrString.append(",");
+  }
+  LlcArgs.push_back(Args.MakeArgString(MAttrString));
+
+  // Add output filename
+  LlcArgs.push_back("-o");
   std::string LlcOutputFileName =
   C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
   const char *LlcOutputFile =

Added: cfe/trunk/test/Driver/hip-toolchain-features.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-features.hip?rev=353880=auto
==
--- cfe/trunk/test/Driver/hip-toolchain-features.hip (added)
+++ cfe/trunk/test/Driver/hip-toolchain-features.hip Tue Feb 12 13:21:06 2019
@@ -0,0 +1,49 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 2>&1 | FileCheck %s -check-prefix=COV3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 2>&1 | FileCheck %s -check-prefix=NOCOV3
+
+// COV3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3"
+// NOCOV3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mxnack 2>&1 | FileCheck %s -check-prefix=XNACK
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-xnack 2>&1 | FileCheck %s -check-prefix=NOXNACK
+
+// XNACK: {{.*}}clang{{.*}}"-target-feature" "+xnack"
+// NOXNACK: {{.*}}clang{{.*}}"-target-feature" "-xnack"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -msram-ecc 2>&1 | FileCheck %s -check-prefix=SRAM
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-sram-ecc 2>&1 | FileCheck %s -check-prefix=NOSRAM
+
+// SRAM: {{.*}}clang{{.*}}"-target-feature" "+sram-ecc"
+// NOSRAM: {{.*}}clang{{.*}}"-target-feature" "-sram-ecc"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 -mxnack -msram-ecc \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ALL3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 -mno-xnack -mno-sram-ecc \
+// RUN:   2>&1 | FileCheck %s -check-prefix=NOALL3
+
+// ALL3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3" 
"-target-feature" "+xnack" "-target-feature" "+sram-ecc"
+// NOALL3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3" 
"-target-feature" "-xnack" "-target-feature" "-sram-ecc"
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r353878 - [X86] Use __m128_u for _mm_loadu_ps after r353555

2019-02-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Feb 12 13:04:21 2019
New Revision: 353878

URL: http://llvm.org/viewvc/llvm-project?rev=353878=rev
Log:
[X86] Use __m128_u for _mm_loadu_ps after r353555

Add secondary triple to existing SSE test for it.  I audited other uses
of __attribute__((__packed__)) in the intrinsic headers, and this seemed
to be the only missing one.

Modified:
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=353878=353877=353878=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Tue Feb 12 13:04:21 2019
@@ -1754,7 +1754,7 @@ static __inline__ __m128 __DEFAULT_FN_AT
 _mm_loadu_ps(const float *__p)
 {
   struct __loadu_ps {
-__m128 __v;
+__m128_u __v;
   } __attribute__((__packed__, __may_alias__));
   return ((struct __loadu_ps*)__p)->__v;
 }

Modified: cfe/trunk/test/CodeGen/sse-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse-builtins.c?rev=353878=353877=353878=diff
==
--- cfe/trunk/test/CodeGen/sse-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse-builtins.c Tue Feb 12 13:04:21 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -fms-compatibility -ffreestanding %s 
-triple=x86_64-windows-msvc -target-feature +sse -emit-llvm -o - -Wall -Werror 
| FileCheck %s
 
 
 #include 


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


[PATCH] D58072: Make ModuleDependencyCollector's method virtual (NFC)

2019-02-12 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Alright, I'll split this up in two patches


Repository:
  rC Clang

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

https://reviews.llvm.org/D58072



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


[PATCH] D56927: Disable PIC/PIE for MSP430 target

2019-02-12 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353877: Disable PIC/PIE for MSP430 target (authored by asl, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56927

Files:
  cfe/trunk/lib/Driver/ToolChains/MSP430.h
  cfe/trunk/test/CodeGen/msp430-reloc.c


Index: cfe/trunk/test/CodeGen/msp430-reloc.c
===
--- cfe/trunk/test/CodeGen/msp430-reloc.c
+++ cfe/trunk/test/CodeGen/msp430-reloc.c
@@ -0,0 +1,30 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s
+
+// Check the compilation does not crash as it was crashing before with "-fPIC" 
enabled
+
+void *alloca(unsigned int size);
+
+// CHECK: .globl foo
+short foo(char** data, char encoding)
+{
+   char* encoding_addr = alloca(sizeof(char));
+   *encoding_addr = encoding;
+
+   char tmp3 = *encoding_addr;
+   short conv2 = tmp3;
+   short and = conv2 & 0xf;
+
+   switch (and)
+   {
+   case 0 :
+   case 4 :
+   case 10 :
+   return 1;
+   case 11 :
+   return 2;
+   }
+
+   return 0;
+}
+
Index: cfe/trunk/lib/Driver/ToolChains/MSP430.h
===
--- cfe/trunk/lib/Driver/ToolChains/MSP430.h
+++ cfe/trunk/lib/Driver/ToolChains/MSP430.h
@@ -36,6 +36,10 @@
  llvm::opt::ArgStringList ,
  Action::OffloadKind) const override;
 
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
+
 protected:
   Tool *buildLinker() const override;
 


Index: cfe/trunk/test/CodeGen/msp430-reloc.c
===
--- cfe/trunk/test/CodeGen/msp430-reloc.c
+++ cfe/trunk/test/CodeGen/msp430-reloc.c
@@ -0,0 +1,30 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s
+
+// Check the compilation does not crash as it was crashing before with "-fPIC" enabled
+
+void *alloca(unsigned int size);
+
+// CHECK: .globl foo
+short foo(char** data, char encoding)
+{
+	char* encoding_addr = alloca(sizeof(char));
+	*encoding_addr = encoding;
+
+	char tmp3 = *encoding_addr;
+	short conv2 = tmp3;
+	short and = conv2 & 0xf;
+
+	switch (and)
+	{
+	case 0 :
+	case 4 :
+	case 10 :
+		return 1;
+	case 11 :
+		return 2;
+	}
+
+	return 0;
+}
+
Index: cfe/trunk/lib/Driver/ToolChains/MSP430.h
===
--- cfe/trunk/lib/Driver/ToolChains/MSP430.h
+++ cfe/trunk/lib/Driver/ToolChains/MSP430.h
@@ -36,6 +36,10 @@
  llvm::opt::ArgStringList ,
  Action::OffloadKind) const override;
 
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
+
 protected:
   Tool *buildLinker() const override;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353877 - Disable PIC/PIE for MSP430 target

2019-02-12 Thread Anton Korobeynikov via cfe-commits
Author: asl
Date: Tue Feb 12 12:46:00 2019
New Revision: 353877

URL: http://llvm.org/viewvc/llvm-project?rev=353877=rev
Log:
Disable PIC/PIE for MSP430 target

Relocatable code generation is meaningless on MSP430, as the platform is too 
small to use shared libraries.

Patch by Dmitry Mikushev!

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

Added:
cfe/trunk/test/CodeGen/msp430-reloc.c
Modified:
cfe/trunk/lib/Driver/ToolChains/MSP430.h

Modified: cfe/trunk/lib/Driver/ToolChains/MSP430.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSP430.h?rev=353877=353876=353877=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSP430.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSP430.h Tue Feb 12 12:46:00 2019
@@ -36,6 +36,10 @@ public:
  llvm::opt::ArgStringList ,
  Action::OffloadKind) const override;
 
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
+
 protected:
   Tool *buildLinker() const override;
 

Added: cfe/trunk/test/CodeGen/msp430-reloc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/msp430-reloc.c?rev=353877=auto
==
--- cfe/trunk/test/CodeGen/msp430-reloc.c (added)
+++ cfe/trunk/test/CodeGen/msp430-reloc.c Tue Feb 12 12:46:00 2019
@@ -0,0 +1,30 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s
+
+// Check the compilation does not crash as it was crashing before with "-fPIC" 
enabled
+
+void *alloca(unsigned int size);
+
+// CHECK: .globl foo
+short foo(char** data, char encoding)
+{
+   char* encoding_addr = alloca(sizeof(char));
+   *encoding_addr = encoding;
+
+   char tmp3 = *encoding_addr;
+   short conv2 = tmp3;
+   short and = conv2 & 0xf;
+
+   switch (and)
+   {
+   case 0 :
+   case 4 :
+   case 10 :
+   return 1;
+   case 11 :
+   return 2;
+   }
+
+   return 0;
+}
+


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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM. Please make sure to update your commit message as your patch processes 
all m options now.


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

https://reviews.llvm.org/D57977



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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 added a comment.

Yes, but it will need this PR: 
https://github.com/ROCm-Developer-Tools/HIP/pull/910
So that the default is set.


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

https://reviews.llvm.org/D57977



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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Is it still code object v2 by default?


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

https://reviews.llvm.org/D57977



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


[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

In D54978#1395268 , @brzycki wrote:

> I think I found why others are struggling to recreate this issue. I did not 
> have the package `z3/bionic` installed. This provides the `/usr/bin/z3` 
> executable which `llvm/cmake/modules/FindZ3.cmake` relies upon to determine 
> the correct `Z3_VERSION_STRING`.


Yeah, that's what I meant by best-effort only. Due to upstream Z3's design, 
without the binary, there is no easy way to retrieve the current installed 
version, so when I originally wrote the Z3 integration, it seemed fine to let 
the version check pass. Given the issues that have come up, it might make more 
sense to at least emit a warning, or explicitly fail if the version can't be 
determined, and prompt the user to install the binary.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 186528.
ashi1 added a comment.

I've added a lit test to check for options such as -mxnack/-mno-xnack, 
-msram-ecc/-mno-sram-ecc, -mcode-object-v3/-mno-code-object-v3


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

https://reviews.llvm.org/D57977

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-toolchain-features.hip


Index: test/Driver/hip-toolchain-features.hip
===
--- /dev/null
+++ test/Driver/hip-toolchain-features.hip
@@ -0,0 +1,48 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 2>&1 | FileCheck %s -check-prefix=COV3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 2>&1 | FileCheck %s -check-prefix=NOCOV3
+
+// COV3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3"
+// NOCOV3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mxnack 2>&1 | FileCheck %s -check-prefix=XNACK
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-xnack 2>&1 | FileCheck %s -check-prefix=NOXNACK
+
+// XNACK: {{.*}}clang{{.*}}"-target-feature" "+xnack"
+// NOXNACK: {{.*}}clang{{.*}}"-target-feature" "-xnack"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -msram-ecc 2>&1 | FileCheck %s -check-prefix=SRAM
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-sram-ecc 2>&1 | FileCheck %s -check-prefix=NOSRAM
+
+// SRAM: {{.*}}clang{{.*}}"-target-feature" "+sram-ecc"
+// NOSRAM: {{.*}}clang{{.*}}"-target-feature" "-sram-ecc"
+
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 -mxnack -msram-ecc \
+// RUN:   2>&1 | FileCheck %s -check-prefix=ALL3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 -mno-xnack -mno-sram-ecc \
+// RUN:   2>&1 | FileCheck %s -check-prefix=NOALL3
+
+// ALL3: {{.*}}clang{{.*}}"-target-feature" "+code-object-v3" 
"-target-feature" "+xnack" "-target-feature" "+sram-ecc"
+// NOALL3: {{.*}}clang{{.*}}"-target-feature" "-code-object-v3" 
"-target-feature" "-xnack" "-target-feature" "-sram-ecc"
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -162,9 +162,26 @@
   // AMDGPUPromoteAlloca pass which cause invalid memory access in PyTorch.
   // Remove this once the issue is fixed.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-"-filetype=obj", "-mattr=-code-object-v3",
+"-filetype=obj",
 "-disable-promote-alloca-to-lds",
-Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
+Args.MakeArgString("-mcpu=" + SubArchName)};
+
+  // Extract all the -m options
+  std::vector Features;
+  handleTargetFeaturesGroup(
+Args, Features, options::OPT_m_amdgpu_Features_Group);
+
+  // Add features to mattr such as code-object-v3 and xnack
+  std::string MAttrString = "-mattr=";
+  for(auto OneFeature : Features) {
+MAttrString.append(Args.MakeArgString(OneFeature));
+if (OneFeature != Features.back())
+  MAttrString.append(",");
+  }
+  LlcArgs.push_back(Args.MakeArgString(MAttrString));
+
+  // Add output filename
+  LlcArgs.push_back("-o");
   std::string LlcOutputFileName =
   C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
   const char *LlcOutputFile =


Index: test/Driver/hip-toolchain-features.hip
===
--- /dev/null
+++ test/Driver/hip-toolchain-features.hip
@@ -0,0 +1,48 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mcode-object-v3 2>&1 | FileCheck %s -check-prefix=COV3
+// RUN: %clang -### -c -target x86_64-linux-gnu -fgpu-rdc \
+// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
+// RUN:   -mno-code-object-v3 2>&1 | FileCheck %s -check-prefix=NOCOV3
+
+// 

r353875 - [NFC] typo

2019-02-12 Thread JF Bastien via cfe-commits
Author: jfb
Date: Tue Feb 12 12:19:16 2019
New Revision: 353875

URL: http://llvm.org/viewvc/llvm-project?rev=353875=rev
Log:
[NFC] typo

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=353875=353874=353875=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Feb 12 12:19:16 2019
@@ -3851,7 +3851,7 @@ public:
   static bool classofKind(Kind K) { return K == FileScopeAsm; }
 };
 
-/// Pepresents a block literal declaration, which is like an
+/// Represents a block literal declaration, which is like an
 /// unnamed FunctionDecl.  For example:
 /// ^{ statement-body }   or   ^(int arg1, float arg2){ statement-body }
 class BlockDecl : public Decl, public DeclContext {


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


[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Brian Rzycki via Phabricator via cfe-commits
brzycki added a comment.

I think I found why others are struggling to recreate this issue. I did not 
have the package `z3/bionic` installed. This provides the `/usr/bin/z3` 
executable which `llvm/cmake/modules/FindZ3.cmake` relies upon to determine the 
correct `Z3_VERSION_STRING`.

If I perform the following on an unpatched checkout of sha b0a227049fda 
 the build 
works :

  sudo apt install -y z3 libz3-4 libz3-dev
  mkdir build && cd build

Either of the following CMake commands build successfully:

  cmake -G Ninja -D LLVM_OPTIMIZED_TABLEGEN=ON ../llvm-project/llvm
  cmake -G Ninja -D LLVM_OPTIMIZED_TABLEGEN=ON -D LLVM_ENABLE_Z3_SOLVER=OFF 
../llvm-project/llvm

And if I try `-D LLVM_ENABLE_Z3_SOLVER=ON` I receive a top-leve CMake error 
immediately:

  -- Could NOT find Z3: Found unsuitable version "4.4.1", but required is at 
least "4.7.1" (found /usr/lib/x86_64-linux-gnu/libz3.so)
  CMake Error at CMakeLists.txt:406 (message):
LLVM_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.
  
  
  -- Configuring incomplete, errors occurred!
  See also "/work/brzycki/build/CMakeFiles/CMakeOutput.log".
  ninja: error: loading 'build.ninja': No such file or directory

Unfortunately it's completely valid to install packages `libz3-4` and 
`libz3-dev` without pulling in `z3` on Ubuntu 18.04.  I've added this to my 
internal build notes.

I'm also looking to see if there's a way to better  handle this case inside the 
`find_package(Z3 ...)` subsystem of llvm.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D57961: [X86] Add explicit alignment to __m128/__m128i/__m128d/etc. to allow matching of MSVC behavior with #pragma pack.

2019-02-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I audited all the intrin header uses of __packed__, and I think this was the 
only one that was missing, so I'll try to fix forward.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57961



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


[PATCH] D57961: [X86] Add explicit alignment to __m128/__m128i/__m128d/etc. to allow matching of MSVC behavior with #pragma pack.

2019-02-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.
Herald added a subscriber: jdoerfert.

Hm, looks like this broke a bunch of code in chromium:
bad build: 
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/ToTWin%28dbg%29/2342
good build: 
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/ToTWin%28dbg%29/2341

A trace from one of the crashing tests:

  [ RUN  ] 
AudioDecoderTestScenarios/AudioDecoderTest.DecodesFramesWithVaryingDuration/3
  Received fatal exception EXCEPTION_ACCESS_VIOLATION
  Backtrace:
xcorr_kernel_sse [0x00D4CEF7+199] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\celt\x86\pitch_sse.c:54)
celt_pitch_xcorr_c [0x00DBC09C+156] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\celt\pitch.c:264)
_celt_autocorr [0x00DBAF20+368] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\celt\celt_lpc.c:266)
pitch_downsample [0x00DBBC98+536] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\celt\pitch.c:182)
run_prefilter [0x00D4093F+703] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\celt\celt_encoder.c:1144)
celt_encode_with_ec [0x00D3C915+3701] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\celt\celt_encoder.c:1606)
opus_encode_native [0x00CBBF8A+16810] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\src\opus_encoder.c:2068)
opus_encode [0x00CBE1C6+374] 
(C:\b\s\w\ir\cache\builder\src\third_party\opus\src\src\opus_encoder.c:2241)
media::cast::AudioDecoderTest::FeedMoreAudio [0x0017F0B8+1064] 
(C:\b\s\w\ir\cache\builder\src\media\cast\receiver\audio_decoder_unittest.cc:111)

The code in question is calling _mm_loadu_ps:
https://cs.chromium.org/chromium/src/third_party/opus/src/celt/x86/pitch_sse.c?type=cs=%22opus/src/celt/x86/pitch_sse.c%22=package:chromium=0=54

  for (j = 0; j < len-3; j += 4)
  {
 __m128 x0 = _mm_loadu_ps(x+j);
 __m128 yj = _mm_loadu_ps(y+j);
 __m128 y3 = _mm_loadu_ps(y+j+3); // crashes




Comment at: lib/Headers/xmmintrin.h:1754
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_loadu_ps(const float *__p)
 {

I guess we just missed this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57961



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


[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-12 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:91
+
+  Finds and fixes `absl::Time` subtraction expressions to do subtraction
+  in the Time domain instead of the numeric domain.

Please use two not one ` for language constructs.



Comment at: docs/clang-tidy/checks/abseil-time-subtraction.rst:11
+information:
+ - When the result is a ``Duration`` and the first argument is a ``Time``.
+ - When the second argument is a ``Time``.

Will be good idea to always use //absl::// prefix. Same in other places.



Comment at: docs/clang-tidy/checks/abseil-time-subtraction.rst:25
+
+  // Original - `Duration` result and first operand is a `Time`.
+  absl::Duration d = absl::Seconds(absl::ToUnixSeconds(t) - x);

` doesn't make sense in comments. Same below.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58137



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


[PATCH] D58072: Make ModuleDependencyCollector's method virtual (NFC)

2019-02-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

I missed that the `DependencyCollector` already marks them virtual, you are 
just making it obvious here.  I think you can omit the ones that are already 
virtual and only add to the ones that are on the intend of this patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58072



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


[PATCH] D58062: Support framework import/include auto-completion

2019-02-12 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 186524.
dgoldman marked 9 inline comments as done.
dgoldman added a comment.
Herald added a subscriber: jdoerfert.

- Misc fixes


Repository:
  rC Clang

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

https://reviews.llvm.org/D58062

Files:
  lib/Sema/SemaCodeComplete.cpp


Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -8371,10 +8371,23 @@
   };
 
   // Helper: scans IncludeDir for nice files, and adds results for each.
-  auto AddFilesFromIncludeDir = [&](StringRef IncludeDir, bool IsSystem) {
+  auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
+bool IsSystem,
+DirectoryLookup::LookupType_t LookupType) {
 llvm::SmallString<128> Dir = IncludeDir;
-if (!NativeRelDir.empty())
-  llvm::sys::path::append(Dir, NativeRelDir);
+if (!NativeRelDir.empty()) {
+  if (LookupType == DirectoryLookup::LT_Framework) {
+// For a framework dir, #include  actually maps to
+// a path of Foo.framework/Headers/Bar/.
+auto Begin = llvm::sys::path::begin(NativeRelDir);
+auto End = llvm::sys::path::end(NativeRelDir);
+
+llvm::sys::path::append(Dir, *Begin + ".framework", "Headers");
+llvm::sys::path::append(Dir, ++Begin, End);
+  } else {
+llvm::sys::path::append(Dir, NativeRelDir);
+  }
+}
 
 std::error_code EC;
 unsigned Count = 0;
@@ -8385,6 +8398,16 @@
   StringRef Filename = llvm::sys::path::filename(It->path());
   switch (It->type()) {
   case llvm::sys::fs::file_type::directory_file:
+// All entries in a framework directory must have a ".framework" 
suffix,
+// but the suffix does not appear in the source code's include/import.
+if (LookupType == DirectoryLookup::LT_Framework) {
+  if (!Filename.endswith(".framework")) {
+break;
+  }
+  if (NativeRelDir.empty()) {
+Filename.consume_back(".framework");
+  }
+}
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
   case llvm::sys::fs::file_type::regular_file:
@@ -8413,10 +8436,12 @@
   // header maps are not (currently) enumerable.
   break;
 case DirectoryLookup::LT_NormalDir:
-  AddFilesFromIncludeDir(IncludeDir.getDir()->getName(), IsSystem);
+  AddFilesFromIncludeDir(IncludeDir.getDir()->getName(), IsSystem,
+ DirectoryLookup::LT_NormalDir);
   break;
 case DirectoryLookup::LT_Framework:
-  AddFilesFromIncludeDir(IncludeDir.getFrameworkDir()->getName(), 
IsSystem);
+  AddFilesFromIncludeDir(IncludeDir.getFrameworkDir()->getName(), IsSystem,
+ DirectoryLookup::LT_Framework);
   break;
 }
   };
@@ -8430,7 +8455,8 @@
 // The current directory is on the include path for "quoted" includes.
 auto *CurFile = PP.getCurrentFileLexer()->getFileEntry();
 if (CurFile && CurFile->getDir())
-  AddFilesFromIncludeDir(CurFile->getDir()->getName(), false);
+  AddFilesFromIncludeDir(CurFile->getDir()->getName(), false,
+ DirectoryLookup::LT_NormalDir);
 for (const auto  : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
   AddFilesFromDirLookup(D, false);
   }


Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -8371,10 +8371,23 @@
   };
 
   // Helper: scans IncludeDir for nice files, and adds results for each.
-  auto AddFilesFromIncludeDir = [&](StringRef IncludeDir, bool IsSystem) {
+  auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
+bool IsSystem,
+DirectoryLookup::LookupType_t LookupType) {
 llvm::SmallString<128> Dir = IncludeDir;
-if (!NativeRelDir.empty())
-  llvm::sys::path::append(Dir, NativeRelDir);
+if (!NativeRelDir.empty()) {
+  if (LookupType == DirectoryLookup::LT_Framework) {
+// For a framework dir, #include  actually maps to
+// a path of Foo.framework/Headers/Bar/.
+auto Begin = llvm::sys::path::begin(NativeRelDir);
+auto End = llvm::sys::path::end(NativeRelDir);
+
+llvm::sys::path::append(Dir, *Begin + ".framework", "Headers");
+llvm::sys::path::append(Dir, ++Begin, End);
+  } else {
+llvm::sys::path::append(Dir, NativeRelDir);
+  }
+}
 
 std::error_code EC;
 unsigned Count = 0;
@@ -8385,6 +8398,16 @@
   StringRef Filename = llvm::sys::path::filename(It->path());
   switch (It->type()) {
   case llvm::sys::fs::file_type::directory_file:
+// All entries in a framework directory must have a ".framework" suffix,
+

[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-12 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:4077
 
+  /// C++ nested name specifier for the assoicated user-defined mapper.
+  NestedNameSpecifierLoc MapperQualifierLoc;

assoicated -> associated



Comment at: include/clang/AST/OpenMPClause.h:4212
+assert(DMDs.size() == varlist_size() &&
+   "Unexpected amount of user-defined mappers.");
+std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin());

amount -> number?



Comment at: include/clang/AST/OpenMPClause.h:4229
   /// \param MapModifiersLoc Location of map-type-modifiers.
+  /// \param UDMQualifierLoc C++ nested name specifier for the assoicated
+  /// user-defined mapper.

assoicated -> associated



Comment at: lib/Parse/ParseOpenMP.cpp:2144
+parseMapType(*this, Data);
 }
 if (Data.MapType == OMPC_MAP_unknown) {

Although it is an error situation, will we have different behavior?

```
... map(xclose, to: x)
```

Previously, it always parses both modifier and type.  After the change, the 
call of `parseMapType` is skipped.  If it `OMPC_MAP_unknown`, 
`IsMapTypeImplicit` is set.


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

https://reviews.llvm.org/D58074



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


[PATCH] D57991: [Driver][Darwin] Emit an error when using -pg on OS without support for it.

2019-02-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 186522.
vsapsai added a comment.
Herald added a subscriber: jdoerfert.

- Use `%select` per Steven's recommendation.


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

https://reviews.llvm.org/D57991

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c


Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -203,6 +203,14 @@
 // LINK_PG: -lgcrt1.o
 // LINK_PG: -no_new_main
 
+// RUN: %clang -target i386-apple-darwin13 -pg -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PG_NO_SUPPORT_OSX %s < %t.log
+// LINK_PG_NO_SUPPORT_OSX: error: the clang compiler does not support -pg 
option on versions of OS X
+
+// RUN: %clang -target x86_64-apple-ios5.0 -pg -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PG_NO_SUPPORT %s < %t.log
+// LINK_PG_NO_SUPPORT: error: the clang compiler does not support -pg option 
on Darwin
+
 // Check that clang links with libgcc_s.1 for iOS 4 and earlier, but not arm64.
 // RUN: %clang -target armv7-apple-ios4.0 -miphoneos-version-min=4.0 -### %t.o 
2> %t.log
 // RUN: FileCheck -check-prefix=LINK_IOS_LIBGCC_S %s < %t.log
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2289,22 +2289,27 @@
   }
 } else {
   if (Args.hasArg(options::OPT_pg) && SupportsProfiling()) {
-if (Args.hasArg(options::OPT_static) ||
-Args.hasArg(options::OPT_object) ||
-Args.hasArg(options::OPT_preload)) {
-  CmdArgs.push_back("-lgcrt0.o");
-} else {
-  CmdArgs.push_back("-lgcrt1.o");
+if (isTargetMacOS() && isMacosxVersionLT(10, 9)) {
+  if (Args.hasArg(options::OPT_static) ||
+  Args.hasArg(options::OPT_object) ||
+  Args.hasArg(options::OPT_preload)) {
+CmdArgs.push_back("-lgcrt0.o");
+  } else {
+CmdArgs.push_back("-lgcrt1.o");
 
-  // darwin_crt2 spec is empty.
+// darwin_crt2 spec is empty.
+  }
+  // By default on OS X 10.8 and later, we don't link with a crt1.o
+  // file and the linker knows to use _main as the entry point.  But,
+  // when compiling with -pg, we need to link with the gcrt1.o file,
+  // so pass the -no_new_main option to tell the linker to use the
+  // "start" symbol as the entry point.
+  if (isTargetMacOS() && !isMacosxVersionLT(10, 8))
+CmdArgs.push_back("-no_new_main");
+} else {
+  getDriver().Diag(diag::err_drv_clang_unsupported_opt_pg_darwin)
+  << isTargetMacOS();
 }
-// By default on OS X 10.8 and later, we don't link with a crt1.o
-// file and the linker knows to use _main as the entry point.  But,
-// when compiling with -pg, we need to link with the gcrt1.o file,
-// so pass the -no_new_main option to tell the linker to use the
-// "start" symbol as the entry point.
-if (isTargetMacOS() && !isMacosxVersionLT(10, 8))
-  CmdArgs.push_back("-no_new_main");
   } else {
 if (Args.hasArg(options::OPT_static) ||
 Args.hasArg(options::OPT_object) ||
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -96,6 +96,8 @@
   "the clang compiler does not support '%0'">;
 def err_drv_clang_unsupported_opt_cxx_darwin_i386 : Error<
   "the clang compiler does not support '%0' for C++ on Darwin/i386">;
+def err_drv_clang_unsupported_opt_pg_darwin: Error<
+  "the clang compiler does not support -pg option on %select{Darwin|versions 
of OS X 10.9 and later}0">;
 def err_drv_clang_unsupported_opt_faltivec : Error<
   "the clang compiler does not support '%0', %1">;
 def err_drv_command_failed : Error<


Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -203,6 +203,14 @@
 // LINK_PG: -lgcrt1.o
 // LINK_PG: -no_new_main
 
+// RUN: %clang -target i386-apple-darwin13 -pg -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PG_NO_SUPPORT_OSX %s < %t.log
+// LINK_PG_NO_SUPPORT_OSX: error: the clang compiler does not support -pg option on versions of OS X
+
+// RUN: %clang -target x86_64-apple-ios5.0 -pg -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PG_NO_SUPPORT %s < %t.log
+// LINK_PG_NO_SUPPORT: error: the clang compiler does not support -pg option on Darwin
+
 // Check that clang links with libgcc_s.1 for iOS 4 and 

[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Can you add some tests? Preferably with -mxnack/-mno-xnack, 
-msram-ecc/-mno-sram-ecc, -mcode-object-v3/-mno-code-object-v3


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

https://reviews.llvm.org/D57977



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


[PATCH] D57977: [HIP] compile option code-object-v3 propagate to llc

2019-02-12 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 186519.
ashi1 added a comment.
Herald added a subscriber: jdoerfert.

Changed patch to us handleTargetFeatures, to consume all -m options passed into 
clang.


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

https://reviews.llvm.org/D57977

Files:
  lib/Driver/ToolChains/HIP.cpp


Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -162,9 +162,26 @@
   // AMDGPUPromoteAlloca pass which cause invalid memory access in PyTorch.
   // Remove this once the issue is fixed.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-"-filetype=obj", "-mattr=-code-object-v3",
+"-filetype=obj",
 "-disable-promote-alloca-to-lds",
-Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
+Args.MakeArgString("-mcpu=" + SubArchName)};
+
+  // Extract all the -m options
+  std::vector Features;
+  handleTargetFeaturesGroup(
+Args, Features, options::OPT_m_amdgpu_Features_Group);
+
+  // Add features to mattr such as code-object-v3 and xnack
+  std::string MAttrString = "-mattr=";
+  for(auto OneFeature : Features) {
+MAttrString.append(Args.MakeArgString(OneFeature));
+if (OneFeature != Features.back())
+  MAttrString.append(",");
+  }
+  LlcArgs.push_back(Args.MakeArgString(MAttrString));
+
+  // Add output filename
+  LlcArgs.push_back("-o");
   std::string LlcOutputFileName =
   C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
   const char *LlcOutputFile =


Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -162,9 +162,26 @@
   // AMDGPUPromoteAlloca pass which cause invalid memory access in PyTorch.
   // Remove this once the issue is fixed.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-"-filetype=obj", "-mattr=-code-object-v3",
+"-filetype=obj",
 "-disable-promote-alloca-to-lds",
-Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
+Args.MakeArgString("-mcpu=" + SubArchName)};
+
+  // Extract all the -m options
+  std::vector Features;
+  handleTargetFeaturesGroup(
+Args, Features, options::OPT_m_amdgpu_Features_Group);
+
+  // Add features to mattr such as code-object-v3 and xnack
+  std::string MAttrString = "-mattr=";
+  for(auto OneFeature : Features) {
+MAttrString.append(Args.MakeArgString(OneFeature));
+if (OneFeature != Features.back())
+  MAttrString.append(",");
+  }
+  LlcArgs.push_back(Args.MakeArgString(MAttrString));
+
+  // Add output filename
+  LlcArgs.push_back("-o");
   std::string LlcOutputFileName =
   C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
   const char *LlcOutputFile =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:1074
 
+  if (NameKind == LookupOMPMapperName) {
+// Skip out-of-scope declarations.

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > lildmh wrote:
> > > > > > > ABataev wrote:
> > > > > > > > Why do we need special processing of the mapper here?
> > > > > > > The declare mapper lookup needs to find all 
> > > > > > > `OMPDeclareMapperDecl`s with the same name (the same as declare 
> > > > > > > reduction lookup), and thus it goes through all scopes from the 
> > > > > > > innermost to the outtermost.
> > > > > > > 
> > > > > > > Then it looks up a parent scope S (e.g., the outter {} in the 
> > > > > > > following example), all `OMPDeclareMapperDecl`s declared in the 
> > > > > > > children scopes of S will appear in the range between 
> > > > > > > `IdResolver.begin(Name)` and `IdResolver.end()`. Also, the 
> > > > > > > `declare mapper(id: struct S s)` will appear before `omp declare 
> > > > > > > mapper(id: struct SS ss)`. This can cause the lookup function to 
> > > > > > > ignore later `omp declare mapper(id: struct SS ss)` declared in 
> > > > > > > the outter scope. As a result, we may not find the corrent mapper.
> > > > > > > 
> > > > > > > ```
> > > > > > > {
> > > > > > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > > > > > >   {
> > > > > > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > > > > > ...
> > > > > > >   }
> > > > > > > }
> > > > > > > ```
> > > > > > > 
> > > > > > > To fix this problem, the purpose of this part of code is to 
> > > > > > > ignore all `OMPDeclareMapperDecl`s in inner scopes, which are 
> > > > > > > already found in previous calls to `LookupParsedName()` from 
> > > > > > > `buildUserDefinedMapperRef`.
> > > > > > > 
> > > > > > > I also found that the declare reduction lookup has the same 
> > > > > > > problem. I'll push out a similar fix for the declare reduction 
> > > > > > > later.
> > > > > > I don't think this is the correct behavior. For user-defined 
> > > > > > reductions, the standard says "This match is done by means of a 
> > > > > > name lookup in the base language." It means we should use the 
> > > > > > lookup rules of C/C++. For mapper, seems to me, we also should 
> > > > > > completely rely on the visibility/accessibility rules used by C/C++.
> > > > > Again, thanks for your quick response!
> > > > > 
> > > > > ```
> > > > > {
> > > > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > > > >   {
> > > > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > > > struct S kk;
> > > > > #pragma omp target map(mapper(id), tofrom: kk)
> > > > > {}
> > > > >   }
> > > > > }
> > > > > ```
> > > > > 
> > > > > If I don't add this code, the above code will report error that it 
> > > > > cannnot find a mapper with name `id` for type `struct S`, because it 
> > > > > can only find the second mapper for type `struct SS`. This doesn't 
> > > > > look like correct behavior to me.
> > > > > 
> > > > > I think we are still following the lookup rules of C/C++ with this 
> > > > > fix. It's because for declare mapper and reduction, we call 
> > > > > `LookupParsedName` multiple times on different scopes. In other 
> > > > > cases, `LookupParsedName` is always called once. Because of this 
> > > > > difference, I think this fix is appropriate. What is your thought?
> > > > No, in your case we don't. According to the C/C++ rules, if the 
> > > > variable is redeclared, the latest declaration is used. The same rule 
> > > > must be applied to the mapper (according to the standard "The 
> > > > visibility and accessibility of this declaration are the same as those 
> > > > of a variable declared at the same point in the program.")
> > > > I think that the code should fail in this case, because you would the 
> > > > error message in case of the variables declarations with the same names 
> > > > in those scopes.
> > > Hi Alexey,
> > > 
> > > Thanks for your quick response! I don't think it's redeclared in this 
> > > case, because a mapper has two properties: name and type, just as declare 
> > > reduction. Only when both name and type are the same, it should be 
> > > considered as redeclaration.
> > > 
> > > If we consider the above example as redeclaration of a mapper, then we 
> > > can always just call `LookupParsedName` once to find the most relevant 
> > > mapper/reductor. Then why do you need to search reductors in a while loop 
> > > in `buildDeclareReductionRef`?
> > > 
> > > Also, the following example will be correct using the original lookup 
> > > functions, without my fix:
> > > 
> > > ```
> > > {
> > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > struct S kk;
> > > #pragma omp target map(mapper(id), tofrom: kk)
> > > {}
> > 

[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-12 Thread Lingda Li via Phabricator via cfe-commits
lildmh marked an inline comment as done.
lildmh added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:1074
 
+  if (NameKind == LookupOMPMapperName) {
+// Skip out-of-scope declarations.

ABataev wrote:
> lildmh wrote:
> > ABataev wrote:
> > > lildmh wrote:
> > > > ABataev wrote:
> > > > > lildmh wrote:
> > > > > > ABataev wrote:
> > > > > > > Why do we need special processing of the mapper here?
> > > > > > The declare mapper lookup needs to find all `OMPDeclareMapperDecl`s 
> > > > > > with the same name (the same as declare reduction lookup), and thus 
> > > > > > it goes through all scopes from the innermost to the outtermost.
> > > > > > 
> > > > > > Then it looks up a parent scope S (e.g., the outter {} in the 
> > > > > > following example), all `OMPDeclareMapperDecl`s declared in the 
> > > > > > children scopes of S will appear in the range between 
> > > > > > `IdResolver.begin(Name)` and `IdResolver.end()`. Also, the `declare 
> > > > > > mapper(id: struct S s)` will appear before `omp declare mapper(id: 
> > > > > > struct SS ss)`. This can cause the lookup function to ignore later 
> > > > > > `omp declare mapper(id: struct SS ss)` declared in the outter 
> > > > > > scope. As a result, we may not find the corrent mapper.
> > > > > > 
> > > > > > ```
> > > > > > {
> > > > > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > > > > >   {
> > > > > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > > > > ...
> > > > > >   }
> > > > > > }
> > > > > > ```
> > > > > > 
> > > > > > To fix this problem, the purpose of this part of code is to ignore 
> > > > > > all `OMPDeclareMapperDecl`s in inner scopes, which are already 
> > > > > > found in previous calls to `LookupParsedName()` from 
> > > > > > `buildUserDefinedMapperRef`.
> > > > > > 
> > > > > > I also found that the declare reduction lookup has the same 
> > > > > > problem. I'll push out a similar fix for the declare reduction 
> > > > > > later.
> > > > > I don't think this is the correct behavior. For user-defined 
> > > > > reductions, the standard says "This match is done by means of a name 
> > > > > lookup in the base language." It means we should use the lookup rules 
> > > > > of C/C++. For mapper, seems to me, we also should completely rely on 
> > > > > the visibility/accessibility rules used by C/C++.
> > > > Again, thanks for your quick response!
> > > > 
> > > > ```
> > > > {
> > > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > > >   {
> > > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > > struct S kk;
> > > > #pragma omp target map(mapper(id), tofrom: kk)
> > > > {}
> > > >   }
> > > > }
> > > > ```
> > > > 
> > > > If I don't add this code, the above code will report error that it 
> > > > cannnot find a mapper with name `id` for type `struct S`, because it 
> > > > can only find the second mapper for type `struct SS`. This doesn't look 
> > > > like correct behavior to me.
> > > > 
> > > > I think we are still following the lookup rules of C/C++ with this fix. 
> > > > It's because for declare mapper and reduction, we call 
> > > > `LookupParsedName` multiple times on different scopes. In other cases, 
> > > > `LookupParsedName` is always called once. Because of this difference, I 
> > > > think this fix is appropriate. What is your thought?
> > > No, in your case we don't. According to the C/C++ rules, if the variable 
> > > is redeclared, the latest declaration is used. The same rule must be 
> > > applied to the mapper (according to the standard "The visibility and 
> > > accessibility of this declaration are the same as those of a variable 
> > > declared at the same point in the program.")
> > > I think that the code should fail in this case, because you would the 
> > > error message in case of the variables declarations with the same names 
> > > in those scopes.
> > Hi Alexey,
> > 
> > Thanks for your quick response! I don't think it's redeclared in this case, 
> > because a mapper has two properties: name and type, just as declare 
> > reduction. Only when both name and type are the same, it should be 
> > considered as redeclaration.
> > 
> > If we consider the above example as redeclaration of a mapper, then we can 
> > always just call `LookupParsedName` once to find the most relevant 
> > mapper/reductor. Then why do you need to search reductors in a while loop 
> > in `buildDeclareReductionRef`?
> > 
> > Also, the following example will be correct using the original lookup 
> > functions, without my fix:
> > 
> > ```
> > {
> >   #pragma omp declare mapper(id: struct S s) (s.a)
> > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > struct S kk;
> > #pragma omp target map(mapper(id), tofrom: kk)
> > {}
> > }
> > ```
> > 
> > If we consider the second mapper as a redeclaration of the first one, this 
> > should fail as well. What do you think?
> The standard clearly states that "The 

[PATCH] D57662: [clang-tidy] Parallelise clang-tidy-diff.py

2019-02-12 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 186514.
zinovy.nis added a comment.

`-j` and `-export-fixes` were made mutually exclusive.


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

https://reviews.llvm.org/D57662

Files:
  clang-tidy/tool/clang-tidy-diff.py

Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -25,9 +25,56 @@
 
 import argparse
 import json
+import multiprocessing
+import os
 import re
 import subprocess
 import sys
+import threading
+
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+import Queue as queue
+else:
+import queue as queue
+
+def run_tidy(task_queue, lock, timeout):
+  watchdog = None
+  while True:
+command = task_queue.get()
+try:
+  proc = subprocess.Popen(command,
+  stdout=subprocess.PIPE,
+  stderr=subprocess.PIPE)
+
+  if not timeout is None:
+watchdog = threading.Timer(timeout, proc.kill)
+watchdog.start()
+
+  stdout, stderr = proc.communicate()
+
+  with lock:
+sys.stdout.write(' '.join(command) + '\n' + stdout.decode('utf-8') + '\n')
+if stderr:
+  sys.stderr.write(stderr.decode('utf-8') + '\n')
+except:
+  with lock:
+sys.stderr.write('Failed: ' + str(sys.exc_info()[0]) + ' '.join(command) + '\n')
+finally:
+  with lock:
+if (not timeout is None) and (not watchdog is None):
+  if not watchdog.is_alive():
+  sys.stderr.write('Terminated by timeout: ' + ' '.join(command) + '\n')
+  watchdog.cancel()
+  task_queue.task_done()
+
+
+def run_workers(max_tasks, tidy_caller, task_queue, lock, timeout):
+  for _ in range(max_tasks):
+t = threading.Thread(target=tidy_caller, args=(task_queue, lock, timeout))
+t.daemon = True
+t.start()
 
 
 def main():
@@ -48,6 +95,10 @@
   help='custom pattern selecting file paths to check '
   '(case insensitive, overridden by -regex)')
 
+  parser.add_argument('-j', type=int, default=0,
+  help='number of tidy instances to be run in parallel.')
+  parser.add_argument('-timeout', type=int, default=None,
+  help='timeout per each file in seconds.')
   parser.add_argument('-fix', action='store_true', default=False,
   help='apply suggested fixes')
   parser.add_argument('-checks',
@@ -77,6 +128,11 @@
 
   args = parser.parse_args(argv)
 
+  if args.j == 0 or args.j > 1:
+if args.export_fixes:
+  print("error: -export-fixes and -j are mutually exclusive.")
+  sys.exit(1)
+
   # Extract changed lines for each file.
   filename = None
   lines_by_file = {}
@@ -84,7 +140,7 @@
 match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
 if match:
   filename = match.group(2)
-if filename == None:
+if filename is None:
   continue
 
 if args.regex is not None:
@@ -102,44 +158,64 @@
 line_count = int(match.group(3))
   if line_count == 0:
 continue
-  end_line = start_line + line_count - 1;
+  end_line = start_line + line_count - 1
   lines_by_file.setdefault(filename, []).append([start_line, end_line])
 
-  if len(lines_by_file) == 0:
+  if not any(lines_by_file):
 print("No relevant changes found.")
 sys.exit(0)
 
-  line_filter_json = json.dumps(
-[{"name" : name, "lines" : lines_by_file[name]} for name in lines_by_file],
-separators = (',', ':'))
+  max_task = args.j
+  if max_task == 0:
+  max_task = multiprocessing.cpu_count()
+  max_task = min(len(lines_by_file), max_task)
+
+  # Tasks for clang-tidy.
+  task_queue = queue.Queue(max_task)
+  # A lock for console output.
+  lock = threading.Lock()
 
-  quote = "";
-  if sys.platform == 'win32':
-line_filter_json=re.sub(r'"', r'"""', line_filter_json)
-  else:
-quote = "'";
+  # Run a pool of clang-tidy workers.
+  run_workers(max_task, run_tidy, task_queue, lock, args.timeout)
 
-  # Run clang-tidy on files containing changes.
-  command = [args.clang_tidy_binary]
-  command.append('-line-filter=' + quote + line_filter_json + quote)
+  quote = ""
+  if sys.platform != 'win32':
+quote = "'"
+
+  # Form the common args list.
+  common_clang_tidy_args = []
   if args.fix:
-command.append('-fix')
+common_clang_tidy_args.append('-fix')
   if args.export_fixes:
-command.append('-export-fixes=' + args.export_fixes)
+common_clang_tidy_args.append('-export-fixes=' + args.export_fixes)
   if args.checks != '':
-command.append('-checks=' + quote + args.checks + quote)
+common_clang_tidy_args.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
-command.append('-quiet')
+common_clang_tidy_args.append('-quiet')
   if args.build_path is not None:
-command.append('-p=%s' % args.build_path)
-  

[PATCH] D58106: [compiler-rt] [profile] Provide lprofGetHostName for all windows environments

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

lgtm


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D58106



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


[PATCH] D58107: [MinGW] Add the profiling library when necessary

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

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D58107



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


[PATCH] D56871: [AMDGPU] Require at least protected visibility for certain symbols

2019-02-12 Thread Scott Linder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353870: [AMDGPU] Require at least protected visibility for 
certain symbols (authored by scott.linder, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56871?vs=182561=186512#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56871

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenOpenCL/visibility.cl

Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3212,6 +3212,9 @@
 return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace,
ExpectedAS, Ty);
 
+  if (GV->isDeclaration())
+getTargetCodeGenInfo().setTargetAttributes(D, GV, *this);
+
   return GV;
 }
 
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7763,8 +7763,23 @@
 };
 }
 
+static bool requiresAMDGPUProtectedVisibility(const Decl *D,
+  llvm::GlobalValue *GV) {
+  if (GV->getVisibility() != llvm::GlobalValue::HiddenVisibility)
+return false;
+
+  return D->hasAttr() ||
+ (isa(D) && D->hasAttr()) ||
+ (isa(D) && D->hasAttr());
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
+  if (requiresAMDGPUProtectedVisibility(D, GV)) {
+GV->setVisibility(llvm::GlobalValue::ProtectedVisibility);
+GV->setDSOLocal(true);
+  }
+
   if (GV->isDeclaration())
 return;
   const FunctionDecl *FD = dyn_cast_or_null(D);
Index: cfe/trunk/test/CodeGenOpenCL/visibility.cl
===
--- cfe/trunk/test/CodeGenOpenCL/visibility.cl
+++ cfe/trunk/test/CodeGenOpenCL/visibility.cl
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility default -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-DEFAULT %s
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility protected -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-PROTECTED %s
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs -fvisibility hidden -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-HIDDEN %s
+
+// REQUIRES: amdgpu-registered-target
+
+// FVIS-DEFAULT:  @glob = local_unnamed_addr
+// FVIS-PROTECTED: @glob = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob = hidden local_unnamed_addr
+int glob = 0;
+// FVIS-DEFAULT:  @glob_hidden = hidden local_unnamed_addr
+// FVIS-PROTECTED: @glob_hidden = hidden local_unnamed_addr
+// FVIS-HIDDEN: @glob_hidden = hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) int glob_hidden = 0;
+// FVIS-DEFAULT:  @glob_protected = protected local_unnamed_addr
+// FVIS-PROTECTED: @glob_protected = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob_protected = protected local_unnamed_addr
+__attribute__((visibility("protected"))) int glob_protected = 0;
+// FVIS-DEFAULT:  @glob_default = local_unnamed_addr
+// FVIS-PROTECTED: @glob_default = local_unnamed_addr
+// FVIS-HIDDEN: @glob_default = local_unnamed_addr
+__attribute__((visibility("default"))) int glob_default = 0;
+
+// FVIS-DEFAULT:  @ext = external local_unnamed_addr
+// FVIS-PROTECTED: @ext = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext = external hidden local_unnamed_addr
+extern int ext;
+// FVIS-DEFAULT:  @ext_hidden = external hidden local_unnamed_addr
+// FVIS-PROTECTED: @ext_hidden = external hidden local_unnamed_addr
+// FVIS-HIDDEN: @ext_hidden = external hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) extern int ext_hidden;
+// FVIS-DEFAULT:  @ext_protected = external protected local_unnamed_addr
+// FVIS-PROTECTED: @ext_protected = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext_protected = external protected local_unnamed_addr
+__attribute__((visibility("protected"))) extern int ext_protected;
+// FVIS-DEFAULT:  @ext_default = external local_unnamed_addr
+// FVIS-PROTECTED: @ext_default = external local_unnamed_addr
+// FVIS-HIDDEN: @ext_default = external local_unnamed_addr
+__attribute__((visibility("default"))) extern int ext_default;
+
+// FVIS-DEFAULT: define amdgpu_kernel void @kern()
+// FVIS-PROTECTED: define protected amdgpu_kernel void @kern()
+// FVIS-HIDDEN: define protected amdgpu_kernel void @kern()
+kernel void kern() {}
+// FVIS-DEFAULT: define protected 

Re: [PATCH] D57984: PR40642: Fix determination of whether the final statement of a statementexpression is a discarded-value expression.

2019-02-12 Thread Richard Smith via cfe-commits
On Tue, 12 Feb 2019, 05:28 Aaron Ballman via Phabricator via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> aaron.ballman added a comment.
>
> Considering that this has been fertile ground for buggy edge cases, should
> we revert my original changes from the 8.0 branch to give this more time to
> bake on trunk before releasing? Or do you think this is fine to move onto
> the release branch once finalized?
>

Let's revert your change for 8.0 and fix forward on trunk.


> Comment at: include/clang/AST/Stmt.h:1598-1602
> +  const Expr *getExprStmt() const;
> +  Expr *getExprStmt() {
> +const ValueStmt *ConstThis = this;
> +return const_cast(ConstThis->getExprStmt());
> +  }
> 
> rsmith wrote:
> > aaron.ballman wrote:
> > > We typically implement this in reverse, where the non-const version
> holds the actual implementation and the const version performs a
> `const_cast`.
> > We do. Do you think that's preferable? I like that this way around
> proves that the `const` version is const-correct, but it's a tiny benefit
> and I'm fine with just being consistent.
> Personally, I prefer the way you have it here (though I wish we had a
> global helper function to hide the dispatch dance).
>
>
> 
> Comment at: include/clang/Parse/Parser.h:374
> +  /// a statement expression and builds a suitable expression statement.
> +  StmtResult handleExprStmt(ExprResult E, WithinStmtExpr IsInStmtExpr);
>
> 
> rsmith wrote:
> > aaron.ballman wrote:
> > > Rather than passing around `IsInStmtExpr` to a bunch of parser APIs,
> would it make more sense to add an RAII object that sets some state on
> `Parser` to test it? The proliferation of arguments seems unfortunate given
> how much of a corner case statement expressions are.
> > Yeah, I tried that approach first, but the parser state turns out to be
> much worse, because it puts a burden on every form of statement that
> constructs a nested parsing context to reset that state. We can put the
> resetting on `ParseScope`, but it still needs to have an effect in the case
> where the scope is disabled, which is surprising, and there's no guarantee
> such statement constructs that can end in an expression will have a nested
> scope (consider, for instance, constructs like `return x;` or `goto
> *label;`). This is really local state that should only be propagated
> through a very small number of syntactic constructs rather than global
> state.
> >
> > Maybe we could combine the new flag with the `AllowOpenMPStandalone` /
> `AllowedConstructsKind` flag into a more general kind of "statement
> context". The propagation rules aren't quite the same
> (`AllowOpenMPStandalone` doesn't get propagated through labels whereas
> `IsInStmtExpr` does), which is a little awkward, but maybe that's not so
> bad -- and maybe that's actually a bug in the OpenMP implementation?
> > Maybe we could combine the new flag with the AllowOpenMPStandalone /
> AllowedConstructsKind flag into a more general kind of "statement context".
>
> That seems like a sensible approach to me.
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D57984/new/
>
> https://reviews.llvm.org/D57984
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353870 - [AMDGPU] Require at least protected visibility for certain symbols

2019-02-12 Thread Scott Linder via cfe-commits
Author: scott.linder
Date: Tue Feb 12 10:30:38 2019
New Revision: 353870

URL: http://llvm.org/viewvc/llvm-project?rev=353870=rev
Log:
[AMDGPU] Require at least protected visibility for certain symbols

This allows the global visibility controls to be restrictive while still
populating the dynamic symbol table where required.

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

Added:
cfe/trunk/test/CodeGenOpenCL/visibility.cl
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=353870=353869=353870=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Feb 12 10:30:38 2019
@@ -3212,6 +3212,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace,
ExpectedAS, Ty);
 
+  if (GV->isDeclaration())
+getTargetCodeGenInfo().setTargetAttributes(D, GV, *this);
+
   return GV;
 }
 

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=353870=353869=353870=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Feb 12 10:30:38 2019
@@ -7763,8 +7763,23 @@ public:
 };
 }
 
+static bool requiresAMDGPUProtectedVisibility(const Decl *D,
+  llvm::GlobalValue *GV) {
+  if (GV->getVisibility() != llvm::GlobalValue::HiddenVisibility)
+return false;
+
+  return D->hasAttr() ||
+ (isa(D) && D->hasAttr()) ||
+ (isa(D) && D->hasAttr());
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
+  if (requiresAMDGPUProtectedVisibility(D, GV)) {
+GV->setVisibility(llvm::GlobalValue::ProtectedVisibility);
+GV->setDSOLocal(true);
+  }
+
   if (GV->isDeclaration())
 return;
   const FunctionDecl *FD = dyn_cast_or_null(D);

Added: cfe/trunk/test/CodeGenOpenCL/visibility.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/visibility.cl?rev=353870=auto
==
--- cfe/trunk/test/CodeGenOpenCL/visibility.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/visibility.cl Tue Feb 12 10:30:38 2019
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs 
-fvisibility default -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck --check-prefix=FVIS-DEFAULT %s
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs 
-fvisibility protected -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck --check-prefix=FVIS-PROTECTED %s
+// RUN: %clang_cc1 -std=cl2.0 -fapply-global-visibility-to-externs 
-fvisibility hidden -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck --check-prefix=FVIS-HIDDEN %s
+
+// REQUIRES: amdgpu-registered-target
+
+// FVIS-DEFAULT:  @glob = local_unnamed_addr
+// FVIS-PROTECTED: @glob = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob = hidden local_unnamed_addr
+int glob = 0;
+// FVIS-DEFAULT:  @glob_hidden = hidden local_unnamed_addr
+// FVIS-PROTECTED: @glob_hidden = hidden local_unnamed_addr
+// FVIS-HIDDEN: @glob_hidden = hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) int glob_hidden = 0;
+// FVIS-DEFAULT:  @glob_protected = protected local_unnamed_addr
+// FVIS-PROTECTED: @glob_protected = protected local_unnamed_addr
+// FVIS-HIDDEN: @glob_protected = protected local_unnamed_addr
+__attribute__((visibility("protected"))) int glob_protected = 0;
+// FVIS-DEFAULT:  @glob_default = local_unnamed_addr
+// FVIS-PROTECTED: @glob_default = local_unnamed_addr
+// FVIS-HIDDEN: @glob_default = local_unnamed_addr
+__attribute__((visibility("default"))) int glob_default = 0;
+
+// FVIS-DEFAULT:  @ext = external local_unnamed_addr
+// FVIS-PROTECTED: @ext = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext = external hidden local_unnamed_addr
+extern int ext;
+// FVIS-DEFAULT:  @ext_hidden = external hidden local_unnamed_addr
+// FVIS-PROTECTED: @ext_hidden = external hidden local_unnamed_addr
+// FVIS-HIDDEN: @ext_hidden = external hidden local_unnamed_addr
+__attribute__((visibility("hidden"))) extern int ext_hidden;
+// FVIS-DEFAULT:  @ext_protected = external protected local_unnamed_addr
+// FVIS-PROTECTED: @ext_protected = external protected local_unnamed_addr
+// FVIS-HIDDEN: @ext_protected = external protected local_unnamed_addr
+__attribute__((visibility("protected"))) extern int ext_protected;
+// FVIS-DEFAULT:  @ext_default = external 

[PATCH] D54978: Move the SMT API to LLVM

2019-02-12 Thread Brian Rzycki via Phabricator via cfe-commits
brzycki added a comment.

The following patch:

  diff --git a/llvm/cmake/modules/CrossCompile.cmake 
b/llvm/cmake/modules/CrossCompile.cmake
  index bc3b210f018..0c30b88f80f 100644
  --- a/llvm/cmake/modules/CrossCompile.cmake
  +++ b/llvm/cmake/modules/CrossCompile.cmake
  @@ -53,6 +53,7 @@ function(llvm_create_cross_target_internal target_name 
toolchain buildtype)
   -DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}"
   -DLLVM_TARGET_ARCH="${LLVM_TARGET_ARCH}"
   
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="${LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN}"
  +-DLLVM_ENABLE_Z3_SOLVER="${LLVM_ENABLE_Z3_SOLVER}"
   ${build_type_flags} ${linker_flag} ${external_clang_dir}
   WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
   DEPENDS CREATE_LLVM_${target_name}

fixes the build break when CMake is called in the following manner:

  cmake -v -G Ninja  -D LLVM_OPTIMIZED_TABLEGEN=ON -D LLVM_ENABLE_Z3_SOLVER=OFF 
../llvm-project/llvm

However, the custom command sub-call to CMake always fails in the same way with 
either of these invocations:

  cmake -v -G Ninja  -D LLVM_OPTIMIZED_TABLEGEN=ON -D LLVM_ENABLE_Z3_SOLVER=ON 
../llvm-project/llvm
  cmake -v -G Ninja  -D LLVM_OPTIMIZED_TABLEGEN=ON ../llvm-project/llvm

The error is the following:

  [209/2543] /usr/bin/c++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Iutils/TableGen -I/work/brzycki/llvm-project/llvm/utils/TableGen 
-I/usr/include/libxml2 -Iinclude -I/work/brzycki/llvm-project/llvm/include 
-fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wno-comment -fdiagnostics-color -g-fno-exceptions -fno-rtti -MD -MT 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelEmitter.cpp.o -MF 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelEmitter.cpp.o.d -o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelEmitter.cpp.o -c 
/work/brzycki/llvm-project/llvm/utils/TableGen/GlobalISelEmitter.cpp
  [210/2543] cd /work/brzycki/build/NATIVE && 
/sarc-c/compiler_tmp/tools/build/cmake-3.13.3/bin/cmake -G Ninja 
-DCMAKE_MAKE_PROGRAM="/sarc-c/compiler_tmp/tools/build/ninja-1.8.2/ninja" 
-DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++ 
/work/brzycki/llvm-project/llvm -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE 
-DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;ARM;BPF;Hexagon;Lanai;Mips;MSP430;NVPTX;PowerPC;Sparc;SystemZ;WebAssembly;X86;XCore"
 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="" 
-DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-unknown-linux-gnu" 
-DLLVM_TARGET_ARCH="host" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="OFF" 
-DLLVM_ENABLE_Z3_SOLVER="ON" -DCMAKE_BUILD_TYPE=Release
  -- The C compiler identification is GNU 7.3.0
  -- The CXX compiler identification is GNU 7.3.0
  -- The ASM compiler identification is GNU
  -- Found assembler: /usr/bin/cc
  ...
  ...
  -- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
  -- Performing Test HAVE_POSIX_REGEX
  -- Performing Test HAVE_POSIX_REGEX
  -- Performing Test HAVE_POSIX_REGEX -- success
  -- Performing Test HAVE_STEADY_CLOCK
  -- Performing Test HAVE_STEADY_CLOCK
  -- Performing Test HAVE_STEADY_CLOCK -- success
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /work/brzycki/build/NATIVE
  ninja: build stopped: subcommand failed.

I tried passing more information to the sub CMake call, but it yielded the 
exact same results:

  +-DLLVM_ENABLE_Z3_SOLVER="${LLVM_ENABLE_Z3_SOLVER}"
  +-DLLVM_Z3_INSTALL_DIR="${LLVM_Z3_INSTALL_DIR}"
  +-DZ3_EXECUTABLE="${Z3_EXECUTABLE}"
  +-DZ3_INCLUDE_DIR="${Z3_INCLUDE_DIR}"
  +-DZ3_LIBRARIES="${Z3_LIBRARIES}"

When I diff the successful sub-CMake with the failing one, the only difference 
is the detection of the Z3 solver library:

  $ diff -u good_submake.txt bad_submake.txt
  --- good_submake.txt2019-02-12 11:41:54.638892191 -0600
  +++ bad_submake.txt 2019-02-12 11:43:30.096484824 -0600
  @@ -14,7 +14,7 @@
   -- Detecting CXX compiler ABI info - done
   -- Detecting CXX compile features
   -- Detecting CXX compile features - done
  --- Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at 
least version "4.7.1")
  +-- Found Z3: /usr/lib/x86_64-linux-gnu/libz3.so (Required is at least 
version "4.7.1")
   -- Looking for dlfcn.h
   -- Looking for dlfcn.h - found
   -- Looking for errno.h


Repository:
  rC Clang

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

https://reviews.llvm.org/D54978



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


[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-12 Thread Hyrum Wright via Phabricator via cfe-commits
hwright created this revision.
hwright added reviewers: ioeric, hokein, JonasToth, aaron.ballman.
hwright added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, jdoerfert, xazax.hun, mgorny.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58137

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tidy/abseil/TimeSubtractionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-time-subtraction.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-time-subtraction.cpp

Index: test/clang-tidy/abseil-time-subtraction.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-time-subtraction.cpp
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s abseil-time-subtraction %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void g(absl::Duration d);
+
+void f() {
+  absl::Time t;
+  int x, y;
+  absl::Duration d;
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(x));
+  d = absl::Minutes(absl::ToUnixMinutes(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMinutes(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x));
+  d = absl::Milliseconds(absl::ToUnixMillis(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMillis(x));
+  d = absl::Microseconds(absl::ToUnixMicros(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMicros(x));
+  d = absl::Nanoseconds(absl::ToUnixNanos(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixNanos(x));
+
+  y = x - absl::ToUnixHours(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Hours(absl::FromUnixHours(x) - t);
+  y = x - absl::ToUnixMinutes(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Minutes(absl::FromUnixMinutes(x) - t);
+  y = x - absl::ToUnixSeconds(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t);
+  y = x - absl::ToUnixMillis(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Milliseconds(absl::FromUnixMillis(x) - t);
+  y = x - absl::ToUnixMicros(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Microseconds(absl::FromUnixMicros(x) - t);
+  y = x - absl::ToUnixNanos(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Nanoseconds(absl::FromUnixNanos(x) - t);
+
+  // Check parenthesis placement
+  d = 5 * absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = 5 * (t - absl::FromUnixSeconds(x));
+
+  // No extra parens around arguments
+  g(absl::Seconds(absl::ToUnixSeconds(t) - x));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(t - absl::FromUnixSeconds(x));
+  g(absl::Seconds(x - absl::ToUnixSeconds(t)));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(absl::FromUnixSeconds(x) - t);
+
+  // These should not trigger; they are likely bugs
+  d = absl::Milliseconds(absl::ToUnixSeconds(t) - x);
+  d = absl::Seconds(absl::ToUnixMicros(t) - x);
+}
+
+absl::Duration parens_in_return() {
+  absl::Time t;
+  int x;
+
+  return absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: return t - absl::FromUnixSeconds(x);
+  return absl::Seconds(x - absl::ToUnixSeconds(t));
+  // CHECK-MESSAGES: 

[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:1074
 
+  if (NameKind == LookupOMPMapperName) {
+// Skip out-of-scope declarations.

lildmh wrote:
> ABataev wrote:
> > lildmh wrote:
> > > ABataev wrote:
> > > > lildmh wrote:
> > > > > ABataev wrote:
> > > > > > Why do we need special processing of the mapper here?
> > > > > The declare mapper lookup needs to find all `OMPDeclareMapperDecl`s 
> > > > > with the same name (the same as declare reduction lookup), and thus 
> > > > > it goes through all scopes from the innermost to the outtermost.
> > > > > 
> > > > > Then it looks up a parent scope S (e.g., the outter {} in the 
> > > > > following example), all `OMPDeclareMapperDecl`s declared in the 
> > > > > children scopes of S will appear in the range between 
> > > > > `IdResolver.begin(Name)` and `IdResolver.end()`. Also, the `declare 
> > > > > mapper(id: struct S s)` will appear before `omp declare mapper(id: 
> > > > > struct SS ss)`. This can cause the lookup function to ignore later 
> > > > > `omp declare mapper(id: struct SS ss)` declared in the outter scope. 
> > > > > As a result, we may not find the corrent mapper.
> > > > > 
> > > > > ```
> > > > > {
> > > > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > > > >   {
> > > > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > > > ...
> > > > >   }
> > > > > }
> > > > > ```
> > > > > 
> > > > > To fix this problem, the purpose of this part of code is to ignore 
> > > > > all `OMPDeclareMapperDecl`s in inner scopes, which are already found 
> > > > > in previous calls to `LookupParsedName()` from 
> > > > > `buildUserDefinedMapperRef`.
> > > > > 
> > > > > I also found that the declare reduction lookup has the same problem. 
> > > > > I'll push out a similar fix for the declare reduction later.
> > > > I don't think this is the correct behavior. For user-defined 
> > > > reductions, the standard says "This match is done by means of a name 
> > > > lookup in the base language." It means we should use the lookup rules 
> > > > of C/C++. For mapper, seems to me, we also should completely rely on 
> > > > the visibility/accessibility rules used by C/C++.
> > > Again, thanks for your quick response!
> > > 
> > > ```
> > > {
> > >   #pragma omp declare mapper(id: struct S s) (s.a)
> > >   {
> > > #pragma omp declare mapper(id: struct SS ss) (ss.b)
> > > struct S kk;
> > > #pragma omp target map(mapper(id), tofrom: kk)
> > > {}
> > >   }
> > > }
> > > ```
> > > 
> > > If I don't add this code, the above code will report error that it 
> > > cannnot find a mapper with name `id` for type `struct S`, because it can 
> > > only find the second mapper for type `struct SS`. This doesn't look like 
> > > correct behavior to me.
> > > 
> > > I think we are still following the lookup rules of C/C++ with this fix. 
> > > It's because for declare mapper and reduction, we call `LookupParsedName` 
> > > multiple times on different scopes. In other cases, `LookupParsedName` is 
> > > always called once. Because of this difference, I think this fix is 
> > > appropriate. What is your thought?
> > No, in your case we don't. According to the C/C++ rules, if the variable is 
> > redeclared, the latest declaration is used. The same rule must be applied 
> > to the mapper (according to the standard "The visibility and accessibility 
> > of this declaration are the same as those of a variable declared at the 
> > same point in the program.")
> > I think that the code should fail in this case, because you would the error 
> > message in case of the variables declarations with the same names in those 
> > scopes.
> Hi Alexey,
> 
> Thanks for your quick response! I don't think it's redeclared in this case, 
> because a mapper has two properties: name and type, just as declare 
> reduction. Only when both name and type are the same, it should be considered 
> as redeclaration.
> 
> If we consider the above example as redeclaration of a mapper, then we can 
> always just call `LookupParsedName` once to find the most relevant 
> mapper/reductor. Then why do you need to search reductors in a while loop in 
> `buildDeclareReductionRef`?
> 
> Also, the following example will be correct using the original lookup 
> functions, without my fix:
> 
> ```
> {
>   #pragma omp declare mapper(id: struct S s) (s.a)
> #pragma omp declare mapper(id: struct SS ss) (ss.b)
> struct S kk;
> #pragma omp target map(mapper(id), tofrom: kk)
> {}
> }
> ```
> 
> If we consider the second mapper as a redeclaration of the first one, this 
> should fail as well. What do you think?
The standard clearly states that "The visibility and accessibility of this 
declaration are the same as those of a variable declared at the same point in 
the program.". For variables (btw, they also have 2 attributes - name and type) 
the inner declaration makes the outer one not visible. The same rule should be 

  1   2   >