[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds

2017-01-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki created this revision.
danielmarjamaki added reviewers: zaks.anna, dcoughlin.
danielmarjamaki added a subscriber: cfe-commits.
danielmarjamaki set the repository for this revision to rL LLVM.

Example code:

  void f1(int x) {
int a[20] = {0};
if (x==25) {}
if (a[x] == 123) {}  // <- Warning
  }

If I don't enable alpha, only core, then Clang writes this misleading FP:

  undef.c:5:12: warning: The left operand of '==' is a garbage value

I say it's a FP because the message is wrong. If the message correctly said 
"array index out of bounds" and pointed out a[x] directly, then it would be TP. 
This message goes away if alpha is enabled and I believe that is by intention.

Since there is a array-index-out-of-bounds check in alpha I am guessing that 
the UndefinedBinaryOperatorResult should not report "array index out of 
bounds". Therefore I remove this warning from this check.

This patch is a experimental work in progress. I would like to know if you 
think I should modifiy the UndefinedBinaryOperatorResult check or if I should 
do something in the ExprEngine? Maybe array index out of bounds should not lead 
to Undef SVal?

With this patch, all the existing tests succeed.


Repository:
  rL LLVM

https://reviews.llvm.org/D28278

Files:
  lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp


Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -61,7 +61,7 @@
 SmallString<256> sbuf;
 llvm::raw_svector_ostream OS(sbuf);
 const Expr *Ex = nullptr;
-bool isLeft = true;
+bool isLeft;
 
 if (state->getSVal(B->getLHS(), LCtx).isUndef()) {
   Ex = B->getLHS()->IgnoreParenCasts();
@@ -73,6 +73,24 @@
 }
 
 if (Ex) {
+  if (isa(Ex)) {
+SVal Loc = state->getSVal(Ex,LCtx);
+if (Loc.isValid()) {
+  const MemRegion *MR = Loc.castAs().getRegion();
+  if (const ElementRegion *ER = dyn_cast(MR)) {
+DefinedOrUnknownSVal Idx = 
ER->getIndex().castAs();
+DefinedOrUnknownSVal NumElements
+  = C.getStoreManager().getSizeInElements(state, 
ER->getSuperRegion(),
+ER->getValueType());
+ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, 
true);
+ProgramStateRef StOutBound = state->assumeInBound(Idx, 
NumElements, false);
+if (StOutBound && !StInBound) {
+  return;
+}
+  }
+}
+  }
+
   OS << "The " << (isLeft ? "left" : "right")
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())


Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -61,7 +61,7 @@
 SmallString<256> sbuf;
 llvm::raw_svector_ostream OS(sbuf);
 const Expr *Ex = nullptr;
-bool isLeft = true;
+bool isLeft;
 
 if (state->getSVal(B->getLHS(), LCtx).isUndef()) {
   Ex = B->getLHS()->IgnoreParenCasts();
@@ -73,6 +73,24 @@
 }
 
 if (Ex) {
+  if (isa(Ex)) {
+SVal Loc = state->getSVal(Ex,LCtx);
+if (Loc.isValid()) {
+  const MemRegion *MR = Loc.castAs().getRegion();
+  if (const ElementRegion *ER = dyn_cast(MR)) {
+DefinedOrUnknownSVal Idx = ER->getIndex().castAs();
+DefinedOrUnknownSVal NumElements
+  = C.getStoreManager().getSizeInElements(state, ER->getSuperRegion(),
+ER->getValueType());
+ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
+ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+if (StOutBound && !StInBound) {
+  return;
+}
+  }
+}
+  }
+
   OS << "The " << (isLeft ? "left" : "right")
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27897: [Modules] Enable the Modules language feature by default for the Clang builtins.

2017-01-03 Thread Elad Cohen via Phabricator via cfe-commits
eladcohen added a comment.

ping


https://reviews.llvm.org/D27897



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


Re: [PATCH] D27123: Add AVR target and toolchain to Clang

2017-01-03 Thread Senthil Kumar Selvaraj via cfe-commits

Dylan McKay writes:

> Did you get the BugZilla account sorted Senthil?

Nope, direct email also didn't help. Can you please file a bug with

Title:

UINT16_TYPE and INT16_TYPE are defined as short instead of int for AVR

Description:

   UINT16_TYPE and INT16_TYPE are implicitly defined by the preprocessor
   to the short type, rather than int. While shorts and ints are both
   16 bits wide on the avr, gcc picks ints to represent 16 bits wherever
   possible, and picking short can cause issues with C++ name mangling
   (see https://reviews.llvm.org/D27123#615854). Therefore, clang should
   define the two types to short.

   Clang's lib/Frontend/InitPreprocessor.cpp::DefineExactWidthIntType does not
   use TargetInfo::getIntTypeByWidth. Instead,
   InitializePredefinedMacros calls
   the function with the specific type (SignedShort/UnsignedShort), because
   getShortWidth() > getCharWidth(), but getIntWidth() ==
   getShortWidth().


What's necessary for sign-off? Should I ping the reviewer (Richard Smith) again?

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


[libcxx] r290939 - build: use the platform dependent library prefix/suffix

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 23:49:57 2017
New Revision: 290939

URL: http://llvm.org/viewvc/llvm-project?rev=290939=rev
Log:
build: use the platform dependent library prefix/suffix

Use the cmake variables to get the platform dependent values for the
static library prefix and suffix, which can be different from the Unix
preference for "lib", ".a" (e.g. Windows uses "", ".lib" respectively).

Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290939=290938=290939=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue Jan  3 23:49:57 2017
@@ -232,7 +232,8 @@ if (LIBCXX_ENABLE_STATIC)
 if (TARGET ${LIBCXX_CXX_ABI_LIBRARY})
   set(MERGE_ARCHIVES_ABI_TARGET 
"$")
 else()
-  set(MERGE_ARCHIVES_ABI_TARGET "lib${LIBCXX_CXX_ABI_LIBRARY}.a")
+  set(MERGE_ARCHIVES_ABI_TARGET
+  
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
 endif()
 add_custom_command(TARGET cxx_static POST_BUILD
 COMMAND


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


[libcxx] r290941 - fix elast configuration on Windows targets

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 23:50:01 2017
New Revision: 290941

URL: http://llvm.org/viewvc/llvm-project?rev=290941=rev
Log:
fix elast configuration on Windows targets

A typo and missing header inclusion was obscured by the litany of user
defined literal warnings.  This fixes the detection of ELAST on windows.

Modified:
libcxx/trunk/src/include/config_elast.h

Modified: libcxx/trunk/src/include/config_elast.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/config_elast.h?rev=290941=290940=290941=diff
==
--- libcxx/trunk/src/include/config_elast.h (original)
+++ libcxx/trunk/src/include/config_elast.h Tue Jan  3 23:50:01 2017
@@ -10,7 +10,9 @@
 #ifndef _LIBCPP_CONFIG_ELAST
 #define _LIBCPP_CONFIG_ELAST
 
-#if defined(_LIBCPP_MSCVRT)
+#include <__config>
+
+#if defined(_LIBCPP_MSVCRT)
 #include 
 #else
 #include 


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


[libcxx] r290940 - config: MSVC 19+ has unicode chars

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 23:49:59 2017
New Revision: 290940

URL: http://llvm.org/viewvc/llvm-project?rev=290940=rev
Log:
config: MSVC 19+ has unicode chars

MSVC 19+ and clang-cl with emulation version >= 19.00 will provide
char{16,32}_t as builtin types.  Adjust the configuration accordingly.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290940=290939=290940=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Jan  3 23:49:59 2017
@@ -475,7 +475,9 @@ using namespace _LIBCPP_NAMESPACE __attr
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+#if _MSC_VER <= 1800
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif
 #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
 #define _LIBCPP_HAS_NO_NOEXCEPT
 #define __alignof__ __alignof


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


[libcxx] r290938 - build: use more portable spelling for flag

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 23:49:55 2017
New Revision: 290938

URL: http://llvm.org/viewvc/llvm-project?rev=290938=rev
Log:
build: use more portable spelling for flag

Use `CMAKE_LIBRARY_PATH_FLAG` instead of hard-coding it to -L.  This
silences a warning with cl which expects `/LIBPATH` instead.

Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290938=290937=290938=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue Jan  3 23:49:55 2017
@@ -28,8 +28,9 @@ if(NOT LIBCXX_INSTALL_LIBRARY)
   set(exclude_from_all EXCLUDE_FROM_ALL)
 endif()
 
-#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search 
path.
-add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH 
"-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
+# If LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search 
path.
+add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH
+  "${CMAKE_LIBRARY_PATH_FLAG}${LIBCXX_CXX_ABI_LIBRARY_PATH}")
 
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 


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


[libcxxabi] r290937 - tweak definition to avoid GCC warning

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 23:45:24 2017
New Revision: 290937

URL: http://llvm.org/viewvc/llvm-project?rev=290937=rev
Log:
tweak definition to avoid GCC warning

Use an `extern "C" { }` block around the definition rather than doing
the inline definition.  This avoids a GCC warning about a declaration
being extern and having a definition.  NFC.

Modified:
libcxxabi/trunk/src/cxa_handlers.cpp

Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=290937=290936=290937=diff
==
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Tue Jan  3 23:45:24 2017
@@ -104,7 +104,9 @@ terminate() _NOEXCEPT
 
 // In the future this will become:
 // std::atomic  __cxa_new_handler(0);
-extern "C" _LIBCXXABI_DATA_VIS new_handler __cxa_new_handler = 0;
+extern "C" {
+_LIBCXXABI_DATA_VIS new_handler __cxa_new_handler = 0;
+}
 
 new_handler
 set_new_handler(new_handler handler) _NOEXCEPT


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


[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

2017-01-03 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 83000.
hintonda added a comment.

Rollback previous change and instead only call
actOnDelayedExceptionSpecification if noexcept type is not EST_None.


https://reviews.llvm.org/D28258

Files:
  lib/Parse/ParseCXXInlineMethods.cpp


Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -442,13 +442,15 @@
 if (Tok.isNot(tok::eof) || Tok.getEofData() != LM.Method)
   Diag(Tok.getLocation(), diag::err_except_spec_unparsed);
 
-// Attach the exception-specification to the method.
-Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
-   SpecificationRange,
-   DynamicExceptions,
-   DynamicExceptionRanges,
-   NoexceptExpr.isUsable()?
- NoexceptExpr.get() : nullptr);
+if (EST != EST_None) {
+  // Attach the exception-specification to the method.
+  Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
+ SpecificationRange,
+ DynamicExceptions,
+ DynamicExceptionRanges,
+ NoexceptExpr.isUsable()?
+   NoexceptExpr.get() : 
nullptr);
+}
 
 // There could be leftover tokens (e.g. because of an error).
 // Skip through until we reach the original token position.


Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -442,13 +442,15 @@
 if (Tok.isNot(tok::eof) || Tok.getEofData() != LM.Method)
   Diag(Tok.getLocation(), diag::err_except_spec_unparsed);
 
-// Attach the exception-specification to the method.
-Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
-   SpecificationRange,
-   DynamicExceptions,
-   DynamicExceptionRanges,
-   NoexceptExpr.isUsable()?
- NoexceptExpr.get() : nullptr);
+if (EST != EST_None) {
+  // Attach the exception-specification to the method.
+  Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
+ SpecificationRange,
+ DynamicExceptions,
+ DynamicExceptionRanges,
+ NoexceptExpr.isUsable()?
+   NoexceptExpr.get() : nullptr);
+}
 
 // There could be leftover tokens (e.g. because of an error).
 // Skip through until we reach the original token position.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290936 - [clang] Update lit config in utils/perf-training

2017-01-03 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Tue Jan  3 22:33:28 2017
New Revision: 290936

URL: http://llvm.org/viewvc/llvm-project?rev=290936=rev
Log:
[clang] Update lit config in utils/perf-training

This diff replaces --driver-mode=cpp in
utils/perf-training/order-files.lit.cfg and
utils/perf-training/lit.cfg with --driver-mode=g++.
clang --driver-mode=cpp will call the preprocessor and will not
trigger compilation.

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

Modified:
cfe/trunk/utils/perf-training/lit.cfg
cfe/trunk/utils/perf-training/order-files.lit.cfg

Modified: cfe/trunk/utils/perf-training/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/lit.cfg?rev=290936=290935=290936=diff
==
--- cfe/trunk/utils/perf-training/lit.cfg (original)
+++ cfe/trunk/utils/perf-training/lit.cfg Tue Jan  3 22:33:28 2017
@@ -31,7 +31,7 @@ cc1_wrapper = '%s %s/perf-helper.py cc1'
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % 
(config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % 
(config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, 
sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )

Modified: cfe/trunk/utils/perf-training/order-files.lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/order-files.lit.cfg?rev=290936=290935=290936=diff
==
--- cfe/trunk/utils/perf-training/order-files.lit.cfg (original)
+++ cfe/trunk/utils/perf-training/order-files.lit.cfg Tue Jan  3 22:33:28 2017
@@ -37,10 +37,9 @@ if 'darwin' in config.target_triple:
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, 
config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
 
-


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


[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290936: [clang] Update lit config in utils/perf-training 
(authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D28269?vs=82986=82999#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28269

Files:
  cfe/trunk/utils/perf-training/lit.cfg
  cfe/trunk/utils/perf-training/order-files.lit.cfg


Index: cfe/trunk/utils/perf-training/lit.cfg
===
--- cfe/trunk/utils/perf-training/lit.cfg
+++ cfe/trunk/utils/perf-training/lit.cfg
@@ -31,7 +31,7 @@
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % 
(config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % 
(config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, 
sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
Index: cfe/trunk/utils/perf-training/order-files.lit.cfg
===
--- cfe/trunk/utils/perf-training/order-files.lit.cfg
+++ cfe/trunk/utils/perf-training/order-files.lit.cfg
@@ -37,10 +37,9 @@
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, 
config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
 
-


Index: cfe/trunk/utils/perf-training/lit.cfg
===
--- cfe/trunk/utils/perf-training/lit.cfg
+++ cfe/trunk/utils/perf-training/lit.cfg
@@ -31,7 +31,7 @@
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % (config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % (config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
Index: cfe/trunk/utils/perf-training/order-files.lit.cfg
===
--- cfe/trunk/utils/perf-training/order-files.lit.cfg
+++ cfe/trunk/utils/perf-training/order-files.lit.cfg
@@ -37,10 +37,9 @@
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
 
-
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28081: Make GetStyle return Expected instead of FormatStyle

2017-01-03 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D28081#633786, @ioeric wrote:

> The patch LGTM now. I'll accept both this and the one for clang-tool-extra 
> when it is ready.
>
> Regarding builbots, we have bots that continually run builds/tests 
> (http://lab.llvm.org:8011/). Many buildbots test llvm and clang as well as 
> clang-tools-extra (e.g. with `ninja check-all`) at some revision. Also note 
> that although llvm/clang and clang-tools-extra are different repos, they do 
> share the same revision sequence. So if clang-tools-extra is in a 
> inconsistent state, many buildbots can fail and affect llvm/clang builds. 
> Unfortunately, there is no atomic way to commit two revisions to two 
> repositories, so we just commit them quickly one after another so that we do 
> less damage. Do you have commit access to LLVM btw?


I do have commit access. I'll get to work on the clang-tools-extras and open a 
new review for it once it's ready. Thanks.


https://reviews.llvm.org/D28081



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


[PATCH] D27430: [libc++] Annotate template methods with visibility

2017-01-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D27430#634882, @smeenai wrote:

> In https://reviews.llvm.org/D27430#634880, @smeenai wrote:
>
> > Sounds good to me for `_LIBCPP_HIDDEN`, but as far as I understand, for the 
> > `inline _LIBCPP_INLINE_VISIBILITY` cases, at least the `inline` needs to be 
> > at the definition itself, otherwise it won't have any effect.
>
>
> Err this might actually have just been me being stupid. Lemme confirm that 
> first.


Yup, I'm dumb; ignore me. I'll move everything to the declarations.


https://reviews.llvm.org/D27430



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


[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

2017-01-03 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Richard, what do you think about just avoiding the problem altogether by only 
calling actOnDelayedExceptionSpecification is noexcept type != EST_None?


https://reviews.llvm.org/D28258



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


[PATCH] D27430: [libc++] Annotate template methods with visibility

2017-01-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D27430#634880, @smeenai wrote:

> Sounds good to me for `_LIBCPP_HIDDEN`, but as far as I understand, for the 
> `inline _LIBCPP_INLINE_VISIBILITY` cases, at least the `inline` needs to be 
> at the definition itself, otherwise it won't have any effect.


Err this might actually have just been me being stupid. Lemme confirm that 
first.


https://reviews.llvm.org/D27430



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


[PATCH] D27430: [libc++] Annotate template methods with visibility

2017-01-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D27430#632652, @EricWF wrote:

> Please put these attributes to the first declaration instead of the 
> definition.


Sounds good to me for `_LIBCPP_HIDDEN`, but as far as I understand, for the 
`inline _LIBCPP_INLINE_VISIBILITY` cases, at least the `inline` needs to be at 
the definition itself, otherwise it won't have any effect. For those, do you 
want to keep the `_LIBCPP_INLINE_VISIBILITY` at the declaration and the 
`inline` at the definition?




Comment at: include/thread:392
 template 
+_LIBCPP_HIDDEN
 thread::thread(_Fp __f)

EricWF wrote:
> We really should hide this using `inline _LIBCPP_INLINE_VISIBILITY` because 
> it's a special C++03 symbol, so we don't even want a hidden definition 
> omitted ideally.
Will do.


https://reviews.llvm.org/D27430



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


r290933 - Fix deduction of pack elements after a braced-init-list.

2017-01-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jan  3 20:59:16 2017
New Revision: 290933

URL: http://llvm.org/viewvc/llvm-project?rev=290933=rev
Log:
Fix deduction of pack elements after a braced-init-list.

Previously, if the arguments for a parameter pack contained a braced-init-list,
we would abort deduction (keeping the pack deductions from prior arguments) at
the point when we reached the braced-init-list, resulting in wrong deductions
and rejects-valids. We now just leave a "hole" in the pack for such an argument,
which needs to be filled by another deduction of the same pack.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290933=290932=290933=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Jan  3 20:59:16 2017
@@ -3468,12 +3468,8 @@ Sema::TemplateDeductionResult Sema::Dedu
   if (InitListExpr *ILE = dyn_cast(Arg)) {
 TemplateDeductionResult Result;
 if (!DeduceFromInitializerList(*this, TemplateParams, ParamType, ILE,
-   Info, Deduced, TDF, Result)) {
-  // FIXME: Bailing out here is wrong; we could still need to deduce
-  // from later pack elements.
-  ++ArgIdx;
-  break;
-}
+   Info, Deduced, TDF, Result))
+  continue;
 
 if (Result)
   return Result;

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=290933=290932=290933=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Tue Jan  3 
20:59:16 2017
@@ -103,6 +103,12 @@ T deduce(std::initializer_list); // e
 template 
 T deduce_ref(const std::initializer_list&); // expected-note {{conflicting 
types for parameter 'T' ('int' vs. 'double')}}
 
+template struct pair { pair(...); };
+template void deduce_pairs(std::initializer_list>);
+struct WithIntType { typedef int type; };
+
+template void deduce_after_init_list_in_pack(void (*)(T...), 
T...); // expected-note {{ vs. <(no value), double>}}
+
 void argument_deduction() {
   static_assert(same_type::value, "bad 
deduction");
   static_assert(same_type::value, 
"bad deduction");
@@ -113,6 +119,14 @@ void argument_deduction() {
   static_assert(same_type::value, "bad deduction");
 
   deduce_ref({1, 2.0}); // expected-error {{no matching function}}
+
+  pair pi;
+  pair pf;
+  deduce_pairs({pi, pi, pi}); // ok
+  deduce_pairs({pi, pf, pi}); // FIXME: This should be rejected, as we fail to 
produce a type that exactly matches the argument type.
+
+  deduce_after_init_list_in_pack((void(*)(int,int))0, {}, 0);
+  deduce_after_init_list_in_pack((void(*)(int,int))0, {}, 0.0); // 
expected-error {{no matching function}}
 }
 
 void auto_deduction() {


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


[PATCH] D28274: [MS] Instantiate default args during instantiation of exported default ctors

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: rsmith.
rnk added a subscriber: cfe-commits.

Replace some old code that probably pre-dated the change to delay
emission of dllexported code until after the closing brace of the
outermost record type. Only uninstantiated default argument expressions
need to be handled now. It is enough to instantiate default argument
expressions when instantiating dllexported default ctors. This also
fixes some double-diagnostic issues in this area.

Fixes PR31500


https://reviews.llvm.org/D28274

Files:
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGenCXX/dllexport.cpp
  test/SemaCXX/default-arg-closures.cpp
  test/SemaCXX/dllexport.cpp

Index: test/SemaCXX/dllexport.cpp
===
--- test/SemaCXX/dllexport.cpp
+++ test/SemaCXX/dllexport.cpp
@@ -741,6 +741,27 @@
   ClassWithMultipleDefaultCtors(int = 40) {} // expected-error{{'__declspec(dllexport)' cannot be applied to more than one default constructor}}
   ClassWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared here}}
 };
+template 
+struct ClassTemplateWithMultipleDefaultCtors {
+  __declspec(dllexport) ClassTemplateWithMultipleDefaultCtors(int = 40) {}  // expected-error{{'__declspec(dllexport)' cannot be applied to more than one default constructor}}
+  __declspec(dllexport) ClassTemplateWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared here}}
+};
+
+template  struct HasDefaults {
+  HasDefaults(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template struct __declspec(dllexport) HasDefaults;
+
+template struct
+__declspec(dllexport) // expected-note {{in instantiation of default function argument expression for 'HasDefaults' required here}}
+HasDefaults; // expected-note {{in instantiation of member function 'HasDefaults::HasDefaults' requested here}}
+
+template  struct HasDefaults2 {
+  __declspec(dllexport) // expected-note {{in instantiation of default function argument expression for 'HasDefaults2' required here}}
+  HasDefaults2(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template struct HasDefaults2; // expected-note {{in instantiation of member function 'HasDefaults2::HasDefaults2' requested here}}
+
 #endif
 
 //===--===//
Index: test/SemaCXX/default-arg-closures.cpp
===
--- test/SemaCXX/default-arg-closures.cpp
+++ test/SemaCXX/default-arg-closures.cpp
@@ -4,16 +4,15 @@
 // instantiating and checking the semantics of default arguments. Make sure we
 // do that right.
 
-// FIXME: Don't diagnose this issue twice.
 template 
-struct DependentDefaultCtorArg { // expected-note {{in instantiation of default function argument}}
-  // expected-error@+1 2 {{type 'int' cannot be used prior to '::' because it has no members}}
+struct DependentDefaultCtorArg {
+  // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}}
   DependentDefaultCtorArg(int n = T::error);
 };
 struct
 __declspec(dllexport) // expected-note {{due to 'ExportDefaultCtorClosure' being dllexported}}
-ExportDefaultCtorClosure // expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}
-: DependentDefaultCtorArg // expected-note {{in instantiation of template class}}
+ExportDefaultCtorClosure // expected-note {{in instantiation of default function argument expression for 'DependentDefaultCtorArg' required here}} expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}
+: DependentDefaultCtorArg
 {};
 
 template 
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -515,6 +515,18 @@
 // M32-DAG:   ret void
 };
 
+template  struct TemplateWithClosure {
+  TemplateWithClosure(int x = sizeof(T)) {}
+};
+extern template struct TemplateWithClosure;
+template struct __declspec(dllexport) TemplateWithClosure;
+extern template struct TemplateWithClosure;
+template struct __declspec(dllexport) TemplateWithClosure;
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@D@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// M32-DAG:   call {{.*}} @"\01??0?$TemplateWithClosure@D@@QAE@H@Z"({{.*}}, i32 1)
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// M32-DAG:   call {{.*}} @"\01??0?$TemplateWithClosure@H@@QAE@H@Z"({{.*}}, i32 4)
+
 struct __declspec(dllexport) NestedOuter {
   DELETE_IMPLICIT_MEMBERS(NestedOuter);
   NestedOuter(void *p = 0) {}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- 

[PATCH] D28165: Change clang-format's Chromium JavaScript defaults

2017-01-03 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

http://llvm.org/viewvc/llvm-project?view=revision=290930


https://reviews.llvm.org/D28165



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


r290930 - Change clang-format's Chromium JavaScript defaults

2017-01-03 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Jan  3 20:33:36 2017
New Revision: 290930

URL: http://llvm.org/viewvc/llvm-project?rev=290930=rev
Log:
Change clang-format's Chromium JavaScript defaults

Chromium is starting to use clang-format on more JavaScript.

In doing this, we discovered that our defaults were not doing a good job
differentiating between JS and C++.

This change moves some defaults to only apply to C++.
https://reviews.llvm.org/D28165

Patch from Dan Beam !

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=290930=290929=290930=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Jan  3 20:33:36 2017
@@ -638,6 +638,9 @@ FormatStyle getChromiumStyle(FormatStyle
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+  } else if (Language == FormatStyle::LK_JavaScript) {
+ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
 ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;


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


[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D28269



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


[PATCH] D28165: Change clang-format's Chromium JavaScript defaults

2017-01-03 Thread Dan Beam via Phabricator via cfe-commits
danbeam updated this revision to Diff 82989.
danbeam marked an inline comment as done.
danbeam added a comment.

setting up arc


https://reviews.llvm.org/D28165

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -638,6 +638,9 @@
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+  } else if (Language == FormatStyle::LK_JavaScript) {
+ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
 ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -638,6 +638,9 @@
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+  } else if (Language == FormatStyle::LK_JavaScript) {
+ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
 ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290926 - Remove accidentally-added lines in r290923 test, and add another testcase.

2017-01-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jan  3 20:03:39 2017
New Revision: 290926

URL: http://llvm.org/viewvc/llvm-project?rev=290926=rev
Log:
Remove accidentally-added lines in r290923 test, and add another testcase.

Modified:
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=290926=290925=290926=diff
==
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Tue Jan  3 20:03:39 2017
@@ -385,8 +385,6 @@ namespace overload_vs_pack {
 
   int n1 = g1(X(), f, g); // expected-error {{no matching 
function}}
   int n2 = g2(x, f, g); // expected-error {{no matching function}}
-  int n3 = g1(X(), f);
-  int n4 = g2(x, f);
 
   int  = h1(0); // ok, skip deduction for 'f's, deduce matching 
value from 'g'
   int  = h2(0);
@@ -399,4 +397,13 @@ namespace overload_vs_pack {
 
   template int partial_deduction_2(void (*...f)(T), ...); // 
expected-note {{deduced incomplete pack <(no value), double> for template 
parameter 'T'}}
   int pd2 = partial_deduction_2(f, g); // expected-error {{no matching 
function}}
+
+  namespace cwg_example {
+void f(char, char);
+void f(int, int);
+void x(int, char);
+
+template void j(void(*)(U...), void 
(*...fns)(T, U));
+void test() { j(x, f, x); }
+  }
 }


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


[PATCH] D28271: [Sema] Get rid of unused default argument to Sema::CheckCallingConvAttr.

2017-01-03 Thread Justin Lebar via Phabricator via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added a subscriber: cfe-commits.

All callers of CheckCallingConvAttr passed FD == nullptr, so just get
rid of the aspirational function arg.


https://reviews.llvm.org/D28271

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3869,7 +3869,7 @@
   // Diagnostic is emitted elsewhere: here we store the (valid) Attr
   // in the Decl node for syntactic reasoning, e.g., pretty-printing.
   CallingConv CC;
-  if (S.CheckCallingConvAttr(Attr, CC, /*FD*/nullptr))
+  if (S.CheckCallingConvAttr(Attr, CC))
 return;
 
   if (!isa(D)) {
@@ -3964,8 +3964,7 @@
   }
 }
 
-bool Sema::CheckCallingConvAttr(const AttributeList , CallingConv , 
-const FunctionDecl *FD) {
+bool Sema::CheckCallingConvAttr(const AttributeList , CallingConv ) {
   if (attr.isInvalid())
 return true;
 
@@ -4030,12 +4029,8 @@
 
 // This convention is not valid for the target. Use the default function or
 // method calling convention.
-bool IsCXXMethod = false, IsVariadic = false;
-if (FD) {
-  IsCXXMethod = FD->isCXXInstanceMember();
-  IsVariadic = FD->isVariadic();
-}
-CC = Context.getDefaultCallingConvention(IsVariadic, IsCXXMethod);
+CC = Context.getDefaultCallingConvention(/*IsVariadic=*/false,
+ /*IsCXXMethod=*/false);
   }
 
   attr.setProcessingCache((unsigned) CC);
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3070,8 +3070,7 @@
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   bool CheckRegparmAttr(const AttributeList , unsigned );
-  bool CheckCallingConvAttr(const AttributeList , CallingConv ,
-const FunctionDecl *FD = nullptr);
+  bool CheckCallingConvAttr(const AttributeList , CallingConv );
   bool CheckNoReturnAttr(const AttributeList );
   bool checkStringLiteralArgumentAttr(const AttributeList ,
   unsigned ArgNum, StringRef ,


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3869,7 +3869,7 @@
   // Diagnostic is emitted elsewhere: here we store the (valid) Attr
   // in the Decl node for syntactic reasoning, e.g., pretty-printing.
   CallingConv CC;
-  if (S.CheckCallingConvAttr(Attr, CC, /*FD*/nullptr))
+  if (S.CheckCallingConvAttr(Attr, CC))
 return;
 
   if (!isa(D)) {
@@ -3964,8 +3964,7 @@
   }
 }
 
-bool Sema::CheckCallingConvAttr(const AttributeList , CallingConv , 
-const FunctionDecl *FD) {
+bool Sema::CheckCallingConvAttr(const AttributeList , CallingConv ) {
   if (attr.isInvalid())
 return true;
 
@@ -4030,12 +4029,8 @@
 
 // This convention is not valid for the target. Use the default function or
 // method calling convention.
-bool IsCXXMethod = false, IsVariadic = false;
-if (FD) {
-  IsCXXMethod = FD->isCXXInstanceMember();
-  IsVariadic = FD->isVariadic();
-}
-CC = Context.getDefaultCallingConvention(IsVariadic, IsCXXMethod);
+CC = Context.getDefaultCallingConvention(/*IsVariadic=*/false,
+ /*IsCXXMethod=*/false);
   }
 
   attr.setProcessingCache((unsigned) CC);
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3070,8 +3070,7 @@
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   bool CheckRegparmAttr(const AttributeList , unsigned );
-  bool CheckCallingConvAttr(const AttributeList , CallingConv ,
-const FunctionDecl *FD = nullptr);
+  bool CheckCallingConvAttr(const AttributeList , CallingConv );
   bool CheckNoReturnAttr(const AttributeList );
   bool checkStringLiteralArgumentAttr(const AttributeList ,
   unsigned ArgNum, StringRef ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 82986.
alexshap added a comment.

switch to --driver-mode=g++


Repository:
  rL LLVM

https://reviews.llvm.org/D28269

Files:
  utils/perf-training/lit.cfg
  utils/perf-training/order-files.lit.cfg


Index: utils/perf-training/order-files.lit.cfg
===
--- utils/perf-training/order-files.lit.cfg
+++ utils/perf-training/order-files.lit.cfg
@@ -37,10 +37,9 @@
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, 
config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
 
-
Index: utils/perf-training/lit.cfg
===
--- utils/perf-training/lit.cfg
+++ utils/perf-training/lit.cfg
@@ -31,7 +31,7 @@
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % 
(config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % 
(config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, 
sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )


Index: utils/perf-training/order-files.lit.cfg
===
--- utils/perf-training/order-files.lit.cfg
+++ utils/perf-training/order-files.lit.cfg
@@ -37,10 +37,9 @@
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=g++ %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
 
-
Index: utils/perf-training/lit.cfg
===
--- utils/perf-training/lit.cfg
+++ utils/perf-training/lit.cfg
@@ -31,7 +31,7 @@
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % (config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % (config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r290924 - Refactor bitscan64 check

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 19:53:24 2017
New Revision: 290924

URL: http://llvm.org/viewvc/llvm-project?rev=290924=rev
Log:
Refactor bitscan64 check

Introduce a `_LIBCPP_HAS_BITSCAN64` macro to specify if the 64-bit
variant of the bitscan family of APIs is available.  This avoids
duplicating the check in the support header.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/support/win32/support.h

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290924=290923=290924=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Jan  3 19:53:24 2017
@@ -173,6 +173,9 @@
 #  ifndef __MINGW32__
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
+#  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || 
defined(__arm__))
+#define _LIBCPP_HAS_BITSCAN64
+#  endif
 #endif // defined(_WIN32)
 
 #ifdef __sun__

Modified: libcxx/trunk/include/support/win32/support.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/support.h?rev=290924=290923=290924=diff
==
--- libcxx/trunk/include/support/win32/support.h (original)
+++ libcxx/trunk/include/support/win32/support.h Tue Jan  3 19:53:24 2017
@@ -110,7 +110,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzl
   unsigned long where;
 // Search from LSB to MSB for first set bit.
 // Returns zero if no set bit is found.
-#if (defined(_M_ARM) || defined(__arm__)) ||   
\
+#if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
   if (_BitScanForward64(, mask))
 return static_cast(where);
@@ -151,8 +151,7 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzl
   unsigned long where;
 // BitScanReverse scans from MSB to LSB for first set bit.
 // Returns 0 if no set bit is found.
-#if (defined(_M_ARM) || defined(__arm__)) ||   
\
-(defined(_M_AMD64) || defined(__x86_64__))
+#if defined(_LIBCPP_HAS_BITSCAN64)
   if (_BitScanReverse64(, mask))
 return static_cast(63 - where);
 #else


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


[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 82985.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

Stripped out the codegen changes since @rnk 's commit fixed the issue.


https://reviews.llvm.org/D28166

Files:
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  lib/Sema/SemaDecl.cpp
  test/Sema/knr-def-call.c
  test/Sema/warn-strict-prototypes.c

Index: test/Sema/warn-strict-prototypes.c
===
--- test/Sema/warn-strict-prototypes.c
+++ test/Sema/warn-strict-prototypes.c
@@ -60,3 +60,8 @@
 // K function definition with previous prototype declared is not diagnosed.
 void foo11(int p, int p2);
 void foo11(p, p2) int p; int p2; {}
+
+// PR31020
+void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
+  short d;
+{}
Index: test/Sema/knr-def-call.c
===
--- test/Sema/knr-def-call.c
+++ test/Sema/knr-def-call.c
@@ -39,3 +39,9 @@
   proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
   ()(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
 }
+
+// PR31020
+void func(short d) __attribute__((cdecl)); // expected-note{{previous declaration is here}}
+void __attribute__((cdecl)) func(d)
+  short d; // expected-warning{{promoted type 'int' of K function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
+{}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7458,11 +7458,12 @@
 // Determine whether the function was written with a
 // prototype. This true when:
 //   - there is a prototype in the declarator, or
-//   - the type R of the function is some kind of typedef or other reference
-// to a type name (which eventually refers to a function type).
+//   - the type R of the function is some kind of typedef or other non-
+// attributed reference to a type name (which eventually refers to a
+// function type).
 bool HasPrototype =
   (D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) ||
-  (!isa(R.getTypePtr()) && R->isFunctionProtoType());
+  (!R->getAsAdjusted() && R->isFunctionProtoType());
 
 NewFD = FunctionDecl::Create(SemaRef.Context, DC,
  D.getLocStart(), NameInfo, R,
@@ -11950,7 +11951,7 @@
   !LangOpts.CPlusPlus) {
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
-FunctionTypeLoc FTL = TL.castAs();
+FunctionTypeLoc FTL = TL.getAsAdjusted();
 Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1;
   }
 }
Index: include/clang/AST/TypeLoc.h
===
--- include/clang/AST/TypeLoc.h
+++ include/clang/AST/TypeLoc.h
@@ -70,6 +70,26 @@
 return t;
   }
 
+  /// \brief Convert to the specified TypeLoc type, returning a null TypeLoc if
+  /// this TypeLock is not of the desired type. It will consider type
+  /// adjustments from a type that wad written as a T to another type that is
+  /// still canonically a T (ignores parens, attributes, elaborated types, etc).
+  template 
+  T getAsAdjusted() const {
+TypeLoc Cur = *this;
+while (!T::isKind(Cur)) {
+  if (auto PTL = Cur.getAs())
+Cur = PTL.getInnerLoc();
+  else if (auto ATL = Cur.getAs())
+Cur = ATL.getModifiedLoc();
+  else if (auto ETL = Cur.getAs())
+Cur = ETL.getNamedTypeLoc();
+  else
+break;
+}
+return Cur.getAs();
+  }
+
   /// The kinds of TypeLocs.  Equivalent to the Type::TypeClass enum,
   /// except it also defines a Qualified enum that corresponds to the
   /// QualifiedLoc class.
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1875,6 +1875,13 @@
   /// immediately following this class.
   template  const T *getAs() const;
 
+  /// Member-template getAsAdjusted. Look through specific kinds
+  /// of sugar (parens, attributes, etc) for an instance of \.
+  /// This is used when you need to walk over sugar nodes that represent some
+  /// kind of type adjustment from a type that was written as a \
+  /// to another type that is still canonically a \.
+  template  const T *getAsAdjusted() const;
+
   /// A variant of getAs<> for array types which silently discards
   /// qualifiers from the outermost type.
   const ArrayType *getAsArrayTypeUnsafe() const;
@@ -5932,6 +5939,36 @@
   return cast(getUnqualifiedDesugaredType());
 }
 
+template  const T *Type::getAsAdjusted() const {
+  static_assert(!TypeIsArrayType::value, "ArrayType 

[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.h:3570
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr));
 

rnk wrote:
> rnk wrote:
> > rnk wrote:
> > > I'm testing this change:
> > > ```
> > > $ git diff
> > > diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
> > > index acf8863..2662ebb 100644
> > > --- a/lib/CodeGen/CodeGenFunction.h
> > > +++ b/lib/CodeGen/CodeGenFunction.h
> > > @@ -3571,7 +3571,8 @@ public:
> > > 
> > >  // If we still have any arguments, emit them using the type of the 
> > > argument.
> > >  for (auto *A : llvm::make_range(Arg, ArgRange.end()))
> > > -  ArgTypes.push_back(getVarArgType(A));
> > > +  ArgTypes.push_back(CalleeDecl->isVariadic() ? getVarArgType(A)
> > > +  : A->getType());
> > > 
> > >  EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip, 
> > > Order);
> > >}
> > > 
> > > ```
> > > 
> > > I'd like to fix this issue in a separate commit.
> > So, that didn't work at all, but the gist of it is that I don't think we 
> > should call a function like `getVarArgType` when we aren't lowering a 
> > variadic function call. I'll look into doing it.
> rL290906 should fix it.
Thanks! I prefer the way you implemented it and agree about the naming. I 
thought of that after I sent the patch, but then got pulled away before I could 
correct it. :-P


https://reviews.llvm.org/D28166



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


r290923 - Fix template argument deduction when only some of a parameter pack is a non-deduced context.

2017-01-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jan  3 19:48:55 2017
New Revision: 290923

URL: http://llvm.org/viewvc/llvm-project?rev=290923=rev
Log:
Fix template argument deduction when only some of a parameter pack is a 
non-deduced context.

When a parameter pack has multiple corresponding arguments, and some subset of
them are overloaded functions, it's possible that some subset of the parameters
are non-deduced contexts. In such a case, keep deducing from the remainder of
the arguments, and resolve the incomplete pack against whatever other
deductions we've performed for the pack.

GCC, MSVC, and ICC give three different bad behaviors for this case; what we do
now (and what we did before) don't exactly match any of them, sadly :( I'm
getting a core issue opened to specify more precisely how this should be
handled.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290923=290922=290923=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan  3 19:48:55 
2017
@@ -3921,6 +3921,8 @@ def ext_ms_deref_template_argument: ExtW
 def ext_ms_delayed_template_argument: ExtWarn<
   "using the undeclared type %0 as a default template argument is a "
   "Microsoft extension">, InGroup;
+def err_template_arg_deduced_incomplete_pack : Error<
+  "deduced incomplete pack %0 for template parameter %1">;
 
 // C++ template specialization
 def err_template_spec_unknown_kind : Error<

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290923=290922=290923=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Jan  3 19:48:55 2017
@@ -288,19 +288,22 @@ checkDeducedTemplateArguments(ASTContext
 X.pack_size() != Y.pack_size())
   return DeducedTemplateArgument();
 
+llvm::SmallVector NewPack;
 for (TemplateArgument::pack_iterator XA = X.pack_begin(),
   XAEnd = X.pack_end(),
  YA = Y.pack_begin();
  XA != XAEnd; ++XA, ++YA) {
-  // FIXME: Do we need to merge the results together here?
-  if (checkDeducedTemplateArguments(Context,
-DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
-DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound()))
-.isNull())
+  TemplateArgument Merged = checkDeducedTemplateArguments(
+  Context, DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()),
+  DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound()));
+  if (Merged.isNull())
 return DeducedTemplateArgument();
+  NewPack.push_back(Merged);
 }
 
-return X;
+return DeducedTemplateArgument(
+TemplateArgument::CreatePackCopy(Context, NewPack),
+X.wasDeducedFromArrayBound() && Y.wasDeducedFromArrayBound());
   }
 
   llvm_unreachable("Invalid TemplateArgument Kind!");
@@ -672,17 +675,20 @@ public:
 // for that pack, then clear out the deduced argument.
 for (auto  : Packs) {
   DeducedTemplateArgument  = Deduced[Pack.Index];
-  if (!DeducedArg.isNull()) {
+  if (!Pack.New.empty() || !DeducedArg.isNull()) {
+while (Pack.New.size() < PackElements)
+  Pack.New.push_back(DeducedTemplateArgument());
 Pack.New.push_back(DeducedArg);
 DeducedArg = DeducedTemplateArgument();
   }
 }
+++PackElements;
   }
 
   /// \brief Finish template argument deduction for a set of argument packs,
   /// producing the argument packs and checking for consistency with prior
   /// deductions.
-  Sema::TemplateDeductionResult finish(bool HasAnyArguments) {
+  Sema::TemplateDeductionResult finish() {
 // Build argument packs for each of the parameter packs expanded by this
 // pack expansion.
 for (auto  : Packs) {
@@ -691,7 +697,7 @@ public:
 
   // Build or find a new value for this pack.
   DeducedTemplateArgument NewPack;
-  if (HasAnyArguments && Pack.New.empty()) {
+  if (PackElements && Pack.New.empty()) {
 if (Pack.DeferredDeduction.isNull()) {
   // We were not able to deduce anything for this parameter pack
   // (because it only appeared in non-deduced contexts), so just
@@ -758,6 +764,7 @@ private:
   TemplateParameterList *TemplateParams;
   SmallVectorImpl 
   TemplateDeductionInfo 
+  unsigned PackElements = 0;
 
   SmallVector 

[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

btw: --driver-mode=g++ works as well


Repository:
  rL LLVM

https://reviews.llvm.org/D28269



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


[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

it works for me, i have just double checked. Although to generate a file which 
provides any measurable improvements (was i measuring the total build time of 
LLVM (using the new binary)) i had to make some extra changes 
(on OSX 10.12.1) (slightly change dtrace script, replace hello_world.cpp with a 
preprocessed version of Sema.cpp)


Repository:
  rL LLVM

https://reviews.llvm.org/D28269



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


[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82983.
compnerd marked 3 inline comments as done.
compnerd added a comment.

Use l-values, static_cast.


Repository:
  rL LLVM

https://reviews.llvm.org/D28226

Files:
  include/__threading_support
  include/mutex

Index: include/mutex
===
--- include/mutex
+++ include/mutex
@@ -206,7 +206,7 @@
 
 class _LIBCPP_TYPE_VIS recursive_mutex
 {
-__libcpp_mutex_t __m_;
+__libcpp_recursive_mutex_t __m_;
 
 public:
  recursive_mutex();
@@ -221,7 +221,7 @@
 bool try_lock() _NOEXCEPT;
 void unlock()  _NOEXCEPT;
 
-typedef __libcpp_mutex_t* native_handle_type;
+typedef __libcpp_recursive_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY
 native_handle_type native_handle() {return &__m_;}
 };
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -63,6 +63,8 @@
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
+typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
@@ -81,21 +83,56 @@
 typedef pthread_key_t __libcpp_tls_key;
 #endif
 
+struct __libcpp_mutex_reference {
+  const bool __recursive;
+  void * const __value;
+
+  _LIBCPP_CONSTEXPR
+  __libcpp_mutex_reference(__libcpp_mutex_t* m) _NOEXCEPT
+  : __recursive(false), __value(m)
+  {
+  }
+
+  template ::value>::type>
+  _LIBCPP_CONSTEXPR
+  __libcpp_mutex_reference(__libcpp_recursive_mutex_t* m) _NOEXCEPT
+  : __recursive(true), __value(m)
+  {
+  }
+
+  operator __libcpp_mutex_t*() const _NOEXCEPT
+  {
+return static_cast<__libcpp_mutex_t*>(__value);
+  }
+
+  template ::value>::type>
+  operator __libcpp_recursive_mutex_t*() const _NOEXCEPT
+  {
+return static_cast<__libcpp_recursive_mutex_t*>(__value);
+  }
+};
+
 // Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_lock(__libcpp_mutex_reference __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_trylock(__libcpp_mutex_reference __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_unlock(__libcpp_mutex_reference __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
+int __libcpp_mutex_destroy(__libcpp_mutex_reference __m);
 
 // Condition variable
 _LIBCPP_THREAD_ABI_VISIBILITY
@@ -105,11 +142,12 @@
 int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv,
+  __libcpp_mutex_reference __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts);
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference __m, timespec* __ts);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
@@ -164,7 +202,7 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
 defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
 
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
   pthread_mutexattr_t attr;
   int __ec = pthread_mutexattr_init();
@@ -188,22 +226,22 @@
   return 0;
 }
 
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_lock(__libcpp_mutex_reference __m)
 {
   return pthread_mutex_lock(__m);
 }
 
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_trylock(__libcpp_mutex_reference __m)
 {
   return pthread_mutex_trylock(__m);
 }
 
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+int __libcpp_mutex_unlock(__libcpp_mutex_reference __m)
 {
   return pthread_mutex_unlock(__m);
 }
 
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+int __libcpp_mutex_destroy(__libcpp_mutex_reference __m)
 {
   return pthread_mutex_destroy(__m);
 }
@@ -219,13 +257,14 @@
   return pthread_cond_broadcast(__cv);
 }
 
-int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv,
+  __libcpp_mutex_reference __m)
 {
   return pthread_cond_wait(__cv, __m);
 }
 
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
-   timespec *__ts)
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+ 

[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 3 inline comments as done.
compnerd added inline comments.



Comment at: include/__threading_support:91
+  {
+return reinterpret_cast<__libcpp_mutex_t*>(__value);
+  }

EricWF wrote:
> Wouldn't a `static_cast` be valid here?
Yeah.



Comment at: include/__threading_support:110
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY

EricWF wrote:
> This uses C++11 features but is limited to C++03. Although we can technically 
> cheat and use Clang extended rvalue references here.
Switched to pass-by-value.



Comment at: include/__threading_support:112
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m);
 

EricWF wrote:
> Won't we ever want to pass an lvalue here?
Just changed it to a pass-by-value, which is a l-value.


Repository:
  rL LLVM

https://reviews.llvm.org/D28226



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


[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I don't think this works either. Pretty sure not setting the driver mode 
defaults it to gcc, when we should be setting it to g++.

Can you try setting driver mode to g++ instead of removing the flag?


Repository:
  rL LLVM

https://reviews.llvm.org/D28269



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


[PATCH] D28269: [clang] Update lit config in utils/perf-training

2017-01-03 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
alexshap added reviewers: mehdi_amini, beanz, bogner.
alexshap added a subscriber: cfe-commits.
alexshap set the repository for this revision to rL LLVM.

This diff removes --driver-mode=cpp from 
utils/perf-training/order-files.lit.cfg and
utils/perf-training/lit.cfg .
clang --driver-mode=cpp will call the preprocessor and will not
trigger the compilation.


Repository:
  rL LLVM

https://reviews.llvm.org/D28269

Files:
  utils/perf-training/lit.cfg
  utils/perf-training/order-files.lit.cfg


Index: utils/perf-training/order-files.lit.cfg
===
--- utils/perf-training/order-files.lit.cfg
+++ utils/perf-training/order-files.lit.cfg
@@ -37,8 +37,8 @@
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s 
--driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % 
(dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % 
(dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s %s ' % (dtrace_wrapper, 
config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, 
config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
Index: utils/perf-training/lit.cfg
===
--- utils/perf-training/lit.cfg
+++ utils/perf-training/lit.cfg
@@ -31,7 +31,7 @@
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % 
(config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s ' % (config.clang, 
sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % 
(cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, 
sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )


Index: utils/perf-training/order-files.lit.cfg
===
--- utils/perf-training/order-files.lit.cfg
+++ utils/perf-training/order-files.lit.cfg
@@ -37,8 +37,8 @@
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
-config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (dtrace_wrapper_cc1, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
Index: utils/perf-training/lit.cfg
===
--- utils/perf-training/lit.cfg
+++ utils/perf-training/lit.cfg
@@ -31,7 +31,7 @@
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")
 config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
-config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=cpp %s ' % (config.clang, sysroot_flags)))
+config.substitutions.append( ('%clang_cpp', ' %s %s ' % (config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
 config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) )
 config.substitutions.append( ('%test_root', config.test_exec_root ) )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r290922 - [libcxx] [test] Strip trailing whitespace.

2017-01-03 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Tue Jan  3 18:53:41 2017
New Revision: 290922

URL: http://llvm.org/viewvc/llvm-project?rev=290922=rev
Log:
[libcxx] [test] Strip trailing whitespace.

Fixes D27786.

Modified:

libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp

libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp

libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp

libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp

libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp?rev=290922=290921=290922=diff
==
--- 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_or.pass.cpp
 Tue Jan  3 18:53:41 2017
@@ -19,7 +19,7 @@ namespace ex = std::experimental;
 
 template 
   using hasFoo = typename T::Foo;
-  
+
 struct yesFoo {
 using Foo = int;
 };

Modified: 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp?rev=290922=290921=290922=diff
==
--- 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/detected_t.pass.cpp
 Tue Jan  3 18:53:41 2017
@@ -19,7 +19,7 @@ namespace ex = std::experimental;
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };

Modified: 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp?rev=290922=290921=290922=diff
==
--- 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp
 Tue Jan  3 18:53:41 2017
@@ -19,7 +19,7 @@ namespace ex = std::experimental;
 
 template 
   using copy_assign_t = decltype(std::declval() = std::declval());
-  
+
 struct not_assignable {
 not_assignable & operator=(const not_assignable&) = delete;
 };

Modified: 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp?rev=290922=290921=290922=diff
==
--- 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_convertible.pass.cpp
 Tue Jan  3 18:53:41 2017
@@ -19,7 +19,7 @@ namespace ex = std::experimental;
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };

Modified: 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp?rev=290922=290921=290922=diff
==
--- 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/utilities/meta/meta.detect/is_detected_exact.pass.cpp
 Tue Jan  3 18:53:41 2017
@@ -19,7 +19,7 @@ namespace ex = std::experimental;
 
 template 
   using callFoo = decltype(std::declval().Foo());
-  
+
 struct yesFoo {
 int Foo() { return 0; }
 };


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


[libcxx] r290921 - [libcxx] [test] Fix recently introduced warnings emitted by MSVC.

2017-01-03 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Tue Jan  3 18:53:31 2017
New Revision: 290921

URL: http://llvm.org/viewvc/llvm-project?rev=290921=rev
Log:
[libcxx] [test] Fix recently introduced warnings emitted by MSVC.

These tests were using malloc()'s return value without checking for null,
which MSVC's /analyze rightly warns about. Asserting that the pointer is
non-null both expresses the test's intention and silences the warning.

Fixes D27785.

Modified:

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp

libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp?rev=290921=290920=290921=diff
==
--- 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp
 Tue Jan  3 18:53:31 2017
@@ -42,6 +42,7 @@ void test_no_inner_alloc()
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, 
"");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Alloc CA(P);
 SA A(CA);
 const PairIn in(x, std::move(y));
@@ -68,6 +69,7 @@ void test_no_inner_alloc()
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, 
"");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Alloc CA(P);
 SA A(CA);
 const PairIn in(x, y);
@@ -104,6 +106,7 @@ void test_with_inner_alloc()
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
@@ -134,6 +137,7 @@ void test_with_inner_alloc()
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);

Modified: 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp?rev=290921=290920=290921=diff
==
--- 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp
 Tue Jan  3 18:53:31 2017
@@ -42,6 +42,7 @@ void test_no_inner_alloc()
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, 
"");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr, std::piecewise_construct,
@@ -68,6 +69,7 @@ void test_no_inner_alloc()
 using SA = std::scoped_allocator_adaptor;
 static_assert(std::uses_allocator::value, 
"");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Alloc CA(P);
 SA A(CA);
 A.construct(ptr, std::piecewise_construct,
@@ -104,6 +106,7 @@ void test_with_inner_alloc()
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Outer O(POuter);
 Inner I(PInner);
 SA A(O, I);
@@ -134,6 +137,7 @@ void test_with_inner_alloc()
 static_assert(!std::uses_allocator::value, "");
 static_assert(std::uses_allocator::value, "");
 Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
+assert(ptr != nullptr);
 Outer O(POuter);
 Inner I(PInner);
   

r290920 - Extend -Wtautological-overlap-compare to more cases.

2017-01-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Jan  3 18:46:30 2017
New Revision: 290920

URL: http://llvm.org/viewvc/llvm-project?rev=290920=rev
Log:
Extend -Wtautological-overlap-compare to more cases.

Previously, -Wtautological-overlap-compare did not warn on cases where the
boolean expression was in an assignment or return statement.  This patch
should cause all boolean statements to be passed to the tautological compare
checks in the CFG analysis.

This is one of the issues from PR13101

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Sema/warn-overlap.c

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=290920=290919=290920=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Jan  3 18:46:30 2017
@@ -1690,15 +1690,19 @@ CFGBuilder::VisitLogicalOperator(BinaryO
 // we have been provided.
 ExitBlock = RHSBlock = createBlock(false);
 
+// Even though KnownVal is only used in the else branch of the next
+// conditional, tryEvaluateBool performs additional checking on the
+// Expr, so it should be called unconditionally.
+TryResult KnownVal = tryEvaluateBool(RHS);
+if (!KnownVal.isKnown())
+  KnownVal = tryEvaluateBool(B);
+
 if (!Term) {
   assert(TrueBlock == FalseBlock);
   addSuccessor(RHSBlock, TrueBlock);
 }
 else {
   RHSBlock->setTerminator(Term);
-  TryResult KnownVal = tryEvaluateBool(RHS);
-  if (!KnownVal.isKnown())
-KnownVal = tryEvaluateBool(B);
   addSuccessor(RHSBlock, TrueBlock, !KnownVal.isFalse());
   addSuccessor(RHSBlock, FalseBlock, !KnownVal.isTrue());
 }

Modified: cfe/trunk/test/Sema/warn-overlap.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-overlap.c?rev=290920=290919=290920=diff
==
--- cfe/trunk/test/Sema/warn-overlap.c (original)
+++ cfe/trunk/test/Sema/warn-overlap.c Tue Jan  3 18:46:30 2017
@@ -96,3 +96,48 @@ void array_out_of_bounds() {
   int buffer[4];
   x = (-7 > 0) ? (buffer[-7]) : 0;
 }
+
+void bool_contexts(int x) {
+  if (x > 4 || x < 10) {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  for (;x > 4 || x < 10;) {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  while (x > 4 || x < 10) {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  do {} while (x > 4 || x < 10);
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  x = (x > 4 || x < 10) ? 1 : 2;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  if ((void)5, x > 4 || x < 10) {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+}
+
+void assignment(int x) {
+  int a = x > 4 || x < 10;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  int b = x < 2 && x > 5;
+  // expected-warning@-1{{overlapping comparisons always evaluate to false}}
+
+  int c = x != 1 || x != 3;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  int d = x == 1 && x == 2;
+  // expected-warning@-1{{overlapping comparisons always evaluate to false}}
+
+  int e = x < 1 || x != 0;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+}
+
+int returns(int x) {
+  return x > 4 || x < 10;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  return x < 2 && x > 5;
+  // expected-warning@-1{{overlapping comparisons always evaluate to false}}
+
+  return x != 1 || x != 3;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  return x == 1 && x == 2;
+  // expected-warning@-1{{overlapping comparisons always evaluate to false}}
+
+  return x < 1 || x != 0;
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+}


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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-01-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:13499
+  if (Attr)
+ProcessDeclAttributeList(S, New, Attr);
+

I wasn't sure if this was the correct change in here.  My other option was to 
move the above 2 lines (13495/13496) above these line's original spot, but 
moving it here seems to have correctly passed all tests.  Anyone with more 
knowledge here want to chime in?



Comment at: test/Sema/transparent-union.c:57
 
+typedef union __attribute__((transparent_union)) {
+  aligned_struct4 s4; // expected-note{{alignment of first field}}

2 Additional sema tests to ensure that the same warnings occur both in prefix 
and postfix attribute definition.


https://reviews.llvm.org/D28266



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-01-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: cfe-commits, bruno, aaron.ballman, rsmith.

This is an update of this patch: https://reviews.llvm.org/D25824

I cannot seem to get that review to update with my diff.  This first patch 
removes the dependency on isParsing and switches to isBeingDefined.  In order 
to get that to work, changing where attributes where changed was necessary.

Original description below:

Clang compiles with error following test case

typedef union attribute((transparent_union)) {

int *i;
struct st *s;

} TU;

void bar(TU);

void foo(int *i) {

bar(i);

}

clang -c tu.c
tu.c:1:30: warning: transparent_union attribute can only be applied to a union 
definition; attribute ignored [-Wignored-attributes]
typedef union attribute((transparent_union)) {

^

tu.c:8:24: error: passing 'int *' to parameter of incompatible type 'TU'
void foo(int *i) { bar(i); }

^

tu.c:6:12: note: passing argument to parameter here
void bar(TU);

^

GCC compiles this test successfully.

The compilation is failed because the routine handleTransparentUnionAttr 
requires for the record decl to be completed. This fix provides handling of the 
attribute ‘transparent_union’ after parsing of union.


https://reviews.llvm.org/D28266

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/transparent-union.c
  test/Sema/transparent-union.c

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1885,6 +1885,10 @@
   ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing TransparentUnion attribute.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), attrs.getList());
+
   const char *PrevSpec = nullptr;
   unsigned DiagID;
   bool Result;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13477,9 +13477,6 @@
   if (Invalid)
 New->setInvalidDecl();
 
-  if (Attr)
-ProcessDeclAttributeList(S, New, Attr);
-
   // Set the lexical context. If the tag has a C++ scope specifier, the
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
@@ -13498,6 +13495,9 @@
   if (TUK == TUK_Definition)
 New->startDefinition();
 
+  if (Attr)
+ProcessDeclAttributeList(S, New, Attr);
+
   // If this has an identifier, add it to the scope stack.
   if (TUK == TUK_Friend) {
 // We might be replacing an existing declaration in the lookup tables;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3109,8 +3109,9 @@
   }
 
   if (!RD->isCompleteDefinition()) {
-S.Diag(Attr.getLoc(),
-diag::warn_transparent_union_attribute_not_definition);
+if (!RD->isBeingDefined())
+  S.Diag(Attr.getLoc(),
+ diag::warn_transparent_union_attribute_not_definition);
 return;
   }
 
@@ -6195,6 +6196,15 @@
   }
 }
 
+// Helper for delayed proccessing TransparentUnion attribute.
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) {
+  for (const AttributeList* l = AttrList; l; l = l->getNext())
+if (l->getKind() == AttributeList::AT_TransparentUnion) {
+  handleTransparentUnionAttr(*this, D, *l);
+  break;
+}
+}
+
 // Annotation attributes are the only attributes allowed after an access
 // specifier.
 bool Sema::ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -3056,6 +3056,8 @@
   void ProcessPragmaWeak(Scope *S, Decl *D);
   // Decl attributes - this routine is the top level dispatcher.
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator );
+  // Helper for delayed proccessing TransparentUnion attribute.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);
   void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
 bool IncludeCXX11Attributes = true);
   bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
Index: test/CodeGen/transparent-union.c
===
--- test/CodeGen/transparent-union.c
+++ test/CodeGen/transparent-union.c
@@ -3,10 +3,21 @@
 // RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple x86_64-linux -emit-llvm -o 

[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

2017-01-03 Thread don hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:3547
   NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
-} else {
-  NoexceptType = EST_None;
 }
   } else {

rsmith wrote:
> Should `NoexceptRange` be set in the `else` case too, now that we're claiming 
> that the type is `EST_ComputedNoexcept`?
If the expression is invalid, it's never used.  In fact, since it is invalid, 
it may not be possible to compute the range.  However, I'll check that.



Comment at: lib/Sema/TreeTransform.h:5044-5057
+if (!NoexceptExpr.isUsable())
   return true;
 
 // FIXME: This is bogus, a noexcept expression is not a condition.
 NoexceptExpr = getSema().CheckBooleanCondition(Loc, NoexceptExpr.get());
-if (NoexceptExpr.isInvalid())
+if (!NoexceptExpr.isUsable())
   return true;

rsmith wrote:
> These changes don't make sense to me: if we get a valid-but-null `ExprResult` 
> from any of the above, there is no guarantee a diagnostic has been produced, 
> so it is not correct to return `true`.
> 
> Which call is producing the valid-but-null `ExprResult`?
If the expression contains an undefined value, then ParseConstantExpression, 
and the functions it calls, will produce diagnostics and return an invalid 
ExprResult, i.e., 0x01.  That means you can't call CheckBooleanCondition 
because it assumes the pointer is good.  The problem is that this information 
is lost once tryParseExceptionSpecification returns.  From then on, it's stored 
as a null value, i.e., as if it never existed which corresponds to EST_None.

However, we need to know that it did in fact exist so we can get the sizes of 
FunctionDecl type and TypeSourceInfo type to match, and that won't happen if we 
set the exception type to EST_None.

So, if we keep EST_ComputedNoexcept, we need to actually test the pointer 
before we use it -- isValid is no longer good enough.



https://reviews.llvm.org/D28258



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


r290919 - Add -plugin-opt=sample-profile for thinLTO build.

2017-01-03 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Tue Jan  3 18:33:23 2017
New Revision: 290919

URL: http://llvm.org/viewvc/llvm-project?rev=290919=rev
Log:
Add -plugin-opt=sample-profile for thinLTO build.

Summary: ThinLTO needs to pass down the sample profile file path to linker.

Reviewers: tejohnson, davidxl, mehdi_amini

Subscribers: bruno, cfe-commits

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

Added:
cfe/trunk/test/Driver/gold-lto-samplepgo.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290919=290918=290919=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan  3 18:33:23 2017
@@ -2235,6 +2235,15 @@ static void AddGoldPlugin(const ToolChai
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef FName = A->getValue();
+if (!llvm::sys::fs::exists(FName))
+  D.Diag(diag::err_drv_no_such_file) << FName;
+else
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step

Added: cfe/trunk/test/Driver/gold-lto-samplepgo.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto-samplepgo.c?rev=290919=auto
==
--- cfe/trunk/test/Driver/gold-lto-samplepgo.c (added)
+++ cfe/trunk/test/Driver/gold-lto-samplepgo.c Tue Jan  3 18:33:23 2017
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -fprofile-sample-use=%s \
+// RUN: | FileCheck %s
+// CHECK: -plugin-opt=sample-profile=


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


[PATCH] D27832: Add -plugin-opt=sample-profile for thinLTO build.

2017-01-03 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 82975.
danielcdh added a comment.

fix function name


https://reviews.llvm.org/D27832

Files:
  lib/Driver/Tools.cpp
  test/Driver/gold-lto-samplepgo.c


Index: test/Driver/gold-lto-samplepgo.c
===
--- /dev/null
+++ test/Driver/gold-lto-samplepgo.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -fprofile-sample-use=%s \
+// RUN: | FileCheck %s
+// CHECK: -plugin-opt=sample-profile=
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2235,6 +2235,15 @@
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef FName = A->getValue();
+if (!llvm::sys::fs::exists(FName))
+  D.Diag(diag::err_drv_no_such_file) << FName;
+else
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step


Index: test/Driver/gold-lto-samplepgo.c
===
--- /dev/null
+++ test/Driver/gold-lto-samplepgo.c
@@ -0,0 +1,7 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -fprofile-sample-use=%s \
+// RUN: | FileCheck %s
+// CHECK: -plugin-opt=sample-profile=
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2235,6 +2235,15 @@
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef FName = A->getValue();
+if (!llvm::sys::fs::exists(FName))
+  D.Diag(diag::err_drv_no_such_file) << FName;
+else
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + FName));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25435: Add -femit-accurate-debug-info to emit more debug info for sample pgo profile collection

2017-01-03 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added a comment.

ping...

Thanks,
Dehao


https://reviews.llvm.org/D25435



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


[PATCH] D28037: [PowerPC, DAGCombiner] Change vec_sl to a << (b % (sizeof(a) * 8)), and fold it back to a << b.

2017-01-03 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

One inline comment for the clang part and then let's split the llvm part out 
into a separate patch please.

Thanks!

-eric




Comment at: clang/lib/Headers/altivec.h:8045
 /* vec_sl */
 
 static __inline__ vector unsigned char __ATTRS_o_ai

Can you add a note here that these functions are documented to return a shift 
with the shift operand modulo the size of the type?


https://reviews.llvm.org/D28037



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


r290916 - Re-add objectsize function/incomplete type checks.

2017-01-03 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Jan  3 17:35:19 2017
New Revision: 290916

URL: http://llvm.org/viewvc/llvm-project?rev=290916=rev
Log:
Re-add objectsize function/incomplete type checks.

I accidentally omitted these when refactoring this code. This caused
problems when building parts of the test-suite on MacOS.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGen/object-size.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=290916=290915=290916=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Jan  3 17:35:19 2017
@@ -7192,6 +7192,12 @@ static bool determineEndOffset(EvalInfo
CharUnits ) {
   bool DetermineForCompleteObject = refersToCompleteObject(LVal);
 
+  auto CheckedHandleSizeof = [&](QualType Ty, CharUnits ) {
+if (Ty.isNull() || Ty->isIncompleteType() || Ty->isFunctionType())
+  return false;
+return HandleSizeof(Info, ExprLoc, Ty, Result);
+  };
+
   // We want to evaluate the size of the entire object. This is a valid 
fallback
   // for when Type=1 and the designator is invalid, because we're asked for an
   // upper-bound.
@@ -7209,7 +7215,7 @@ static bool determineEndOffset(EvalInfo
   return false;
 
 QualType BaseTy = getObjectType(LVal.getLValueBase());
-return !BaseTy.isNull() && HandleSizeof(Info, ExprLoc, BaseTy, EndOffset);
+return CheckedHandleSizeof(BaseTy, EndOffset);
   }
 
   // We want to evaluate the size of a subobject.
@@ -7238,7 +7244,7 @@ static bool determineEndOffset(EvalInfo
   }
 
   CharUnits BytesPerElem;
-  if (!HandleSizeof(Info, ExprLoc, Designator.MostDerivedType, BytesPerElem))
+  if (!CheckedHandleSizeof(Designator.MostDerivedType, BytesPerElem))
 return false;
 
   // According to the GCC documentation, we want the size of the subobject

Modified: cfe/trunk/test/CodeGen/object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=290916=290915=290916=diff
==
--- cfe/trunk/test/CodeGen/object-size.c (original)
+++ cfe/trunk/test/CodeGen/object-size.c Tue Jan  3 17:35:19 2017
@@ -536,3 +536,16 @@ void PR30346() {
   // CHECK: store i32 14
   gi = __builtin_object_size(sa->sa_data, 3);
 }
+
+extern char incomplete_char_array[];
+// CHECK-LABEL: @incomplete_and_function_types
+int incomplete_and_function_types() {
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8
+  gi = __builtin_object_size(incomplete_char_array, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8
+  gi = __builtin_object_size(incomplete_char_array, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8
+  gi = __builtin_object_size(incomplete_char_array, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(incomplete_char_array, 3);
+}


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


[PATCH] D28260: Add an argumentsAre matcher

2017-01-03 Thread Matt Kulukundis via Phabricator via cfe-commits
fowles created this revision.
fowles added a reviewer: klimek.
fowles added a subscriber: cfe-commits.

Add an argumentsAre matcher


https://reviews.llvm.org/D28260

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -375,6 +375,14 @@
   EXPECT_TRUE(notMatches("void x(int) { int y; x(y); }", WrongIndex));
 }
 
+TEST(Matcher, ArgumentsAre) {
+  StatementMatcher Call = callExpr(argumentsAre(declRefExpr(), declRefExpr()));
+
+  EXPECT_TRUE(notMatches("void f(int x) { f(x); }", Call));
+  EXPECT_TRUE(matches("void f(int x, int y) { f(x, y); }", Call));
+  EXPECT_TRUE(notMatches("void f(int x, int y, int z) { f(x, y, z); }", Call));
+}
+
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
 hasAnyArgument(
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3055,6 +3055,34 @@
   *Node.getArg(N)->IgnoreParenImpCasts(), Finder, Builder));
 }
 
+namespace internal {
+inline auto argumentsAreImpl(int n) -> decltype(argumentCountIs(n)) {
+  return argumentCountIs(n);
+}
+
+template 
+auto argumentsAreImpl(int n, First &, Rest &&... rest)
+-> decltype(allOf(hasArgument(n, std::forward(first)),
+  argumentsAreImpl(n + 1, std::forward(rest)...))) {
+  return allOf(hasArgument(n, std::forward(first)),
+   argumentsAreImpl(n + 1, std::forward(rest)...));
+}
+} // end namespace internal
+
+/// \brief Matches all the arguments of a call expression or a constructor
+/// call expression.
+///
+/// Example matches the call to f2, but not f1 or f3.
+/// (matcher = callExpr(argumentsAre(declRefExpr(), declRefExpr(
+/// \code
+///   void x(int a, int b, int c) { f1(a); f2(a, b); f3(a, b, c); }
+/// \endcode
+template 
+auto argumentsAre(T &&... t)
+-> decltype(internal::argumentsAreImpl(0, std::forward(t)...)) {
+  return internal::argumentsAreImpl(0, std::forward(t)...);
+}
+
 /// \brief Matches declaration statements that contain a specific number of
 /// declarations.
 ///


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -375,6 +375,14 @@
   EXPECT_TRUE(notMatches("void x(int) { int y; x(y); }", WrongIndex));
 }
 
+TEST(Matcher, ArgumentsAre) {
+  StatementMatcher Call = callExpr(argumentsAre(declRefExpr(), declRefExpr()));
+
+  EXPECT_TRUE(notMatches("void f(int x) { f(x); }", Call));
+  EXPECT_TRUE(matches("void f(int x, int y) { f(x, y); }", Call));
+  EXPECT_TRUE(notMatches("void f(int x, int y, int z) { f(x, y, z); }", Call));
+}
+
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
 hasAnyArgument(
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3055,6 +3055,34 @@
   *Node.getArg(N)->IgnoreParenImpCasts(), Finder, Builder));
 }
 
+namespace internal {
+inline auto argumentsAreImpl(int n) -> decltype(argumentCountIs(n)) {
+  return argumentCountIs(n);
+}
+
+template 
+auto argumentsAreImpl(int n, First &, Rest &&... rest)
+-> decltype(allOf(hasArgument(n, std::forward(first)),
+  argumentsAreImpl(n + 1, std::forward(rest)...))) {
+  return allOf(hasArgument(n, std::forward(first)),
+   argumentsAreImpl(n + 1, std::forward(rest)...));
+}
+} // end namespace internal
+
+/// \brief Matches all the arguments of a call expression or a constructor
+/// call expression.
+///
+/// Example matches the call to f2, but not f1 or f3.
+/// (matcher = callExpr(argumentsAre(declRefExpr(), declRefExpr(
+/// \code
+///   void x(int a, int b, int c) { f1(a); f2(a, b); f3(a, b, c); }
+/// \endcode
+template 
+auto argumentsAre(T &&... t)
+-> decltype(internal::argumentsAreImpl(0, std::forward(t)...)) {
+  return internal::argumentsAreImpl(0, std::forward(t)...);
+}
+
 /// \brief Matches declaration statements that contain a specific number of
 /// declarations.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

2017-01-03 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:3547
   NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
-} else {
-  NoexceptType = EST_None;
 }
   } else {

Should `NoexceptRange` be set in the `else` case too, now that we're claiming 
that the type is `EST_ComputedNoexcept`?



Comment at: lib/Sema/TreeTransform.h:5044-5057
+if (!NoexceptExpr.isUsable())
   return true;
 
 // FIXME: This is bogus, a noexcept expression is not a condition.
 NoexceptExpr = getSema().CheckBooleanCondition(Loc, NoexceptExpr.get());
-if (NoexceptExpr.isInvalid())
+if (!NoexceptExpr.isUsable())
   return true;

These changes don't make sense to me: if we get a valid-but-null `ExprResult` 
from any of the above, there is no guarantee a diagnostic has been produced, so 
it is not correct to return `true`.

Which call is producing the valid-but-null `ExprResult`?


https://reviews.llvm.org/D28258



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


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2017-01-03 Thread Kevin Hu via Phabricator via cfe-commits
hxy9243 updated this revision to Diff 82962.
hxy9243 marked 4 inline comments as done.
hxy9243 added a comment.

Minor fix, remove redundant inlines.


Repository:
  rL LLVM

https://reviews.llvm.org/D24991

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp

Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -17,28 +17,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-namespace
-{
-
-// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
-// should be sufficient for thread safety.
-// See https://llvm.org/bugs/show_bug.cgi?id=22803
-template 
-inline T
-increment(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(, 1, _AO_Relaxed);
-}
-
-template 
-inline T
-decrement(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(, -1, _AO_Acq_Rel);
-}
-
-}  // namespace
-
 const allocator_arg_t allocator_arg = allocator_arg_t();
 
 bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
@@ -53,27 +31,27 @@
 {
 }
 
+__shared_weak_count::~__shared_weak_count()
+{
+}
+
 void
 __shared_count::__add_shared() _NOEXCEPT
 {
-increment(__shared_owners_);
+__libcpp_atomic_increment(__shared_owners_);
 }
 
 bool
 __shared_count::__release_shared() _NOEXCEPT
 {
-if (decrement(__shared_owners_) == -1)
+if (__libcpp_atomic_decrement(__shared_owners_) == -1)
 {
 __on_zero_shared();
 return true;
 }
 return false;
 }
 
-__shared_weak_count::~__shared_weak_count()
-{
-}
-
 void
 __shared_weak_count::__add_shared() _NOEXCEPT
 {
@@ -83,7 +61,7 @@
 void
 __shared_weak_count::__add_weak() _NOEXCEPT
 {
-increment(__shared_weak_owners_);
+__libcpp_atomic_increment(__shared_weak_owners_);
 }
 
 void
@@ -124,7 +102,7 @@
 //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
 __on_zero_shared_weak();
 }
-else if (decrement(__shared_weak_owners_) == -1)
+else if (__libcpp_atomic_decrement(__shared_weak_owners_) == -1)
 __on_zero_shared_weak();
 }
 
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3681,6 +3681,44 @@
 
 #endif // _LIBCPP_STD_VER > 14
 
+// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
+// should be sufficient for thread safety.
+// See https://llvm.org/bugs/show_bug.cgi?id=22803
+#if defined(__clang__) && __has_builtin(__atomic_load_n) \
+   && __has_builtin(__atomic_store_n)\
+   && __has_builtin(__atomic_add_fetch)  \
+   && __has_builtin(__atomic_compare_exchange_n) \
+   && defined(__ATOMIC_RELAXED)  \
+   && defined(__ATOMIC_CONSUME)  \
+   && defined(__ATOMIC_ACQUIRE)  \
+   && defined(__ATOMIC_RELEASE)  \
+   && defined(__ATOMIC_ACQ_REL)  \
+   && defined(__ATOMIC_SEQ_CST)
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#endif
+
+template 
+inline T
+__libcpp_atomic_increment(T& t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(, 1, __ATOMIC_RELAXED);
+#else
+return t += 1;
+#endif
+}
+
+template 
+inline T
+__libcpp_atomic_decrement(T& t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(, -1, __ATOMIC_ACQ_REL);
+#else
+return t -= 1;
+#endif
+}
+
 class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
 : public std::exception
 {
@@ -3717,8 +3755,23 @@
 explicit __shared_count(long __refs = 0) _NOEXCEPT
 : __shared_owners_(__refs) {}
 
-void __add_shared() _NOEXCEPT;
-bool __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+void _LIBCPP_FUNC_VIS __add_shared() _NOEXCEPT;
+bool _LIBCPP_FUNC_VIS __release_shared() _NOEXCEPT;
+#else
+_LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {
+  __libcpp_atomic_increment(__shared_owners_);
+}
+_LIBCPP_INLINE_VISIBILITY
+bool __release_shared() _NOEXCEPT {
+  if (__libcpp_atomic_decrement(__shared_owners_) == -1) {
+__on_zero_shared();
+return true;
+  }
+  return false;
+}
+#endif
 _LIBCPP_INLINE_VISIBILITY
 long use_count() const _NOEXCEPT {
 return __libcpp_relaxed_load(&__shared_owners_) + 1;
@@ -3739,9 +3792,25 @@
 virtual ~__shared_weak_count();
 
 public:
-void __add_shared() _NOEXCEPT;
-void __add_weak() _NOEXCEPT;
-void __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+void _LIBCPP_FUNC_VIS __add_shared() _NOEXCEPT;
+void _LIBCPP_FUNC_VIS __add_weak() _NOEXCEPT;
+void _LIBCPP_FUNC_VIS __release_shared() _NOEXCEPT;
+#else
+_LIBCPP_INLINE_VISIBILITY
+

[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

2017-01-03 Thread don hinton via Phabricator via cfe-commits
hintonda created this revision.
hintonda added reviewers: sepavloff, rsmith, aaron.ballman.
hintonda added a subscriber: cfe-commits.

Treat invalid noexcept specifications in the same way we
treat invalid throw specifications, by not resetting the exception
type to EST_None, and testing isUsable instead of isInvalid.

Rational: In order to add source locations for exception
specifications (see https://reviews.llvm.org/D20428) we need to
maintain the correct exception type, otherwise, FunctionDecl types
won't include space for source ranges, but the associated
TypeSourceInfo type will, causing ASTContext::adjustExceptionSpec to
assert once source ranges have been added.


https://reviews.llvm.org/D28258

Files:
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/TreeTransform.h


Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5041,20 +5041,20 @@
 EnterExpressionEvaluationContext Unevaluated(getSema(),
  Sema::ConstantEvaluated);
 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
-if (NoexceptExpr.isInvalid())
+if (!NoexceptExpr.isUsable())
   return true;
 
 // FIXME: This is bogus, a noexcept expression is not a condition.
 NoexceptExpr = getSema().CheckBooleanCondition(Loc, NoexceptExpr.get());
-if (NoexceptExpr.isInvalid())
+if (!NoexceptExpr.isUsable())
   return true;
 
 if (!NoexceptExpr.get()->isValueDependent()) {
   NoexceptExpr = getSema().VerifyIntegerConstantExpression(
   NoexceptExpr.get(), nullptr,
   diag::err_noexcept_needs_constant_expression,
   /*AllowFold*/false);
-  if (NoexceptExpr.isInvalid())
+  if (!NoexceptExpr.isUsable())
 return true;
 }
 
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3544,8 +3544,6 @@
   NoexceptExpr =
   Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.get());
   NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
-} else {
-  NoexceptType = EST_None;
 }
   } else {
 // There is no argument.


Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5041,20 +5041,20 @@
 EnterExpressionEvaluationContext Unevaluated(getSema(),
  Sema::ConstantEvaluated);
 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
-if (NoexceptExpr.isInvalid())
+if (!NoexceptExpr.isUsable())
   return true;
 
 // FIXME: This is bogus, a noexcept expression is not a condition.
 NoexceptExpr = getSema().CheckBooleanCondition(Loc, NoexceptExpr.get());
-if (NoexceptExpr.isInvalid())
+if (!NoexceptExpr.isUsable())
   return true;
 
 if (!NoexceptExpr.get()->isValueDependent()) {
   NoexceptExpr = getSema().VerifyIntegerConstantExpression(
   NoexceptExpr.get(), nullptr,
   diag::err_noexcept_needs_constant_expression,
   /*AllowFold*/false);
-  if (NoexceptExpr.isInvalid())
+  if (!NoexceptExpr.isUsable())
 return true;
 }
 
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -3544,8 +3544,6 @@
   NoexceptExpr =
   Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.get());
   NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
-} else {
-  NoexceptType = EST_None;
 }
   } else {
 // There is no argument.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2017-01-03 Thread Kevin Hu via Phabricator via cfe-commits
hxy9243 set the repository for this revision to rL LLVM.
hxy9243 updated this revision to Diff 82958.
hxy9243 added a comment.

Move the header back in its place, and only copy over necessary parts. Now call 
__atomic_add_fetch from inside the functions.


Repository:
  rL LLVM

https://reviews.llvm.org/D24991

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp

Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -17,28 +17,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-namespace
-{
-
-// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
-// should be sufficient for thread safety.
-// See https://llvm.org/bugs/show_bug.cgi?id=22803
-template 
-inline T
-increment(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(, 1, _AO_Relaxed);
-}
-
-template 
-inline T
-decrement(T& t) _NOEXCEPT
-{
-return __libcpp_atomic_add(, -1, _AO_Acq_Rel);
-}
-
-}  // namespace
-
 const allocator_arg_t allocator_arg = allocator_arg_t();
 
 bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
@@ -53,27 +31,27 @@
 {
 }
 
+__shared_weak_count::~__shared_weak_count()
+{
+}
+
 void
 __shared_count::__add_shared() _NOEXCEPT
 {
-increment(__shared_owners_);
+__libcpp_atomic_increment(__shared_owners_);
 }
 
 bool
 __shared_count::__release_shared() _NOEXCEPT
 {
-if (decrement(__shared_owners_) == -1)
+if (__libcpp_atomic_decrement(__shared_owners_) == -1)
 {
 __on_zero_shared();
 return true;
 }
 return false;
 }
 
-__shared_weak_count::~__shared_weak_count()
-{
-}
-
 void
 __shared_weak_count::__add_shared() _NOEXCEPT
 {
@@ -83,7 +61,7 @@
 void
 __shared_weak_count::__add_weak() _NOEXCEPT
 {
-increment(__shared_weak_owners_);
+__libcpp_atomic_increment(__shared_weak_owners_);
 }
 
 void
@@ -124,7 +102,7 @@
 //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
 __on_zero_shared_weak();
 }
-else if (decrement(__shared_weak_owners_) == -1)
+else if (__libcpp_atomic_decrement(__shared_weak_owners_) == -1)
 __on_zero_shared_weak();
 }
 
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3681,6 +3681,44 @@
 
 #endif // _LIBCPP_STD_VER > 14
 
+// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
+// should be sufficient for thread safety.
+// See https://llvm.org/bugs/show_bug.cgi?id=22803
+#if defined(__clang__) && __has_builtin(__atomic_load_n) \
+   && __has_builtin(__atomic_store_n)\
+   && __has_builtin(__atomic_add_fetch)  \
+   && __has_builtin(__atomic_compare_exchange_n) \
+   && defined(__ATOMIC_RELAXED)  \
+   && defined(__ATOMIC_CONSUME)  \
+   && defined(__ATOMIC_ACQUIRE)  \
+   && defined(__ATOMIC_RELEASE)  \
+   && defined(__ATOMIC_ACQ_REL)  \
+   && defined(__ATOMIC_SEQ_CST)
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#endif
+
+template 
+inline T
+__libcpp_atomic_increment(T& t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(, 1, __ATOMIC_RELAXED);
+#else
+return t += 1;
+#endif
+}
+
+template 
+inline T
+__libcpp_atomic_decrement(T& t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+return __atomic_add_fetch(, -1, __ATOMIC_ACQ_REL);
+#else
+return t -= 1;
+#endif
+}
+
 class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
 : public std::exception
 {
@@ -3717,8 +3755,23 @@
 explicit __shared_count(long __refs = 0) _NOEXCEPT
 : __shared_owners_(__refs) {}
 
-void __add_shared() _NOEXCEPT;
-bool __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+void _LIBCPP_FUNC_VIS __add_shared() _NOEXCEPT;
+bool _LIBCPP_FUNC_VIS __release_shared() _NOEXCEPT;
+#else
+inline _LIBCPP_INLINE_VISIBILITY
+void __add_shared() _NOEXCEPT {
+  __libcpp_atomic_increment(__shared_owners_);
+}
+inline _LIBCPP_INLINE_VISIBILITY
+bool __release_shared() _NOEXCEPT {
+  if (__libcpp_atomic_decrement(__shared_owners_) == -1) {
+__on_zero_shared();
+return true;
+  }
+  return false;
+}
+#endif
 _LIBCPP_INLINE_VISIBILITY
 long use_count() const _NOEXCEPT {
 return __libcpp_relaxed_load(&__shared_owners_) + 1;
@@ -3739,9 +3792,25 @@
 virtual ~__shared_weak_count();
 
 public:
-void __add_shared() _NOEXCEPT;
-void __add_weak() _NOEXCEPT;
-void __release_shared() _NOEXCEPT;
+#ifdef _LIBCPP_BUILDING_MEMORY
+void _LIBCPP_FUNC_VIS __add_shared() _NOEXCEPT;
+void _LIBCPP_FUNC_VIS 

[PATCH] D28257: [OpenCL] Re-enable supported core extensions based on opencl version when disabling all extensions using pragma

2017-01-03 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: yaxunl, Anastasia, b-sumner.
kzhuravl added a subscriber: cfe-commits.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D28257

Files:
  lib/Parse/ParsePragma.cpp
  test/SemaOpenCL/extensions.cl


Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -22,6 +22,17 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 
-cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 
-DNOFP64
 
+// Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
+// disables all extensions by default, but supported core extensions for a
+// particular OpenCL version must be re-enabled (for example, cl_khr_fp64 is
+// enabled by default with -cl-std=CL2.0).
+//
+// RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic 
-fsyntax-only -cl-std=CL2.0 -finclude-default-header
+
+#ifdef _OPENCL_H_
+// expected-no-diagnostics
+#endif
+
 #ifdef FP64
 // expected-no-diagnostics
 #endif
@@ -33,13 +44,15 @@
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
 return __builtin_isnan(x);
 }
 
 int isfinite(float x) {
 return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -506,10 +506,12 @@
   // overriding all previously issued extension directives, but only if the
   // behavior is set to disable."
   if (Name == "all") {
-if (State == Disable)
+if (State == Disable) {
   Opt.disableAll();
-else
+  Opt.enableSupportedCore(getLangOpts().OpenCLVersion);
+} else {
   PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
+}
   } else if (State == Begin) {
 if (!Opt.isKnown(Name) ||
 !Opt.isSupported(Name, getLangOpts().OpenCLVersion)) {


Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -22,6 +22,17 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
 
+// Test with -finclude-default-header, which includes opencl-c.h. opencl-c.h
+// disables all extensions by default, but supported core extensions for a
+// particular OpenCL version must be re-enabled (for example, cl_khr_fp64 is
+// enabled by default with -cl-std=CL2.0).
+//
+// RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
+
+#ifdef _OPENCL_H_
+// expected-no-diagnostics
+#endif
+
 #ifdef FP64
 // expected-no-diagnostics
 #endif
@@ -33,13 +44,15 @@
 }
 #endif
 
+#ifndef _OPENCL_H_
 int isnan(float x) {
 return __builtin_isnan(x);
 }
 
 int isfinite(float x) {
 return __builtin_isfinite(x);
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -506,10 +506,12 @@
   // overriding all previously issued extension directives, but only if the
   // behavior is set to disable."
   if (Name == "all") {
-if (State == Disable)
+if (State == Disable) {
   Opt.disableAll();
-else
+  Opt.enableSupportedCore(getLangOpts().OpenCLVersion);
+} else {
   PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
+}
   } else if (State == Begin) {
 if (!Opt.isKnown(Name) ||
 !Opt.isSupported(Name, getLangOpts().OpenCLVersion)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82954.
compnerd added a comment.

Remove incorrect use of `VC_EXTRALEAN`.  Fix signature for 
`__libcpp_set_thread_specific`.  Provide CC adjustment thunks for the thread 
creation.  Add an assertion for sleep timeout truncation.  Implement exec-once 
interfaces.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -43,10 +43,21 @@
 #include <__external_threading>
 #else
 
+#if !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) &&\
+!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD) &&   \
+!defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#error "unknown threading model"
+#endif
+
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
 defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
 #include 
 #include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -81,6 +92,29 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Execute once
+typedef INIT_ONCE __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
 #endif
 
 struct __libcpp_mutex_reference {
@@ -347,6 +381,236 @@
 return pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+EnterCriticalSection(__m);
+  else
+AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+return TryEnterCriticalSection(__m);
+  return TryAcquireSRWLockExclusive(__m);
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+LeaveCriticalSection(__m);
+  else
+ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_reference&& __m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv,
+  __libcpp_mutex_reference&& __m)
+{
+  if (__m.__recursive)
+SleepConditionVariableCS(__cv, __m, INFINITE);
+  else
+SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv,
+   __libcpp_mutex_reference&& __m,
+   timespec* __ts)
+{
+  using namespace _VSTD::chrono;
+  auto timeout = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  auto timeout_ms = duration_cast(timeout);
+
+  _LIBCPP_ASSERT(timeout_ms.count() < _VSTD::numeric_limits::max(),
+ "timeout duration overflows");
+
+  if (__m.__recursive) {
+if (!SleepConditionVariableCS(__cv, __m, timeout_ms.count()))
+  return GetLastError();
+  } else {
+if (!SleepConditionVariableSRW(__cv, __m, timeout_ms.count(), 0))
+  return GetLastError();
+  }
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+  static_cast(__cv);
+  return 0;
+}
+
+// Execute once
+static inline _LIBCPP_ALWAYS_INLINE BOOL CALLBACK
+__libcpp_init_once_trampoline(PINIT_ONCE InitOnce, PVOID Parameter,
+  PVOID *Context)
+{
+  static_cast(InitOnce);
+  static_cast(Context);
+
+  void (*init_routine)(void) = reinterpret_cast(Parameter);
+  init_routine();
+  return TRUE;
+}
+
+int __libcpp_execute_once(__libcpp_exec_once_flag* flag,
+  void (*init_routine)(void))
+{
+  if (!InitOnceExecuteOnce(flag, __libcpp_init_once_trampoline,
+   reinterpret_cast(init_routine), NULL))
+return GetLastError();
+  

[PATCH] D28255: [OpenMP] support the 'is_device_ptr' clause with 'target parallel for' pragma

2017-01-03 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: ABataev, sfantao, carlo.bertolli, arpith-jacob, 
hfinkel, mikerice.
kkwli0 added a subscriber: cfe-commits.

This patch is to add support of the 'is_device_ptr' clause in the 'target 
parallel for' pragma.


https://reviews.llvm.org/D28255

Files:
  include/clang/Basic/OpenMPKinds.def
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_parallel_for_is_device_ptr_ast_print.cpp
  test/OpenMP/target_parallel_for_is_device_ptr_messages.cpp

Index: test/OpenMP/target_parallel_for_is_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_for_is_device_ptr_messages.cpp
@@ -0,0 +1,311 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s
+
+struct ST {
+  int *a;
+};
+typedef int arr[10];
+typedef ST STarr[10];
+typedef struct {
+  int a;
+} S;
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  STarr  = g;
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  arr  = aa;
+  S *ps;
+  void func(int arg) {
+#pragma omp target parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr() // expected-error {{expected expression}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(k) // OK
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(z) // OK
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(aa) // OK
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(raa) // OK
+for (int ii=0; ii<10; ii++)
+  ;   
+#pragma omp target parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(g) // OK
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(rg) // OK
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(da) // OK
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target parallel for' directive}} expected-note{{defined as firstprivate}}
+for (int ii=0; ii<10; ii++)
+  ;
+#pragma omp target parallel for private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in 

[PATCH] D28165: Change clang-format's Chromium JavaScript defaults

2017-01-03 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

I'd rather we don't deviate from google style at all, but this brings us closer 
from where we are to that, so lgtm :-)


https://reviews.llvm.org/D28165



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r290910.  I like your idea for an additional BITSCAN macro.  I think that 
Id rather do that in a follow up.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[libcxx] r290910 - clean up use of _WIN32

2017-01-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Jan  3 15:53:51 2017
New Revision: 290910

URL: http://llvm.org/viewvc/llvm-project?rev=290910=rev
Log:
clean up use of _WIN32

Replace the use of _WIN32 in libc++. Replace most use with a C runtime
check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are
using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we
are on an environment that has a short wchar_t.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__locale
libcxx/trunk/include/support/win32/support.h
libcxx/trunk/include/type_traits
libcxx/trunk/src/chrono.cpp
libcxx/trunk/src/include/config_elast.h
libcxx/trunk/src/locale.cpp
libcxx/trunk/src/new.cpp
libcxx/trunk/src/system_error.cpp
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=290910=290909=290910=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Jan  3 15:53:51 2017
@@ -154,11 +154,13 @@
 # define _LIBCPP_HAS_QUICK_EXIT
 #endif  // __NetBSD__
 
-#ifdef _WIN32
+#if defined(_WIN32)
+#  define _LIBCPP_WIN32API  1
 #  define _LIBCPP_LITTLE_ENDIAN 1
 #  define _LIBCPP_BIG_ENDIAN0
+#  define _LIBCPP_SHORT_WCHAR   1
 // Compiler intrinsics (MSVC)
-#if defined(_MSC_VER) && _MSC_VER >= 1400
+#  if defined(_MSC_VER) && _MSC_VER >= 1400
 #define _LIBCPP_HAS_IS_BASE_OF
 #  endif
 #  if defined(_MSC_VER) && !defined(__clang__)
@@ -167,11 +169,11 @@
 #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
 #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" 
_LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
 #  endif
-#  // If mingw not explicitly detected, assume using MS C runtime only.
+// If mingw not explicitly detected, assume using MS C runtime only.
 #  ifndef __MINGW32__
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
-#endif  // _WIN32
+#endif // defined(_WIN32)
 
 #ifdef __sun__
 # include 
@@ -195,7 +197,7 @@
   // including accesses to the special files under /dev. C++11's
   // std::random_device is instead exposed through a NaCl syscall.
 # define _LIBCPP_USING_NACL_RANDOM
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_WIN32API)
 # define _LIBCPP_USING_WIN32_RANDOM
 #else
 # define _LIBCPP_USING_DEV_RANDOM
@@ -520,8 +522,15 @@ namespace std {
 
 #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
 
+#if defined(__ELF__)
+#define _LIBCPP_OBJECT_FORMAT_ELF   1
+#elif defined(__MACH__)
+#define _LIBCPP_OBJECT_FORMAT_MACHO 1
+#else
+#define _LIBCPP_OBJECT_FORMAT_COFF  1
+#endif
 
-#ifdef _WIN32
+#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
 #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 # define _LIBCPP_DLL_VIS
 # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
@@ -546,6 +555,7 @@ namespace std {
 #define _LIBCPP_TYPE_VIS_ONLY
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
+
 #if defined(_LIBCPP_MSVC)
 # define _LIBCPP_INLINE_VISIBILITY __forceinline
 # define _LIBCPP_ALWAYS_INLINE __forceinline
@@ -555,7 +565,7 @@ namespace std {
 # define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
 # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ 
((__always_inline__))
 #endif
-#endif // _WIN32
+#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
 #ifndef _LIBCPP_HIDDEN
 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
@@ -778,14 +788,14 @@ template  struct __static_asse
 #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) ||   
\
 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 
 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 // Most unix variants have catopen.  These are the specific ones that don't.
-#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
 #define _LIBCPP_HAS_CATOPEN 1
 #endif
 #endif
@@ -959,7 +969,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
 #define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
 #endif
 #endif

Modified: libcxx/trunk/include/__locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=290910=290909=290910=diff
==
--- libcxx/trunk/include/__locale (original)
+++ libcxx/trunk/include/__locale Tue Jan  3 15:53:51 2017
@@ -342,7 +342,7 @@ public:
 static const mask punct  = _ISpunct;
 static const mask xdigit = _ISxdigit;
 static const mask blank  = _ISblank;
-#elif defined(_WIN32)
+#elif 

[PATCH] D28165: Change clang-format's Chromium JavaScript defaults

2017-01-03 Thread Dan Beam via Phabricator via cfe-commits
danbeam marked an inline comment as done.
danbeam added inline comments.



Comment at: lib/Format/Format.cpp:643
+ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+ChromiumStyle.AllowShortLoopsOnASingleLine = false;
+  }

thakis wrote:
> Thanks for the patch! Do we want these as false in Chromium's JS? I would've 
> thought the diff would just be 
> 
> ```
> - } else {
> + } else if (Language != FormatStyle::LK_JavaScript)
> ```
> 
> so that we just use google style for JS.
> 
> If we do want to deviate from google style here for some reason then
> a) say why somewhere
> b) change the check for cpp to also include `|| Language == 
> FormatStyle::LK_ObjC`
> 
> (If you include more diff context as described on 
> http://llvm.org/docs/Phabricator.html, reviewing on phab is a bit easier.)
> so that we just use google style for JS

we want to tweak Google style a little bit.  I mentioned this on the [[ 
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/OTEfsPvp0qc/UsaOTR9IEQAJ
 | chromium-dev@ thread ]].

I added a specific branch for JS with explicit specializations so it's clearer 
to the reader how Google and Chromium differ.

> (If you include more diff context as described on 
> http://llvm.org/docs/Phabricator.html, reviewing on phab is a bit easier.)

Done.


https://reviews.llvm.org/D28165



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


[PATCH] D28253: static_assert inside make_shared when the object is not constructible

2017-01-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.
mclow.lists added a subscriber: cfe-commits.

http://llvm.org/show_bug.cgi?id=28929 shows a scenario where `make_shared` of a 
class with a protected constructor compiles successfully (it should fail).

This is because we apply an empty-base class optimization to the shared_ptr.

This is one way to solve the problem; there are probably others.
However, this works, and passes all the tests (including the two new ones I 
just added).


https://reviews.llvm.org/D28253

Files:
  include/memory
  test/libcxx/test/config.py
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.private.fail.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.fail.cpp

Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.fail.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.fail.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.protected.fail.cpp
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// shared_ptr
+
+// template shared_ptr make_shared(Args&&... args);
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct S {
+protected:
+   S () {};  // ctor is protected
+};
+
+int main()
+{
+std::shared_ptr p = std::make_shared();
+}
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.private.fail.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.private.fail.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.private.fail.cpp
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// shared_ptr
+
+// template shared_ptr make_shared(Args&&... args);
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct S {
+private:
+   S () {};  // ctor is private
+};
+
+int main()
+{
+std::shared_ptr p = std::make_shared();
+}
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -412,6 +412,8 @@
 self.lit_config.fatal("cxx_headers='%s' is not a directory."
   % cxx_headers)
 self.cxx.compile_flags += ['-I' + cxx_headers]
+if self.libcxx_obj_root is None:
+return
 cxxabi_headers = os.path.join(self.libcxx_obj_root, 'include', 'c++-build')
 if os.path.isdir(cxxabi_headers):
 self.cxx.compile_flags += ['-I' + cxxabi_headers]
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -4435,6 +4435,7 @@
 shared_ptr<_Tp>
 shared_ptr<_Tp>::make_shared(_Args&& ...__args)
 {
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared" );
 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
 typedef allocator<_CntrlBlk> _A2;
 typedef __allocator_destructor<_A2> _D2;
@@ -4453,6 +4454,7 @@
 shared_ptr<_Tp>
 shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
 {
+static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared" );
 typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
 typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
 typedef __allocator_destructor<_A2> _D2;
@@ -4473,6 +4475,7 @@
 shared_ptr<_Tp>
 shared_ptr<_Tp>::make_shared()
 {
+static_assert((is_constructible<_Tp>::value), "Can't construct object in make_shared" );
 typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
 typedef allocator<_CntrlBlk> _Alloc2;
 typedef __allocator_destructor<_Alloc2> _D2;
@@ -4491,6 +4494,7 @@
 shared_ptr<_Tp>
 shared_ptr<_Tp>::make_shared(_A0& __a0)
 {
+static_assert((is_constructible<_Tp, _A0>::value), "Can't construct object in 

[PATCH] D28253: static_assert inside make_shared when the object is not constructible

2017-01-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: test/libcxx/test/config.py:415
 self.cxx.compile_flags += ['-I' + cxx_headers]
+if self.libcxx_obj_root is None:
+return

Whoops. This change doesn't belong here.
But it fixes a problem running LIT to test libc++ on Mac OS when building with 
the system libc++abi.



https://reviews.llvm.org/D28253



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


[PATCH] D28165: Change clang-format's Chromium JavaScript defaults

2017-01-03 Thread Dan Beam via Phabricator via cfe-commits
danbeam updated this revision to Diff 82946.
danbeam added a comment.

make a branch specific to JS and duplicate some format options for explicitness


https://reviews.llvm.org/D28165

Files:
  lib/Format/Format.cpp


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -638,6 +638,9 @@
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+  } else if (Language == FormatStyle::LK_JavaScript) {
+ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
 ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -638,6 +638,9 @@
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
 ChromiumStyle.IndentWidth = 4;
+  } else if (Language == FormatStyle::LK_JavaScript) {
+ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
+ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
 ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false;
 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290907 - Relax CHECK line from r290906

2017-01-03 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Jan  3 15:29:51 2017
New Revision: 290907

URL: http://llvm.org/viewvc/llvm-project?rev=290907=rev
Log:
Relax CHECK line from r290906

Modified:
cfe/trunk/test/CodeGen/variadic-null-win64.c

Modified: cfe/trunk/test/CodeGen/variadic-null-win64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/variadic-null-win64.c?rev=290907=290906=290907=diff
==
--- cfe/trunk/test/CodeGen/variadic-null-win64.c (original)
+++ cfe/trunk/test/CodeGen/variadic-null-win64.c Tue Jan  3 15:29:51 2017
@@ -20,4 +20,4 @@ void f(const char *f) {
 // WINDOWS: call void bitcast (void (...)* @kr to void (i8*, i32, i32, i32, 
i32)*)(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
 // LINUX: define void @f(i8* %f)
 // LINUX: call void (i8*, ...) @v(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
-// LINUX: call void (i8*, i32, i32, i32, i32, ...) bitcast (void (...)* @kr to 
void (i8*, i32, i32, i32, i32, ...)*)(i8* %1, i32 1, i32 2, i32 3, i32 0)
+// LINUX: call void (i8*, i32, i32, i32, i32, ...) bitcast (void (...)* @kr to 
void (i8*, i32, i32, i32, i32, ...)*)(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)


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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM.  My comment is a suggestion, not a requirement.




Comment at: include/support/win32/support.h:112
 // Search from LSB to MSB for first set bit.
 // Returns zero if no set bit is found.
+#if (defined(_M_ARM) || defined(__arm__)) ||   
\

I would be tempted to add another macro here. Something like:

#if (defined(_M_ARM) || defined(__arm__)) || \
  (defined(_M_AMD64) || defined(__x86_64__))
#define _LIBCPP_WIN_HAS_BITSCAN
#endif

to avoid repeating the "four-armed combo"


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82944.
compnerd added a comment.

fix `__LP64__` usage as pointed out by @smeenai


Repository:
  rL LLVM

https://reviews.llvm.org/D28223

Files:
  include/__config
  include/__locale
  include/support/win32/support.h
  include/type_traits
  src/chrono.cpp
  src/include/config_elast.h
  src/locale.cpp
  src/new.cpp
  src/system_error.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -24,16 +24,17 @@
 # endif // defined(BSD)
 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
-#if !defined(_WIN32)
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 # include 
-#endif // !_WIN32
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
 #if defined(__NetBSD__)
 #pragma weak pthread_create // Do not create libpthread dependency
 #endif
-#if defined(_WIN32)
+
+#if defined(_LIBCPP_WIN32API)
 #include 
-#endif
+#endif // defined(_LIBCPP_WIN32API)
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -91,7 +92,7 @@
 if (result < 0)
 return 0;
 return static_cast(result);
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_WIN32API)
 SYSTEM_INFO info;
 GetSystemInfo();
 return info.dwNumberOfProcessors;
Index: src/system_error.cpp
===
--- src/system_error.cpp
+++ src/system_error.cpp
@@ -65,7 +65,7 @@
 
 string do_strerror_r(int ev);
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSVCRT)
 string do_strerror_r(int ev) {
   char buffer[strerror_buff_size];
   if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -72,7 +72,7 @@
 if (static_cast(alignment) < sizeof(void*))
   alignment = std::align_val_t(sizeof(void*));
 void* p;
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSVCRT)
 while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr)
 #else
 while (::posix_memalign(, static_cast(alignment), size) != 0)
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -3254,7 +3254,7 @@
 const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
 extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
 {
-#if _WIN32
+#if defined(_LIBCPP_SHORT_WCHAR)
 const uint16_t* _frm = reinterpret_cast(frm);
 const uint16_t* _frm_end = reinterpret_cast(frm_end);
 const uint16_t* _frm_nxt = _frm;
@@ -3266,7 +3266,7 @@
 uint8_t* _to = reinterpret_cast(to);
 uint8_t* _to_end = reinterpret_cast(to_end);
 uint8_t* _to_nxt = _to;
-#if _WIN32
+#if defined(_LIBCPP_SHORT_WCHAR)
 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
 _Maxcode_, _Mode_);
 #else
@@ -3286,7 +3286,7 @@
 const uint8_t* _frm = reinterpret_cast(frm);
 const uint8_t* _frm_end = reinterpret_cast(frm_end);
 const uint8_t* _frm_nxt = _frm;
-#if _WIN32
+#if defined(_LIBCPP_SHORT_WCHAR)
 uint16_t* _to = reinterpret_cast(to);
 uint16_t* _to_end = reinterpret_cast(to_end);
 uint16_t* _to_nxt = _to;
Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -10,7 +10,7 @@
 #ifndef _LIBCPP_CONFIG_ELAST
 #define _LIBCPP_CONFIG_ELAST
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSCVRT)
 #include 
 #else
 #include 
@@ -28,7 +28,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_MSCVRT)
 #define _LIBCPP_ELAST _sys_nerr
 #else
 // Warn here so that the person doing the libcxx port has an easier time:
Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,7 +12,7 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_WIN32API)
 #define WIN32_LEAN_AND_MEAN
 #define VC_EXTRA_LEAN
 #include 
@@ -22,13 +22,13 @@
 #else
 #if !defined(CLOCK_REALTIME)
 #include // for gettimeofday and timeval
-#endif
-#endif
+#endif // !defined(CLOCK_REALTIME)
+#endif // defined(_LIBCPP_WIN32API)
 
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_WIN32) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
 #error "Monotonic clock not implemented"
 #endif
 #endif
@@ -45,7 +45,7 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_WIN32)
+#if defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   

[PATCH] D28220: provide Win32 native threading

2017-01-03 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added inline comments.



Comment at: include/__threading_support:421
+if (!SleepConditionVariableCS(__cv, __m,
+  
duration_cast(timeout).count()))
+  return GetLastError();

We can have integer overflow on cast to DWORD here and get unexpectedly small 
wait for large timeouts.



Comment at: include/__threading_support:458
+{
+  // TODO(compnerd) provide a wrapper for CC adjustment
+  *__t = reinterpret_cast(_beginthreadex(

For other reviewers: CC means Calling Convention.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D27478: Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls

2017-01-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D27478



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


[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.h:3570
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr));
 

rnk wrote:
> rnk wrote:
> > I'm testing this change:
> > ```
> > $ git diff
> > diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
> > index acf8863..2662ebb 100644
> > --- a/lib/CodeGen/CodeGenFunction.h
> > +++ b/lib/CodeGen/CodeGenFunction.h
> > @@ -3571,7 +3571,8 @@ public:
> > 
> >  // If we still have any arguments, emit them using the type of the 
> > argument.
> >  for (auto *A : llvm::make_range(Arg, ArgRange.end()))
> > -  ArgTypes.push_back(getVarArgType(A));
> > +  ArgTypes.push_back(CalleeDecl->isVariadic() ? getVarArgType(A)
> > +  : A->getType());
> > 
> >  EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip, 
> > Order);
> >}
> > 
> > ```
> > 
> > I'd like to fix this issue in a separate commit.
> So, that didn't work at all, but the gist of it is that I don't think we 
> should call a function like `getVarArgType` when we aren't lowering a 
> variadic function call. I'll look into doing it.
rL290906 should fix it.


https://reviews.llvm.org/D28166



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


r290906 - [Win64] Don't widen integer literal zero arguments to unprototyped function calls

2017-01-03 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Jan  3 15:23:35 2017
New Revision: 290906

URL: http://llvm.org/viewvc/llvm-project?rev=290906=rev
Log:
[Win64] Don't widen integer literal zero arguments to unprototyped function 
calls

The special case to widen the integer literal zero when passed to
variadic function calls should only apply to variadic functions, not
unprototyped functions. This is consistent with what MSVC does. In this
test case, MSVC uses a 4-byte store to pass the 5th argument to 'kr' and
an 8-byte store to pass the zero to 'v':

  void v(int, ...);
  void kr();
  void f(void) {
v(1, 2, 3, 4, 0);
kr(1, 2, 3, 4, 0);
  }

Aaron Ballman discovered this issue in https://reviews.llvm.org/D28166

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/variadic-null-win64.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=290906=290905=290906=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jan  3 15:23:35 2017
@@ -3571,7 +3571,7 @@ public:
 
 // If we still have any arguments, emit them using the type of the 
argument.
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(CallArgTypeInfo ? getVarArgType(A) : A->getType());
 
 EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip, Order);
   }

Modified: cfe/trunk/test/CodeGen/variadic-null-win64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/variadic-null-win64.c?rev=290906=290905=290906=diff
==
--- cfe/trunk/test/CodeGen/variadic-null-win64.c (original)
+++ cfe/trunk/test/CodeGen/variadic-null-win64.c Tue Jan  3 15:23:35 2017
@@ -3,15 +3,21 @@
 
 // Make it possible to pass NULL through variadic functions on platforms where
 // NULL has an integer type that is more narrow than a pointer. On such
-// platforms we widen null pointer constants to a pointer-sized integer.
+// platforms we widen null pointer constants passed to variadic functions to a
+// pointer-sized integer. We don't apply this special case to K
+// unprototyped functions, because MSVC doesn't either.
 
 #define NULL 0
 
 void v(const char *f, ...);
+void kr();
 void f(const char *f) {
   v(f, 1, 2, 3, NULL);
+  kr(f, 1, 2, 3, 0);
 }
 // WINDOWS: define void @f(i8* %f)
 // WINDOWS: call void (i8*, ...) @v(i8* {{.*}}, i32 1, i32 2, i32 3, i64 0)
+// WINDOWS: call void bitcast (void (...)* @kr to void (i8*, i32, i32, i32, 
i32)*)(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
 // LINUX: define void @f(i8* %f)
 // LINUX: call void (i8*, ...) @v(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
+// LINUX: call void (i8*, i32, i32, i32, i32, ...) bitcast (void (...)* @kr to 
void (i8*, i32, i32, i32, i32, ...)*)(i8* %1, i32 1, i32 2, i32 3, i32 0)


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


[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-03 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

In https://reviews.llvm.org/D28226#634282, @compnerd wrote:

> The dynamic behavior only is used for Windows, not pthreads.  So, we dont see 
> it here, but it becomes apparent in the windows support.  I was trying to 
> minimize the changes to libc++ itself to avoid having it to consider the 
> recursive vs non-recursive cases.  If the libc++ maintainers would prefer to 
> expand the interfaces rather than use the dynamic behavior, Im fine with that 
> approach too.


Another argument that I forgot to mention: `__libcpp_condvar_wait` and 
`__libcpp_condvar_timedwait` are only expected to work with non-recursive 
mutexes. I feel that this overwidens the API surface. Flattening it out removes 
the dynamic behavior and makes it clear what operations needs to support what 
types of mutexes.


Repository:
  rL LLVM

https://reviews.llvm.org/D28226



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I like this.  A lot.

I'm a bit concerned about @smeenai 's comments about __LP64_, and @EricWF 's 
comment about solaris.

This patch accomplishes (or maybe just moves closer, I need to check) to a goal 
of mine, which is to have no references to `_WIN32` in any header files other 
that `<__config>` (and maybe in support/)


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.h:3570
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr));
 

rnk wrote:
> I'm testing this change:
> ```
> $ git diff
> diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
> index acf8863..2662ebb 100644
> --- a/lib/CodeGen/CodeGenFunction.h
> +++ b/lib/CodeGen/CodeGenFunction.h
> @@ -3571,7 +3571,8 @@ public:
> 
>  // If we still have any arguments, emit them using the type of the 
> argument.
>  for (auto *A : llvm::make_range(Arg, ArgRange.end()))
> -  ArgTypes.push_back(getVarArgType(A));
> +  ArgTypes.push_back(CalleeDecl->isVariadic() ? getVarArgType(A)
> +  : A->getType());
> 
>  EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip, Order);
>}
> 
> ```
> 
> I'd like to fix this issue in a separate commit.
So, that didn't work at all, but the gist of it is that I don't think we should 
call a function like `getVarArgType` when we aren't lowering a variadic 
function call. I'll look into doing it.


https://reviews.llvm.org/D28166



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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2017-01-03 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz abandoned this revision.
kparzysz added a comment.

In https://reviews.llvm.org/D25811#632670, @EricWF wrote:

> While I was attempting to review this patch I ended up coming up with fixed 
> tests myself. I committed them in r290746. I'm very sorry to step on your 
> toes.


No problem at all.  Thanks for the fixes!


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.h:3570
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr));
 

I'm testing this change:
```
$ git diff
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index acf8863..2662ebb 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -3571,7 +3571,8 @@ public:

 // If we still have any arguments, emit them using the type of the 
argument.
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(CalleeDecl->isVariadic() ? getVarArgType(A)
+  : A->getType());

 EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip, Order);
   }

```

I'd like to fix this issue in a separate commit.


https://reviews.llvm.org/D28166



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


[PATCH] D25556: [Sema] Add variable captured by a block to the enclosing lambda's potential capture list

2017-01-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D25556



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


r290904 - [OpenMP] Code cleanup for NVPTX OpenMP codegen

2017-01-03 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Tue Jan  3 14:19:56 2017
New Revision: 290904

URL: http://llvm.org/viewvc/llvm-project?rev=290904=rev
Log:
[OpenMP] Code cleanup for NVPTX OpenMP codegen

This patch cleans up private methods for NVPTX OpenMP codegen. It converts 
private
members to static functions to follow the coding style of CGOpenMPRuntime.cpp 
and
declutter the header file.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28124


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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=290904=290903=290904=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Jan  3 14:19:56 2017
@@ -20,53 +20,64 @@
 using namespace clang;
 using namespace CodeGen;
 
-/// \brief Get the GPU warp size.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXWarpSize(CodeGenFunction ) {
+namespace {
+enum OpenMPRTLFunctionNVPTX {
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
+  /// kmp_int32 thread_limit);
+  OMPRTL_NVPTX__kmpc_kernel_init,
+};
+
+// NVPTX Address space
+enum AddressSpace {
+  AddressSpaceShared = 3,
+};
+} // namespace
+
+/// Get the GPU warp size.
+static llvm::Value *getNVPTXWarpSize(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
   llvm::None, "nvptx_warp_size");
 }
 
-/// \brief Get the id of the current thread on the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXThreadID(CodeGenFunction ) {
+/// Get the id of the current thread on the GPU.
+static llvm::Value *getNVPTXThreadID(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
   llvm::None, "nvptx_tid");
 }
 
-// \brief Get the maximum number of threads in a block of the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXNumThreads(CodeGenFunction ) {
+/// Get the maximum number of threads in a block of the GPU.
+static llvm::Value *getNVPTXNumThreads(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
   llvm::None, "nvptx_num_threads");
 }
 
-/// \brief Get barrier to synchronize all threads in a block.
-void CGOpenMPRuntimeNVPTX::getNVPTXCTABarrier(CodeGenFunction ) {
+/// Get barrier to synchronize all threads in a block.
+static void getNVPTXCTABarrier(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   Bld.CreateCall(llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_barrier0));
+  (), llvm::Intrinsic::nvvm_barrier0));
 }
 
-// \brief Synchronize all GPU threads in a block.
-void CGOpenMPRuntimeNVPTX::syncCTAThreads(CodeGenFunction ) {
-  getNVPTXCTABarrier(CGF);
-}
+/// Synchronize all GPU threads in a block.
+static void syncCTAThreads(CodeGenFunction ) { getNVPTXCTABarrier(CGF); }
 
-/// \brief Get the thread id of the OMP master thread.
+/// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
 /// Thread id is 0 indexed.
 /// E.g: If NumThreads is 33, master id is 32.
 ///  If NumThreads is 64, master id is 32.
 ///  If NumThreads is 1024, master id is 992.
-llvm::Value *CGOpenMPRuntimeNVPTX::getMasterThreadID(CodeGenFunction ) {
+static llvm::Value *getMasterThreadID(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   llvm::Value *NumThreads = getNVPTXNumThreads(CGF);
 
@@ -77,19 +88,6 @@ llvm::Value *CGOpenMPRuntimeNVPTX::getMa
Bld.CreateNot(Mask), "master_tid");
 }
 
-namespace {
-enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
-  /// kmp_int32 thread_limit);
-  OMPRTL_NVPTX__kmpc_kernel_init,
-};
-
-// NVPTX Address space
-enum ADDRESS_SPACE {
-  ADDRESS_SPACE_SHARED = 3,
-};
-} // namespace
-
 CGOpenMPRuntimeNVPTX::WorkerFunctionState::WorkerFunctionState(
 CodeGenModule )
 : WorkerFn(nullptr), CGFI(nullptr) {
@@ -119,14 +117,14 @@ void CGOpenMPRuntimeNVPTX::initializeEnv
   CGM.getModule(), CGM.Int32Ty, /*isConstant=*/false,
   llvm::GlobalValue::CommonLinkage,
   llvm::Constant::getNullValue(CGM.Int32Ty), "__omp_num_threads", 0,
-  llvm::GlobalVariable::NotThreadLocal, ADDRESS_SPACE_SHARED);
+  llvm::GlobalVariable::NotThreadLocal, 

[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/support/win32/support.h:113
 // Returns zero if no set bit is found.
-#if defined(_WIN64)
+#if defined(__LP64__)
   if (_BitScanForward64(, mask))

Windows wouldn't have `__LP64__` defined (since it's LLP64 anyway). According 
to MSDN `_BitScanForward64` is available on x64 and ARM, so the conditional 
should reflect that (i.e. the existing conditional was incorrect, but since 
you're changing it you may as well fix it).



Comment at: include/support/win32/support.h:153
 // Returns 0 if no set bit is found.
-#if defined(_WIN64)
+#if defined(__LP64__)
   if (_BitScanReverse64(, mask))

Same `__LP64__` comment here.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28124: [OpenMP] Code cleanup for NVPTX OpenMP codegen

2017-01-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290904: [OpenMP] Code cleanup for NVPTX OpenMP codegen 
(authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D28124?vs=82619=82931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28124

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -20,53 +20,64 @@
 using namespace clang;
 using namespace CodeGen;
 
-/// \brief Get the GPU warp size.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXWarpSize(CodeGenFunction ) {
+namespace {
+enum OpenMPRTLFunctionNVPTX {
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
+  /// kmp_int32 thread_limit);
+  OMPRTL_NVPTX__kmpc_kernel_init,
+};
+
+// NVPTX Address space
+enum AddressSpace {
+  AddressSpaceShared = 3,
+};
+} // namespace
+
+/// Get the GPU warp size.
+static llvm::Value *getNVPTXWarpSize(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
   llvm::None, "nvptx_warp_size");
 }
 
-/// \brief Get the id of the current thread on the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXThreadID(CodeGenFunction ) {
+/// Get the id of the current thread on the GPU.
+static llvm::Value *getNVPTXThreadID(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_tid_x),
   llvm::None, "nvptx_tid");
 }
 
-// \brief Get the maximum number of threads in a block of the GPU.
-llvm::Value *CGOpenMPRuntimeNVPTX::getNVPTXNumThreads(CodeGenFunction ) {
+/// Get the maximum number of threads in a block of the GPU.
+static llvm::Value *getNVPTXNumThreads(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   return Bld.CreateCall(
   llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
+  (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x),
   llvm::None, "nvptx_num_threads");
 }
 
-/// \brief Get barrier to synchronize all threads in a block.
-void CGOpenMPRuntimeNVPTX::getNVPTXCTABarrier(CodeGenFunction ) {
+/// Get barrier to synchronize all threads in a block.
+static void getNVPTXCTABarrier(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   Bld.CreateCall(llvm::Intrinsic::getDeclaration(
-  (), llvm::Intrinsic::nvvm_barrier0));
+  (), llvm::Intrinsic::nvvm_barrier0));
 }
 
-// \brief Synchronize all GPU threads in a block.
-void CGOpenMPRuntimeNVPTX::syncCTAThreads(CodeGenFunction ) {
-  getNVPTXCTABarrier(CGF);
-}
+/// Synchronize all GPU threads in a block.
+static void syncCTAThreads(CodeGenFunction ) { getNVPTXCTABarrier(CGF); }
 
-/// \brief Get the thread id of the OMP master thread.
+/// Get the thread id of the OMP master thread.
 /// The master thread id is the first thread (lane) of the last warp in the
 /// GPU block.  Warp size is assumed to be some power of 2.
 /// Thread id is 0 indexed.
 /// E.g: If NumThreads is 33, master id is 32.
 ///  If NumThreads is 64, master id is 32.
 ///  If NumThreads is 1024, master id is 992.
-llvm::Value *CGOpenMPRuntimeNVPTX::getMasterThreadID(CodeGenFunction ) {
+static llvm::Value *getMasterThreadID(CodeGenFunction ) {
   CGBuilderTy  = CGF.Builder;
   llvm::Value *NumThreads = getNVPTXNumThreads(CGF);
 
@@ -77,19 +88,6 @@
Bld.CreateNot(Mask), "master_tid");
 }
 
-namespace {
-enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 omp_handle,
-  /// kmp_int32 thread_limit);
-  OMPRTL_NVPTX__kmpc_kernel_init,
-};
-
-// NVPTX Address space
-enum ADDRESS_SPACE {
-  ADDRESS_SPACE_SHARED = 3,
-};
-} // namespace
-
 CGOpenMPRuntimeNVPTX::WorkerFunctionState::WorkerFunctionState(
 CodeGenModule )
 : WorkerFn(nullptr), CGFI(nullptr) {
@@ -119,14 +117,14 @@
   CGM.getModule(), CGM.Int32Ty, /*isConstant=*/false,
   llvm::GlobalValue::CommonLinkage,
   llvm::Constant::getNullValue(CGM.Int32Ty), "__omp_num_threads", 0,
-  llvm::GlobalVariable::NotThreadLocal, ADDRESS_SPACE_SHARED);
+  llvm::GlobalVariable::NotThreadLocal, AddressSpaceShared);
   ActiveWorkers->setAlignment(DL.getPrefTypeAlignment(CGM.Int32Ty));
 
   WorkID = new llvm::GlobalVariable(
   CGM.getModule(), CGM.Int64Ty, /*isConstant=*/false,
   llvm::GlobalValue::CommonLinkage,
   llvm::Constant::getNullValue(CGM.Int64Ty), "__tgt_work_id", 0,
-  llvm::GlobalVariable::NotThreadLocal, ADDRESS_SPACE_SHARED);
+  

[PATCH] D28231: -Wunreachable-code: Avoid multiple diagnostics that are triggered by the same source range and fix the unary operator fixit source range

2017-01-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

If I change the condition to the following,

  if (!s->p || 1)

clang suggests enclosing !s->p with a parenthesis, but the comment in 
ReachableCode.cpp says the parenthesis should enclose the integer literal. It 
seems like there is a contradiction here?


Repository:
  rL LLVM

https://reviews.llvm.org/D28231



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


[PATCH] D28220: provide Win32 native threading

2017-01-03 Thread Kyrill Briantsev via Phabricator via cfe-commits
awson added a comment.

You don't need #define VC_EXTRA_LEAN since:

1. VC_EXTRA_LEAN is a mistype, only VC_EXTRALEAN has some meaning in Windows 
ecosystem;
2. VC_EXTRALEAN is used *only* in MFC headers which obviously aren't used in 
clang codebase.

Thus it would be better to remove this altogether, and (perhaps) replace with 
the relevant #define WIN32_LEAN_AND_MEAN.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 82930.
aaron.ballman added a comment.

I've updated this patch to correct the codegen changes. If you'd prefer, I can 
review/commit in two separate phases, one for the codegen bug and one for the 
attribute issue, as I think these changes might be reasonably considered 
separately despite the gating.


https://reviews.llvm.org/D28166

Files:
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/ms_abi.c
  test/Sema/knr-def-call.c
  test/Sema/warn-strict-prototypes.c

Index: test/Sema/warn-strict-prototypes.c
===
--- test/Sema/warn-strict-prototypes.c
+++ test/Sema/warn-strict-prototypes.c
@@ -60,3 +60,8 @@
 // K function definition with previous prototype declared is not diagnosed.
 void foo11(int p, int p2);
 void foo11(p, p2) int p; int p2; {}
+
+// PR31020
+void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
+  short d;
+{}
Index: test/Sema/knr-def-call.c
===
--- test/Sema/knr-def-call.c
+++ test/Sema/knr-def-call.c
@@ -39,3 +39,9 @@
   proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
   ()(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}}
 }
+
+// PR31020
+void func(short d) __attribute__((cdecl)); // expected-note{{previous declaration is here}}
+void __attribute__((cdecl)) func(d)
+  short d; // expected-warning{{promoted type 'int' of K function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
+{}
Index: test/CodeGen/ms_abi.c
===
--- test/CodeGen/ms_abi.c
+++ test/CodeGen/ms_abi.c
@@ -146,3 +146,18 @@
   // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
   // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
 }
+
+// Ensure that K C function types are not treated the same as a varargs call
+// when it comes to the null pointer constant value 0. For a varargs call, this
+// should be widened to a pointer-sized type, and for a K C call, it should
+// remain an int.
+void f7(int n) {}
+void(*f7_ptr)() = f7;
+
+void f8(void) {
+  f7_ptr(0);
+  // WIN64: %callee.knr.cast = bitcast void (...)* %0 to void (i32)*
+  // WIN64-NEXT: call void %callee.knr.cast(i32 0)
+  // FREEBSD: %callee.knr.cast = bitcast void (...)* %0 to void (i32, ...)*
+  // FREEBSD-NEXT: call void (i32, ...) %callee.knr.cast(i32 0)
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7458,11 +7458,12 @@
 // Determine whether the function was written with a
 // prototype. This true when:
 //   - there is a prototype in the declarator, or
-//   - the type R of the function is some kind of typedef or other reference
-// to a type name (which eventually refers to a function type).
+//   - the type R of the function is some kind of typedef or other non-
+// attributed reference to a type name (which eventually refers to a
+// function type).
 bool HasPrototype =
   (D.isFunctionDeclarator() && D.getFunctionTypeInfo().hasPrototype) ||
-  (!isa(R.getTypePtr()) && R->isFunctionProtoType());
+  (!R->getAsAdjusted() && R->isFunctionProtoType());
 
 NewFD = FunctionDecl::Create(SemaRef.Context, DC,
  D.getLocStart(), NameInfo, R,
@@ -11950,7 +11951,7 @@
   !LangOpts.CPlusPlus) {
 TypeSourceInfo *TI = FD->getTypeSourceInfo();
 TypeLoc TL = TI->getTypeLoc();
-FunctionTypeLoc FTL = TL.castAs();
+FunctionTypeLoc FTL = TL.getAsAdjusted();
 Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1;
   }
 }
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3567,7 +3567,7 @@
 
 // If we still have any arguments, emit them using the type of the argument.
 for (auto *A : llvm::make_range(Arg, ArgRange.end()))
-  ArgTypes.push_back(getVarArgType(A));
+  ArgTypes.push_back(getVarArgType(A, CallArgTypeInfo == nullptr));
 
 EmitCallArgs(Args, ArgTypes, ArgRange, CalleeDecl, ParamsToSkip, Order);
   }
@@ -3605,7 +3605,7 @@
   void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
 
 private:
-  QualType getVarArgType(const Expr *Arg);
+  QualType getVarArgType(const Expr *Arg, bool KNRFunction);
 
   const TargetCodeGenInfo () const {
 return CGM.getTargetCodeGenInfo();
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp

[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

I agree. Since the current set of encodings all have different element sizes 
and this is not likely to change, this looks good.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2017-01-03 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D26267



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


[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.

2017-01-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

This has been discussed during the initial review for the header:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160425/157187.html

The main issue is after preprocessing the header the original function name is 
no longer available in diagnostics reported. The spec defines as_type as a 
builtin function and not a macro. Additionally your patch would allow as_type 
to be used with extra type (not only those defined in spec). Also I don't see 
the problem to implement as_type with just simply calling a builtin. It should 
be inlined later anyways.


https://reviews.llvm.org/D28136



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I think that it will suffice for now.  We can change the flag to be more 
granular in the future.  I think that this is going well beyond the original 
intent of cleaning up the usage of the `_WIN32` macros at this point.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

Another belated thought: it all depends on the intended meaning of the symbol:

- Does it say anything about the element size (i.e. sizeof(wchar_t)?
- Does it specify the native encoding of wide-char strings for a platform (i.e. 
UTF-16 on Windows)?

It looks like the same symbol is now used for both things, which may not be a 
good idea.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 82927.
compnerd added a comment.

Switch to `_LIBCPP_SHORT_WCHAR`.


Repository:
  rL LLVM

https://reviews.llvm.org/D28223

Files:
  include/__config
  include/__locale
  include/support/win32/support.h
  include/type_traits
  src/chrono.cpp
  src/include/config_elast.h
  src/locale.cpp
  src/new.cpp
  src/system_error.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -24,16 +24,17 @@
 # endif // defined(BSD)
 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
-#if !defined(_WIN32)
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 # include 
-#endif // !_WIN32
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
 #if defined(__NetBSD__)
 #pragma weak pthread_create // Do not create libpthread dependency
 #endif
-#if defined(_WIN32)
+
+#if defined(_LIBCPP_WIN32API)
 #include 
-#endif
+#endif // defined(_LIBCPP_WIN32API)
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -91,7 +92,7 @@
 if (result < 0)
 return 0;
 return static_cast(result);
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_WIN32API)
 SYSTEM_INFO info;
 GetSystemInfo();
 return info.dwNumberOfProcessors;
Index: src/system_error.cpp
===
--- src/system_error.cpp
+++ src/system_error.cpp
@@ -65,7 +65,7 @@
 
 string do_strerror_r(int ev);
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSVCRT)
 string do_strerror_r(int ev) {
   char buffer[strerror_buff_size];
   if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
Index: src/new.cpp
===
--- src/new.cpp
+++ src/new.cpp
@@ -72,7 +72,7 @@
 if (static_cast(alignment) < sizeof(void*))
   alignment = std::align_val_t(sizeof(void*));
 void* p;
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSVCRT)
 while ((p = _aligned_malloc(size, static_cast(alignment))) == nullptr)
 #else
 while (::posix_memalign(, static_cast(alignment), size) != 0)
Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -3254,7 +3254,7 @@
 const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
 extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
 {
-#if _WIN32
+#if defined(_LIBCPP_SHORT_WCHAR)
 const uint16_t* _frm = reinterpret_cast(frm);
 const uint16_t* _frm_end = reinterpret_cast(frm_end);
 const uint16_t* _frm_nxt = _frm;
@@ -3266,7 +3266,7 @@
 uint8_t* _to = reinterpret_cast(to);
 uint8_t* _to_end = reinterpret_cast(to_end);
 uint8_t* _to_nxt = _to;
-#if _WIN32
+#if defined(_LIBCPP_SHORT_WCHAR)
 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
 _Maxcode_, _Mode_);
 #else
@@ -3286,7 +3286,7 @@
 const uint8_t* _frm = reinterpret_cast(frm);
 const uint8_t* _frm_end = reinterpret_cast(frm_end);
 const uint8_t* _frm_nxt = _frm;
-#if _WIN32
+#if defined(_LIBCPP_SHORT_WCHAR)
 uint16_t* _to = reinterpret_cast(to);
 uint16_t* _to_end = reinterpret_cast(to_end);
 uint16_t* _to_nxt = _to;
Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -10,7 +10,7 @@
 #ifndef _LIBCPP_CONFIG_ELAST
 #define _LIBCPP_CONFIG_ELAST
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_MSCVRT)
 #include 
 #else
 #include 
@@ -28,7 +28,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_WIN32)
+#elif defined(_LIBCPP_MSCVRT)
 #define _LIBCPP_ELAST _sys_nerr
 #else
 // Warn here so that the person doing the libcxx port has an easier time:
Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -12,7 +12,7 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
-#if defined(_WIN32)
+#if defined(_LIBCPP_WIN32API)
 #define WIN32_LEAN_AND_MEAN
 #define VC_EXTRA_LEAN
 #include 
@@ -22,13 +22,13 @@
 #else
 #if !defined(CLOCK_REALTIME)
 #include // for gettimeofday and timeval
-#endif
-#endif
+#endif // !defined(CLOCK_REALTIME)
+#endif // defined(_LIBCPP_WIN32API)
 
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_WIN32) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
 #error "Monotonic clock not implemented"
 #endif
 #endif
@@ -45,7 +45,7 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_WIN32)
+#if defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using 

[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd commandeered this revision.
compnerd edited reviewers, added: EricWF; removed: compnerd.
compnerd added a comment.

Ill use this version for the commit, but Id like to get an okay on it before I 
do that :-).


https://reviews.llvm.org/D28212



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


[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2017-01-03 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob updated this revision to Diff 82922.
arpith-jacob added a comment.

Updated patch based on reviews.

The serialized parallel region executed by the master was modified to call the 
'end' runtime call with a PrePostActionTy so that it is called upon exit of any 
cleanup scope.

Added reference to OpenMP spec regarding implicit barrier at the end of a 
parallel region.


https://reviews.llvm.org/D28145

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_parallel_codegen.cpp

Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -0,0 +1,323 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx a = 0;
+  short aa = 0;
+  tx b[10];
+
+  #pragma omp target if(0)
+  {
+#pragma omp parallel
+{
+  int a = 41;
+}
+a += 1;
+  }
+
+  #pragma omp target
+  {
+#pragma omp parallel
+{
+  int a = 42;
+}
+#pragma omp parallel if(0)
+{
+  int a = 43;
+}
+#pragma omp parallel if(1)
+{
+  int a = 44;
+}
+a += 1;
+  }
+
+  #pragma omp target if(n>40)
+  {
+#pragma omp parallel if(n>1000)
+{
+  int a = 45;
+}
+a += 1;
+aa += 1;
+b[2] += 1;
+  }
+
+  return a;
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+  // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l17}}_worker()
+
+
+
+
+
+
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker()
+  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]])
+  // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
+  // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
+  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
+  // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]]
+  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
+  // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
+  // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
+  //
+  // CHECK: [[EXEC_PFN1]]
+  // CHECK: call void [[PARALLEL_FN1]](
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[CHECK_NEXT1]]
+  // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
+  // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
+  //
+  // CHECK: [[EXEC_PFN2]]
+  // CHECK: call void [[PARALLEL_FN2]](
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[CHECK_NEXT2]]
+  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK: call void @__kmpc_kernel_end_parallel()
+  // CHECK: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK: call void @llvm.nvvm.barrier0()
+  // CHECK: br label 

[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

@smeenai I think I tried to make a jumbled mess of points :-)

1. Associating an encoding with a char/element type seems wrong; any number of 
encodings can use wchar_t.
2. Windows allegedly uses UTF-16 now, not UCS-2
3. There might be a bug in locale.cpp if it actually does UCS-2 -> UTF-8 
conversion and Windows no longer uses UCS-2 (though I think they overlap for a 
lot of code-points)

@compnerd _LIBCPP_SHORT_WCHAR sounds good to me, especially in light of the 
front-end flag (didn't know that existed.)


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D28246: clang-format: [JS] avoid indent after ambient function declarations.

2017-01-03 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Before:

  declare function foo();
let x = 1;

After:

  declare function foo();
  let x = 1;

The problem was that clang-format would unconditionally try to parse a child 
block, even though ambient function declarations do not have a body (similar to 
forward declarations).


https://reviews.llvm.org/D28246

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,12 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1259,6 +1259,9 @@
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,12 @@
   "declare function\n"
   "x();",  // TODO(martinprobst): should ideally be indented.
   NineCols);
+  verifyFormat("declare function foo();\n"
+   "let x = 1;\n");
+  verifyFormat("declare class X {}\n"
+   "let x = 1;\n");
+  verifyFormat("declare interface Y {}\n"
+   "let x = 1;\n");
   verifyFormat(
   "declare enum X {\n"
   "}",
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1259,6 +1259,9 @@
 nextToken();
   }
 
+  if (FormatTok->is(tok::semi))
+return;
+
   parseChildBlock();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28166: Properly merge K functions that have attributes

2017-01-03 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D28166#634196, @aaron.ballman wrote:

> So I think the correct behavior is to only enable the vararg behavior when 
> the function is variadic with an ellipsis rather than variadic due to a lack 
> of prototype.


That sounds right. Note that functions with no prototype are not actually 
variadic, so it's permitted for a vararg definition to use a different calling 
convention from a no-prototype call, as happens in this case.


https://reviews.llvm.org/D28166



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


[PATCH] D28226: threading_support: introduce __libcpp_recursive_mutex_t

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

The dynamic behavior only is used for Windows, not pthreads.  So, we dont see 
it here, but it becomes apparent in the windows support.  I was trying to 
minimize the changes to libc++ itself to avoid having it to consider the 
recursive vs non-recursive cases.  If the libc++ maintainers would prefer to 
expand the interfaces rather than use the dynamic behavior, Im fine with that 
approach too.


Repository:
  rL LLVM

https://reviews.llvm.org/D28226



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


[PATCH] D28229: [libcxx] Fix testing of the externally-threaded library build after r290850

2017-01-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I dont think that making Win32 threading an external one makes much sense 
unless we also do the same for pthreads.  Its just as valid a threading model 
as pthreads, so why give preferential treatment to that?  (Sure, there are more 
buildbots using it, but thats not a strong technical justification).




Comment at: include/__threading_support:30-50
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+!__libcpp_has_include(<__external_threading>)
+// If the <__external_threading> header is absent, build libc++ against a
+// pthread-oriented thread api but leave out its implementation. This setup
+// allows building+testing of an externally-threaded library variant (on any
+// platform that supports pthreads). Here, an 'externally-threaded' library
+// variant is one where the implementation of the libc++ thread api is provided

Can you break this down into this which IMO is far more readable:

#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
#if __libcpp_has_include()
#include <__external_threading>
#else
// Why pthread?
#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
#endif
#endif

#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) ||
defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
#include 
#include 
#endif


https://reviews.llvm.org/D28229



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


[PATCH] D20791: Support SOURCE_DATE_EPOCH environment variable

2017-01-03 Thread Ed Maste via Phabricator via cfe-commits
emaste abandoned this revision.
emaste added a comment.

Abandon in favour of https://reviews.llvm.org/D23934


https://reviews.llvm.org/D20791



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2017-01-03 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > firolino wrote:
> > > > firolino wrote:
> > > > > firolino wrote:
> > > > > > firolino wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > Why do we not want to match this?
> > > > > > > > > If we decide, whether we transform 
> > > > > > > > > ```
> > > > > > > > > class A { 
> > > > > > > > > } Object1, Object2;
> > > > > > > > > ``` 
> > > > > > > > > to
> > > > > > > > > ```
> > > > > > > > > class A { 
> > > > > > > > > } Object1, 
> > > > > > > > > Object2;
> > > > > > > > > ``` 
> > > > > > > > > or
> > > > > > > > > ```
> > > > > > > > > class A { 
> > > > > > > > > } 
> > > > > > > > > Object1, 
> > > > > > > > > Object2;
> > > > > > > > > ``` 
> > > > > > > > > I might consider adding support for it. Moreover, this kind 
> > > > > > > > > of definition is usually seen globally and I don't know how 
> > > > > > > > > to handle globals yet. See 
> > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > I think this should be handled. It can be handled in either of 
> > > > > > > > the forms you show, or by saying:
> > > > > > > > ```
> > > > > > > > A Object1;
> > > > > > > > A Object2;
> > > > > > > > ```
> > > > > > > > If all of these turn out to be a problem, we can still diagnose 
> > > > > > > > without providing a fixit.
> > > > > > > > 
> > > > > > > > As for globals in general, they can be handled in a separate 
> > > > > > > > patch once we figure out the declaration grouping.
> > > > > > > OK. I will try to split the object definition from the class 
> > > > > > > definition, as you have suggested. Thus, I can kick out the 
> > > > > > > tagDecl-matcher as well. If there is no easy way to do this, it 
> > > > > > > will be reported anyway but without a fixit.
> > > > > > > 
> > > > > > > Note for me: Update documentation!
> > > > > > What about
> > > > > > ```
> > > > > > struct S {
> > > > > > } S1;
> > > > > > ```
> > > > > > I would like to report this too, since two names are being declared 
> > > > > > here. `S` and `S1`. What do you think?
> > > > > ```
> > > > > struct {
> > > > > } nn1, nn2;
> > > > > ```
> > > > > Shall we ignore anonymous definitions?
> > > > To be more precise: Warn and provide a fixit for `struct S {} S1`. Only 
> > > > warn for `struct {} nn1, nn2`.
> > > > What about
> > > > 
> > > > ```
> > > > struct S {
> > > > } S1;
> > > > ```
> > > > I would like to report this too, since two names are being declared 
> > > > here. S and S1. What do you think?
> > > 
> > > I don't think that this should be diagnosed. For one, this is a 
> > > relatively common pattern (arguably more common than `struct S { } S1, 
> > > S2;`), but also, it names two very distinct entities (a type and a 
> > > variable).
> > > 
> > > > ```
> > > > struct {
> > > > } nn1, nn2;
> > > >```
> > > > Shall we ignore anonymous definitions?
> > > 
> > > Yes, we basically have to.
> > > 
> > Transforming
> > ```
> > typedef struct X { int t; } X, Y;
> > ```
> > to
> > ```
> > typedef struct X { int t; };
> > typedef X X;
> > typedef X Y;
> > ```
> > will be valid, but looks odd.
> I am on the fence about this transformation -- it does not declare new 
> objects, but instead declares new types. A very common pattern in some 
> libraries (such as the Win32 SDK) is to declare:
> ```
> typedef struct Blah {
> 
> } Blah, *PBlah, **PPBlah;
> ```
> Because of that pattern, diagnosing the above typedef is likely to be very 
> chatty in some projects, and I don't know that the fixit provides much real 
> benefit for types.
> 
> At least for the CERT DCL04-C version of this rule, that code should not be 
> flagged. Do you think any of the variations of this check should flag it?
Maybe we should reconsider where to split and where not. The original idea was 
to minimize confusion on code like
```
int* a,b;
```
whereas 
```
struct S {} *s1, s2;
```
seems not so confusing as above. However, 
```
struct S {}* s1, s2;
```
looks dangerous again.

Even following code looks unfamiliar to me.
```
typedef struct Blah {} Blah, *PBlah;
```

It really depends on the beholder. So, how about letting this check split 
**everything** and provide options for maximum flexibility? So specific 
rulesets or the user may configure it as they wish. We could add for example 
split-after-tag-def, split-tag-typedef in addition to cppcore and cert and use 
a default setting (split-after-tag-def=true, split-tag-typedef=false).


https://reviews.llvm.org/D27621



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

[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2017-01-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:511-516
+// Activate workers.
+syncCTAThreads(CGF);
+
+// Barrier at end of parallel region.
+syncCTAThreads(CGF);
+

arpith-jacob wrote:
> tra wrote:
> > Are two back-to-back syncCTAThreads() intentional or did you mean to call 
> > something else to activate workers?
> Intentional.  The first wakes up worker warps to execute the parallel region. 
>  The second is for the master warp to wait until the region has completed 
> execution.  This is to implement the semantics of an implicit barrier at the 
> end of an OpenMP parallel region.
OK. It may be good to add few comments documenting these assumptions (or point 
to existing docs) here.



https://reviews.llvm.org/D28145



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


[PATCH] D28223: clean up use of _WIN32

2017-01-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D28223#634199, @compnerd wrote:

> I figured that using the explicit encoding is nicer since it means that its 
> more documenting.


I think @kimgr's point was that if you're using an explicit encoding, it should 
be UTF-16 rather than UCS-2 :)


Repository:
  rL LLVM

https://reviews.llvm.org/D28223



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


[PATCH] D17840: [OPENMP] Private, firstprivate, and lastprivate clauses for distribute, host code generation

2017-01-03 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli added a comment.

Commited r290898.


Repository:
  rL LLVM

https://reviews.llvm.org/D17840



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


[PATCH] D28243: [OpenMP] Add missing regression test for pragma distribute, clause firstprivate

2017-01-03 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added reviewers: ABataev, sfantao, kkwli0.
carlo.bertolli added subscribers: arpith-jacob, gtbercea, caomhin, cfe-commits.

The regression test was missing from the previous already accepted patch.


https://reviews.llvm.org/D28243

Files:
  test/OpenMP/distribute_firstprivate_codegen.cpp

Index: test/OpenMP/distribute_firstprivate_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_firstprivate_codegen.cpp
@@ -0,0 +1,382 @@
+// RUN: %clang_cc1 -DLAMBDA -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-64
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-64
+// RUN: %clang_cc1 -DLAMBDA -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-32
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -DLAMBDA -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix LAMBDA --check-prefix LAMBDA-32
+
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1  -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template 
+struct S {
+  T f;
+  S(T a) : f(a) {}
+  S() : f() {}
+  operator T() { return T(); }
+  ~S() {}
+};
+
+// CHECK: [[S_FLOAT_TY:%.+]] = type { float }
+// CHECK: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
+template 
+T tmain() {
+  S test;
+  T t_var = T();
+  T vec[] = {1, 2};
+  S s_arr[] = {1, 2};
+  S  = test;
+  #pragma omp target
+  #pragma omp teams
+#pragma omp distribute firstprivate(t_var, vec, s_arr, s_arr, var, var)
+  for (int i = 0; i < 2; ++i) {
+vec[i] = t_var;
+s_arr[i] = var;
+  }
+  return T();
+}
+
+int main() {
+  static int svar;
+  volatile double g;
+  volatile double  = g;
+
+  #ifdef LAMBDA
+  // LAMBDA-LABEL: @main
+  // LAMBDA: call{{.*}} void [[OUTER_LAMBDA:@.+]](
+  [&]() {
+static float sfvar;
+// LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
+// LAMBDA: call i{{[0-9]+}} @__tgt_target_teams(
+// LAMBDA: call void [[OFFLOADING_FUN:@.+]](
+
+// LAMBDA: define{{.+}} void [[OFFLOADING_FUN]](
+// LAMBDA: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}}* [[OMP_OUTLINED:@.+]] to {{.+}})
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute firstprivate(g, g1, svar, sfvar)
+for (int i = 0; i < 2; ++i) {
+  // LAMBDA-64: define{{.*}} internal{{.*}} void [[OMP_OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i{{[0-9]+}} [[G_IN:%.+]], i{{[0-9]+}} [[G1_IN:%.+]], i{{[0-9]+}} [[SVAR_IN:%.+]], i{{[0-9]+}} [[SFVAR_IN:%.+]])
+  // LAMBDA-32: define internal{{.*}} void [[OMP_OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, double*{{.*}} [[G_IN:%.+]], i{{[0-9]+}} [[G1_IN:%.+]], i{{[0-9]+}} [[SVAR_IN:%.+]], i{{[0-9]+}} [[SFVAR_IN:%.+]])
+  // Private alloca's for conversion
+  // LAMBDA-64: [[G_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // LAMBDA-32: [[G_ADDR:%.+]] = alloca double*,
+  // LAMBDA: [[G1_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // LAMBDA: [[SVAR_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // LAMBDA: [[SFVAR_ADDR:%.+]] = alloca i{{[0-9]+}},
+  // LAMBDA: 

[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.

2017-01-03 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:511-516
+// Activate workers.
+syncCTAThreads(CGF);
+
+// Barrier at end of parallel region.
+syncCTAThreads(CGF);
+

tra wrote:
> Are two back-to-back syncCTAThreads() intentional or did you mean to call 
> something else to activate workers?
Intentional.  The first wakes up worker warps to execute the parallel region.  
The second is for the master warp to wait until the region has completed 
execution.  This is to implement the semantics of an implicit barrier at the 
end of an OpenMP parallel region.


https://reviews.llvm.org/D28145



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


  1   2   >