[PATCH] D51021: ABI-Testsuite: Force the old c++11 ABI in mangling/test.xpp

2018-08-20 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added a reviewer: Sunil_Srivastava.

The check lines for this test assume the old c++11 ABI.

This resolved PR33132.


Repository:
  rT test-suite

https://reviews.llvm.org/D51021

Files:
  ABI-Testsuite/test/mangling/test.xpp


Index: ABI-Testsuite/test/mangling/test.xpp
===
--- ABI-Testsuite/test/mangling/test.xpp
+++ ABI-Testsuite/test/mangling/test.xpp
@@ -1,6 +1,6 @@
 // This file is distributed under the University of Illinois Open Source 
License.
 // See LICENSE.TXT for details.
-// RUN: cxx_compiler cxx_11 -c %s -o %t.o
+// RUN: cxx_compiler cxx_11 -D_GLIBCXX_USE_CXX11_ABI=0 -c %s -o %t.o
 // RUN: bindump %t.o | FileCheck -allow-deprecated-dag-overlap prefixes %s
 
 #include 


Index: ABI-Testsuite/test/mangling/test.xpp
===
--- ABI-Testsuite/test/mangling/test.xpp
+++ ABI-Testsuite/test/mangling/test.xpp
@@ -1,6 +1,6 @@
 // This file is distributed under the University of Illinois Open Source License.
 // See LICENSE.TXT for details.
-// RUN: cxx_compiler cxx_11 -c %s -o %t.o
+// RUN: cxx_compiler cxx_11 -D_GLIBCXX_USE_CXX11_ABI=0 -c %s -o %t.o
 // RUN: bindump %t.o | FileCheck -allow-deprecated-dag-overlap prefixes %s
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51020: MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMP: Fix build with newer libstdc++

2018-08-20 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added a reviewer: homerdin.

Repository:
  rT test-suite

https://reviews.llvm.org/D51020

Files:
  MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h


Index: MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
===
--- MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
+++ MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
@@ -99,9 +99,9 @@
 
 struct cmp_str
 {
-   bool operator()(char const *a, char const *b)
+   bool operator()(const string , const string )
{
-  return strcmp(a, b) < 0;
+  return a.compare(b) < 0;
}
 };
 


Index: MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
===
--- MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
+++ MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
@@ -99,9 +99,9 @@
 
 struct cmp_str
 {
-   bool operator()(char const *a, char const *b)
+   bool operator()(const string , const string )
{
-  return strcmp(a, b) < 0;
+  return a.compare(b) < 0;
}
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51011: [Preprocessor] raise gcc compatibility macros.

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Another possibility would be to add a command-line argument to set the version 
of GCC that clang pretends to be. We have a similar mechanism for our MSVC 
compatibility mode already.


Repository:
  rC Clang

https://reviews.llvm.org/D51011



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


[PATCH] D51011: [Preprocessor] raise gcc compatibility macros.

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

We are not fully compatible with any version of GCC later than 4.2, as we do 
not implement `__builtin_va_arg_pack` / `__builtin_va_arg_pack_len`. These 
builtins are used by the glibc headers if we claim to be GCC >= 4.3 (at least 
according to 
http://clang.llvm.org/docs/UsersManual.html#gcc-extensions-not-implemented-yet),
 so this change will cause Clang to no longer compile (some versions of) the 
glibc headers.

Can you instead change the kernel to require GCC >= 4.6 or some suitable 
version of Clang?


Repository:
  rC Clang

https://reviews.llvm.org/D51011



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


[PATCH] D51008: Enable -fsanitize=fuzzer and -fsanitize=fuzzer-no-link on Windows.

2018-08-20 Thread Jonathan Metzman via Phabricator via cfe-commits
metzman added inline comments.



Comment at: lib/Driver/ToolChains/MSVC.cpp:373
+ TC.getCompilerRTArgString(Args, "fuzzer", 
false)));
+CmdArgs.push_back(Args.MakeArgString("-debug"));
+// Prevent the linker from padding sections we use for instrumentation

morehouse wrote:
> Why is `-debug` needed?
Without it, libFuzzer quits early with the following error message:
```
ERROR: no interesting inputs were found. Is the code instrumented for coverage? 
Exiting.
```
I think it's because `sancov.module_ctor` isn't executed (or it isn't calling 
the init functions in libFuzzer), but I'm not 100% sure about this (or why this 
is the case).

I guess `-debug` isn't strictly necessary because I don't have libFuzzer 
working perfectly without ASAN yet (I always get warnings from libFuzzer about 
`__sanitizer_print_stack_trace`, `__sanitizer_acquire_crash_state`, and 
`__sanitizer_set_death_callback` being missing) and ASAN includes this argument 
(as well as `-incremental:no`,  removing this line doesn't break anything as 
long as we always compile with ASAN).
Do you think I should remove these two arguments?

I was planning on tracking down why exactly this occurs later on, but I'm fine 
doing this now.


Repository:
  rC Clang

https://reviews.llvm.org/D51008



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


[PATCH] D51008: Enable -fsanitize=fuzzer and -fsanitize=fuzzer-no-link on Windows.

2018-08-20 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

LGTM




Comment at: lib/Driver/ToolChains/MSVC.cpp:373
+ TC.getCompilerRTArgString(Args, "fuzzer", 
false)));
+CmdArgs.push_back(Args.MakeArgString("-debug"));
+// Prevent the linker from padding sections we use for instrumentation

Why is `-debug` needed?


Repository:
  rC Clang

https://reviews.llvm.org/D51008



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


[PATCH] D51013: [WebAssembly] Revert type of wake count in atomic.wake to i32

2018-08-20 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340235: [WebAssembly] Revert type of wake count in 
atomic.wake to i32 (authored by aheejin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51013?vs=161615=161620#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51013

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  test/CodeGen/builtins-wasm.c


Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -37,6 +37,6 @@
 // Atomic wait and notify.
 BUILTIN(__builtin_wasm_atomic_wait_i32, "ii*iLLi", "n")
 BUILTIN(__builtin_wasm_atomic_wait_i64, "iLLi*LLiLLi", "n")
-BUILTIN(__builtin_wasm_atomic_notify, "ULLii*LLi", "n")
+BUILTIN(__builtin_wasm_atomic_notify, "Uii*i", "n")
 
 #undef BUILTIN
Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -63,8 +63,8 @@
 // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
 }
 
-unsigned long long f10(int *addr, long long count) {
+unsigned int f10(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
-// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
-// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }


Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -37,6 +37,6 @@
 // Atomic wait and notify.
 BUILTIN(__builtin_wasm_atomic_wait_i32, "ii*iLLi", "n")
 BUILTIN(__builtin_wasm_atomic_wait_i64, "iLLi*LLiLLi", "n")
-BUILTIN(__builtin_wasm_atomic_notify, "ULLii*LLi", "n")
+BUILTIN(__builtin_wasm_atomic_notify, "Uii*i", "n")
 
 #undef BUILTIN
Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -63,8 +63,8 @@
 // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
 }
 
-unsigned long long f10(int *addr, long long count) {
+unsigned int f10(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
-// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
-// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340235 - [WebAssembly] Revert type of wake count in atomic.wake to i32

2018-08-20 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Mon Aug 20 16:49:34 2018
New Revision: 340235

URL: http://llvm.org/viewvc/llvm-project?rev=340235=rev
Log:
[WebAssembly] Revert type of wake count in atomic.wake to i32

Summary:
We decided to revert this from i64 to i32 in Nov 28 CG meeting. Fixes
PR38632.

Reviewers: dschuff

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

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=340235=340234=340235=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Mon Aug 20 16:49:34 
2018
@@ -37,6 +37,6 @@ BUILTIN(__builtin_wasm_rethrow, "v", "r"
 // Atomic wait and notify.
 BUILTIN(__builtin_wasm_atomic_wait_i32, "ii*iLLi", "n")
 BUILTIN(__builtin_wasm_atomic_wait_i64, "iLLi*LLiLLi", "n")
-BUILTIN(__builtin_wasm_atomic_notify, "ULLii*LLi", "n")
+BUILTIN(__builtin_wasm_atomic_notify, "Uii*i", "n")
 
 #undef BUILTIN

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=340235=340234=340235=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Mon Aug 20 16:49:34 2018
@@ -63,8 +63,8 @@ int f9(long long *addr, long long expect
 // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
 }
 
-unsigned long long f10(int *addr, long long count) {
+unsigned int f10(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
-// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
-// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }


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


[PATCH] D51008: Enable -fsanitize=fuzzer and -fsanitize=fuzzer-no-link on Windows.

2018-08-20 Thread Jonathan Metzman via Phabricator via cfe-commits
metzman added a reviewer: morehouse.
metzman added a comment.

Matt could you please take a look at this? 
I'll add rnk as reviewer once you sign off, since he is a CODE_OWNER for 
Windows in Clang.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D51008



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


[PATCH] D51013: [WebAssembly] Revert type of wake count in atomic.wake to i32

2018-08-20 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: cfe-commits, jfb, sunfish, jgravelle-google, sbc100.

We decided to revert this from i64 to i32 in Nov 28 CG meeting. Fixes
PR38632.


Repository:
  rC Clang

https://reviews.llvm.org/D51013

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  test/CodeGen/builtins-wasm.c


Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -63,8 +63,8 @@
 // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
 }
 
-unsigned long long f10(int *addr, long long count) {
+unsigned int f10(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
-// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
-// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }
Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -37,6 +37,6 @@
 // Atomic wait and notify.
 BUILTIN(__builtin_wasm_atomic_wait_i32, "ii*iLLi", "n")
 BUILTIN(__builtin_wasm_atomic_wait_i64, "iLLi*LLiLLi", "n")
-BUILTIN(__builtin_wasm_atomic_notify, "ULLii*LLi", "n")
+BUILTIN(__builtin_wasm_atomic_notify, "Uii*i", "n")
 
 #undef BUILTIN


Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -63,8 +63,8 @@
 // WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
 }
 
-unsigned long long f10(int *addr, long long count) {
+unsigned int f10(int *addr, int count) {
   return __builtin_wasm_atomic_notify(addr, count);
-// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
-// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.notify(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.notify(i32* %{{.*}}, i32 %{{.*}})
 }
Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -37,6 +37,6 @@
 // Atomic wait and notify.
 BUILTIN(__builtin_wasm_atomic_wait_i32, "ii*iLLi", "n")
 BUILTIN(__builtin_wasm_atomic_wait_i64, "iLLi*LLiLLi", "n")
-BUILTIN(__builtin_wasm_atomic_notify, "ULLii*LLi", "n")
+BUILTIN(__builtin_wasm_atomic_notify, "Uii*i", "n")
 
 #undef BUILTIN
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51011: [Preprocessor] raise gcc compatibility macros.

2018-08-20 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Building the Linux kernel with clang is now broken as of commit
cafa0010cd51 ("Raise the minimum required gcc version to 4.6").

We were getting lucky that Clang previously declared compatibility with
gcc 4.2.1 as the kernel only errored out for gcc < 3.2. The compiler
check in the kernel should be improved as well.


Repository:
  rC Clang

https://reviews.llvm.org/D51011

Files:
  lib/Frontend/InitPreprocessor.cpp


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -587,12 +587,12 @@
   "\"" CLANG_VERSION_STRING " "
   + getClangFullRepositoryVersion() + "\"");
   if (!LangOpts.MSVCCompat) {
-// Currently claim to be compatible with GCC 4.2.1-5621, but only if we're
+// Currently claim to be compatible with GCC 8.2, but only if we're
 // not compiling for MSVC compatibility
 Builder.defineMacro("__GNUC_MINOR__", "2");
-Builder.defineMacro("__GNUC_PATCHLEVEL__", "1");
-Builder.defineMacro("__GNUC__", "4");
-Builder.defineMacro("__GXX_ABI_VERSION", "1002");
+Builder.defineMacro("__GNUC_PATCHLEVEL__", "0");
+Builder.defineMacro("__GNUC__", "8");
+Builder.defineMacro("__GXX_ABI_VERSION", "1013");
   }
 
   // Define macros for the C11 / C++11 memory orderings


Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -587,12 +587,12 @@
   "\"" CLANG_VERSION_STRING " "
   + getClangFullRepositoryVersion() + "\"");
   if (!LangOpts.MSVCCompat) {
-// Currently claim to be compatible with GCC 4.2.1-5621, but only if we're
+// Currently claim to be compatible with GCC 8.2, but only if we're
 // not compiling for MSVC compatibility
 Builder.defineMacro("__GNUC_MINOR__", "2");
-Builder.defineMacro("__GNUC_PATCHLEVEL__", "1");
-Builder.defineMacro("__GNUC__", "4");
-Builder.defineMacro("__GXX_ABI_VERSION", "1002");
+Builder.defineMacro("__GNUC_PATCHLEVEL__", "0");
+Builder.defineMacro("__GNUC__", "8");
+Builder.defineMacro("__GXX_ABI_VERSION", "1013");
   }
 
   // Define macros for the C11 / C++11 memory orderings
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51008: Enable -fsanitize=fuzzer and -fsanitize=fuzzer-no-link on Windows.

2018-08-20 Thread Jonathan Metzman via Phabricator via cfe-commits
metzman created this revision.
Herald added a subscriber: cfe-commits.

This allows -fsanitize=fuzzer and -fsanitize=fuzzer-no-link to be used on 
Windows.
When either used, Clang will also use some default flags that are needed (such 
as incremental linking and debug).


Repository:
  rC Clang

https://reviews.llvm.org/D51008

Files:
  lib/Driver/ToolChains/MSVC.cpp


Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -365,6 +365,17 @@
 CmdArgs.push_back(Args.MakeArgString(std::string("-implib:") + 
ImplibName));
   }
 
+  if (TC.getSanitizerArgs().needsFuzzer()) {
+if (!Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("-wholearchive:") +
+ TC.getCompilerRTArgString(Args, "fuzzer", 
false)));
+CmdArgs.push_back(Args.MakeArgString("-debug"));
+// Prevent the linker from padding sections we use for instrumentation
+// arrays.
+CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
+  }
+
   if (TC.getSanitizerArgs().needsAsanRt()) {
 CmdArgs.push_back(Args.MakeArgString("-debug"));
 CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
@@ -1298,6 +1309,8 @@
 SanitizerMask MSVCToolChain::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res &= ~SanitizerKind::CFIMFCall;
   return Res;
 }


Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -365,6 +365,17 @@
 CmdArgs.push_back(Args.MakeArgString(std::string("-implib:") + ImplibName));
   }
 
+  if (TC.getSanitizerArgs().needsFuzzer()) {
+if (!Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("-wholearchive:") +
+ TC.getCompilerRTArgString(Args, "fuzzer", false)));
+CmdArgs.push_back(Args.MakeArgString("-debug"));
+// Prevent the linker from padding sections we use for instrumentation
+// arrays.
+CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
+  }
+
   if (TC.getSanitizerArgs().needsAsanRt()) {
 CmdArgs.push_back(Args.MakeArgString("-debug"));
 CmdArgs.push_back(Args.MakeArgString("-incremental:no"));
@@ -1298,6 +1309,8 @@
 SanitizerMask MSVCToolChain::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res &= ~SanitizerKind::CFIMFCall;
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51007: Test the cross-product of options that affect how libgcc-related arguments are passed to the linker.

2018-08-20 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

I am refactoring the code that does this, in preparation for adding support for 
-shared-libgcc, and, after that, shared compiler-rt. These tests are to defend 
against mistakes in that refactoring and prepare for correct handling of the 
other cases.


Repository:
  rC Clang

https://reviews.llvm.org/D51007



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


[PATCH] D51007: Test the cross-product of options that affect how libgcc-related arguments are passed to the linker.

2018-08-20 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine created this revision.
saugustine added a reviewer: echristo.
Herald added a subscriber: cfe-commits.

NFC. Add tests to verify how the driver passes libgcc arguments to the linker


Repository:
  rC Clang

https://reviews.llvm.org/D51007

Files:
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -150,6 +150,88 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-NO-LIBGCC %s
+// CHECK-CLANG-NO-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-NO-LIBGCC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-CLANG-NO-LIBGCC: "-lc"
+// CHECK-CLANG-NO-LIBGCC: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+//
+// RUN: %clang++ -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGXX-NO-LIBGCC %s
+// CHECK-CLANGXX-NO-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANGXX-NO-LIBGCC: "-lgcc_s" "-lgcc"
+// CHECK-CLANGXX-NO-LIBGCC: "-lc"
+// CHECK-CLANGXX-NO-LIBGCC: "-lgcc_s" "-lgcc"
+//
+// RUN: %clang -static -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-NO-LIBGCC-STATIC %s
+// CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
+//
+// RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-NO-LIBGCC-DYNAMIC %s
+// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "-lgcc" "--as-needed" "-lgcc_s" 
"--no-as-needed"
+// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "-lc"
+// CHECK-CLANG-NO-LIBGCC-DYNAMIC: "-lgcc" "--as-needed" "-lgcc_s" 
"--no-as-needed"
+//
+// RUN: %clang -static-libgcc -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-STATIC-LIBGCC %s
+// CHECK-CLANG-STATIC-LIBGCC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-STATIC-LIBGCC: "-lgcc" "-lgcc_eh"
+// CHECK-CLANG-STATIC-LIBGCC: "-lc"
+// CHECK-CLANG-STATIC-LIBGCC: "-lgcc" "-lgcc_eh"
+//
+// RUN: %clang -static-libgcc -dynamic -no-canonical-prefixes %s -### -o %t.o 
2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-STATIC-LIBGCC-DYNAMIC %s
+// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "-lgcc" "-lgcc_eh"
+// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "-lc"
+// CHECK-CLANG-STATIC-LIBGCC-DYNAMIC: "-lgcc" "-lgcc_eh"
+//
+// RUN: %clang -shared-libgcc -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-SHARED-LIBGCC %s
+// CHECK-CLANG-SHARED-LIBGCC: warning: argument unused during compilation: 
'-shared-libgcc'
+// This will be the correct check once the driver supports -shared-libgcc
+// SKIP-CHECK-CLANG-SHARED-LIBGCC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc"
+// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lc"
+// SKIP-CHECK-CLANG-SHARED-LIBGCC: "-lgcc_s" "-lgcc"
+//
+// RUN: %clang -shared-libgcc -dynamic -no-canonical-prefixes %s -### -o %t.o 
2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-SHARED-LIBGCC-DYNAMIC %s
+// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: warning: argument unused during 
compilation: '-shared-libgcc'
+// CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// This will be the correct check once the driver supports -shared-libgcc
+// SKIP-CHECK-CLANG-SHARED-LIBGCC-DYNAMIC: "-lgcc_s" "-lgcc"
+// 

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley accepted this revision.
delesley added a comment.

This looks good to me.  Thanks for the patch.




Comment at: lib/Analysis/ThreadSafety.cpp:932
+  // We're relocking the underlying mutexes. Warn on double locking.
+  if (FSet.findLock(FactMan, UnderCp))
+Handler.handleDoubleLock(DiagKind, UnderCp.toString(), entry.loc());

Minor nit.  Use curly braces on the if, to match the else.


Repository:
  rC Clang

https://reviews.llvm.org/D49885



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1472
 
+  /// Do we need to emit an exit-time destructor for this variable?
+  bool isNoDestroy(const ASTContext &) const;

erik.pilkington wrote:
> jfb wrote:
> > rsmith wrote:
> > > jfb wrote:
> > > > This is only valid for static variables, right? It's probably better to 
> > > > document the function name that way, e.g. `isStaticWithNoDestroy`.
> > > I think the question (and hence current function name) is meaningful for 
> > > any variable, but it just happens that the answer will always be "no" for 
> > > non-static variables (for now, at least). Are you concerned that people 
> > > will think calls to this function are missing from codepaths that only 
> > > deal with automatic storage duration variables with the current name?
> > Yeah it seems like "this variable has no destructor". I guess even trivial 
> > automatic variables have a (trivial) destructor, so maybe it's not 
> > ambiguous? Up to y'all :)
> If anyone has a strong preference I'd be happy either way!
Considering what Richard pointed out below w.r.t. naming convention, this is 
good with me.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5931
+handleSimpleAttributeWithExclusions(S, 
D, A);
+  }
+}

erik.pilkington wrote:
> jfb wrote:
> > This allows a variable with both attributes :)
> > Looking at the code above it seems like having both attributes is 
> > equivalent to no-destroy.
> `handleSimpleAttributeWithExclusions` handles that automagically, i.e.:
> ```
> $ cat t.cpp
> [[clang::no_destroy]] [[clang::always_destroy]] int x;
> $ ~/dbg-bld/bin/clang t.cpp
> t.cpp:1:25: error: 'always_destroy' and 'no_destroy' attributes are not 
> compatible
> [[clang::no_destroy]] [[clang::always_destroy]] int x;
> ^
> t.cpp:1:3: note: conflicting attribute is here
> [[clang::no_destroy]] [[clang::always_destroy]] int x;
>   ^
> 1 error generated.
> ```
> I'll add a test to prove this though...
Ah nice!


https://reviews.llvm.org/D50994



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


[PATCH] D50866: [analyzer] CFRetainReleaseChecker: Avoid checking C++ methods with the same name.

2018-08-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:537
+  mutable APIMisuse BT{this, "null passed to CF memory management function"};
+  CallDescription CFRetain{"CFRetain", 1},
+  CFRelease{"CFRelease", 1},

george.karpenkov wrote:
> I personally would prefer being less fancy, and avoiding the comma operator, 
> but I suppose it's a matter of style.
This isn't comma operator, just initializer list.

Alternatives are:

- `CallDescription CFRetain = {"CFRetain", 1}` (longer but looks the same)

- `CallDescription CFRetain = CallDescription("CFRetain", 1), ...` (longer and 
duplicates type)

- `CallDescription CFRetain;` `CFRetainReleaseChecker(): CFRetain("CFRetain", 
1)` (longer and duplicates variable name)




Comment at: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:567
+  ProgramStateRef stateNonNull, stateNull;
+  std::tie(stateNonNull, stateNull) = state->assume(*DefArgVal);
 

george.karpenkov wrote:
> There's also DefArgVal
?


Repository:
  rC Clang

https://reviews.llvm.org/D50866



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


[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 161598.
aaronpuchert added a comment.

Reformat tests. I promise, this is the last one.


Repository:
  rC Clang

https://reviews.llvm.org/D49885

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2621,6 +2621,170 @@
 } // end namespace ReleasableScopedLock
 
 
+namespace RelockableScopedLock {
+
+class SCOPED_LOCKABLE RelockableExclusiveMutexLock {
+public:
+  RelockableExclusiveMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableExclusiveMutexLock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+};
+
+struct SharedTraits {};
+struct ExclusiveTraits {};
+
+class SCOPED_LOCKABLE RelockableMutexLock {
+public:
+  RelockableMutexLock(Mutex *mu, SharedTraits) SHARED_LOCK_FUNCTION(mu);
+  RelockableMutexLock(Mutex *mu, ExclusiveTraits) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableMutexLock() UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+
+  void ReaderLock() SHARED_LOCK_FUNCTION();
+  void ReaderUnlock() UNLOCK_FUNCTION();
+
+  void PromoteShared() UNLOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION();
+  void DemoteExclusive() UNLOCK_FUNCTION() SHARED_LOCK_FUNCTION();
+};
+
+Mutex mu;
+int x GUARDED_BY(mu);
+
+void print(int);
+
+void relock() {
+  RelockableExclusiveMutexLock scope();
+  x = 2;
+  scope.Unlock();
+
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.Lock();
+  x = 4;
+}
+
+void relockExclusive() {
+  RelockableMutexLock scope(, SharedTraits{});
+  print(x);
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.ReaderUnlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.Lock();
+  print(x);
+  x = 4;
+
+  scope.DemoteExclusive();
+  print(x);
+  x = 5; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void relockShared() {
+  RelockableMutexLock scope(, ExclusiveTraits{});
+  print(x);
+  x = 2;
+  scope.Unlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.ReaderLock();
+  print(x);
+  x = 4; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.PromoteShared();
+  print(x);
+  x = 5;
+}
+
+void doubleUnlock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+void doubleLock1() {
+  RelockableExclusiveMutexLock scope();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleLock2() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void directUnlock() {
+  RelockableExclusiveMutexLock scope();
+  mu.Unlock();
+  // Debatable that there is no warning. Currently we don't track in the scoped
+  // object whether it is active, but just check if the contained locks can be
+  // reacquired. Here they can, because mu has been unlocked manually.
+  scope.Lock();
+}
+
+void directRelock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  mu.Lock();
+  // Similarly debatable that there is no warning.
+  scope.Unlock();
+}
+
+// Doesn't make a lot of sense, just making sure there is no crash.
+void destructLock() {
+  RelockableExclusiveMutexLock scope();
+  scope.~RelockableExclusiveMutexLock();
+  scope.Lock(); // Should be UB, so we don't really care.
+}
+
+class SCOPED_LOCKABLE MemberLock {
+public:
+  MemberLock() EXCLUSIVE_LOCK_FUNCTION(mutex);
+  ~MemberLock() UNLOCK_FUNCTION(mutex);
+  void Lock() EXCLUSIVE_LOCK_FUNCTION(mutex);
+  Mutex mutex;
+};
+
+void relockShared2() {
+  MemberLock lock;
+  lock.Lock(); // expected-warning {{acquiring mutex 'lock.mutex' that is already held}}
+}
+
+class SCOPED_LOCKABLE WeirdScope {
+private:
+  Mutex *other;
+
+public:
+  WeirdScope(Mutex *mutex) EXCLUSIVE_LOCK_FUNCTION(mutex);
+  void unlock() EXCLUSIVE_UNLOCK_FUNCTION() EXCLUSIVE_UNLOCK_FUNCTION(other);
+  void lock() EXCLUSIVE_LOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION(other);
+  ~WeirdScope() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void requireOther() EXCLUSIVE_LOCKS_REQUIRED(other);
+};
+
+void relockWeird() {
+  WeirdScope scope();
+  x = 1;
+  scope.unlock(); // expected-warning {{releasing mutex 'scope.other' that was not held}}
+  x = 2; // \
+// expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.requireOther(); // \
+// expected-warning {{calling function 'requireOther' requires 

[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Seems fine to me, once you add the test for always_destroy + no_destroy.




Comment at: clang/include/clang/Basic/LangOptions.def:311
 
+LANGOPT(RegisterStaticDestructors, 1, 1, "Register C++ static destructors")
+

erik.pilkington wrote:
> rsmith wrote:
> > Should be a `BENIGN_LANGOPT` because it doesn't affect AST construction, 
> > only the generated code.
> It does affect AST construction though, we don't mark a static VarDecl's 
> type's destructor referenced in this mode, or check it's access (because we 
> aren't actually using it). Do you think this is the wrong choice of semantics?
Ah, no, good point. This is right, then. (And I think avoiding checking the 
destructor is also appropriate, so that a private or deleted destructor can be 
used to "remind" people to use the attribute.)


https://reviews.llvm.org/D50994



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


r340228 - libclang: add install/distribution targets for python

2018-08-20 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Aug 20 15:50:18 2018
New Revision: 340228

URL: http://llvm.org/viewvc/llvm-project?rev=340228=rev
Log:
libclang: add install/distribution targets for python

Add installation support for the python bindings for libclang.  Add an
additional CMake configuration variable to enumerate the python versions for
which the bindings should be installed.  This allows for a LLVM/clang
distribution to distribute the python bindings for libclang as part of the
image.  Because the python versions need to be explicitly stated by the user,
the default image remains unchanged.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=340228=340227=340228=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Aug 20 15:50:18 2018
@@ -279,6 +279,9 @@ endif()
 set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
   "Vendor-specific uti.")
 
+set(CLANG_PYTHON_BINDINGS_VERSIONS "" CACHE STRING
+"Python versions to install libclang python bindings for")
+
 # The libdir suffix must exactly match whatever LLVM's configuration used.
 set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}")
 

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=340228=340227=340228=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Mon Aug 20 15:50:18 2018
@@ -151,3 +151,22 @@ if (NOT CMAKE_CONFIGURATION_TYPES) # don
   add_llvm_install_targets(install-libclang-headers
COMPONENT libclang-headers)
 endif()
+
+# Create a target to install the python bindings to make them easier to
+# distribute.  Since the bindings are over libclang, which is installed
+# unbundled to the clang version, follow suit.
+foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS})
+  install(DIRECTORY
+${CMAKE_CURRENT_SOURCE_DIR}/../../bindings/python/clang
+  COMPONENT
+libclang-python-bindings
+  DESTINATION
+"lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
+endforeach()
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_custom_target(libclang-python-bindings)
+  add_llvm_install_targets(install-libclang-python-bindings
+   COMPONENT
+ libclang-python-bindings)
+endif()
+


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


[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 161596.
aaronpuchert added a comment.

Formatting changes.


Repository:
  rC Clang

https://reviews.llvm.org/D49885

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2621,6 +2621,171 @@
 } // end namespace ReleasableScopedLock
 
 
+namespace RelockableScopedLock {
+
+class SCOPED_LOCKABLE RelockableExclusiveMutexLock {
+public:
+  RelockableExclusiveMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableExclusiveMutexLock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+};
+
+struct SharedTraits {};
+struct ExclusiveTraits {};
+
+class SCOPED_LOCKABLE RelockableMutexLock {
+public:
+  RelockableMutexLock(Mutex *mu, SharedTraits) SHARED_LOCK_FUNCTION(mu);
+  RelockableMutexLock(Mutex *mu, ExclusiveTraits) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableMutexLock() UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+
+  void ReaderLock() SHARED_LOCK_FUNCTION();
+  void ReaderUnlock() UNLOCK_FUNCTION();
+
+  void PromoteShared() UNLOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION();
+  void DemoteExclusive() UNLOCK_FUNCTION() SHARED_LOCK_FUNCTION();
+};
+
+Mutex mu;
+int x GUARDED_BY(mu);
+
+void print(int);
+
+void relock() {
+  RelockableExclusiveMutexLock scope();
+  x = 2;
+  scope.Unlock();
+
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.Lock();
+  x = 4;
+}
+
+void relockExclusive() {
+  RelockableMutexLock scope(, SharedTraits{});
+  print(x);
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.ReaderUnlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.Lock();
+  print(x);
+  x = 4;
+
+  scope.DemoteExclusive();
+  print(x);
+  x = 5; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void relockShared() {
+  RelockableMutexLock scope(, ExclusiveTraits{});
+  print(x);
+  x = 2;
+  scope.Unlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.ReaderLock();
+  print(x);
+  x = 4; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.PromoteShared();
+  print(x);
+  x = 5;
+}
+
+void doubleUnlock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+void doubleLock1() {
+  RelockableExclusiveMutexLock scope();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleLock2() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void directUnlock() {
+  RelockableExclusiveMutexLock scope();
+  mu.Unlock();
+  // Debatable that there is no warning. Currently we don't track in the scoped
+  // object whether it is active, but just check if the contained locks can be
+  // reacquired. Here they can, because mu has been unlocked manually.
+  scope.Lock();
+}
+
+void directRelock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  mu.Lock();
+  // Similarly debatable that there is no warning.
+  scope.Unlock();
+}
+
+// Doesn't make a lot of sense, just making sure there is no crash.
+void destructLock() {
+  RelockableExclusiveMutexLock scope();
+  scope.~RelockableExclusiveMutexLock();
+  scope.Lock(); // Should be UB, so we don't really care.
+}
+
+class SCOPED_LOCKABLE MemberLock {
+ public:
+  MemberLock() EXCLUSIVE_LOCK_FUNCTION(mutex);
+  ~MemberLock() UNLOCK_FUNCTION(mutex);
+  void Lock() EXCLUSIVE_LOCK_FUNCTION(mutex);
+  Mutex mutex;
+};
+
+void relockShared2() {
+  MemberLock lock;
+  lock.Lock(); // expected-warning {{acquiring mutex 'lock.mutex' that is already held}}
+}
+
+class SCOPED_LOCKABLE WeirdScope {
+private:
+  Mutex *other;
+
+public:
+  WeirdScope(Mutex *mutex) EXCLUSIVE_LOCK_FUNCTION(mutex);
+  void unlock() EXCLUSIVE_UNLOCK_FUNCTION() EXCLUSIVE_UNLOCK_FUNCTION(other);
+  void lock() EXCLUSIVE_LOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION(other);
+  ~WeirdScope() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void requireOther() EXCLUSIVE_LOCKS_REQUIRED(other);
+};
+
+void relockWeird()
+{
+  WeirdScope scope();
+  x = 1;
+  scope.unlock(); // expected-warning {{releasing mutex 'scope.other' that was not held}}
+  x = 2; // \
+// expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.requireOther(); // \
+// expected-warning {{calling function 'requireOther' requires holding mutex 'scope.other' 

[PATCH] D49885: Thread safety analysis: Allow relockable scopes

2018-08-20 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 161595.
aaronpuchert added a comment.

Proper capitalization of member function, reduction of test code.


Repository:
  rC Clang

https://reviews.llvm.org/D49885

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp

Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -2621,6 +2621,171 @@
 } // end namespace ReleasableScopedLock
 
 
+namespace RelockableScopedLock {
+
+class SCOPED_LOCKABLE RelockableExclusiveMutexLock {
+public:
+  RelockableExclusiveMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableExclusiveMutexLock() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+};
+
+struct SharedTraits {};
+struct ExclusiveTraits {};
+
+class SCOPED_LOCKABLE RelockableMutexLock {
+public:
+  RelockableMutexLock(Mutex *mu, SharedTraits) SHARED_LOCK_FUNCTION(mu);
+  RelockableMutexLock(Mutex *mu, ExclusiveTraits) EXCLUSIVE_LOCK_FUNCTION(mu);
+  ~RelockableMutexLock() UNLOCK_FUNCTION();
+
+  void Lock() EXCLUSIVE_LOCK_FUNCTION();
+  void Unlock() UNLOCK_FUNCTION();
+
+  void ReaderLock() SHARED_LOCK_FUNCTION();
+  void ReaderUnlock() UNLOCK_FUNCTION();
+
+  void PromoteShared() UNLOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION();
+  void DemoteExclusive() UNLOCK_FUNCTION() SHARED_LOCK_FUNCTION();
+};
+
+Mutex mu;
+int x GUARDED_BY(mu);
+
+void print(int);
+
+void relock() {
+  RelockableExclusiveMutexLock scope();
+  x = 2;
+  scope.Unlock();
+
+  x = 3; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.Lock();
+  x = 4;
+}
+
+void relockExclusive() {
+  RelockableMutexLock scope(, SharedTraits{});
+  print(x);
+  x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.ReaderUnlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.Lock();
+  print(x);
+  x = 4;
+
+  scope.DemoteExclusive();
+  print(x);
+  x = 5; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+}
+
+void relockShared() {
+  RelockableMutexLock scope(, ExclusiveTraits{});
+  print(x);
+  x = 2;
+  scope.Unlock();
+
+  print(x); // expected-warning {{reading variable 'x' requires holding mutex 'mu'}}
+
+  scope.ReaderLock();
+  print(x);
+  x = 4; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+
+  scope.PromoteShared();
+  print(x);
+  x = 5;
+}
+
+void doubleUnlock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Unlock(); // expected-warning {{releasing mutex 'mu' that was not held}}
+}
+
+void doubleLock1() {
+  RelockableExclusiveMutexLock scope();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void doubleLock2() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  scope.Lock();
+  scope.Lock(); // expected-warning {{acquiring mutex 'mu' that is already held}}
+}
+
+void directUnlock() {
+  RelockableExclusiveMutexLock scope();
+  mu.Unlock();
+  // Debatable that there is no warning. Currently we don't track in the scoped
+  // object whether it is active, but just check if the contained locks can be
+  // reacquired. Here they can, because mu has been unlocked manually.
+  scope.Lock();
+}
+
+void directRelock() {
+  RelockableExclusiveMutexLock scope();
+  scope.Unlock();
+  mu.Lock();
+  // Similarly debatable that there is no warning.
+  scope.Unlock();
+}
+
+// Doesn't make a lot of sense, just making sure there is no crash.
+void destructLock() {
+  RelockableExclusiveMutexLock scope();
+  scope.~RelockableExclusiveMutexLock();
+  scope.Lock(); // Should be UB, so we don't really care.
+}
+
+class SCOPED_LOCKABLE MemberLock {
+ public:
+  MemberLock() EXCLUSIVE_LOCK_FUNCTION(mutex);
+  ~MemberLock() UNLOCK_FUNCTION(mutex);
+  void Lock() EXCLUSIVE_LOCK_FUNCTION(mutex);
+  Mutex mutex;
+};
+
+void relockShared2() {
+  MemberLock lock;
+  lock.Lock(); // expected-warning {{acquiring mutex 'lock.mutex' that is already held}}
+}
+
+class SCOPED_LOCKABLE WeirdScope {
+private:
+  Mutex *other;
+
+public:
+  WeirdScope(Mutex *mutex) EXCLUSIVE_LOCK_FUNCTION(mutex);
+  void unlock() EXCLUSIVE_UNLOCK_FUNCTION() EXCLUSIVE_UNLOCK_FUNCTION(other);
+  void lock() EXCLUSIVE_LOCK_FUNCTION() EXCLUSIVE_LOCK_FUNCTION(other);
+  ~WeirdScope() EXCLUSIVE_UNLOCK_FUNCTION();
+
+  void requireOther() EXCLUSIVE_LOCKS_REQUIRED(other);
+};
+
+void relockWeird()
+{
+  WeirdScope scope();
+  x = 1;
+  scope.unlock(); // expected-warning {{releasing mutex 'scope.other' that was not held}}
+  x = 2; // \
+// expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+  scope.requireOther(); // \
+// expected-warning {{calling function 

[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1472
 
+  /// Do we need to emit an exit-time destructor for this variable?
+  bool isNoDestroy(const ASTContext &) const;

jfb wrote:
> rsmith wrote:
> > jfb wrote:
> > > This is only valid for static variables, right? It's probably better to 
> > > document the function name that way, e.g. `isStaticWithNoDestroy`.
> > I think the question (and hence current function name) is meaningful for 
> > any variable, but it just happens that the answer will always be "no" for 
> > non-static variables (for now, at least). Are you concerned that people 
> > will think calls to this function are missing from codepaths that only deal 
> > with automatic storage duration variables with the current name?
> Yeah it seems like "this variable has no destructor". I guess even trivial 
> automatic variables have a (trivial) destructor, so maybe it's not ambiguous? 
> Up to y'all :)
If anyone has a strong preference I'd be happy either way!



Comment at: clang/include/clang/Basic/LangOptions.def:311
 
+LANGOPT(RegisterStaticDestructors, 1, 1, "Register C++ static destructors")
+

rsmith wrote:
> Should be a `BENIGN_LANGOPT` because it doesn't affect AST construction, only 
> the generated code.
It does affect AST construction though, we don't mark a static VarDecl's type's 
destructor referenced in this mode, or check it's access (because we aren't 
actually using it). Do you think this is the wrong choice of semantics?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5931
+handleSimpleAttributeWithExclusions(S, 
D, A);
+  }
+}

jfb wrote:
> This allows a variable with both attributes :)
> Looking at the code above it seems like having both attributes is equivalent 
> to no-destroy.
`handleSimpleAttributeWithExclusions` handles that automagically, i.e.:
```
$ cat t.cpp
[[clang::no_destroy]] [[clang::always_destroy]] int x;
$ ~/dbg-bld/bin/clang t.cpp
t.cpp:1:25: error: 'always_destroy' and 'no_destroy' attributes are not 
compatible
[[clang::no_destroy]] [[clang::always_destroy]] int x;
^
t.cpp:1:3: note: conflicting attribute is here
[[clang::no_destroy]] [[clang::always_destroy]] int x;
  ^
1 error generated.
```
I'll add a test to prove this though...


https://reviews.llvm.org/D50994



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 161594.
erik.pilkington marked 7 inline comments as done.
erik.pilkington added a comment.

In this new patch:

- Fix some grammar errors in the documentation.
- Add a testcase for both attributes appearing on a variable.
- Just use hasArg() in the driver.
- Improve the diagnostic.

Thanks for the feedback!


https://reviews.llvm.org/D50994

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/always_destroy.cpp
  clang/test/CodeGenCXX/no_destroy.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/no_destroy.cpp

Index: clang/test/SemaCXX/no_destroy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/no_destroy.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -DNO_DTORS -fno-c++-static-destructors -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct SecretDestructor {
+#ifndef NO_DTORS
+  // expected-note@+2 4 {{private}}
+#endif
+private: ~SecretDestructor(); // expected-note 2 {{private}}
+};
+
+SecretDestructor sd1;
+thread_local SecretDestructor sd2;
+void locals() {
+  static SecretDestructor sd3;
+  thread_local SecretDestructor sd4;
+}
+
+#ifndef NO_DTORS
+// SecretDestructor sd1;  // expected-error@-8 {{private}}
+// thread_local SecretDestructor sd2; // expected-error@-8 {{private}}
+// void locals() {
+//   static SecretDestructor sd3; // expected-error@-8 {{private}}
+//   thread_local SecretDestructor sd4;   // expected-error@-8 {{private}}
+// }
+#endif
+
+[[clang::always_destroy]] SecretDestructor sd6; // expected-error{{private}}
+[[clang::always_destroy]] thread_local SecretDestructor sd7; // expected-error{{private}}
+
+[[clang::no_destroy]] SecretDestructor sd8;
+
+int main() {
+  [[clang::no_destroy]] int p; // expected-error{{no_destroy attribute can only be applied to a variable with static or thread storage duration}}
+  [[clang::always_destroy]] int p2; // expected-error{{always_destroy attribute can only be applied to a variable with static or thread storage duration}}
+  [[clang::no_destroy]] static int p3;
+  [[clang::always_destroy]] static int p4;
+}
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
@@ -2,15 +2,16 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 72 attributes:
+// CHECK: #pragma clang attribute supports 74 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUWavesPerEU (SubjectMatchRule_function)
 // CHECK-NEXT: AVRSignal (SubjectMatchRule_function)
 // CHECK-NEXT: AbiTag (SubjectMatchRule_record_not_is_union, SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_namespace)
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
+// CHECK-NEXT: AlwaysDestroy (SubjectMatchRule_variable)
 // CHECK-NEXT: Annotate ()
 // CHECK-NEXT: AnyX86NoCfCheck (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
@@ -38,6 +39,7 @@
 // CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
+// CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: clang/test/CodeGenCXX/no_destroy.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no_destroy.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s
+
+struct NonTrivial {
+  ~NonTrivial();
+};
+
+// CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
+[[clang::no_destroy]] NonTrivial nt1;
+// CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
+[[clang::no_destroy]] thread_local NonTrivial nt2;
+
+struct NonTrivial2 {
+  

[PATCH] D47814: Teach libc++ to use native NetBSD's max_align_t

2018-08-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX340224: Teach libc++ to use native NetBSDs 
max_align_t (authored by kamil, committed by ).
Herald added a subscriber: ldionne.

Repository:
  rCXX libc++

https://reviews.llvm.org/D47814

Files:
  include/cstddef
  include/stddef.h


Index: include/stddef.h
===
--- include/stddef.h
+++ include/stddef.h
@@ -54,7 +54,7 @@
 
 // Re-use the compiler's  max_align_t where possible.
 #if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t)
+!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
 typedef long double max_align_t;
 #endif
 
Index: include/cstddef
===
--- include/cstddef
+++ include/cstddef
@@ -50,7 +50,7 @@
 using ::size_t;
 
 #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t)
+defined(__DEFINED_max_align_t) || defined(__NetBSD__)
 // Re-use the compiler's  max_align_t where possible.
 using ::max_align_t;
 #else


Index: include/stddef.h
===
--- include/stddef.h
+++ include/stddef.h
@@ -54,7 +54,7 @@
 
 // Re-use the compiler's  max_align_t where possible.
 #if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t)
+!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
 typedef long double max_align_t;
 #endif
 
Index: include/cstddef
===
--- include/cstddef
+++ include/cstddef
@@ -50,7 +50,7 @@
 using ::size_t;
 
 #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t)
+defined(__DEFINED_max_align_t) || defined(__NetBSD__)
 // Re-use the compiler's  max_align_t where possible.
 using ::max_align_t;
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r340224 - Teach libc++ to use native NetBSD's max_align_t

2018-08-20 Thread Kamil Rytarowski via cfe-commits
Author: kamil
Date: Mon Aug 20 15:29:20 2018
New Revision: 340224

URL: http://llvm.org/viewvc/llvm-project?rev=340224=rev
Log:
Teach libc++ to use native NetBSD's max_align_t

Summary:
The NetBSD headers ship with max_align_t, that is not
compatible with the fallback version in libc++.

There is no defined a compiler specific symbol in the headers like:
 - __CLANG_MAX_ALIGN_T_DEFINED
 - _GCC_MAX_ALIGN_T
 - __DEFINED_max_align_t

Sponsored by 

Reviewers: chandlerc, dlj, EricWF, joerg

Reviewed By: joerg

Subscribers: bsdjhb, llvm-commits, cfe-commits

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

Modified:
libcxx/trunk/include/cstddef
libcxx/trunk/include/stddef.h

Modified: libcxx/trunk/include/cstddef
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstddef?rev=340224=340223=340224=diff
==
--- libcxx/trunk/include/cstddef (original)
+++ libcxx/trunk/include/cstddef Mon Aug 20 15:29:20 2018
@@ -50,7 +50,7 @@ using ::ptrdiff_t;
 using ::size_t;
 
 #if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
-defined(__DEFINED_max_align_t)
+defined(__DEFINED_max_align_t) || defined(__NetBSD__)
 // Re-use the compiler's  max_align_t where possible.
 using ::max_align_t;
 #else

Modified: libcxx/trunk/include/stddef.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stddef.h?rev=340224=340223=340224=diff
==
--- libcxx/trunk/include/stddef.h (original)
+++ libcxx/trunk/include/stddef.h Mon Aug 20 15:29:20 2018
@@ -54,7 +54,7 @@ using std::nullptr_t;
 
 // Re-use the compiler's  max_align_t where possible.
 #if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
-!defined(__DEFINED_max_align_t)
+!defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
 typedef long double max_align_t;
 #endif
 


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


[PATCH] D50978: [ASTImporter] Add test for C++'s try/catch statements.

2018-08-20 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340220: [ASTImporter] Add test for C++s try/catch 
statements. (authored by teemperor, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50978

Files:
  test/Import/cxx-try-catch/Inputs/F.cpp
  test/Import/cxx-try-catch/test.cpp
  tools/clang-import-test/clang-import-test.cpp


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
Index: test/Import/cxx-try-catch/Inputs/F.cpp
===
--- test/Import/cxx-try-catch/Inputs/F.cpp
+++ test/Import/cxx-try-catch/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}
Index: test/Import/cxx-try-catch/test.cpp
===
--- test/Import/cxx-try-catch/test.cpp
+++ test/Import/cxx-try-catch/test.cpp
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
Index: test/Import/cxx-try-catch/Inputs/F.cpp
===
--- test/Import/cxx-try-catch/Inputs/F.cpp
+++ test/Import/cxx-try-catch/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}
Index: test/Import/cxx-try-catch/test.cpp
===
--- test/Import/cxx-try-catch/test.cpp
+++ test/Import/cxx-try-catch/test.cpp
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340220 - [ASTImporter] Add test for C++'s try/catch statements.

2018-08-20 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Mon Aug 20 15:13:24 2018
New Revision: 340220

URL: http://llvm.org/viewvc/llvm-project?rev=340220=rev
Log:
[ASTImporter] Add test for C++'s try/catch statements.

Summary: Also enable exceptions in clang-import-test so that we can parse the 
test files.

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

Added:
cfe/trunk/test/Import/cxx-try-catch/
cfe/trunk/test/Import/cxx-try-catch/Inputs/
cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp
cfe/trunk/test/Import/cxx-try-catch/test.cpp
Modified:
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Added: cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp?rev=340220=auto
==
--- cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/cxx-try-catch/Inputs/F.cpp Mon Aug 20 15:13:24 2018
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}

Added: cfe/trunk/test/Import/cxx-try-catch/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-try-catch/test.cpp?rev=340220=auto
==
--- cfe/trunk/test/Import/cxx-try-catch/test.cpp (added)
+++ cfe/trunk/test/Import/cxx-try-catch/test.cpp Mon Aug 20 15:13:24 2018
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=340220=340219=340220=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Mon Aug 20 15:13:24 
2018
@@ -194,6 +194,8 @@ std::unique_ptr BuildC
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);


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


[PATCH] D50978: [ASTImporter] Add test for C++'s try/catch statements.

2018-08-20 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 161580.
teemperor added a comment.

- Clarified that the Exception options in LangOpts are not related to the 
dynamic_cast support by moving them above the comment (Thanks Aleksei!)


https://reviews.llvm.org/D50978

Files:
  test/Import/cxx-try-catch/Inputs/F.cpp
  test/Import/cxx-try-catch/test.cpp
  tools/clang-import-test/clang-import-test.cpp


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
Index: test/Import/cxx-try-catch/test.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/test.cpp
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-try-catch/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
Index: test/Import/cxx-try-catch/test.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/test.cpp
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-try-catch/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51001: [ASTImporter] Add test for CXXForRangeStmt

2018-08-20 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added subscribers: cfe-commits, martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D51001

Files:
  test/Import/cxx-for-range/Inputs/F.cpp
  test/Import/cxx-for-range/test.cpp


Index: test/Import/cxx-for-range/test.cpp
===
--- /dev/null
+++ test/Import/cxx-for-range/test.cpp
@@ -0,0 +1,53 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXForRangeStmt
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: 'c'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .begin
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .end
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: BinaryOperator
+// CHECK-SAME: '!='
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__end1'
+
+// CHECK-NEXT: UnaryOperator
+// CHECK-SAME: '++'
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+
+// CHECK: ReturnStmt
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-for-range/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-for-range/Inputs/F.cpp
@@ -0,0 +1,11 @@
+struct Container {
+  int *begin();
+  int *end();
+};
+
+void f() {
+  Container c;
+  for (int varname : c) {
+return;
+  }
+}


Index: test/Import/cxx-for-range/test.cpp
===
--- /dev/null
+++ test/Import/cxx-for-range/test.cpp
@@ -0,0 +1,53 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXForRangeStmt
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: 'c'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .begin
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .end
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: BinaryOperator
+// CHECK-SAME: '!='
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__end1'
+
+// CHECK-NEXT: UnaryOperator
+// CHECK-SAME: '++'
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+
+// CHECK: ReturnStmt
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-for-range/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-for-range/Inputs/F.cpp
@@ -0,0 +1,11 @@
+struct Container {
+  int *begin();
+  int *end();
+};
+
+void f() {
+  Container c;
+  for (int varname : c) {
+return;
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50662: Add dump() method for SourceRange

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Basic/SourceLocation.cpp:89-93
+  B.print(OS, SM);
+  OS << ",\n ";
+  E.print(OS, SM);
+  OS << "]\n";
+}

It would seem somewhat more natural to dump `SourceRange`s the same way we dump 
them in `-ast-dump`. (That is: use angle brackets, no newline, and omit the 
file name / line number / column number on the end location if it's the same as 
on the start location.)


Repository:
  rC Clang

https://reviews.llvm.org/D50662



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


[PATCH] D50662: Add dump() method for SourceRange

2018-08-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin requested changes to this revision.
a_sidorin added a comment.
This revision now requires changes to proceed.

Hello Stephen,
These methods will be really useful.




Comment at: lib/Basic/SourceLocation.cpp:90
+  B.print(OS, SM);
+  OS << ",\n ";
+  E.print(OS, SM);

I think we should print both locations on the same line, without adding a 
newline after the start SLoc.



Comment at: lib/Basic/SourceLocation.cpp:92
+  E.print(OS, SM);
+  OS << "]\n";
+}

print() shouldn't add a newline, it is up to dump() methods.


Repository:
  rC Clang

https://reviews.llvm.org/D50662



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


[PATCH] D50662: Add dump() method for SourceRange

2018-08-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Thanks, I've done that now.


Repository:
  rC Clang

https://reviews.llvm.org/D50662



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


[PATCH] D50662: Add dump() method for SourceRange

2018-08-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 161570.
steveire added a comment.

Add dump() and supporting methods to SourceRange


Repository:
  rC Clang

https://reviews.llvm.org/D50662

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceLocation.cpp


Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,26 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager ) const {
+  print(llvm::errs(), SM);
+}
+
+void SourceRange::print(raw_ostream , const SourceManager ) const {
+  OS << '[';
+  B.print(OS, SM);
+  OS << ",\n ";
+  E.print(OS, SM);
+  OS << "]\n";
+}
+
+LLVM_DUMP_METHOD std::string
+SourceRange::printToString(const SourceManager ) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return OS.str();
+}
+
 
//===--===//
 // FullSourceLoc
 
//===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange ) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream , const SourceManager ) const;
+  std::string printToString(const SourceManager ) const;
+  void dump(const SourceManager ) const;
 };
 
 /// Represents a character-granular source range.


Index: lib/Basic/SourceLocation.cpp
===
--- lib/Basic/SourceLocation.cpp
+++ lib/Basic/SourceLocation.cpp
@@ -80,6 +80,26 @@
   llvm::errs() << '\n';
 }
 
+LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager ) const {
+  print(llvm::errs(), SM);
+}
+
+void SourceRange::print(raw_ostream , const SourceManager ) const {
+  OS << '[';
+  B.print(OS, SM);
+  OS << ",\n ";
+  E.print(OS, SM);
+  OS << "]\n";
+}
+
+LLVM_DUMP_METHOD std::string
+SourceRange::printToString(const SourceManager ) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return OS.str();
+}
+
 //===--===//
 // FullSourceLoc
 //===--===//
Index: include/clang/Basic/SourceLocation.h
===
--- include/clang/Basic/SourceLocation.h
+++ include/clang/Basic/SourceLocation.h
@@ -220,6 +220,10 @@
   bool operator!=(const SourceRange ) const {
 return B != X.B || E != X.E;
   }
+
+  void print(raw_ostream , const SourceManager ) const;
+  std::string printToString(const SourceManager ) const;
+  void dump(const SourceManager ) const;
 };
 
 /// Represents a character-granular source range.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340215 - Model type attributes as regular Attrs.

2018-08-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 20 14:47:29 2018
New Revision: 340215

URL: http://llvm.org/viewvc/llvm-project?rev=340215=rev
Log:
Model type attributes as regular Attrs.

Specifically, AttributedType now tracks a regular attr::Kind rather than
having its own parallel Kind enumeration, and AttributedTypeLoc now
holds an Attr* instead of holding an ad-hoc collection of Attr fields.

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

This reinstates r339623, reverted in r339638, with a fix to not fail
template instantiation if we instantiate a QualType with no associated
type source information and we encounter an AttributedType.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
cfe/trunk/test/SemaCXX/calling-conv-compat.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=340215=340214=340215=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug 20 14:47:29 2018
@@ -31,6 +31,7 @@
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/AttrKinds.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
@@ -1422,7 +1423,7 @@ public:
 
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
-  QualType getAttributedType(AttributedType::Kind attrKind,
+  QualType getAttributedType(attr::Kind attrKind,
  QualType modifiedType,
  QualType equivalentType);
 

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=340215=340214=340215=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Mon Aug 20 14:47:29 2018
@@ -113,6 +113,19 @@ public:
   void printPretty(raw_ostream , const PrintingPolicy ) const;
 };
 
+class TypeAttr : public Attr {
+protected:
+  TypeAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,
+   bool IsLateParsed)
+  : Attr(AK, R, SpellingListIndex, IsLateParsed) {}
+
+public:
+  static bool classof(const Attr *A) {
+return A->getKind() >= attr::FirstTypeAttr &&
+   A->getKind() <= attr::LastTypeAttr;
+  }
+};
+
 class StmtAttr : public Attr {
 protected:
   StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex,

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=340215=340214=340215=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Aug 20 14:47:29 2018
@@ -21,6 +21,7 @@
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/AttrKinds.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
 #include "clang/Basic/LLVM.h"
@@ -1970,7 +1971,16 @@ public:
   bool isObjCQualifiedClassType() const;// Class
   bool isObjCObjectOrInterfaceType() const;
   bool isObjCIdType() const;// id
-  bool isObjCInertUnsafeUnretainedType() const;
+
+  /// Was this type written with the special inert-in-ARC __unsafe_unretained
+  /// qualifier?
+  ///
+  /// This approximates the answer to the following question: if this
+  /// translation unit were compiled in ARC, would this type be qualified
+  /// with __unsafe_unretained?
+  bool isObjCInertUnsafeUnretainedType() const {
+return hasAttr(attr::ObjCInertUnsafeUnretained);
+  }
 
   /// Whether the type is Objective-C 'id' or a __kindof 

[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1472
 
+  /// Do we need to emit an exit-time destructor for this variable?
+  bool isNoDestroy(const ASTContext &) const;

rsmith wrote:
> jfb wrote:
> > This is only valid for static variables, right? It's probably better to 
> > document the function name that way, e.g. `isStaticWithNoDestroy`.
> I think the question (and hence current function name) is meaningful for any 
> variable, but it just happens that the answer will always be "no" for 
> non-static variables (for now, at least). Are you concerned that people will 
> think calls to this function are missing from codepaths that only deal with 
> automatic storage duration variables with the current name?
Yeah it seems like "this variable has no destructor". I guess even trivial 
automatic variables have a (trivial) destructor, so maybe it's not ambiguous? 
Up to y'all :)


Repository:
  rC Clang

https://reviews.llvm.org/D50994



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1472
 
+  /// Do we need to emit an exit-time destructor for this variable?
+  bool isNoDestroy(const ASTContext &) const;

jfb wrote:
> This is only valid for static variables, right? It's probably better to 
> document the function name that way, e.g. `isStaticWithNoDestroy`.
I think the question (and hence current function name) is meaningful for any 
variable, but it just happens that the answer will always be "no" for 
non-static variables (for now, at least). Are you concerned that people will 
think calls to this function are missing from codepaths that only deal with 
automatic storage duration variables with the current name?



Comment at: clang/include/clang/Basic/Attr.td:2999
+
+def NoDestroy : InheritableAttr {
+  let Spellings = [Clang<"no_destroy", 0>];

jfb wrote:
> Ditto for these, I think the names of the variables should clarify that it's 
> only for `static`. Note that I wouldn't rename the attributes themselves! 
> Usage in context is unambiguous, and the docs should be clear. I just think 
> the variable names don't provide the required context.
Our convention is that the `Attr` name matches the source spelling, so I think 
this is appropriate as-is.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:1813
+def err_destroy_attr_on_non_static_var : Error<
+  "%select{no_destroy|always_destroy}0 attribute must be applied to a"
+  " variable with static or thread storage duration">;

"must" -> "can only". (There is no requirement to apply the attribute to 
anything.)



Comment at: clang/include/clang/Basic/LangOptions.def:311
 
+LANGOPT(RegisterStaticDestructors, 1, 1, "Register C++ static destructors")
+

Should be a `BENIGN_LANGOPT` because it doesn't affect AST construction, only 
the generated code.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2769-2771
+  Opts.RegisterStaticDestructors =
+  Args.hasFlag(OPT_fcxx_static_destructors, OPT_fno_cxx_static_destructors,
+   Opts.RegisterStaticDestructors);

`-fc++-static-destructors` is not a CC1 flag, so this should just be a `hasArg` 
call.


Repository:
  rC Clang

https://reviews.llvm.org/D50994



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


[PATCH] D50962: [clangd] Speculative code completion index request before Sema is run.

2018-08-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: unittests/clangd/CodeCompleteTests.cpp:1710
+  $bol^
+  ab$ab^
+  x.ab$dot^

Maybe an EXPECT for this one as well?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50962



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


[PATCH] D50527: [Parser] Support alternative operator token keyword args in Objective-C++

2018-08-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D50527#1206460, @erik.pilkington wrote:

> Ping!


If the build came back clean, then I think our combination of previous 
sign-offs is good enough. :)


https://reviews.llvm.org/D50527



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


[PATCH] D50547: [Driver] Use normalized triples for multiarch runtime path

2018-08-20 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Just want to bring an IRC conversation that I had with @phosek into the proper 
code review.

This patch is great as-is, but if we want to extend this to Darwin there are 
some problems because of how Darwin handles triples. Specifically Darwin has 
multiple potentially valid triples that can mean the same things. For example 
x86_64-apple-darwin17.7.0 and x86_64-apple-macos10.13.6 are 100% 
interchangeable (even down to referring to the same OS version). Things get 
even stranger when you start talking about the -simulator triples...

This means that to support this in Darwin we need to support iterating over a 
list of triples. We also probably want to cache that list so that we don't run 
`getVFS().exists(...)` over and over again. @phosek said on IRC he will update 
the patch to reflect our conversation.

Thanks @phosek for all the great work on this!


Repository:
  rC Clang

https://reviews.llvm.org/D50547



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1472
 
+  /// Do we need to emit an exit-time destructor for this variable?
+  bool isNoDestroy(const ASTContext &) const;

This is only valid for static variables, right? It's probably better to 
document the function name that way, e.g. `isStaticWithNoDestroy`.



Comment at: clang/include/clang/Basic/Attr.td:2999
+
+def NoDestroy : InheritableAttr {
+  let Spellings = [Clang<"no_destroy", 0>];

Ditto for these, I think the names of the variables should clarify that it's 
only for `static`. Note that I wouldn't rename the attributes themselves! Usage 
in context is unambiguous, and the docs should be clear. I just think the 
variable names don't provide the required context.



Comment at: clang/include/clang/Basic/AttrDocs.td:3494
+The ``always_destroy`` attribute specifies that a variable with static or 
thread
+storage duration should have it's exit-time destructor run. This attribute does
+nothing unless clang was invoked with -fno-c++-static-destructors.

"its"



Comment at: clang/include/clang/Basic/AttrDocs.td:3495
+storage duration should have it's exit-time destructor run. This attribute does
+nothing unless clang was invoked with -fno-c++-static-destructors.
+  }];

"does nothing" is more "is the default".



Comment at: clang/include/clang/Basic/AttrDocs.td:3503
+The ``no_destroy`` attribute specifies that a variable with static or thread
+storage duration shouldn't have it's exit-time destructor run. Annotating every
+static or thread duration variable with this attribute is equalivant to 
invoking

"its"



Comment at: clang/include/clang/Basic/AttrDocs.td:3504
+storage duration shouldn't have it's exit-time destructor run. Annotating every
+static or thread duration variable with this attribute is equalivant to 
invoking
+clang with -fno-c++-static-destructors.

"static and thread"



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5931
+handleSimpleAttributeWithExclusions(S, 
D, A);
+  }
+}

This allows a variable with both attributes :)
Looking at the code above it seems like having both attributes is equivalent to 
no-destroy.


Repository:
  rC Clang

https://reviews.llvm.org/D50994



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


[PATCH] D50978: [ASTImporter] Add test for C++'s try/catch statements.

2018-08-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added inline comments.
This revision is now accepted and ready to land.



Comment at: tools/clang-import-test/clang-import-test.cpp:199
   Inv->getLangOpts()->RTTI = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;

Could you please add a newline after RTTI? Now, it looks like the comment is 
for all lines below.


Repository:
  rC Clang

https://reviews.llvm.org/D50978



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


[PATCH] D50866: [analyzer] CFRetainReleaseChecker: Avoid checking C++ methods with the same name.

2018-08-20 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:537
+  mutable APIMisuse BT{this, "null passed to CF memory management function"};
+  CallDescription CFRetain{"CFRetain", 1},
+  CFRelease{"CFRelease", 1},

I personally would prefer being less fancy, and avoiding the comma operator, 
but I suppose it's a matter of style.



Comment at: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp:567
+  ProgramStateRef stateNonNull, stateNull;
+  std::tie(stateNonNull, stateNull) = state->assume(*DefArgVal);
 

There's also DefArgVal


Repository:
  rC Clang

https://reviews.llvm.org/D50866



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


[PATCH] D47814: Teach libc++ to use native NetBSD's max_align_t

2018-08-20 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

@chandlerc thank you for your note. I've originally treated this change as an 
obvious code change, just the reviewers regardless of reviewing an analogous 
change for MUSL, had no interest in NetBSD.


Repository:
  rL LLVM

https://reviews.llvm.org/D47814



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


[PATCH] D50527: [Parser] Support alternative operator token keyword args in Objective-C++

2018-08-20 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D50527



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-20 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: jfb, rsmith, aaron.ballman, rjmccall, bruno.
Herald added a subscriber: dexonsmith.

See the recent thread here: 
http://lists.llvm.org/pipermail/cfe-dev/2018-July/058494.html

This patch adds the flag -fno-c++-static-destructors, which disables 
registration of exit-time destructors of static or thread storage duration 
variables. This patch also adds [[clang::no_destroy]] and 
[[clang::always_destroy]] attributes for disabling dtors in 
-fc++-static-destructors mode, and enabling dtors in 
-fno-c++-static-destructors mode, respectively. This patch was based on 
@bruno's https://reviews.llvm.org/D22474.

rdar://21734598

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D50994

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/always_destroy.cpp
  clang/test/CodeGenCXX/no_destroy.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/no_destroy.cpp

Index: clang/test/SemaCXX/no_destroy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/no_destroy.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -DNO_DTORS -fno-c++-static-destructors -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct SecretDestructor {
+#ifndef NO_DTORS
+  // expected-note@+2 4 {{private}}
+#endif
+private: ~SecretDestructor(); // expected-note 2 {{private}}
+};
+
+SecretDestructor sd1;
+thread_local SecretDestructor sd2;
+void locals() {
+  static SecretDestructor sd3;
+  thread_local SecretDestructor sd4;
+}
+
+#ifndef NO_DTORS
+// SecretDestructor sd1;  // expected-error@-8 {{private}}
+// thread_local SecretDestructor sd2; // expected-error@-8 {{private}}
+// void locals() {
+//   static SecretDestructor sd3; // expected-error@-8 {{private}}
+//   thread_local SecretDestructor sd4;   // expected-error@-8 {{private}}
+// }
+#endif
+
+[[clang::always_destroy]] SecretDestructor sd6; // expected-error{{private}}
+[[clang::always_destroy]] thread_local SecretDestructor sd7; // expected-error{{private}}
+
+[[clang::no_destroy]] SecretDestructor sd8;
+
+int main() {
+  [[clang::no_destroy]] int p; // expected-error{{no_destroy attribute must be applied to a variable with static or thread storage duration}}
+  [[clang::always_destroy]] int p2; // expected-error{{always_destroy attribute must be applied to a variable with static or thread storage duration}}
+  [[clang::no_destroy]] static int p3;
+  [[clang::always_destroy]] static int p4;
+}
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
@@ -2,15 +2,16 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 72 attributes:
+// CHECK: #pragma clang attribute supports 74 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUWavesPerEU (SubjectMatchRule_function)
 // CHECK-NEXT: AVRSignal (SubjectMatchRule_function)
 // CHECK-NEXT: AbiTag (SubjectMatchRule_record_not_is_union, SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_namespace)
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
+// CHECK-NEXT: AlwaysDestroy (SubjectMatchRule_variable)
 // CHECK-NEXT: Annotate ()
 // CHECK-NEXT: AnyX86NoCfCheck (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
@@ -38,6 +39,7 @@
 // CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
+// CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: clang/test/CodeGenCXX/no_destroy.cpp
===
--- /dev/null
+++ 

[PATCH] D47814: Teach libc++ to use native NetBSD's max_align_t

2018-08-20 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

In https://reviews.llvm.org/D47814#1206372, @krytarowski wrote:

> If there are no more comments, I will land this by the end of this week.


Just for the record, this is not OK and not how LLVM's code review works.

You can and must wait for review. I think Joerg already marked this as 
accepted, but it didn't send out an email[1]. That means it got reviewed, so 
all is good here, but I wanted to make it clear to others on the list what the 
expectations are here.

-Chandler

[1]: FYI, it's useful to put *some* text in the text box when marking a 
revision as accepted on Phab so that it will in fact send email. I typically 
put "LGTM" or a brief thank-you note to the author.


Repository:
  rL LLVM

https://reviews.llvm.org/D47814



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


[PATCH] D40925: Add option -fkeep-static-consts

2018-08-20 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews marked an inline comment as done.
eandrews added a comment.

In https://reviews.llvm.org/D40925#1206416, @rnk wrote:

> lgtm!


Thanks!


https://reviews.llvm.org/D40925



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


r340206 - DebugInfo: Add the ability to disable DWARF name tables entirely

2018-08-20 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Aug 20 13:14:08 2018
New Revision: 340206

URL: http://llvm.org/viewvc/llvm-project?rev=340206=rev
Log:
DebugInfo: Add the ability to disable DWARF name tables entirely

This changes the current default behavior (from emitting pubnames by
default, to not emitting them by default) & moves to matching GCC's
behavior* with one significant difference: -gno(-gnu)-pubnames disables
pubnames even in the presence of -gsplit-dwarf (though -gsplit-dwarf
still by default enables -ggnu-pubnames). This allows users to disable
pubnames (& the new DWARF5 accelerated access tables) when they might
not be worth the size overhead.

* GCC's behavior is that -ggnu-pubnames and -gpubnames override each
other, and that -gno-gnu-pubnames and -gno-pubnames act as synonyms and
disable either kind of pubnames if they come last. (eg: -gpubnames
-gno-gnu-pubnames causes no pubnames (neither gnu or standard) to be
emitted)

Added:
cfe/trunk/test/CodeGen/debug-info-names.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/debug-info-global-constant.c
cfe/trunk/test/CodeGen/debug-info-macro.c
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=340206=340205=340206=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 20 13:14:08 2018
@@ -197,10 +197,6 @@ def dwarf_column_info : Flag<["-"], "dwa
   HelpText<"Turn on column location information.">;
 def split_dwarf : Flag<["-"], "split-dwarf">,
   HelpText<"Split out the dwarf .dwo sections">;
-def gnu_pubnames : Flag<["-"], "gnu-pubnames">,
-  HelpText<"Emit newer GNU style pubnames">;
-def arange_sections : Flag<["-"], "arange_sections">,
-  HelpText<"Emit DWARF .debug_arange sections">;
 def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=340206=340205=340206=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Aug 20 13:14:08 2018
@@ -1807,6 +1807,8 @@ def gno_column_info : Flag<["-"], "gno-c
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, 
Flags<[CC1Option]>;
 def gno_gnu_pubnames : Flag<["-"], "gno-gnu-pubnames">, Group, 
Flags<[CC1Option]>;
+def gpubnames : Flag<["-"], "gpubnames">, Group, 
Flags<[CC1Option]>;
+def gno_pubnames : Flag<["-"], "gno-pubnames">, Group, 
Flags<[CC1Option]>;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
 def gmodules : Flag <["-"], "gmodules">, Group,
   HelpText<"Generate debug info with external references to clang modules"

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=340206=340205=340206=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Aug 20 13:14:08 2018
@@ -326,7 +326,7 @@ CODEGENOPT(DebugInfoForProfiling, 1, 0)
 CODEGENOPT(PreserveVec3Type, 1, 0)
 
 /// Whether to emit .debug_gnu_pubnames section instead of .debug_pubnames.
-CODEGENOPT(GnuPubnames, 1, 0)
+CODEGENOPT(DebugNameTable, 2, 0)
 
 CODEGENOPT(NoPLT, 1, 0)
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=340206=340205=340206=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Aug 20 13:14:08 2018
@@ -581,9 +581,8 @@ void CGDebugInfo::CreateCompileUnit() {
   0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,
   CGM.getTarget().getTriple().isNVPTX()
   ? llvm::DICompileUnit::DebugNameTableKind::None
-  : CGOpts.GnuPubnames
-? llvm::DICompileUnit::DebugNameTableKind::GNU
-: llvm::DICompileUnit::DebugNameTableKind::Default);
+  : static_cast(
+CGOpts.DebugNameTable));
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

Modified: 

[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2018-08-20 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov created this revision.
Dmitry.Kozhevnikov added reviewers: ilya-biryukov, sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric.

By default it's 512K, which is way to small for clang parser to run on. There 
is no way to do it via platform-independent API, so it's implemented via 
pthreads directly in clangd/Threading.cpp.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50993

Files:
  clangd/Threading.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -963,6 +963,27 @@
Field(::Name, "baz")));
 }
 
+TEST_F(ClangdVFSTest, TestStackOverflow) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  const auto SourceContents = R"cpp(
+constexpr int foo() { return foo(); }
+static_assert(foo());
+  )cpp";
+
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  // check that we got a constexpr depth error, and not crashed by stack
+  // overflow
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -42,6 +42,56 @@
   SlotsChanged.notify_one();
 }
 
+namespace {
+template 
+using UserFnPtr = void (*)(Data);
+
+template 
+struct ThreadInfo {
+  UserFnPtr UserFn;
+  Data UserData;
+};
+} // namespace
+
+template 
+static void executeOnThreadAndDetach(UserFnPtr UserFn, Data UserData) {
+#if !defined(__APPLE__)
+  std::thread([UserFn](Data UserData) { UserFn(std::move(UserData)); },
+  std::move(UserData))
+  .detach();
+#else
+  // On macOS, there is no way to change the default 512K stack size for threads
+  // other than main using the std::thread API. 512K, however, is way to small
+  // for the parser to run. Here we're using pthreads API to set the 8 Mb
+  // stack size, as it's the default for the main thread in modern Linux/macOS
+  // distributions, so it's probably the most well-tested value.
+
+  pthread_attr_t Attr;
+  if (::pthread_attr_init() != 0)
+return;
+
+  auto AttrGuard =
+  llvm::make_scope_exit([&] { ::pthread_attr_destroy(); });
+
+  if (::pthread_attr_setstacksize(, 8 * 1024 * 1024) != 0)
+return;
+
+  std::unique_ptr> Info(
+  new ThreadInfo{UserFn, std::move(UserData)});
+  pthread_t Thread;
+  auto ThreadFun = [](void *Arg) -> void * {
+std::unique_ptr> TI(static_cast *>(Arg));
+TI->UserFn(std::move(TI->UserData));
+return nullptr;
+  };
+  if (::pthread_create(, , ThreadFun, Info.get()) != 0)
+return;
+
+  // now it would be destroyed in the new thread
+  Info.release();
+#endif
+}
+
 AsyncTaskRunner::~AsyncTaskRunner() { wait(); }
 
 bool AsyncTaskRunner::wait(Deadline D) const {
@@ -67,16 +117,22 @@
 }
   });
 
-  std::thread(
-  [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
-llvm::set_thread_name(Name);
-Action();
-// Make sure function stored by Action is destroyed before CleanupTask
-// is run.
-Action = nullptr;
-  },
-  Name.str(), std::move(Action), std::move(CleanupTask))
-  .detach();
+  struct Data {
+std::string Name;
+decltype(Action) Action;
+decltype(CleanupTask) CleanupTask;
+  };
+  Data UserData{Name.str(), std::move(Action), std::move(CleanupTask)};
+
+  auto Func = [](Data UserData) {
+llvm::set_thread_name(UserData.Name);
+UserData.Action();
+// Make sure function stored by Action is destroyed before CleanupTask
+// is run.
+UserData.Action = nullptr;
+  };
+
+  executeOnThreadAndDetach(Func, std::move(UserData));
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40925: Add option -fkeep-static-consts

2018-08-20 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!


https://reviews.llvm.org/D40925



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


[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-20 Thread Hugo Gonzalez via Phabricator via cfe-commits
hugoeg updated this revision to Diff 161550.
hugoeg added a comment.

refined test to include some more cases as a result of the new matcher


https://reviews.llvm.org/D50542

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/NoInternalDepsCheck.cpp
  clang-tidy/abseil/NoInternalDepsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-no-internal-deps.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/external-file.h
  test/clang-tidy/Inputs/absl/strings/internal-file.h
  test/clang-tidy/abseil-no-internal-deps.cpp

Index: test/clang-tidy/abseil-no-internal-deps.cpp
===
--- test/clang-tidy/abseil-no-internal-deps.cpp
+++ test/clang-tidy/abseil-no-internal-deps.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s abseil-no-internal-deps %t,  -- -- -I %S/Inputs
+// RUN: clang-tidy -checks='-*, abseil-no-internal-deps' -header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
+
+#include "absl/strings/internal-file.h"
+// CHECK-NOT: warning:
+
+#include "absl/external-file.h"
+// CHECK: absl/external-file.h:1:23: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil [abseil-no-internal-deps]
+
+void DirectAcess() {
+  absl::strings_internal::InternalFunction();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
+
+  absl::strings_internal::InternalTemplateFunction("a");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
+}
+
+class FriendUsage {
+  friend struct absl::container_internal::InternalStruct;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
+};
+
+namespace absl {
+void OpeningNamespace() {
+  strings_internal::InternalFunction();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil
+}
+} // namespace absl
+
+// should not trigger warnings
+void CorrectUsage() {
+  std::string Str = absl::StringsFunction("a");
+  absl::SomeContainer b;
+}
+
+namespace absl {
+SomeContainer b;
+std::string Str = absl::StringsFunction("a");
+} // namespace absl
Index: test/clang-tidy/Inputs/absl/strings/internal-file.h
===
--- test/clang-tidy/Inputs/absl/strings/internal-file.h
+++ test/clang-tidy/Inputs/absl/strings/internal-file.h
@@ -0,0 +1,33 @@
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+} // namespace std
+
+namespace absl {
+std::string StringsFunction(std::string s1) { return s1; }
+class SomeContainer {};
+namespace strings_internal {
+void InternalFunction() {}
+template  P InternalTemplateFunction(P a) {}
+} // namespace strings_internal
+
+namespace container_internal {
+struct InternalStruct {};
+} // namespace container_internal
+} // namespace absl
+
+// should not trigger warnings because inside Abseil files
+void DirectAcessInternal() {
+  absl::strings_internal::InternalFunction();
+  absl::strings_internal::InternalTemplateFunction("a");
+}
+
+class FriendUsageInternal {
+  friend struct absl::container_internal::InternalStruct;
+};
+
+namespace absl {
+void OpeningNamespaceInternally() { strings_internal::InternalFunction(); }
+} // namespace absl
Index: test/clang-tidy/Inputs/absl/external-file.h
===
--- test/clang-tidy/Inputs/absl/external-file.h
+++ test/clang-tidy/Inputs/absl/external-file.h
@@ -0,0 +1 @@
+void DirectAcess2() { absl::strings_internal::InternalFunction(); }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-no-internal-deps
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-no-internal-deps.rst
===
--- docs/clang-tidy/checks/abseil-no-internal-deps.rst
+++ docs/clang-tidy/checks/abseil-no-internal-deps.rst
@@ -0,0 +1,23 @@
+subl.. title:: clang-tidy - abseil-no-internal-deps
+
+abseil-no-internal-deps
+===
+
+Gives a warning if code using Abseil depends on internal details. If something
+is in a namespace that includes the word “internal”, code is not allowed to 
+depend upon it beaucse it’s an implementation detail. They cannot friend it, 
+include it, you mention it or refer to it in any way. Doing so violates 
+Abseil's compatibility guidelines and may result in breakage. See 
+https://abseil.io/about/compatibility for 

[PATCH] D40925: Add option -fkeep-static-consts

2018-08-20 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews marked an inline comment as done.
eandrews added inline comments.



Comment at: include/clang/Basic/LangOptions.def:311
 
+BENIGN_LANGOPT(KeepStaticConsts  , 1, 0, "keep static const variables even 
if unused")
+

rnk wrote:
> Let's make this a CodeGenOption, since only CodeGen needs to look at it.
Thanks for the feedback Reid! I've changed it


https://reviews.llvm.org/D40925



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D50564#1206370, @cdavis5x wrote:

> In https://reviews.llvm.org/D50564#1206302, @kristina wrote:
>
> > I'm all for this change except the core issue is that you're using 
> > libunwind as a shim around the actual unwinding API provided by Windows. It 
> > would be nice to have something that did not have to do that and was 
> > capable of performing unwinding of SEH-style exceptions without needing 
> > additional runtime support.
>
>
> It would be nice, but that would require extra work. We'd have to implement 
> reading and interpreting unwind codes, and calling any handlers present at 
> each frame (which all have a different calling convention from Itanium 
> handlers), and handling chained unwind info... Or we could use the 
> implementation that MS provided to us for free--and which gets loaded into 
> every process anyway by virtue of being in NTDLL, and which is extremely well 
> tested. Given all that, I'm wondering what implementing all that ourselves 
> would gain us. I suppose we could eventually do all that, but for now, I 
> think this is outside the scope of my change.


+1. I guess such a library would be very nice to have, but from the point of 
view of implementing exception handling, using the underlying APIs probably is 
the way to go. The other question, as posted before, is whether we want to wrap 
the whole CONTEXT structs in the UnwindCursor class and expose it via the unw_* 
set of APIs. It gives quite a significant amount of extra code here compared to 
libgcc's unwind-seh.c which is <500 loc altogether, providing only the 
_Unwind_* API, implementing it directly with the Windows Rtl* APIs from ntdll. 
That would give only a partial libunwind, with only the higher level API 
available, but that's the only part used for exception handling at least.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D40925: Add option -fkeep-static-consts

2018-08-20 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 161544.
eandrews added a comment.

Based on Reid's feedback, I changed option to CodeGenOption


https://reviews.llvm.org/D40925

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/keep-static-consts.cpp


Index: test/CodeGen/keep-static-consts.cpp
===
--- /dev/null
+++ test/CodeGen/keep-static-consts.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fkeep-static-consts -emit-llvm %s -o - 
-triple=x86_64-unknown-linux-gnu | FileCheck %s
+
+// CHECK: @_ZL7srcvers = internal constant [4 x i8] c"xyz\00", align 1
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* getelementptr inbounds 
([4 x i8], [4 x i8]* @_ZL7srcvers, i32 0, i32 0)], section "llvm.metadata"
+static const char srcvers[] = "xyz";
+extern const int b = 1;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1125,6 +1125,8 @@
 
   Opts.Addrsig = Args.hasArg(OPT_faddrsig);
 
+  Opts.KeepStaticConsts = Args.hasArg(OPT_fkeep_static_consts);
+
   return Success;
 }
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3996,6 +3996,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
   Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
   options::OPT_fno_emulated_tls);
+  Args.AddLastArg(CmdArgs, options::OPT_fkeep_static_consts);
 
   // AltiVec-like language extensions aren't relevant for assembling.
   if (!isa(JA) || Output.getType() != types::TY_PP_Asm)
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1350,6 +1350,12 @@
 
   if (D && D->hasAttr())
 addUsedGlobal(GV);
+
+  if (CodeGenOpts.KeepStaticConsts && D && isa(D)) {
+const auto *VD = cast(D);
+if (VD->getType().isConstQualified() && VD->getStorageClass() == SC_Static)
+  addUsedGlobal(GV);
+  }
 }
 
 bool CodeGenModule::GetCPUAndFeaturesAttributes(const Decl *D,
@@ -1985,6 +1991,13 @@
   if (LangOpts.EmitAllDecls)
 return true;
 
+  if (CodeGenOpts.KeepStaticConsts) {
+const auto *VD = dyn_cast(Global);
+if (VD && VD->getType().isConstQualified() &&
+VD->getStorageClass() == SC_Static)
+  return true;
+  }
+
   return getContext().DeclMustBeEmitted(Global);
 }
 
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -339,6 +339,9 @@
 /// Whether to emit an address-significance table into the object file.
 CODEGENOPT(Addrsig, 1, 0)
 
+/// Whether to emit unused static constants.
+CODEGENOPT(KeepStaticConsts, 1, 0)
+
 
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -893,7 +893,8 @@
 def fno_force_enable_int128 : Flag<["-"], "fno-force-enable-int128">,
   Group, Flags<[CC1Option]>,
   HelpText<"Disable support for int128_t type">;
-
+def fkeep_static_consts : Flag<["-"], "fkeep-static-consts">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Keep static const variables even if unused">;
 def ffixed_point : Flag<["-"], "ffixed-point">, Group,
Flags<[CC1Option]>, HelpText<"Enable fixed point types">;
 def fno_fixed_point : Flag<["-"], "fno-fixed-point">, Group,


Index: test/CodeGen/keep-static-consts.cpp
===
--- /dev/null
+++ test/CodeGen/keep-static-consts.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fkeep-static-consts -emit-llvm %s -o - -triple=x86_64-unknown-linux-gnu | FileCheck %s
+
+// CHECK: @_ZL7srcvers = internal constant [4 x i8] c"xyz\00", align 1
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @_ZL7srcvers, i32 0, i32 0)], section "llvm.metadata"
+static const char srcvers[] = "xyz";
+extern const int b = 1;
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1125,6 +1125,8 @@
 
   Opts.Addrsig = Args.hasArg(OPT_faddrsig);
 
+  Opts.KeepStaticConsts = Args.hasArg(OPT_fkeep_static_consts);
+
   return Success;
 }
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ 

[PATCH] D47814: Teach libc++ to use native NetBSD's max_align_t

2018-08-20 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

If there are no more comments, I will land this by the end of this week.


Repository:
  rL LLVM

https://reviews.llvm.org/D47814



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-20 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

In https://reviews.llvm.org/D50564#1206302, @kristina wrote:

> I'm all for this change except the core issue is that you're using libunwind 
> as a shim around the actual unwinding API provided by Windows. It would be 
> nice to have something that did not have to do that and was capable of 
> performing unwinding of SEH-style exceptions without needing additional 
> runtime support.


It would be nice, but that would require extra work. We'd have to implement 
reading and interpreting unwind codes, and calling any handlers present at each 
frame (which all have a different calling convention from Itanium handlers), 
and handling chained unwind info... Or we could use the implementation that MS 
provided to us for free--and which gets loaded into every process anyway by 
virtue of being in NTDLL, and which is extremely well tested. Given all that, 
I'm wondering what implementing all that ourselves would gain us. I suppose we 
could eventually do all that, but for now, I think this is outside the scope of 
my change.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-08-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D50616#1206181, @leonardchan wrote:

> I made a post on llvm-dev 
> (http://lists.llvm.org/pipermail/llvm-dev/2018-August/125433.html) to see if 
> other people have opinions on this. In the meantime, do you think I should 
> make a separate patch that moves this into an LLVM intrinsic function?


Yeah, I think that even if LLVM decides they don't want to include first-class 
IR support for fixed-point types, it makes more sense to provide standard 
intrinsics for these operations than to do all of the lowering in the frontend.


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


[PATCH] D50927: [Sema] Remove location from implicit capture init expr

2018-08-20 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 161536.
vsk added a comment.

- Here is a GIF that might help illustrate the bug: 
http://net.vedantk.com/static/llvm/lambda-implicit-capture-bug.gif
- Update test/SemaCXX/uninitialized.cpp to highlight the behavior change which 
comes from using getBeginOrDeclLoc().


https://reviews.llvm.org/D50927

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCXX/debug-info-lambda.cpp
  clang/test/SemaCXX/uninitialized.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
@@ -75,11 +75,14 @@
 TEST(RecursiveASTVisitor, VisitsImplicitLambdaCaptureInit) {
   DeclRefExprVisitor Visitor;
   Visitor.setShouldVisitImplicitCode(true);
-  // We're expecting the "i" in the lambda to be visited twice:
-  // - Once for the DeclRefExpr in the lambda capture initialization (whose
-  //   source code location is set to the first use of the variable).
-  // - Once for the DeclRefExpr for the use of "i" inside the lambda.
-  Visitor.ExpectMatch("i", 1, 24, /*Times=*/2);
+  // We're expecting the "i" in the lambda to be visited just once (for the
+  // DeclRefExpr for the use of "i" inside the lambda).
+  //
+  // Previously, the DeclRefExpr in the implicit lambda capture initialization
+  // (whose source code location is set to the first use of the variable) was
+  // also matched. This behavior was removed because it resulted in poor debug
+  // info.
+  Visitor.ExpectMatch("i", 1, 24, /*Times=*/1);
   EXPECT_TRUE(Visitor.runOver(
 "void f() { int i; [=]{ i; }; }",
 DeclRefExprVisitor::Lang_CXX11));
Index: clang/test/SemaCXX/uninitialized.cpp
===
--- clang/test/SemaCXX/uninitialized.cpp
+++ clang/test/SemaCXX/uninitialized.cpp
@@ -884,8 +884,10 @@
 int x;
   };
   A a0([] { return a0.x; }); // ok
-  void f() { 
-A a1([=] { return a1.x; }); // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}}
+  void f() {
+A a1([=] { // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}}
+  return a1.x;
+});
 A a2([&] { return a2.x; }); // ok
   }
 }
Index: clang/test/CodeGenCXX/debug-info-lambda.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-lambda.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm \
+// RUN:   -debug-info-kind=line-tables-only -std=c++11 %s -o - | FileCheck %s
+
+// CHECK-LABEL: define{{.*}}lambda_in_func
+void lambda_in_func(int ) {
+  // CHECK: [[ref_slot:%.*]] = getelementptr inbounds %class.anon, %class.anon* {{.*}}, i32 0, i32 0, !dbg [[lambda_decl_loc:![0-9]+]]
+  // CHECK-NEXT: %1 = load i32*, i32** %ref.addr, align 8, !dbg [[init_sequence_loc:![0-9]+]]
+  // CHECK-NEXT: store i32* %1, i32** %0, align 8, !dbg [[lambda_decl_loc]]
+  // CHECK-NEXT: call void {{.*}}, !dbg [[lambda_call_loc:![0-9]+]]
+
+  auto helper = [&]() { // CHECK: [[lambda_decl_loc]] = !DILocation(line: [[@LINE]]
+++ref;  // CHECK: [[init_sequence_loc]] = !DILocation(line: 0
+  };
+  helper(); // CHECK: [[lambda_call_loc]] = !DILocation(line: [[@LINE]]
+}
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1392,13 +1392,13 @@
   Class->addDecl(Conversion);
 }
 
-static ExprResult performLambdaVarCaptureInitialization(Sema ,
-const Capture ,
-FieldDecl *Field) {
+static ExprResult performLambdaVarCaptureInitialization(
+Sema , const Capture , FieldDecl *Field, bool IsImplicitCapture) {
   assert(Capture.isVariableCapture() && "not a variable capture");
 
   auto *Var = Capture.getVariable();
   SourceLocation Loc = Capture.getLocation();
+  SourceLocation InitLoc = IsImplicitCapture ? SourceLocation() : Loc;
 
   // C++11 [expr.prim.lambda]p21:
   //   When the lambda-expression is evaluated, the entities that
@@ -1413,7 +1413,7 @@
   //   An entity captured by a lambda-expression is odr-used (3.2) in
   //   the scope containing the lambda-expression.
   ExprResult RefResult = S.BuildDeclarationNameExpr(
-  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(), Loc), Var);
+  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(), InitLoc), Var);
   if (RefResult.isInvalid())
 return ExprError();
   Expr *Ref = RefResult.get();
@@ -1607,8 +1607,8 @@

[PATCH] D50962: [clangd] Speculative code completion index request before Sema is run.

2018-08-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 161537.
ioeric added a comment.

- Make sure completion result callback can be called even if the unused 
speculative request has not finished.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50962

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/IndexTests.cpp

Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -321,6 +321,21 @@
   EXPECT_EQ(M.Name, "right");
 }
 
+TEST(AsyncFuzzyFind, Simple) {
+  MemIndex Idx;
+  Idx.build(generateSymbols({"ns::abc", "ns::xyz"}));
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  Req.Scopes = {"ns::"};
+
+  AsyncFuzzyFind Async(Idx, Req);
+
+  EXPECT_EQ(Async.getRequest(), Req);
+  EXPECT_THAT(Async.getResult(),
+  UnorderedElementsAre(Named("abc"), Named("xyz")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -923,7 +923,11 @@
llvm::function_ref
Callback) const override {}
 
-  const std::vector allRequests() const { return Requests; }
+  const std::vector consumeRequests() const {
+auto Reqs = std::move(Requests);
+Requests.clear();
+return Reqs;
+  }
 
 private:
   mutable std::vector Requests;
@@ -934,7 +938,7 @@
   IndexRequestCollector Requests;
   Opts.Index = 
   completions(Code, {}, Opts);
-  return Requests.allRequests();
+  return Requests.consumeRequests();
 }
 
 TEST(CompletionTest, UnqualifiedIdQuery) {
@@ -1700,6 +1704,71 @@
   }
 }
 
+TEST(SpeculateCompletionFilter, Filters) {
+  Annotations F(R"cpp($bof^
+  $bol^
+  ab$ab^
+  x.ab$dot^
+  x.$dotempty^
+  x::ab$scoped^
+  x::$scopedempty^
+
+  )cpp");
+  auto speculate = [&](StringRef PointName) {
+auto Filter = speculateCompletionFilter(F.code(), F.point(PointName));
+assert(Filter);
+return *Filter;
+  };
+  EXPECT_EQ(speculate("bof"), "");
+  EXPECT_EQ(speculate("bol"), "");
+  EXPECT_EQ(speculate("dot"), "ab");
+  EXPECT_EQ(speculate("dotempty"), "");
+  EXPECT_EQ(speculate("scoped"), "ab");
+  EXPECT_EQ(speculate("scopedempty"), "");
+}
+
+TEST(CompletionTest, EnableSpeculativeIndexRequest) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  auto File = testPath("foo.cpp");
+  Annotations Test(R"cpp(
+  namespace ns1 { int abc; }
+  namespace ns2 { int abc; }
+  void f() { ns1::ab$1^; ns1::ab$2^; }
+  void f() { ns2::ab$3^; }
+  )cpp");
+  runAddDocument(Server, File, Test.code());
+  clangd::CodeCompleteOptions Opts = {};
+
+  IndexRequestCollector Requests;
+  Opts.Index = 
+  Opts.SpeculativeIndexRequest = true;
+
+  cantFail(runCodeComplete(Server, File, Test.point("1"), Opts));
+  auto Reqs1 = Requests.consumeRequests();
+  ASSERT_EQ(Reqs1.size(), 1u);
+  EXPECT_THAT(Reqs1[0].Scopes, UnorderedElementsAre("ns1::"));
+
+  // Speculation succeeded. Use speculative index result.
+  cantFail(runCodeComplete(Server, File, Test.point("2"), Opts));
+  auto Reqs2 = Requests.consumeRequests();
+  ASSERT_EQ(Reqs2.size(), 1u);
+  EXPECT_EQ(Reqs2[0], Reqs1[0]);
+
+  cantFail(runCodeComplete(Server, File, Test.point("3"), Opts));
+  // Sleep for a while to make sure asynchronous call is also triggered before
+  // callback is invoked.
+  std::this_thread::sleep_for(std::chrono::milliseconds(100));
+
+  // Speculation failed. Sent speculative index request and the new index
+  // request after sema.
+  auto Reqs3 = Requests.consumeRequests();
+  ASSERT_EQ(Reqs3.size(), 2u);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -164,6 +164,20 @@
"an include line will be inserted or not."),
 llvm::cl::init(true));
 
+static llvm::cl::opt SpeculateCompletionIndexRequest(
+"speculative-completion-index-request",
+llvm::cl::desc(
+R"(If set to true and static index is enabled, this will send an
+asynchronous speculative index request, based on the index request for
+the last code completion on the same file and the filter text typed
+before the cursor, before sema code completion is invoked. This can
+reduce the code completion latency (by roughly latency of sema code
+completion) if the speculative request is the same as 

[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-20 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

> EmitAArch64BuiltinExpr() also emits args into Ops before the big switch (with 
> some more subtlety around the last arg that I don't understand), but then 
> almost every switch case does EmitScalarExpr(E->getArg(n)).

Took me a while to remember, but I can at least explain this bit now I think. 
The key is that there are two kinds of NEON intrinsics. Overloaded ones have a 
constant last argument that describes the real type, and non-overloaded ones 
use that last argument as a normal parameter.

The first massive switch you see handles the ones in the second case, so it 
always CodeGens the last parameter, but if you scroll all the way down to line 
7369 there's another switch where only the pregenerated Ops are used, and this 
last arg is visible as `Ty` and/or `VTy`.

It may or may not be the best way to handle that situation, of course.


https://reviews.llvm.org/D50979



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


[PATCH] D50989: Remove Darwin support from POWER backend.

2018-08-20 Thread Kit Barton via Phabricator via cfe-commits
kbarton created this revision.
kbarton added reviewers: power-llvm-team, hfinkel, echristo, rsmith.
Herald added a subscriber: nemanjai.

This is the clang counterpart to the patch posted in 
https://reviews.llvm.org/D50988.

The patch removes Darwin support from the POWER backend. A similar approach 
will be taken for the relevant code in Clang. Once the initial patch lands, 
cleanup of the old PPC-specific Darwin paths can be done on demand, using 
post-commit reviews whenever possible.


https://reviews.llvm.org/D50989

Files:
  clang/test/CodeGen/bool_test.c
  clang/test/CodeGen/darwin-ppc-varargs.c
  clang/test/CodeGen/darwin-string-literals.c
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenCXX/mangle-long-double.cpp
  clang/test/Coverage/targets.c

Index: clang/test/Coverage/targets.c
===
--- clang/test/Coverage/targets.c
+++ clang/test/Coverage/targets.c
@@ -5,9 +5,7 @@
 // RUN: %clang_cc1 -debug-info-kind=limited -triple i686-unknown-dragonfly -emit-llvm -o %t %s
 // RUN: %clang_cc1 -debug-info-kind=limited -triple i686-unknown-unknown -emit-llvm -o %t %s
 // RUN: %clang_cc1 -debug-info-kind=limited -triple i686-unknown-win32 -emit-llvm -o %t %s
-// RUN: %clang_cc1 -debug-info-kind=limited -triple powerpc-apple-darwin9 -emit-llvm -o %t %s
 // RUN: %clang_cc1 -debug-info-kind=limited -triple powerpc-unknown-unknown -emit-llvm -o %t %s
-// RUN: %clang_cc1 -debug-info-kind=limited -triple powerpc64-apple-darwin9 -emit-llvm -o %t %s
 // RUN: %clang_cc1 -debug-info-kind=limited -triple powerpc64-unknown-unknown -emit-llvm -o %t %s
 // RUN: %clang_cc1 -debug-info-kind=limited -triple sparc-unknown-solaris -emit-llvm -o %t %s
 // RUN: %clang_cc1 -debug-info-kind=limited -triple sparc-unknown-unknown -emit-llvm -o %t %s
Index: clang/test/CodeGenCXX/mangle-long-double.cpp
===
--- clang/test/CodeGenCXX/mangle-long-double.cpp
+++ clang/test/CodeGenCXX/mangle-long-double.cpp
@@ -1,12 +1,8 @@
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER64-LINUX
 // RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu   %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER-LINUX
-// RUN: %clang_cc1 -triple powerpc64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER64-DARWIN
-// RUN: %clang_cc1 -triple powerpc-apple-darwin9   %s -emit-llvm -o - | FileCheck %s --check-prefix=POWER-DARWIN
 // RUN: %clang_cc1 -triple s390x-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefix=S390X-LINUX
 
 void f(long double) {}
 // POWER64-LINUX:  _Z1fg
 // POWER-LINUX:_Z1fg
-// POWER64-DARWIN: _Z1fe
-// POWER-DARWIN:   _Z1fe
 // S390X-LINUX:_Z1fg
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -106,14 +106,6 @@
 // RUN: FileCheck %s -check-prefix=PPC64LE-LINUX
 // PPC64LE-LINUX: target datalayout = "e-m:e-i64:64-n32:64"
 
-// RUN: %clang_cc1 -triple powerpc-darwin -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=PPC32-DARWIN
-// PPC32-DARWIN: target datalayout = "E-m:o-p:32:32-f64:32:64-n32"
-
-// RUN: %clang_cc1 -triple powerpc64-darwin -o - -emit-llvm %s | \
-// RUN: FileCheck %s -check-prefix=PPC64-DARWIN
-// PPC64-DARWIN: target datalayout = "E-m:o-i64:64-n32:64"
-
 // RUN: %clang_cc1 -triple nvptx-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=NVPTX
 // NVPTX: target datalayout = "e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64"
Index: clang/test/CodeGen/darwin-string-literals.c
===
--- clang/test/CodeGen/darwin-string-literals.c
+++ clang/test/CodeGen/darwin-string-literals.c
@@ -5,14 +5,6 @@
 // CHECK-LSB: @.str.2 = private unnamed_addr constant [18 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 32, i16 8594, i16 32, i16 9731, i16 32, i16 8592, i16 32, i16 119, i16 111, i16 114, i16 108, i16 100, i16 0], section "__TEXT,__ustring", align 2
 // CHECK-LSB: @.str.4 = private unnamed_addr constant [6 x i16] [i16 116, i16 101, i16 115, i16 116, i16 8482, i16 0], section "__TEXT,__ustring", align 2
 
-
-// RUN: %clang_cc1 -triple powerpc-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix CHECK-MSB %s
-
-// CHECK-MSB: @.str = private unnamed_addr constant [8 x i8] c"string0\00"
-// CHECK-MSB: @.str.1 = private unnamed_addr constant [8 x i8] c"string1\00"
-// CHECK-MSB: @.str.2 = private unnamed_addr constant [18 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 32, i16 8594, i16 32, i16 9731, i16 32, i16 8592, i16 32, i16 119, i16 111, i16 114, i16 108, i16 100, i16 0], section "__TEXT,__ustring", align 2
-// CHECK-MSB: @.str.4 = private unnamed_addr constant [6 x i16] [i16 116, i16 101, i16 115, i16 116, i16 8482, i16 0], section 

[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-20 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

I'm all for this change except the core issue is that you're using libunwind as 
a shim around the actual unwinding API provided by Windows. It would be nice to 
have something that did not have to do that and was capable of performing 
unwinding of SEH-style exceptions without needing additional runtime support.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-20 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

From my point of view, the number of people who have idea about these types and 
why do they differ between ABIs and OSes is so low, that it's even hard to get 
someone to review it here.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D50945: [Lex] Make HeaderMaps a unique_ptr vector

2018-08-20 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340198: [Lex] Make HeaderMaps a unique_ptr vector (authored 
by MaskRay, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50945?vs=161391=161530#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50945

Files:
  include/clang/Lex/HeaderMap.h
  include/clang/Lex/HeaderSearch.h
  lib/Lex/HeaderMap.cpp
  lib/Lex/HeaderSearch.cpp

Index: lib/Lex/HeaderMap.cpp
===
--- lib/Lex/HeaderMap.cpp
+++ lib/Lex/HeaderMap.cpp
@@ -48,7 +48,8 @@
 /// map.  If it doesn't look like a HeaderMap, it gives up and returns null.
 /// If it looks like a HeaderMap but is obviously corrupted, it puts a reason
 /// into the string error argument and returns null.
-const HeaderMap *HeaderMap::Create(const FileEntry *FE, FileManager ) {
+std::unique_ptr HeaderMap::Create(const FileEntry *FE,
+ FileManager ) {
   // If the file is too small to be a header map, ignore it.
   unsigned FileSize = FE->getSize();
   if (FileSize <= sizeof(HMapHeader)) return nullptr;
@@ -59,7 +60,7 @@
   bool NeedsByteSwap;
   if (!checkHeader(**FileBuffer, NeedsByteSwap))
 return nullptr;
-  return new HeaderMap(std::move(*FileBuffer), NeedsByteSwap);
+  return std::unique_ptr(new HeaderMap(std::move(*FileBuffer), NeedsByteSwap));
 }
 
 bool HeaderMapImpl::checkHeader(const llvm::MemoryBuffer ,
Index: lib/Lex/HeaderSearch.cpp
===
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -75,12 +75,6 @@
   FileMgr(SourceMgr.getFileManager()), FrameworkMap(64),
   ModMap(SourceMgr, Diags, LangOpts, Target, *this) {}
 
-HeaderSearch::~HeaderSearch() {
-  // Delete headermaps.
-  for (unsigned i = 0, e = HeaderMaps.size(); i != e; ++i)
-delete HeaderMaps[i].second;
-}
-
 void HeaderSearch::PrintStats() {
   fprintf(stderr, "\n*** HeaderSearch Stats:\n");
   fprintf(stderr, "%d files tracked.\n", (int)FileInfo.size());
@@ -113,12 +107,12 @@
   // Pointer equality comparison of FileEntries works because they are
   // already uniqued by inode.
   if (HeaderMaps[i].first == FE)
-return HeaderMaps[i].second;
+return HeaderMaps[i].second.get();
   }
 
-  if (const HeaderMap *HM = HeaderMap::Create(FE, FileMgr)) {
-HeaderMaps.push_back(std::make_pair(FE, HM));
-return HM;
+  if (std::unique_ptr HM = HeaderMap::Create(FE, FileMgr)) {
+HeaderMaps.emplace_back(FE, std::move(HM));
+return HeaderMaps.back().second.get();
   }
 
   return nullptr;
Index: include/clang/Lex/HeaderMap.h
===
--- include/clang/Lex/HeaderMap.h
+++ include/clang/Lex/HeaderMap.h
@@ -71,7 +71,8 @@
 public:
   /// This attempts to load the specified file as a header map.  If it doesn't
   /// look like a HeaderMap, it gives up and returns null.
-  static const HeaderMap *Create(const FileEntry *FE, FileManager );
+  static std::unique_ptr Create(const FileEntry *FE,
+   FileManager );
 
   /// Check to see if the specified relative filename is located in this
   /// HeaderMap.  If so, open it and return its FileEntry.  If RawPath is not
Index: include/clang/Lex/HeaderSearch.h
===
--- include/clang/Lex/HeaderSearch.h
+++ include/clang/Lex/HeaderSearch.h
@@ -17,6 +17,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/DirectoryLookup.h"
+#include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
@@ -38,7 +39,6 @@
 class ExternalPreprocessorSource;
 class FileEntry;
 class FileManager;
-class HeaderMap;
 class HeaderSearchOptions;
 class IdentifierInfo;
 class LangOptions;
@@ -226,9 +226,8 @@
   llvm::StringMap;
   std::unique_ptr IncludeAliases;
 
-  /// This is a mapping from FileEntry -> HeaderMap, uniquing
-  /// headermaps.  This vector owns the headermap.
-  std::vector> HeaderMaps;
+  /// This is a mapping from FileEntry -> HeaderMap, uniquing headermaps.
+  std::vector>> HeaderMaps;
 
   /// The mapping between modules and headers.
   mutable ModuleMap ModMap;
@@ -264,7 +263,6 @@
const LangOptions , const TargetInfo *Target);
   HeaderSearch(const HeaderSearch &) = delete;
   HeaderSearch =(const HeaderSearch &) = delete;
-  ~HeaderSearch();
 
   /// Retrieve the header-search options with which this header search
   /// was initialized.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340198 - [Lex] Make HeaderMaps a unique_ptr vector

2018-08-20 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Mon Aug 20 12:15:02 2018
New Revision: 340198

URL: http://llvm.org/viewvc/llvm-project?rev=340198=rev
Log:
[Lex] Make HeaderMaps a unique_ptr vector

Summary: unique_ptr makes the ownership clearer than a raw pointer container.

Reviewers: Eugene.Zelenko, dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Lex/HeaderMap.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Lex/HeaderMap.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMap.h?rev=340198=340197=340198=diff
==
--- cfe/trunk/include/clang/Lex/HeaderMap.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderMap.h Mon Aug 20 12:15:02 2018
@@ -71,7 +71,8 @@ class HeaderMap : private HeaderMapImpl
 public:
   /// This attempts to load the specified file as a header map.  If it doesn't
   /// look like a HeaderMap, it gives up and returns null.
-  static const HeaderMap *Create(const FileEntry *FE, FileManager );
+  static std::unique_ptr Create(const FileEntry *FE,
+   FileManager );
 
   /// Check to see if the specified relative filename is located in this
   /// HeaderMap.  If so, open it and return its FileEntry.  If RawPath is not

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=340198=340197=340198=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Mon Aug 20 12:15:02 2018
@@ -17,6 +17,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/DirectoryLookup.h"
+#include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
@@ -38,7 +39,6 @@ class DirectoryEntry;
 class ExternalPreprocessorSource;
 class FileEntry;
 class FileManager;
-class HeaderMap;
 class HeaderSearchOptions;
 class IdentifierInfo;
 class LangOptions;
@@ -226,9 +226,8 @@ class HeaderSearch {
   llvm::StringMap;
   std::unique_ptr IncludeAliases;
 
-  /// This is a mapping from FileEntry -> HeaderMap, uniquing
-  /// headermaps.  This vector owns the headermap.
-  std::vector> HeaderMaps;
+  /// This is a mapping from FileEntry -> HeaderMap, uniquing headermaps.
+  std::vector>> 
HeaderMaps;
 
   /// The mapping between modules and headers.
   mutable ModuleMap ModMap;
@@ -264,7 +263,6 @@ public:
const LangOptions , const TargetInfo *Target);
   HeaderSearch(const HeaderSearch &) = delete;
   HeaderSearch =(const HeaderSearch &) = delete;
-  ~HeaderSearch();
 
   /// Retrieve the header-search options with which this header search
   /// was initialized.

Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=340198=340197=340198=diff
==
--- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderMap.cpp Mon Aug 20 12:15:02 2018
@@ -48,7 +48,8 @@ static inline unsigned HashHMapKey(Strin
 /// map.  If it doesn't look like a HeaderMap, it gives up and returns null.
 /// If it looks like a HeaderMap but is obviously corrupted, it puts a reason
 /// into the string error argument and returns null.
-const HeaderMap *HeaderMap::Create(const FileEntry *FE, FileManager ) {
+std::unique_ptr HeaderMap::Create(const FileEntry *FE,
+ FileManager ) {
   // If the file is too small to be a header map, ignore it.
   unsigned FileSize = FE->getSize();
   if (FileSize <= sizeof(HMapHeader)) return nullptr;
@@ -59,7 +60,7 @@ const HeaderMap *HeaderMap::Create(const
   bool NeedsByteSwap;
   if (!checkHeader(**FileBuffer, NeedsByteSwap))
 return nullptr;
-  return new HeaderMap(std::move(*FileBuffer), NeedsByteSwap);
+  return std::unique_ptr(new HeaderMap(std::move(*FileBuffer), 
NeedsByteSwap));
 }
 
 bool HeaderMapImpl::checkHeader(const llvm::MemoryBuffer ,

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=340198=340197=340198=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Mon Aug 20 12:15:02 2018
@@ -75,12 +75,6 @@ HeaderSearch::HeaderSearch(std::shared_p
   FileMgr(SourceMgr.getFileManager()), FrameworkMap(64),
   ModMap(SourceMgr, Diags, LangOpts, Target, *this) {}
 
-HeaderSearch::~HeaderSearch() {
-  // Delete headermaps.
-  for (unsigned i = 0, e = HeaderMaps.size(); i != 

[PATCH] D50945: [Lex] Make HeaderMaps a unique_ptr vector

2018-08-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D50945



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


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-20 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

This doesn't seem like a great idea to me, it's a negligible amount of type 
safety gained over using `stdint.h` types most people are more familiar with 
anyway. If you need something niche like those typedefs it's probably better to 
include the header and define them yourself in your application.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In https://reviews.llvm.org/D50979#1206282, @thakis wrote:

> In https://reviews.llvm.org/D50979#1206211, @rsmith wrote:
>
> > I don't think this is NFC. Testcase:
> >
> >   long long int a, b, c, d;
> >   unsigned char f() { return _InterlockedCompareExchange128(&(++a), ++b, 
> > ++c, &(++d)); }
> >
> >
> > Today, Clang increments `a`, `b`, `c`, and `d` twice each in `f()`.
>
>
> Thanks for pointing this out, good to hear that this even happens to find a 
> bug :-) I'll add some tests to document the progression.


*happens to _fix_ a bug


https://reviews.llvm.org/D50979



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


[PATCH] D50580: [clang-tidy] Abseil: no namespace check

2018-08-20 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia added inline comments.



Comment at: clang-tidy/abseil/NoNamespaceCheck.cpp:23
+
+  Finder->addMatcher(namespaceDecl(hasName("absl")).bind("absl_namespace"),
+ this);

hokein wrote:
> JonasToth wrote:
> > hugoeg wrote:
> > > deannagarcia wrote:
> > > > aaron.ballman wrote:
> > > > > hokein wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > I think this needs a `not(isExpansionInSystemHeader())` in there, 
> > > > > > > as this is going to trigger on code that includes a header file 
> > > > > > > using an `absl` namespace. If I'm incorrect and users typically 
> > > > > > > include abseil as something other than system includes, you'll 
> > > > > > > have to find a different way to solve this.
> > > > > > Yeah, we have discussed this issue internally.  abseil-user code 
> > > > > > usually includes abseil header like `#include 
> > > > > > "whatever/abseil/base/optimization.h"`, so 
> > > > > > `IsExpansionInSystemHeader` doesn't work for most cases. 
> > > > > > 
> > > > > > We need a way to filter out all headers being a part of abseil 
> > > > > > library. I think we can create a matcher 
> > > > > > `InExpansionInAbseilHeader` -- basically using 
> > > > > > `IsExpansionInFileMatching` with a regex expression that matches 
> > > > > > typical abseil include path. What do you think?
> > > > > > 
> > > > > > And we'll have more abseil checks (e.g.  `abseil-no-internal-deps`) 
> > > > > > that use `InExpansionInAbseilHeader`, we should put it to a common 
> > > > > > header.
> > > > > I think that is a sensible approach.
> > > > We will begin working on this, I think it will first be implemented in 
> > > > abseil-no-internal-deps but once it looks good I will add it to this 
> > > > patch.
> > > I'm going to go ahead a implement this in ASTMatchers.h and include it on 
> > > the patch for **abseil-no-internal-dep**s
> > In principle it is ok, but I don't think ASTMatchers.h is the correct 
> > place, because it is only of use to clang-tidy.
> > 
> > There is a `util` directory in clang-tidy for this kind of stuff. Defining 
> > you own matchers works the same as in ASTMatchers, you can grep through 
> > clang-tidy checks (e.g. `AST_MATCHER`) to have some examples of private 
> > matchers.
> `ASTMatchers.h` is not a reasonable place to put `asseil`-specific matchers. 
> We  have `clang-tidy/utils/Matchers.h` for putting clang-tidy specific 
> matchers. I'm not sure whether it is reasonable to put abseil-specific 
> matchers there. Maybe we create a `AbseilMatcher.h` file in 
> `clang-tidy/abseil` directory?
I put it in clang-tidy/abseil for now but I can definitely move it to 
clang-tidy/utils/ if you would prefer that


https://reviews.llvm.org/D50580



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


[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In https://reviews.llvm.org/D50979#1206211, @rsmith wrote:

> I don't think this is NFC. Testcase:
>
>   long long int a, b, c, d;
>   unsigned char f() { return _InterlockedCompareExchange128(&(++a), ++b, ++c, 
> &(++d)); }
>
>
> Today, Clang increments `a`, `b`, `c`, and `d` twice each in `f()`.


Thanks for pointing this out, good to hear that this even happens to find a bug 
:-) I'll add some tests to document the progression.


https://reviews.llvm.org/D50979



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


[PATCH] D50580: [clang-tidy] Abseil: no namespace check

2018-08-20 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 161526.
deannagarcia edited the summary of this revision.
deannagarcia added a comment.

This revision includes a matcher so that the warning does not trigger on 
internal Abseil files.


https://reviews.llvm.org/D50580

Files:
  clang-tidy/abseil/AbseilMatcher.h
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/NoNamespaceCheck.cpp
  clang-tidy/abseil/NoNamespaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-no-namespace.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/external-file.h
  test/clang-tidy/Inputs/absl/strings/internal-file.h
  test/clang-tidy/abseil-no-namespace.cpp

Index: test/clang-tidy/abseil-no-namespace.cpp
===
--- test/clang-tidy/abseil-no-namespace.cpp
+++ test/clang-tidy/abseil-no-namespace.cpp
@@ -0,0 +1,26 @@
+// RUN: %check_clang_tidy %s abseil-no-namespace %t -- -- -I %S/Inputs
+// RUN: clang-tidy -checks='-*, abseil-no-namespace' -header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
+
+// Warning will not be triggered on internal Abseil code that is included.
+#include "absl/strings/internal-file.h"
+// CHECK-NOT: warning:
+
+// Warning will be triggered on code that is not internal that is included.
+#include "absl/external-file.h"
+// CHECK: absl/external-file.h:1:11: warning: namespace 'absl' is reserved
+// for implementation of the Abseil library and should not be opened in
+// user code [abseil-no-namespace]
+
+namespace absl {}
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'absl' is reserved for
+// implementation of the Abseil library and should not be opened in the user
+// code [abseil-no-namespace]
+
+namespace absl {
+int i = 5;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:11: warning: namespace 'absl' 
+
+// Things that shouldn't trigger the check
+int i = 5;
+namespace std {}
Index: test/clang-tidy/Inputs/absl/strings/internal-file.h
===
--- test/clang-tidy/Inputs/absl/strings/internal-file.h
+++ test/clang-tidy/Inputs/absl/strings/internal-file.h
@@ -0,0 +1 @@
+namespace absl {}
Index: test/clang-tidy/Inputs/absl/external-file.h
===
--- test/clang-tidy/Inputs/absl/external-file.h
+++ test/clang-tidy/Inputs/absl/external-file.h
@@ -0,0 +1 @@
+namespace absl {}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-no-namespace
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-no-namespace.rst
===
--- docs/clang-tidy/checks/abseil-no-namespace.rst
+++ docs/clang-tidy/checks/abseil-no-namespace.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - abseil-no-namespace
+
+abseil-no-namespace
+===
+
+This check gives users a warning if they attempt to open ``namespace absl``.
+Users should not open ``namespace absl`` as that conflicts with abseil's
+compatibility guidelines and may result in breakage.
+
+Any user that uses:
+
+.. code-block:: c++
+
+ namespace absl {
+  ...
+ }
+
+will be prompted with a warning.
+
+See `the full Abseil compatibility guidelines `_ for more information.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,7 +57,11 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+- New :doc:`abseil-no-namespace
+  ` check.
+
+  Checks to ensure code does not open `namespace absl` as that
+  violates Abseil's compatibility guidelines.
 
 Improvements to include-fixer
 -
Index: clang-tidy/abseil/NoNamespaceCheck.h
===
--- clang-tidy/abseil/NoNamespaceCheck.h
+++ clang-tidy/abseil/NoNamespaceCheck.h
@@ -0,0 +1,36 @@
+//===--- NoNamespaceCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NONAMESPACECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NONAMESPACECHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+/// This test ensures users don't open namespace absl, as that violates
+/// our compatibility guidelines.
+///
+/// For the user-facing documentation see:
+/// 

[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-20 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Is there a reason for defining them? As in: does anything outside libunwind use 
them? I haven't seen such software yet.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D49511#1206265, @rsmith wrote:

> In https://reviews.llvm.org/D49511#1194716, @leonardchan wrote:
>
> > @rsmith any more feedback on this current version? If it still looks 
> > incorrect to use the record this way, I don't mind simplifying it to work 
> > on lvalue to rvalue conversions without checking for a leading address 
> > space operation.
>
>
> I've been thinking more about cleaner ways to implement this (and in 
> particular, approaches that will provide more reasonable semantics in C++ -- 
> allowing references to `noderef`, for example). We want to disallow operands 
> of type `noderef T` to all operations by default, and only allow very 
> specific operations on lvalues of type `noderef T` -- taking the address, 
> performing member accesses, lvalue casts. The most natural way to get that 
> effect would be to add a new form of placeholder type for a "dereferenced 
> noderef" expression, that `CheckPlaceholderExpr` rejects, and that we add 
> explicit support for in the contexts where such a construct is valid. (This 
> is similar to how we handle overloaded function names and bound member 
> function expressions in C++, for example.) (When we reach a context that 
> "consumes" a dereferenced noderef expression, we'd need to go back and patch 
> up its type, but I think that can be handled in a straightforward way.)
>
> I think we should also treat `noderef` more like a type qualifier: as an 
> important example, if we have a pointer or reference to `noderef struct X`, 
> then member access for a member of type `T` should give an lvalue of type 
> `noderef T`.


Sorry, I forgot to say: I do not think we need to do this for the initial 
version of this functionality. This is mostly about cleanly extending the 
functionality to cover more C++ constructs.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D49511#1194716, @leonardchan wrote:

> @rsmith any more feedback on this current version? If it still looks 
> incorrect to use the record this way, I don't mind simplifying it to work on 
> lvalue to rvalue conversions without checking for a leading address space 
> operation.


I've been thinking more about cleaner ways to implement this (and in 
particular, approaches that will provide more reasonable semantics in C++ -- 
allowing references to `noderef`, for example). We want to disallow operands of 
type `noderef T` to all operations by default, and only allow very specific 
operations on lvalues of type `noderef T` -- taking the address, performing 
member accesses, lvalue casts. The most natural way to get that effect would be 
to add a new form of placeholder type for a "dereferenced noderef" expression, 
that `CheckPlaceholderExpr` rejects, and that we add explicit support for in 
the contexts where such a construct is valid. (This is similar to how we handle 
overloaded function names and bound member function expressions in C++, for 
example.) (When we reach a context that "consumes" a dereferenced noderef 
expression, we'd need to go back and patch up its type, but I think that can be 
handled in a straightforward way.)

I think we should also treat `noderef` more like a type qualifier: as an 
important example, if we have a pointer or reference to `noderef struct X`, 
then member access for a member of type `T` should give an lvalue of type 
`noderef T`.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-20 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

Ping...


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D50413: [libunwind][include] Add some missing definitions to .

2018-08-20 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

Ping.

Are y'all waiting for me to do something?


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50413



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


[PATCH] D50984: AMDGPU: Move target code into TargetParser

2018-08-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: rampitec, kzhuravl, yaxunl.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, jvesely.
arsenm added a dependency: D50983: AMDGPU: Partially move target handling code 
from clang to TargetParser.

https://reviews.llvm.org/D50984

Files:
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h

Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/TargetParser.h"
 
 namespace clang {
 namespace targets {
@@ -38,160 +39,61 @@
   static const LangASMap AMDGPUDefIsGenMap;
   static const LangASMap AMDGPUDefIsPrivMap;
 
-  /// GPU kinds supported by the AMDGPU target.
-  enum GPUKind : uint32_t {
-// Not specified processor.
-GK_NONE = 0,
-
-// R600-based processors.
-GK_R600,
-GK_R630,
-GK_RS880,
-GK_RV670,
-GK_RV710,
-GK_RV730,
-GK_RV770,
-GK_CEDAR,
-GK_CYPRESS,
-GK_JUNIPER,
-GK_REDWOOD,
-GK_SUMO,
-GK_BARTS,
-GK_CAICOS,
-GK_CAYMAN,
-GK_TURKS,
-
-GK_R600_FIRST = GK_R600,
-GK_R600_LAST = GK_TURKS,
-
-// AMDGCN-based processors.
-GK_GFX600,
-GK_GFX601,
-GK_GFX700,
-GK_GFX701,
-GK_GFX702,
-GK_GFX703,
-GK_GFX704,
-GK_GFX801,
-GK_GFX802,
-GK_GFX803,
-GK_GFX810,
-GK_GFX900,
-GK_GFX902,
-GK_GFX904,
-GK_GFX906,
-
-GK_AMDGCN_FIRST = GK_GFX600,
-GK_AMDGCN_LAST = GK_GFX906,
-  };
+  llvm::AMDGPU::GPUKind GPUKind;
+  unsigned GPUFeatures;
 
-  struct GPUInfo {
-llvm::StringLiteral Name;
-llvm::StringLiteral CanonicalName;
-AMDGPUTargetInfo::GPUKind Kind;
-bool HasFMAF;
-bool HasFastFMAF;
-bool HasLDEXPF;
-bool HasFP64;
-bool HasFastFMA;
-bool HasFullRateF32Denorms;
-  };
 
-  static constexpr GPUInfo InvalidGPU =
-{{""}, {""}, GK_NONE, false, false, false, false, false, false};
-  static constexpr GPUInfo R600GPUs[26] = {
-  // Name CanonicalKindHasHasHasHasHasHas
-  //  Name FMAF   Fast   LDEXPF FP64   Fast   Fast
-  //  FMAF FMADenorm
-{{"r600"},{"r600"},GK_R600,false, false, false, false, false, false},
-{{"rv630"},   {"r600"},GK_R600,false, false, false, false, false, false},
-{{"rv635"},   {"r600"},GK_R600,false, false, false, false, false, false},
-{{"r630"},{"r630"},GK_R630,false, false, false, false, false, false},
-{{"rs780"},   {"rs880"},   GK_RS880,   false, false, false, false, false, false},
-{{"rs880"},   {"rs880"},   GK_RS880,   false, false, false, false, false, false},
-{{"rv610"},   {"rs880"},   GK_RS880,   false, false, false, false, false, false},
-{{"rv620"},   {"rs880"},   GK_RS880,   false, false, false, false, false, false},
-{{"rv670"},   {"rv670"},   GK_RV670,   false, false, false, false, false, false},
-{{"rv710"},   {"rv710"},   GK_RV710,   false, false, false, false, false, false},
-{{"rv730"},   {"rv730"},   GK_RV730,   false, false, false, false, false, false},
-{{"rv740"},   {"rv770"},   GK_RV770,   false, false, false, false, false, false},
-{{"rv770"},   {"rv770"},   GK_RV770,   false, false, false, false, false, false},
-{{"cedar"},   {"cedar"},   GK_CEDAR,   false, false, false, false, false, false},
-{{"palm"},{"cedar"},   GK_CEDAR,   false, false, false, false, false, false},
-{{"cypress"}, {"cypress"}, GK_CYPRESS, true,  false, false, false, false, false},
-{{"hemlock"}, {"cypress"}, GK_CYPRESS, true,  false, false, false, false, false},
-{{"juniper"}, {"juniper"}, GK_JUNIPER, false, false, false, false, false, false},
-{{"redwood"}, {"redwood"}, GK_REDWOOD, false, false, false, false, false, false},
-{{"sumo"},{"sumo"},GK_SUMO,false, false, false, false, false, false},
-{{"sumo2"},   {"sumo"},GK_SUMO,false, false, false, false, false, false},
-{{"barts"},   {"barts"},   GK_BARTS,   false, false, false, false, false, false},
-{{"caicos"},  {"caicos"},  GK_CAICOS,  false, false, false, false, false, false},
-{{"aruba"},   {"cayman"},  GK_CAYMAN,  true,  false, false, false, false, false},
-{{"cayman"},  {"cayman"},  GK_CAYMAN,  true,  false, false, false, false, false},
-{{"turks"},   {"turks"},   GK_TURKS,   false, false, false, false, false, false},
-  };
-  static constexpr GPUInfo AMDGCNGPUs[32] = {
-  // Name   CanonicalKindHas   HasHasHas   Has   Has
-  //Name FMAF  Fast   LDEXPF FP64  Fast  Fast
-  //   FMAFFMA   Denorm
-{{"gfx600"},

[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I don't think this is NFC. Testcase:

  long long int a, b, c, d;
  unsigned char f() { return _InterlockedCompareExchange128(&(++a), ++b, ++c, 
&(++d)); }

Today, Clang increments `a`, `b`, `c`, and `d` twice each in `f()`.


https://reviews.llvm.org/D50979



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


[PATCH] D50462: Try building complete AST after a fatal error was emitted if further diagnostics are expected

2018-08-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.
Herald added a subscriber: kadircet.

Thanks, Dmitry, for your explanation. It does help to understand your use case 
better.

What about having a mode that treats missing header as non-fatal error? Because 
I believe there are cases where there is no sense to continue after a fatal 
error. For example, consider hitting the error limit. Showing too many errors 
isn't useful and also after 50 errors it is a little bit too optimistic to 
assume that AST is in a good shape. I don't know if there are other 
fatal-but-we-can-continue errors and if we need a more general solution. So far 
looks like missing include is the biggest blocker for IDE-like functionality.


Repository:
  rC Clang

https://reviews.llvm.org/D50462



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


[PATCH] D50957: Rename -mlink-cuda-bitcode to -mlink-builtin-bitcode

2018-08-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r340193


https://reviews.llvm.org/D50957



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


r340193 - Rename -mlink-cuda-bitcode to -mlink-builtin-bitcode

2018-08-20 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Aug 20 11:16:48 2018
New Revision: 340193

URL: http://llvm.org/viewvc/llvm-project?rev=340193=rev
Log:
Rename -mlink-cuda-bitcode to -mlink-builtin-bitcode

The same semantics work for OpenCL, and probably any offload
language. Keep the old name around as an alias.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
cfe/trunk/test/CodeGenCUDA/propagate-metadata.cu
cfe/trunk/test/Driver/cuda-detect.cu
cfe/trunk/test/Driver/openmp-offload-gpu.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=340193=340192=340193=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 20 11:16:48 2018
@@ -287,9 +287,11 @@ def mconstructor_aliases : Flag<["-"], "
   HelpText<"Emit complete constructors and destructors as aliases when 
possible">;
 def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">,
   HelpText<"Link the given bitcode file before performing optimizations.">;
-def mlink_cuda_bitcode : Separate<["-"], "mlink-cuda-bitcode">,
+def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">,
   HelpText<"Link and internalize needed symbols from the given bitcode file "
"before performing optimizations.">;
+def mlink_cuda_bitcode : Separate<["-"], "mlink-cuda-bitcode">,
+  Alias;
 def vectorize_loops : Flag<["-"], "vectorize-loops">,
   HelpText<"Run the Loop vectorization passes">;
 def vectorize_slp : Flag<["-"], "vectorize-slp">,

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=340193=340192=340193=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Mon Aug 20 11:16:48 2018
@@ -621,7 +621,7 @@ void CudaToolChain::addClangTargetOption
 return;
   }
 
-  CC1Args.push_back("-mlink-cuda-bitcode");
+  CC1Args.push_back("-mlink-builtin-bitcode");
   CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
 
   // Libdevice in CUDA-7.0 requires PTX version that's more recent than LLVM
@@ -667,7 +667,7 @@ void CudaToolChain::addClangTargetOption
   SmallString<128> LibOmpTargetFile(LibraryPath);
   llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
   if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back("-mlink-builtin-bitcode");
 CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
 FoundBCLibrary = true;
 break;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=340193=340192=340193=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Aug 20 11:16:48 2018
@@ -912,10 +912,10 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
   for (auto *A :
-   Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_cuda_bitcode)) {
+   Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_builtin_bitcode)) {
 CodeGenOptions::BitcodeFileToLink F;
 F.Filename = A->getValue();
-if (A->getOption().matches(OPT_mlink_cuda_bitcode)) {
+if (A->getOption().matches(OPT_mlink_builtin_bitcode)) {
   F.LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded;
   // When linking CUDA bitcode, propagate function attributes so that
   // e.g. libdevice gets fast-math attrs if we're building with fast-math.

Modified: cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu?rev=340193=340192=340193=diff
==
--- cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/link-device-bitcode.cu Mon Aug 20 11:16:48 2018
@@ -11,13 +11,19 @@
 //
 // Make sure function in device-code gets linked in and internalized.
 // RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-builtin-bitcode %t.bc  -emit-llvm \
+// RUN:-disable-llvm-passes -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-IR
+
+// Make sure legacy flag name works
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
 // RUN:-mlink-cuda-bitcode %t.bc  

[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-08-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

I made a post on llvm-dev 
(http://lists.llvm.org/pipermail/llvm-dev/2018-August/125433.html) to see if 
other people have opinions on this. In the meantime, do you think I should make 
a separate patch that moves this into an LLVM intrinsic function?


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes

2018-08-20 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama abandoned this revision.
pirama added a comment.

Thanks for the clarification Richard and Eli.  I agree that leaving the status 
quo will match the intent of the macro.  I'll abandon this.


Repository:
  rC Clang

https://reviews.llvm.org/D50683



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


r340191 - [OPENMP] Fix crash on the emission of the weak function declaration.

2018-08-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Aug 20 11:03:40 2018
New Revision: 340191

URL: http://llvm.org/viewvc/llvm-project?rev=340191=rev
Log:
[OPENMP] Fix crash on the emission of the weak function declaration.

If the function is actually a weak reference, it should not be marked as
deferred definition as this is only a declaration. Patch adds checks for
the definitions if they must be emitted. Otherwise, only declaration is
emitted.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=340191=340190=340191=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 20 11:03:40 2018
@@ -2558,15 +2558,17 @@ llvm::Constant *CodeGenModule::GetOrCrea
 if (getLangOpts().OpenMPIsDevice && OpenMPRuntime &&
 !OpenMPRuntime->markAsGlobalTarget(GD) && FD->isDefined() &&
 !DontDefer && !IsForDefinition) {
-  const FunctionDecl *FDDef = FD->getDefinition();
-  GlobalDecl GDDef;
-  if (const auto *CD = dyn_cast(FDDef))
-GDDef = GlobalDecl(CD, GD.getCtorType());
-  else if (const auto *DD = dyn_cast(FDDef))
-GDDef = GlobalDecl(DD, GD.getDtorType());
-  else
-GDDef = GlobalDecl(FDDef);
-  addDeferredDeclToEmit(GDDef);
+  if (const FunctionDecl *FDDef = FD->getDefinition())
+if (getContext().DeclMustBeEmitted(FDDef)) {
+  GlobalDecl GDDef;
+  if (const auto *CD = dyn_cast(FDDef))
+GDDef = GlobalDecl(CD, GD.getCtorType());
+  else if (const auto *DD = dyn_cast(FDDef))
+GDDef = GlobalDecl(DD, GD.getDtorType());
+  else
+GDDef = GlobalDecl(FDDef);
+  addDeferredDeclToEmit(GDDef);
+}
 }
 
 if (FD->isMultiVersion()) {

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=340191=340190=340191=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Mon Aug 20 11:03:40 2018
@@ -128,5 +128,19 @@ int baz2() {
   return 2 + baz3();
 }
 
+extern int create() throw();
+
+static __typeof(create) __t_create __attribute__((__weakref__("__create")));
+
+int baz5() {
+  bool a;
+// CHECK-DAG: define weak void 
@__omp_offloading_{{.*}}baz5{{.*}}_l[[@LINE+1]](i64 {{.*}})
+#pragma omp target
+  a = __extension__(void *) & __t_create != 0;
+  return a;
+}
+
+// CHECK-DAG: declare extern_weak signext i32 @__create()
+
 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
 #endif // HEADER


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


[PATCH] D50862: [clang-tidy] Abseil: faster strsplit delimiter check

2018-08-20 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 161513.

https://reviews.llvm.org/D50862

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
  clang-tidy/abseil/FasterStrsplitDelimiterCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-faster-strsplit-delimiter.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-faster-strsplit-delimiter.cpp

Index: test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
===
--- test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
+++ test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
@@ -0,0 +1,99 @@
+// RUN: %check_clang_tidy %s abseil-faster-strsplit-delimiter %t
+
+namespace absl {
+
+class string_view {
+  public:
+string_view();
+string_view(const char *);
+};
+
+namespace strings_internal {
+struct Splitter {};
+struct MaxSplitsImpl {
+  MaxSplitsImpl();
+  ~MaxSplitsImpl();
+};
+} //namespace strings_internal
+
+template 
+strings_internal::Splitter StrSplit(absl::string_view, Delim) {
+  return {};
+}
+template 
+strings_internal::Splitter StrSplit(absl::string_view, Delim, Pred) {
+  return {};
+}
+
+class ByAnyChar {
+  public:
+explicit ByAnyChar(absl::string_view);
+~ByAnyChar();
+};
+
+template 
+strings_internal::MaxSplitsImpl MaxSplits(Delim, int) {
+  return {};
+}
+
+} //namespace absl
+
+void SplitDelimiters() {
+  absl::StrSplit("ABC", "A");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a string literal consisting of a single character; consider using the character overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", 'A');
+
+  absl::StrSplit("ABC", absl::ByAnyChar("\n"));
+  // CHECK-MESSAGES: [[@LINE-1]]:41: warning: absl::StrSplit()
+  // CHECK-FIXES: absl::StrSplit("ABC", '\n');
+
+  // Works with predicate
+  absl::StrSplit("ABC", "A", [](absl::string_view) { return true; });
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit()
+  // CHECK-FIXES: absl::StrSplit("ABC", 'A', [](absl::string_view) { return true; });
+
+  // Doesn't do anything with other strings lenghts.
+  absl::StrSplit("ABC", "AB");
+  absl::StrSplit("ABC", absl::ByAnyChar(""));
+  absl::StrSplit("ABC", absl::ByAnyChar(" \t"));
+
+  // Escapes a single quote in the resulting character literal.
+  absl::StrSplit("ABC", "'");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit()
+  // CHECK-FIXES: absl::StrSplit("ABC", '\'');
+
+  absl::StrSplit("ABC", "\"");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit()
+  // CHECK-FIXES: absl::StrSplit("ABC", '\"');
+
+  absl::StrSplit("ABC", absl::MaxSplits("\t", 1));
+  // CHECK-MESSAGES: [[@LINE-1]]:41: warning: absl::MaxSplits()
+  // CHECK-FIXES: absl::StrSplit("ABC", absl::MaxSplits('\t', 1));
+
+  auto delim = absl::MaxSplits(absl::ByAnyChar(" "), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:48: warning: absl::MaxSplits()
+  // CHECK-FIXES: auto delim = absl::MaxSplits(' ', 1);
+}
+
+#define MACRO(str) absl::StrSplit("ABC", str)
+
+void Macro() {
+  MACRO("A");
+}
+
+template 
+void FunctionTemplate() {
+  // This one should not warn because ByAnyChar is a dependent type.
+  absl::StrSplit("TTT", T("A"));
+
+  // This one will warn, but we are checking that we get a correct warning only
+  // once.
+  absl::StrSplit("TTT", "A");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit()
+  // CHECK-FIXES: absl::StrSplit("TTT", 'A');
+}
+
+void FunctionTemplateCaller() {
+  FunctionTemplate();
+  FunctionTemplate();
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   abseil-faster-strsplit-delimiter
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-faster-strsplit-delimiter.rst
===
--- docs/clang-tidy/checks/abseil-faster-strsplit-delimiter.rst
+++ docs/clang-tidy/checks/abseil-faster-strsplit-delimiter.rst
@@ -0,0 +1,41 @@
+.. title:: clang-tidy - abseil-faster-strsplit-delimiter
+
+abseil-faster-strsplit-delimiter
+
+
+Finds instances of ``absl::StrSplit()`` or ``absl::MaxSplits()`` where the
+delimiter is a single character string literal and replaces with a character.
+The check will offer a suggestion to change the string literal into a character.
+It will also catch code using ``absl::ByAnyChar()`` for just a single character
+and will transform that into a single character as well.
+
+These changes will give the same result, but using characters rather than
+single character string literals is more efficient and readable.
+
+Examples:
+
+.. code-block:: c++
+
+  // Original - the argument is a string literal.

[PATCH] D50945: [Lex] Make HeaderMaps a unique_ptr vector

2018-08-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good - thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D50945



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


[PATCH] D50945: [Lex] Make HeaderMaps a unique_ptr vector

2018-08-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In https://reviews.llvm.org/D50945#1205337, @kristina wrote:

> Given the context (class an file name itself) and documentation around the 
> function, I don't think in this particular case it improves readability or 
> maintainability, the lifetime of the `HeaderMap` is (IMHO) fairly obvious 
> from the const qualifier and from the documentation of the function itself. I 
> would say leave it as is.


I'd vote in favor of the change - since it makes the ownership obvious 
at-a-glance (documentation or not) & helps catch any mistakes that can be 
easily introduced when handling object ownership.


Repository:
  rC Clang

https://reviews.llvm.org/D50945



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


[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-20 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.

EmitX86BuiltinExpr() emits all args into Ops at the beginning, so don't do that 
work again. No intended behavior change.

(TNorthover: EmitAArch64BuiltinExpr() also emits args into Ops before the big 
switch (with some more subtlety around the last arg that I don't understand), 
but then almost every switch case does `EmitScalarExpr(E->getArg(n))`. It's 
been like this since the commit that added the arm64 code. Was the Ops pushing 
code added later and all the EmitScalarExpr()s are now unneeded, or is some 
reason for this?)


https://reviews.llvm.org/D50979

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10480,14 +10480,11 @@
 llvm::Type *Int128PtrTy = Int128Ty->getPointerTo();
 
 Value *Destination =
-Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), Int128PtrTy);
-Value *ExchangeHigh128 =
-Builder.CreateZExt(EmitScalarExpr(E->getArg(1)), Int128Ty);
-Value *ExchangeLow128 =
-Builder.CreateZExt(EmitScalarExpr(E->getArg(2)), Int128Ty);
-Address ComparandResult(
-Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int128PtrTy),
-getContext().toCharUnitsFromBits(128));
+Builder.CreateBitCast(Ops[0], Int128PtrTy);
+Value *ExchangeHigh128 = Builder.CreateZExt(Ops[1], Int128Ty);
+Value *ExchangeLow128 = Builder.CreateZExt(Ops[2], Int128Ty);
+Address ComparandResult(Builder.CreateBitCast(Ops[3], Int128PtrTy),
+getContext().toCharUnitsFromBits(128));
 
 Value *Exchange = Builder.CreateOr(
 Builder.CreateShl(ExchangeHigh128, 64, "", false, false),
@@ -10538,8 +10535,8 @@
   case X86::BI__readfsdword:
   case X86::BI__readfsqword: {
 llvm::Type *IntTy = ConvertType(E->getType());
-Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
-llvm::PointerType::get(IntTy, 257));
+Value *Ptr =
+Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 257));
 LoadInst *Load = Builder.CreateAlignedLoad(
 IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
 Load->setVolatile(true);
@@ -10550,8 +10547,8 @@
   case X86::BI__readgsdword:
   case X86::BI__readgsqword: {
 llvm::Type *IntTy = ConvertType(E->getType());
-Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
-llvm::PointerType::get(IntTy, 256));
+Value *Ptr =
+Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 256));
 LoadInst *Load = Builder.CreateAlignedLoad(
 IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
 Load->setVolatile(true);


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10480,14 +10480,11 @@
 llvm::Type *Int128PtrTy = Int128Ty->getPointerTo();
 
 Value *Destination =
-Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), Int128PtrTy);
-Value *ExchangeHigh128 =
-Builder.CreateZExt(EmitScalarExpr(E->getArg(1)), Int128Ty);
-Value *ExchangeLow128 =
-Builder.CreateZExt(EmitScalarExpr(E->getArg(2)), Int128Ty);
-Address ComparandResult(
-Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int128PtrTy),
-getContext().toCharUnitsFromBits(128));
+Builder.CreateBitCast(Ops[0], Int128PtrTy);
+Value *ExchangeHigh128 = Builder.CreateZExt(Ops[1], Int128Ty);
+Value *ExchangeLow128 = Builder.CreateZExt(Ops[2], Int128Ty);
+Address ComparandResult(Builder.CreateBitCast(Ops[3], Int128PtrTy),
+getContext().toCharUnitsFromBits(128));
 
 Value *Exchange = Builder.CreateOr(
 Builder.CreateShl(ExchangeHigh128, 64, "", false, false),
@@ -10538,8 +10535,8 @@
   case X86::BI__readfsdword:
   case X86::BI__readfsqword: {
 llvm::Type *IntTy = ConvertType(E->getType());
-Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
-llvm::PointerType::get(IntTy, 257));
+Value *Ptr =
+Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 257));
 LoadInst *Load = Builder.CreateAlignedLoad(
 IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
 Load->setVolatile(true);
@@ -10550,8 +10547,8 @@
   case X86::BI__readgsdword:
   case X86::BI__readgsqword: {
 llvm::Type *IntTy = ConvertType(E->getType());
-Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
-llvm::PointerType::get(IntTy, 256));
+Value *Ptr =
+

[PATCH] D50535: Fix selective formatting of ObjC scope

2018-08-20 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added a comment.

Nice! That looks very promising.

It still fails when we pass a longer range (maybe mimicking `PreviousRBrace` 
will help), e.g.:
Base code:

  @protocol A
   @optional
  // comment
  - (void)f;
  @end
  MACRO

formatted with `clang-format -lines=3:6 file.m` gives:

  @protocol A
   @optional
   // comment
   - (void)f;
   @end
   MACRO

This is not happening for Cpp, e.g.:
Base code:

  class A {
   void f ();
  // comment
  void g ();
  };
  MACRO

running `clang-format -lines=3:6 file.cpp` gives:

  class A {
   void f ();
   // comment
   void g ();
  };
  MACRO

I think it would be good to add all these tests to unit tests, but I see that 
an interface to pass line ranges is not very pleasant.


Repository:
  rC Clang

https://reviews.llvm.org/D50535



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


[PATCH] D50926: [SourceManager] Extract 'findFileIDsForFile' from 'translateFile' to allow mapping from one file entry to multiple FileIDs

2018-08-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 161504.
arphaman marked 2 inline comments as done.
arphaman added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D50926

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp
  unittests/Basic/SourceManagerTest.cpp

Index: unittests/Basic/SourceManagerTest.cpp
===
--- unittests/Basic/SourceManagerTest.cpp
+++ unittests/Basic/SourceManagerTest.cpp
@@ -377,6 +377,51 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, findFileIDsForFile) {
+  const char *header = "int x;";
+
+  const char *main = "#include \n"
+ "#include \n";
+
+  std::unique_ptr HeaderBuf =
+  llvm::MemoryBuffer::getMemBuffer(header);
+  std::unique_ptr MainBuf =
+  llvm::MemoryBuffer::getMemBuffer(main);
+  SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(MainBuf)));
+
+  const FileEntry *headerFile =
+  FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
+
+  TrivialModuleLoader ModLoader;
+  MemoryBufferCache PCMCache;
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, &*Target);
+  Preprocessor PP(std::make_shared(), Diags, LangOpts,
+  SourceMgr, PCMCache, HeaderInfo, ModLoader,
+  /*IILookup =*/nullptr,
+  /*OwnsHeaderSearch =*/false);
+  PP.Initialize(*Target);
+
+  PP.EnterMainSourceFile();
+
+  while (1) {
+Token tok;
+PP.Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+
+  llvm::SmallVector Files = SourceMgr.findFileIDsForFile(headerFile);
+
+  ASSERT_EQ(2U, Files.size());
+  ASSERT_NE(Files[0], Files[1]);
+  SourceLocation Loc1 = SourceMgr.translateLineCol(Files[0], 1, 1);
+  SourceLocation Loc2 = SourceMgr.translateLineCol(Files[1], 1, 1);
+  ASSERT_NE(Loc1, Loc2);
+  ASSERT_TRUE(SourceMgr.isBeforeInTranslationUnit(Loc1, Loc2));
+}
+
 #endif
 
 } // anonymous namespace
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1602,6 +1602,47 @@
   return translateLineCol(FirstFID, Line, Col);
 }
 
+bool SourceManager::findFileIDsForFile(
+const FileEntry *SourceFile,
+llvm::function_ref Callback) const {
+  assert(SourceFile && "Null source file!");
+
+  // Look through all of the local source locations.
+  for (unsigned I = 0, N = local_sloc_entry_size(); I != N; ++I) {
+bool Invalid = false;
+const SLocEntry  = getLocalSLocEntry(I, );
+if (Invalid)
+  return false;
+
+if (SLoc.isFile() && SLoc.getFile().getContentCache() &&
+SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
+  if (Callback(FileID::get(I)))
+return true;
+}
+  }
+
+  // If that still didn't help, try the modules.
+  for (unsigned I = 0, N = loaded_sloc_entry_size(); I != N; ++I) {
+const SLocEntry  = getLoadedSLocEntry(I);
+if (SLoc.isFile() && SLoc.getFile().getContentCache() &&
+SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
+  if (Callback(FileID::get(-int(I) - 2)))
+return true;
+}
+  }
+  return false;
+}
+
+llvm::SmallVector
+SourceManager::findFileIDsForFile(const FileEntry *SourceFile) const {
+  llvm::SmallVector Result;
+  findFileIDsForFile(SourceFile, [&](FileID F) {
+Result.push_back(F);
+return false;
+  });
+  return Result;
+}
+
 /// Get the FileID for the given file.
 ///
 /// If the source file is included multiple times, the FileID will be the
@@ -1650,35 +1691,16 @@
 }
   }
 
-  if (FirstFID.isInvalid()) {
-// The location we're looking for isn't in the main file; look
-// through all of the local source locations.
-for (unsigned I = 0, N = local_sloc_entry_size(); I != N; ++I) {
-  bool Invalid = false;
-  const SLocEntry  = getLocalSLocEntry(I, );
-  if (Invalid)
-return FileID();
+  if (FirstFID.isValid())
+return FirstFID;
 
-  if (SLoc.isFile() &&
-  SLoc.getFile().getContentCache() &&
-  SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
-FirstFID = FileID::get(I);
-break;
-  }
-}
-// If that still didn't help, try the modules.
-if (FirstFID.isInvalid()) {
-  for (unsigned I = 0, N = loaded_sloc_entry_size(); I != N; ++I) {
-const SLocEntry  = getLoadedSLocEntry(I);
-if (SLoc.isFile() &&
-SLoc.getFile().getContentCache() &&
-SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
-  FirstFID = FileID::get(-int(I) - 2);
-  break;
-}
-  }
-}
-  }
+  // The location we're looking for isn't in the main file; look
+  // through all of the local and the imported 

[PATCH] D50926: [SourceManager] Extract 'findFileIDsForFile' from 'translateFile' to allow mapping from one file entry to multiple FileIDs

2018-08-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/SourceManager.h:1539
+  /// \returns true if the callback returned true, false otherwise.
+  bool findFileIDsForFile(const FileEntry *SourceFile,
+  llvm::function_ref Callback) const;

ioeric wrote:
> Callback pattern seems uncommon in LLVM/Clang. I'd suggest making this return 
> a set of `FileID`s and put the callback-based function as a helper (shared by 
> this and `translateFile`)in the implementation.
I created a helper, but unfortunately it needs to be a member of SourceManager 
as FileID::get is private.


Repository:
  rC Clang

https://reviews.llvm.org/D50926



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


[PATCH] D42043: c-index: CXString: fix MSAN read-past-end bug

2018-08-20 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added subscribers: jkorous, vsapsai.
vsk added a comment.

+ Jan and Volodymyr. This seemed to be in good shape the last time I looked at 
it. Not having touched libclang for a while I don't think I can give an 
official lgtm.


Repository:
  rC Clang

https://reviews.llvm.org/D42043



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


[PATCH] D50978: [ASTImporter] Add test for C++'s try/catch statements.

2018-08-20 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added subscribers: cfe-commits, martong.
Herald added a reviewer: a.sidorin.

Also enable exceptions in clang-import-test so that we can parse the test files.


Repository:
  rC Clang

https://reviews.llvm.org/D50978

Files:
  test/Import/cxx-try-catch/Inputs/F.cpp
  test/Import/cxx-try-catch/test.cpp
  tools/clang-import-test/clang-import-test.cpp


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -196,6 +196,8 @@
   Inv->getLangOpts()->DollarIdents = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
Index: test/Import/cxx-try-catch/test.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/test.cpp
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-try-catch/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}


Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -196,6 +196,8 @@
   Inv->getLangOpts()->DollarIdents = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
+  Inv->getLangOpts()->Exceptions = true;
+  Inv->getLangOpts()->CXXExceptions = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
Index: test/Import/cxx-try-catch/test.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/test.cpp
@@ -0,0 +1,39 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+
+// CHECK: CXXTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname1
+// CHECK-SAME: 'int'
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CXXCatchStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname2
+// CHECK-SAME: 'long'
+// CHECK-NEXT: CompoundStmt
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-try-catch/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/cxx-try-catch/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  try {
+  } catch (...) {
+  }
+
+  try {
+  } catch (int) {
+  }
+
+  try {
+  } catch (int varname) {
+  }
+
+  try {
+  } catch (int varname1) {
+  } catch (long varname2) {
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50870: Close FileEntries of cached files in ModuleManager::addModule().

2018-08-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340188: Close FileEntries of cached files in 
ModuleManager::addModule(). (authored by adrian, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50870?vs=161119=161501#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50870

Files:
  cfe/trunk/lib/Serialization/ModuleManager.cpp


Index: cfe/trunk/lib/Serialization/ModuleManager.cpp
===
--- cfe/trunk/lib/Serialization/ModuleManager.cpp
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp
@@ -161,21 +161,24 @@
   if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
 // The buffer was already provided for us.
 NewModule->Buffer = >addBuffer(FileName, std::move(Buffer));
+// Since the cached buffer is reused, it is safe to close the file
+// descriptor that was opened while stat()ing the PCM in
+// lookupModuleFile() above, it won't be needed any longer.
+Entry->closeFile();
   } else if (llvm::MemoryBuffer *Buffer = PCMCache->lookupBuffer(FileName)) {
 NewModule->Buffer = Buffer;
+// As above, the file descriptor is no longer needed.
+Entry->closeFile();
   } else {
 // Open the AST file.
 llvm::ErrorOr> 
Buf((std::error_code()));
 if (FileName == "-") {
   Buf = llvm::MemoryBuffer::getSTDIN();
 } else {
-  // Leave the FileEntry open so if it gets read again by another
-  // ModuleManager it must be the same underlying file.
-  // FIXME: Because FileManager::getFile() doesn't guarantee that it will
-  // give us an open file, this may not be 100% reliable.
+  // Get a buffer of the file and close the file descriptor when done.
   Buf = FileMgr.getBufferForFile(NewModule->File,
  /*IsVolatile=*/false,
- /*ShouldClose=*/false);
+ /*ShouldClose=*/true);
 }
 
 if (!Buf) {


Index: cfe/trunk/lib/Serialization/ModuleManager.cpp
===
--- cfe/trunk/lib/Serialization/ModuleManager.cpp
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp
@@ -161,21 +161,24 @@
   if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
 // The buffer was already provided for us.
 NewModule->Buffer = >addBuffer(FileName, std::move(Buffer));
+// Since the cached buffer is reused, it is safe to close the file
+// descriptor that was opened while stat()ing the PCM in
+// lookupModuleFile() above, it won't be needed any longer.
+Entry->closeFile();
   } else if (llvm::MemoryBuffer *Buffer = PCMCache->lookupBuffer(FileName)) {
 NewModule->Buffer = Buffer;
+// As above, the file descriptor is no longer needed.
+Entry->closeFile();
   } else {
 // Open the AST file.
 llvm::ErrorOr> Buf((std::error_code()));
 if (FileName == "-") {
   Buf = llvm::MemoryBuffer::getSTDIN();
 } else {
-  // Leave the FileEntry open so if it gets read again by another
-  // ModuleManager it must be the same underlying file.
-  // FIXME: Because FileManager::getFile() doesn't guarantee that it will
-  // give us an open file, this may not be 100% reliable.
+  // Get a buffer of the file and close the file descriptor when done.
   Buf = FileMgr.getBufferForFile(NewModule->File,
  /*IsVolatile=*/false,
- /*ShouldClose=*/false);
+ /*ShouldClose=*/true);
 }
 
 if (!Buf) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340188 - Close FileEntries of cached files in ModuleManager::addModule().

2018-08-20 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Aug 20 10:10:27 2018
New Revision: 340188

URL: http://llvm.org/viewvc/llvm-project?rev=340188=rev
Log:
Close FileEntries of cached files in ModuleManager::addModule().

While investigating why LLDB (which can build hundreds of clang
modules during one debug session) was getting "too many open files"
errors, I found that most of them are .pcm files that are kept open by
ModuleManager. Pretty much all of the open file dscriptors are
FileEntries that are refering to `.pcm` files for which a buffer
already exists in a CompilerInstance's PCMCache.

Before PCMCache was added it was necessary to hold on to open file
descriptors to ensure that all ModuleManagers using the same
FileManager read the a consistent version of a given `.pcm` file on
disk, even when a concurrent clang process overwrites the file halfway
through. The PCMCache makes this practice unnecessary, since it caches
the entire contents of a `.pcm` file, while the FileManager caches all
the stat() information.

This patch adds a call to FileEntry::closeFile() to the path where a
Buffer has already been created. This is necessary because even for a
freshly written `.pcm` file the file is stat()ed once immediately
after writing to generate a FileEntry in the FileManager. Because a
freshly-generated file's contents is stored in the PCMCache, it is
fine to close the file immediately thereafter.  The second change this
patch makes is to set the `ShouldClose` flag to true when reading a
`.pcm` file into the PCMCache for the first time.

[For reference, in 1 Clang instance there is
 - 1 FileManager and
 - n ModuleManagers with
 - n PCMCaches.]

rdar://problem/40906753

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

Modified:
cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=340188=340187=340188=diff
==
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Mon Aug 20 10:10:27 2018
@@ -161,21 +161,24 @@ ModuleManager::addModule(StringRef FileN
   if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
 // The buffer was already provided for us.
 NewModule->Buffer = >addBuffer(FileName, std::move(Buffer));
+// Since the cached buffer is reused, it is safe to close the file
+// descriptor that was opened while stat()ing the PCM in
+// lookupModuleFile() above, it won't be needed any longer.
+Entry->closeFile();
   } else if (llvm::MemoryBuffer *Buffer = PCMCache->lookupBuffer(FileName)) {
 NewModule->Buffer = Buffer;
+// As above, the file descriptor is no longer needed.
+Entry->closeFile();
   } else {
 // Open the AST file.
 llvm::ErrorOr> 
Buf((std::error_code()));
 if (FileName == "-") {
   Buf = llvm::MemoryBuffer::getSTDIN();
 } else {
-  // Leave the FileEntry open so if it gets read again by another
-  // ModuleManager it must be the same underlying file.
-  // FIXME: Because FileManager::getFile() doesn't guarantee that it will
-  // give us an open file, this may not be 100% reliable.
+  // Get a buffer of the file and close the file descriptor when done.
   Buf = FileMgr.getBufferForFile(NewModule->File,
  /*IsVolatile=*/false,
- /*ShouldClose=*/false);
+ /*ShouldClose=*/true);
 }
 
 if (!Buf) {


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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseExpr.cpp:1126
+
+Actions.StartCheckingNoDeref();
+

This parser-driven start/stop mechanism will not work in C++ templates. 
Instead, can you remove the "start" part and check the noderef exprs as part of 
popping the ExprEvaluationContextRecord?



Comment at: lib/Sema/SemaExpr.cpp:14230-14242
+class DeclRefFinder : public ConstEvaluatedExprVisitor {
+public:
+  typedef ConstEvaluatedExprVisitor Inherited;
+
+  DeclRefFinder(ASTContext ) : Inherited(Ctx) {}
+
+  void VisitDeclRefExpr(const DeclRefExpr *E) { DeclRef = E; }

rsmith wrote:
> I don't see any reason to assume that the `DeclRefExpr` found by this visitor 
> will be the one you're interested in (the one the `noderef` attribute came 
> from).
> 
> How about instead you walk over only expressions that you *know* preserve 
> `noderef`, and if you can't find a declaration as the source of the `noderef` 
> attribute, produce a differently-worded diagnostic that doesn't give a 
> variable name?
This comment is marked done but has not been addressed.



Comment at: lib/Sema/SemaExpr.cpp:4267
+  } else if (const auto *Member = dyn_cast(StrippedExpr)) {
+// Getting the address of a member expr in the form &(*s).b
+const Expr *Base = Member->getBase()->IgnoreParenImpCasts();

You need to loop/recurse here; there could be a sequence of `.` member accesses 
to strip.



Comment at: lib/Sema/SemaExpr.cpp:4291
+  const QualType  = Base->getType();
+  QualType ElemTy;
+  if (const auto *ArrayTy = dyn_cast(BaseTy))

Did you mean to use ElemTy somewhere below? (I'd guess you intended to check 
whether it's marked noderef?)



Comment at: lib/Sema/SemaType.cpp:4209
+  bool IsNoDeref = false;
+  if (const auto *AT = dyn_cast(T))
+IsNoDeref = AT->getAttrKind() == AttributedType::attr_noderef;

This is not correct (there could be multiple attributes on the type). See below.



Comment at: lib/Sema/SemaType.cpp:4816
+
+if (const auto *AT = dyn_cast(T))
+  IsNoDeref = AT->getAttrKind() == AttributedType::attr_noderef;

Move this after the check below (directly setting ExpectNoDerefChunk instead), 
and remove the unnecessary IsNoDeref variable.



Comment at: lib/Sema/SemaType.cpp:4816
+
+if (const auto *AT = dyn_cast(T))
+  IsNoDeref = AT->getAttrKind() == AttributedType::attr_noderef;

rsmith wrote:
> Move this after the check below (directly setting ExpectNoDerefChunk 
> instead), and remove the unnecessary IsNoDeref variable.
This is not correct: there could be multiple attributes at this level. You 
could fix this locally either by looping through the attributes on the type or 
iterating through the ParsedAttrs on the chunk. But I think my preference would 
be to store state indicating that we have an unvalidated noderef attribute on 
the TypeProcessingState at the point where you create the AttributedType, and 
check and clear that flag here when creating a type chunk.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-20 Thread Hugo Gonzalez via Phabricator via cfe-commits
hugoeg marked an inline comment as done.
hugoeg added inline comments.



Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:20
+
+bool IsInAbseilFile(const SourceManager& manager, SourceLocation loc){
+  if (loc.isInvalid()) {

hokein wrote:
> hugoeg wrote:
> > hokein wrote:
> > > I think we can make it as an ASTMatcher instead of a function like:
> > > 
> > > ```
> > > AST_POLYMORPHIC_MATCHER_P(isInAbseilFile,
> > >   AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, 
> > > TypeLoc)) {
> > >// your code here.
> > > }
> > > ```
> > Unfortunately, I do not think we can.  That was the way I originally tried 
> > to implement it. It worked on no-namespace-check, but not in this one. This 
> > is because as an AST_POLYMORPHIC_MATCHER_P, we are trying to match an usage 
> > of a Decl, not the Decl itself and since we are matching a TypeLoc in 
> > no-internal-deps-check, not really the usage, it doesn't work.
> > 
> > As a result, I modified my original implementation, which you will see in 
> > no-namespace-check and turned it into IsInAbseilFile(SourceManager&,  
> > SourceLocation), which is just takes a source location and returns whether 
> > the location we matched is in an Abseil file
> Could you explain a bit more why it won't work? I don't understand why it 
> doesn't work. 
> 
> Basically you define the matcher like:
> 
> ```
> AST_POLYMORPHIC_MATCHER(
> isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc,
> NestedNameSpecifierLoc)) {
>   auto  = Finder->getASTContext().getSourceManager();
>   SourceLocation loc = Node.getBeginLoc();
>   if (loc.isInvalid()) return false;
>   const FileEntry *FileEntry =
>   SourceManager.getFileEntryForID(SourceManager.getFileID(loc));
>   if (!FileEntry) return false;
>   StringRef Filename = FileEntry->getName();
>   llvm::Regex RE("absl/(base|container|debugging|memory|meta|numeric|strings|"
>  "synchronization|types|utiliy)");
>   return RE.match(Filename);
> }
> ```
> 
> And use it for example in your check
> 
> ```
> Finder->addMatcher(nestedNameSpecifierLoc(
>  loc(specifiesNamespace(namespaceDecl(
>  matchesName("internal"),
>  hasParent(namespaceDecl(hasName("absl")),
>  unless(isInAbseilFile()))
>  .bind("InternalDep"),
>  this);
> ```
You're right, this implementation seems to work, I seemed to have a simple 
logic error in my original implementation, the new diff will include this 
version 


https://reviews.llvm.org/D50542



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


[PATCH] D50571: [clangd] add an extension field to LSP to transfer the diagnostic's category

2018-08-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D50571#1205650, @joaotavora wrote:

> > LGTM. Let's watch out for possible breakages in any of the clients, though. 
> > I've checked VSCode and it seems to be fine with the added fields.
>
> This isn't in the spec and broke the LSP client eglot 
> (https://github.com/joaotavora/eglot/pull/81). Why don't you put this in the 
> "source" field, or concat it to the "message" field.  Who can even use this 
> information if it's not in the spec? Are clients supposed to code against 
> every LSP server's whim?


Thanks for the feedback. I'll make a patch that turns this off by default so 
that clients can opt-in into it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50571



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


[PATCH] D50932: [ASTImporter] Add test for C++ casts and fix broken const_cast importing.

2018-08-20 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340182: [ASTImporter] Add test for C++ casts and fix broken 
const_cast importing. (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50932?vs=161496=161498#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50932

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
  cfe/trunk/test/Import/cxx-casts/test.cpp
  cfe/trunk/tools/clang-import-test/clang-import-test.cpp


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -6897,6 +6897,10 @@
 return CXXReinterpretCastExpr::Create(
 Importer.getToContext(), ToType, VK, CK, ToOp, ,
 ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
+  } else if (isa(E)) {
+return CXXConstCastExpr::Create(Importer.getToContext(), ToType, VK, ToOp,
+ToWritten, ToOperatorLoc, ToRParenLoc,
+ToAngleBrackets);
   } else {
 return nullptr;
   }
Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
===
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  // Needed for testing dynamic_cast.
+  Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
Index: cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
===
--- cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
+++ cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
@@ -0,0 +1,12 @@
+struct A {
+  virtual ~A() {}
+};
+struct B : public A {};
+
+void f() {
+  const A *b = new B();
+  const B *c1 = dynamic_cast(b);
+  const B *c2 = static_cast(b);
+  const B *c3 = reinterpret_cast(b);
+  A *c4 = const_cast(b);
+}
Index: cfe/trunk/test/Import/cxx-casts/test.cpp
===
--- cfe/trunk/test/Import/cxx-casts/test.cpp
+++ cfe/trunk/test/Import/cxx-casts/test.cpp
@@ -0,0 +1,21 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXDynamicCastExpr
+// CHECK-SAME: dynamic_cast
+// CHECK-SAME: 
+
+// CHECK: CXXStaticCastExpr
+// CHECK-SAME: static_cast
+// CHECK-SAME: 
+
+// CHECK: CXXReinterpretCastExpr
+// CHECK-SAME: reinterpret_cast
+// CHECK-SAME: 
+
+// CHECK: CXXConstCastExpr
+// CHECK-SAME: const_cast
+// CHECK-SAME: 
+
+void expr() {
+  f();
+}


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -6897,6 +6897,10 @@
 return CXXReinterpretCastExpr::Create(
 Importer.getToContext(), ToType, VK, CK, ToOp, ,
 ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
+  } else if (isa(E)) {
+return CXXConstCastExpr::Create(Importer.getToContext(), ToType, VK, ToOp,
+ToWritten, ToOperatorLoc, ToRParenLoc,
+ToAngleBrackets);
   } else {
 return nullptr;
   }
Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
===
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp
@@ -194,6 +194,8 @@
   Inv->getLangOpts()->ThreadsafeStatics = false;
   Inv->getLangOpts()->AccessControl = false;
   Inv->getLangOpts()->DollarIdents = true;
+  // Needed for testing dynamic_cast.
+  Inv->getLangOpts()->RTTI = true;
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
Index: cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
===
--- cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
+++ cfe/trunk/test/Import/cxx-casts/Inputs/F.cpp
@@ -0,0 +1,12 @@
+struct A {
+  virtual ~A() {}
+};
+struct B : public A {};
+
+void f() {
+  const A *b = new B();
+  const B *c1 = dynamic_cast(b);
+  const B *c2 = static_cast(b);
+  const B *c3 = reinterpret_cast(b);
+  A *c4 = const_cast(b);
+}
Index: cfe/trunk/test/Import/cxx-casts/test.cpp
===
--- cfe/trunk/test/Import/cxx-casts/test.cpp
+++ cfe/trunk/test/Import/cxx-casts/test.cpp
@@ -0,0 +1,21 @@
+// RUN: clang-import-test -dump-ast 

  1   2   >