[libcxx] r307997 - [libc++] Clean up cl warning 4231 disabling

2017-07-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 13 20:56:54 2017
New Revision: 307997

URL: http://llvm.org/viewvc/llvm-project?rev=307997=rev
Log:
[libc++] Clean up cl warning 4231 disabling

Once upon a time, extern templates used to be a Microsoft extension, so
cl would warn about their usage, and libc++ suppressed that warning.
They've long since been standardized, so the warning is defunct. (libc++
also doesn't currently support building with cl anyway.)

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/string
libcxx/trunk/include/vector

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=307997=307996=307997=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Thu Jul 13 20:56:54 2017
@@ -4234,10 +4234,6 @@ sort(__wrap_iter<_Tp*> __first, __wrap_i
 _VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
 }
 
-#ifdef _LIBCPP_MSVC
-#pragma warning( push )
-#pragma warning( disable: 4231)
-#endif // _LIBCPP_MSVC
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, 
char*>(char*, char*, __less&))
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, 
wchar_t*>(wchar_t*, wchar_t*, __less&))
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, 
signed char*>(signed char*, signed char*, __less&))
@@ -4271,9 +4267,6 @@ _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool 
__insertion_sort_incomplete<__less&, long double*>(long double*, 
long double*, __less&))
 
 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, 
long double*, __less&))
-#ifdef _LIBCPP_MSVC
-#pragma warning( pop )
-#endif  // _LIBCPP_MSVC
 
 // lower_bound
 

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307997=307996=307997=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Thu Jul 13 20:56:54 2017
@@ -578,14 +578,7 @@ __basic_string_common<__b>::__throw_out_
 _VSTD::__throw_out_of_range("basic_string");
 }
 
-#ifdef _LIBCPP_MSVC
-#pragma warning( push )
-#pragma warning( disable: 4231 )
-#endif // _LIBCPP_MSVC
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
__basic_string_common)
-#ifdef _LIBCPP_MSVC
-#pragma warning( pop )
-#endif // _LIBCPP_MSVC
 
 #ifdef _LIBCPP_NO_EXCEPTIONS
 template 

Modified: libcxx/trunk/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=307997=307996=307997=diff
==
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Thu Jul 13 20:56:54 2017
@@ -310,14 +310,7 @@ __vector_base_common<__b>::__throw_out_o
 _VSTD::__throw_out_of_range("vector");
 }
 
-#ifdef _LIBCPP_MSVC
-#pragma warning( push )
-#pragma warning( disable: 4231 )
-#endif // _LIBCPP_MSVC
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
__vector_base_common)
-#ifdef _LIBCPP_MSVC
-#pragma warning( pop )
-#endif // _LIBCPP_MSVC
 
 template 
 class __vector_base


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


r307995 - Add release notes for the overloadable attribute

2017-07-13 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Jul 13 20:23:57 2017
New Revision: 307995

URL: http://llvm.org/viewvc/llvm-project?rev=307995=rev
Log:
Add release notes for the overloadable attribute

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=307995=307994=307995=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Jul 13 20:23:57 2017
@@ -82,7 +82,9 @@ Clang now supports the ...
 Attribute Changes in Clang
 --
 
--  ...
+-  The ``overloadable`` attribute now allows at most one function with a given
+   name to lack the ``overloadable`` attribute. This unmarked function will not
+   have its name mangled.
 
 Windows Support
 ---


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


[PATCH] D35338: Add the -fdestroy-globals flag

2017-07-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

This is interesting. Do you have any results/metrics to share (e.g some any 
binary size reduction for projects you've looked at)?




Comment at: lib/Frontend/CompilerInvocation.cpp:585
   Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
+  Opts.DestroyGlobals = !Args.hasArg(OPT_fno_destroy_globals);
   Opts.CodeModel = getCodeModel(Args, Diags);

I think this will do the wrong thing when passed: -cc1 -fno-destroy-globals 
-fdestroy-globals. Using hasFlag here should fix the issue. I'm just noting 
this as a FYI, there's no need to update the diff right away, since I'd first 
like to find out if there are any correctness concerns / what the use cases for 
this functionality are.


https://reviews.llvm.org/D35338



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


[PATCH] D35212: [Index] Prevent canonical decl becoming nullptr

2017-07-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added subscribers: arphaman, vsk.
vsk added a comment.

Do you have a test case?


https://reviews.llvm.org/D35212



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


r307989 - Use EXPECT_TRUE rather than EXPECT_EQ(true, ...) to clean up the code and silence a null conversion warning.

2017-07-13 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Jul 13 19:03:03 2017
New Revision: 307989

URL: http://llvm.org/viewvc/llvm-project?rev=307989=rev
Log:
Use EXPECT_TRUE rather than EXPECT_EQ(true, ...) to clean up the code and 
silence a null conversion warning.

Modified:
cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp?rev=307989=307988=307989=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp Thu Jul 13 19:03:03 
2017
@@ -80,8 +80,8 @@ TEST(ParserTest, ParseBoolean) {
   Sema.parse("true");
   Sema.parse("false");
   EXPECT_EQ(2U, Sema.Values.size());
-  EXPECT_EQ(true, Sema.Values[0].getBoolean());
-  EXPECT_EQ(false, Sema.Values[1].getBoolean());
+  EXPECT_TRUE(Sema.Values[0].getBoolean());
+  EXPECT_FALSE(Sema.Values[1].getBoolean());
 }
 
 TEST(ParserTest, ParseDouble) {


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


r307988 - Change dyn_casts with unused variables to isa statements to avoid unused variables.

2017-07-13 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Jul 13 18:42:57 2017
New Revision: 307988

URL: http://llvm.org/viewvc/llvm-project?rev=307988=rev
Log:
Change dyn_casts with unused variables to isa statements to avoid unused 
variables.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=307988=307987=307988=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Jul 13 18:42:57 2017
@@ -956,7 +956,7 @@ void CodeGenFunction::EmitOMPReductionCl
 
 auto *LHSVD = cast(cast(*ILHS)->getDecl());
 auto *RHSVD = cast(cast(*IRHS)->getDecl());
-if (auto *OASE = dyn_cast(IRef)) {
+if (isa(IRef)) {
   // Store the address of the original variable associated with the LHS
   // implicit variable.
   PrivateScope.addPrivate(LHSVD, [, Count]() -> Address {
@@ -965,7 +965,7 @@ void CodeGenFunction::EmitOMPReductionCl
   PrivateScope.addPrivate(RHSVD, [this, PrivateVD]() -> Address {
 return GetAddrOfLocalVar(PrivateVD);
   });
-} else if (auto *ASE = dyn_cast(IRef)) {
+} else if (isa(IRef)) {
   // Store the address of the original variable associated with the LHS
   // implicit variable.
   PrivateScope.addPrivate(LHSVD, [, Count]() -> Address {

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=307988=307987=307988=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 13 18:42:57 2017
@@ -255,7 +255,7 @@ static void DiagnoseObjCImplementedDepre
   bool IsCategory = false;
   AvailabilityResult Availability = ND->getAvailability();
   if (Availability != AR_Deprecated) {
-if (const auto *MD = dyn_cast(ND)) {
+if (isa(ND)) {
   if (Availability != AR_Unavailable)
 return;
   // Warn about implementing unavailable methods.


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


r307986 - [ODRHash] Avoid taking the types of FunctionDecl's

2017-07-13 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Jul 13 18:36:41 2017
New Revision: 307986

URL: http://llvm.org/viewvc/llvm-project?rev=307986=rev
Log:
[ODRHash] Avoid taking the types of FunctionDecl's

FunctionDecl already hashes most of the information in the function's type.
Add hashing of the return type, and skip hashing the function's type to avoid
redundancy and extra work when computing the hash.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=307986=307985=307986=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jul 13 18:36:41 2017
@@ -246,7 +246,9 @@ public:
   }
 
   void VisitValueDecl(const ValueDecl *D) {
-AddQualType(D->getType());
+if (!isa(D)) {
+  AddQualType(D->getType());
+}
 Inherited::VisitValueDecl(D);
   }
 
@@ -305,6 +307,8 @@ public:
   Hash.AddSubDecl(Param);
 }
 
+AddQualType(D->getReturnType());
+
 Inherited::VisitFunctionDecl(D);
   }
 

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=307986=307985=307986=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Thu Jul 13 18:36:41 2017
@@ -517,6 +517,20 @@ S14 s14;
 // expected-error@second.h:* {{'Method::S14' has different definitions in 
different modules; first difference is definition in module 'SecondModule' 
found method 'A' with 1st parameter of type 'int *' decayed from 'int [3]'}}
 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st 
parameter of type 'int *' decayed from 'int [2]'}}
 #endif
+
+#if defined(FIRST)
+struct S15 {
+  int A() { return 0; }
+};
+#elif defined(SECOND)
+struct S15 {
+  long A() { return 0; }
+};
+#else
+S15 s15;
+// expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is 
not present in definition of 'Method::S15' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'A' does not match}}
+#endif
 }  // namespace Method
 
 // Naive parsing of AST can lead to cycles in processing.  Ensure


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


[PATCH] D34267: do more processing in clang-fuzzer (use EmitAssemblyAction)

2017-07-13 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc updated this revision to Diff 106573.
kcc added a comment.

Use EmitObjAction; also link and initialize the targets so
that we actually call the optimizer.


https://reviews.llvm.org/D34267

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ClangFuzzer.cpp


Index: tools/clang-fuzzer/ClangFuzzer.cpp
===
--- tools/clang-fuzzer/ClangFuzzer.cpp
+++ tools/clang-fuzzer/ClangFuzzer.cpp
@@ -14,18 +14,25 @@
 
//===--===//
 
 #include "clang/Tooling/Tooling.h"
-#include "clang/Frontend/FrontendActions.h"
+#include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/TargetSelect.h"
 
 using namespace clang;
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllAsmParsers();
+
   llvm::opt::ArgStringList CC1Args;
   CC1Args.push_back("-cc1");
   CC1Args.push_back("./test.cc");
+  CC1Args.push_back("-O2");
   llvm::IntrusiveRefCntPtr Files(
   new FileManager(FileSystemOptions()));
   IgnoringDiagConsumer Diags;
@@ -39,7 +46,7 @@
   llvm::MemoryBuffer::getMemBuffer(s);
   Invocation->getPreprocessorOpts().addRemappedFile("./test.cc", 
Input.release());
   std::unique_ptr action(
-  tooling::newFrontendActionFactory());
+  tooling::newFrontendActionFactory());
   std::shared_ptr PCHContainerOps =
   std::make_shared();
   action->runInvocation(std::move(Invocation), Files.get(), PCHContainerOps,
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS support)
+  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
 
   add_clang_executable(clang-fuzzer
 EXCLUDE_FROM_ALL
@@ -10,6 +10,7 @@
 ${CLANG_FORMAT_LIB_DEPS}
 clangAST
 clangBasic
+clangCodeGen
 clangDriver
 clangFrontend
 clangRewriteFrontend


Index: tools/clang-fuzzer/ClangFuzzer.cpp
===
--- tools/clang-fuzzer/ClangFuzzer.cpp
+++ tools/clang-fuzzer/ClangFuzzer.cpp
@@ -14,18 +14,25 @@
 //===--===//
 
 #include "clang/Tooling/Tooling.h"
-#include "clang/Frontend/FrontendActions.h"
+#include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/TargetSelect.h"
 
 using namespace clang;
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllAsmParsers();
+
   llvm::opt::ArgStringList CC1Args;
   CC1Args.push_back("-cc1");
   CC1Args.push_back("./test.cc");
+  CC1Args.push_back("-O2");
   llvm::IntrusiveRefCntPtr Files(
   new FileManager(FileSystemOptions()));
   IgnoringDiagConsumer Diags;
@@ -39,7 +46,7 @@
   llvm::MemoryBuffer::getMemBuffer(s);
   Invocation->getPreprocessorOpts().addRemappedFile("./test.cc", Input.release());
   std::unique_ptr action(
-  tooling::newFrontendActionFactory());
+  tooling::newFrontendActionFactory());
   std::shared_ptr PCHContainerOps =
   std::make_shared();
   action->runInvocation(std::move(Invocation), Files.get(), PCHContainerOps,
Index: tools/clang-fuzzer/CMakeLists.txt
===
--- tools/clang-fuzzer/CMakeLists.txt
+++ tools/clang-fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS support)
+  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
 
   add_clang_executable(clang-fuzzer
 EXCLUDE_FROM_ALL
@@ -10,6 +10,7 @@
 ${CLANG_FORMAT_LIB_DEPS}
 clangAST
 clangBasic
+clangCodeGen
 clangDriver
 clangFrontend
 clangRewriteFrontend
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307982 - [Driver] Respect -target when determining target platform on Apple

2017-07-13 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jul 13 17:21:32 2017
New Revision: 307982

URL: http://llvm.org/viewvc/llvm-project?rev=307982=rev
Log:
[Driver] Respect -target when determining target platform on Apple
platforms.

Set the target OS based on -target if it is present on the command
line and -arch is not.

With this commit, "-target x86_64-apple-ios8.0" does the same thing as
"-arch x86_64 -mios-version-min=8.0".

rdar://problem/21012522

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=307982=307981=307982=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Jul 13 17:21:32 2017
@@ -1262,28 +1262,58 @@ void Darwin::AddDeploymentTarget(Derived
   }
 }
 
-// If no OSX or iOS target has been specified, try to guess platform
-// from arch name and compute the version from the triple.
+// If no OS targets have been specified, try to guess platform from -target
+// or arch name and compute the version from the triple.
 if (OSXTarget.empty() && iOSTarget.empty() && TvOSTarget.empty() &&
 WatchOSTarget.empty()) {
-  StringRef MachOArchName = getMachOArchName(Args);
-  unsigned Major, Minor, Micro;
-  if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
-  MachOArchName == "arm64") {
-getTriple().getiOSVersion(Major, Minor, Micro);
-llvm::raw_string_ostream(iOSTarget) << Major << '.' << Minor << '.'
-<< Micro;
-  } else if (MachOArchName == "armv7k") {
-getTriple().getWatchOSVersion(Major, Minor, Micro);
-llvm::raw_string_ostream(WatchOSTarget) << Major << '.' << Minor << '.'
-<< Micro;
-  } else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
- MachOArchName != "armv7em") {
-if (!getTriple().getMacOSXVersion(Major, Minor, Micro)) {
-  getDriver().Diag(diag::err_drv_invalid_darwin_version)
-  << getTriple().getOSName();
+  llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS;
+
+  // Set the OSTy based on -target if -arch isn't present.
+  if (Args.hasArg(options::OPT_target) && !Args.hasArg(options::OPT_arch)) 
{
+OSTy = getTriple().getOS();
+  } else {
+StringRef MachOArchName = getMachOArchName(Args);
+if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
+MachOArchName == "arm64")
+  OSTy = llvm::Triple::IOS;
+else if (MachOArchName == "armv7k")
+  OSTy = llvm::Triple::WatchOS;
+else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
+ MachOArchName != "armv7em")
+  OSTy = llvm::Triple::MacOSX;
+  }
+
+
+  if (OSTy != llvm::Triple::UnknownOS) {
+unsigned Major, Minor, Micro;
+std::string *OSTarget;
+
+switch (OSTy) {
+case llvm::Triple::Darwin:
+case llvm::Triple::MacOSX:
+  if (!getTriple().getMacOSXVersion(Major, Minor, Micro))
+getDriver().Diag(diag::err_drv_invalid_darwin_version)
+<< getTriple().getOSName();
+  OSTarget = 
+  break;
+case llvm::Triple::IOS:
+  getTriple().getiOSVersion(Major, Minor, Micro);
+  OSTarget = 
+  break;
+case llvm::Triple::TvOS:
+  getTriple().getOSVersion(Major, Minor, Micro);
+  OSTarget = 
+  break;
+case llvm::Triple::WatchOS:
+  getTriple().getWatchOSVersion(Major, Minor, Micro);
+  OSTarget = 
+  break;
+default:
+  llvm_unreachable("Unexpected OS type");
+  break;
 }
-llvm::raw_string_ostream(OSXTarget) << Major << '.' << Minor << '.'
+
+llvm::raw_string_ostream(*OSTarget) << Major << '.' << Minor << '.'
 << Micro;
   }
 }

Modified: cfe/trunk/test/Driver/darwin-version.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=307982=307981=307982=diff
==
--- cfe/trunk/test/Driver/darwin-version.c (original)
+++ cfe/trunk/test/Driver/darwin-version.c Thu Jul 13 17:21:32 2017
@@ -121,3 +121,15 @@
 // RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOSSIM %s
 // CHECK-VERSION-WATCHOSSIM: "i386-apple-watchos2.0.0"
+
+// RUN: %clang -target x86_64-apple-ios11.0.0 -c %s -### 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS-TARGET %s
+// CHECK-VERSION-IOS-TARGET: "x86_64-apple-ios11.0.0"
+
+// RUN: %clang 

[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2017-07-13 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist added a comment.

Gaaah. I'm so sorry. I wrote that last comment months ago and never submitted. 
No wonder you guys weren't responding.




Comment at: lib/Format/WhitespaceManager.cpp:470
 // definitions.
 return C.Tok->is(TT_StartOfName) ||
C.Tok->is(TT_FunctionDeclarationName) ||

@djasper, this is my reasoning for the special case (whether or not it's a good 
reason, is open to discussion, but this is the reason anyway):
AlignConsecutiveDeclarations only needs to look at one token, since the 
information required to determine a suitable token for this alignment is 
provided with the FormatToken. So, it doesn't matter if the current set of 
changes only contains one token (because, say, the previous portion was in a 
diff. scope and handled by a recursive invocation of AlignTokens).

However, in order to determine an appropriate token in a PP macro, since these 
tokens are not annotated with the required information, the lambda function 
must attempt to crawl through the whole statement back to the '#define' keyword 
(meaning, all those tokens need to be processed in a single invocation of 
AlignTokens, without recurring).

The best alternative I could see for this was to just annotate the FormatTokens 
with the needed info, which was in my initial implementation of this patch, 
however this adds unconditional overhead as you know.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Frederich Munch via Phabricator via cfe-commits
marsupial marked 3 inline comments as done.
marsupial added a comment.

Done, and changed to 'windows.h', but blocked mingw from even attempting SEH 
for now.


https://reviews.llvm.org/D35103



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Frederich Munch via Phabricator via cfe-commits
marsupial updated this revision to Diff 106548.
marsupial added a comment.

Blocked Win64 SEH for MingW entirely.
Theoretically it should be possible to throw a SEH from within mingw, but but 
I'm thinking clang may be generating exception handlers for the gcc runtime in 
that case.
I'll leave it up to someone with interest in such a mixture to figure that tout.


https://reviews.llvm.org/D35103

Files:
  examples/clang-interpreter/CMakeLists.txt
  examples/clang-interpreter/Invoke.cpp
  examples/clang-interpreter/Invoke.h
  examples/clang-interpreter/Manager.cpp
  examples/clang-interpreter/Manager.h
  examples/clang-interpreter/README.txt
  examples/clang-interpreter/Test.cxx
  examples/clang-interpreter/main.cpp

Index: examples/clang-interpreter/main.cpp
===
--- examples/clang-interpreter/main.cpp
+++ examples/clang-interpreter/main.cpp
@@ -7,6 +7,9 @@
 //
 //===--===//
 
+#include "Invoke.h"
+#include "Manager.h"
+
 #include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Compilation.h"
@@ -26,73 +29,61 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
+
 using namespace clang;
 using namespace clang::driver;
 
+namespace interpreter {
+
+static llvm::ExecutionEngine *
+createExecutionEngine(std::unique_ptr M, std::string *ErrorStr) {
+  llvm::EngineBuilder EB(std::move(M));
+  EB.setErrorStr(ErrorStr);
+  EB.setMemoryManager(llvm::make_unique());
+  llvm::ExecutionEngine *EE = EB.create();
+  EE->finalizeObject();
+  return EE;
+}
+
+// Invoked from a try/catch block in invoke.cpp.
+//
+static int Invoke(llvm::ExecutionEngine *EE, llvm::Function *EntryFn,
+  const std::vector , char *const *EnvP) {
+  return EE->runFunctionAsMain(EntryFn, Args, EnvP);
+}
+
 // This function isn't referenced outside its translation unit, but it
 // can't use the "static" keyword because its address is used for
 // GetMainExecutable (since some platforms don't support taking the
 // address of main, and some platforms can't implement GetMainExecutable
 // without being given the address of a function in the main executable).
-std::string GetExecutablePath(const char *Argv0) {
-  // This just needs to be some symbol in the binary; C++ doesn't
-  // allow taking the address of ::main however.
-  void *MainAddr = (void*) (intptr_t) GetExecutablePath;
+std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
   return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
 }
 
-static llvm::ExecutionEngine *
-createExecutionEngine(std::unique_ptr M, std::string *ErrorStr) {
-  return llvm::EngineBuilder(std::move(M))
-  .setEngineKind(llvm::EngineKind::Either)
-  .setErrorStr(ErrorStr)
-  .create();
-}
-
-static int Execute(std::unique_ptr Mod, char *const *envp) {
-  llvm::InitializeNativeTarget();
-  llvm::InitializeNativeTargetAsmPrinter();
-
-  llvm::Module  = *Mod;
-  std::string Error;
-  std::unique_ptr EE(
-  createExecutionEngine(std::move(Mod), ));
-  if (!EE) {
-llvm::errs() << "unable to make execution engine: " << Error << "\n";
-return 255;
-  }
-
-  llvm::Function *EntryFn = M.getFunction("main");
-  if (!EntryFn) {
-llvm::errs() << "'main' function not found in module.\n";
-return 255;
-  }
-
-  // FIXME: Support passing arguments.
-  std::vector Args;
-  Args.push_back(M.getModuleIdentifier());
-
-  EE->finalizeObject();
-  return EE->runFunctionAsMain(EntryFn, Args, envp);
-}
+} // namespace interpreter
 
 int main(int argc, const char **argv, char * const *envp) {
-  void *MainAddr = (void*) (intptr_t) GetExecutablePath;
-  std::string Path = GetExecutablePath(argv[0]);
+  // This just needs to be some symbol in the binary; C++ doesn't
+  // allow taking the address of ::main however.
+  void *MainAddr = (void*) (intptr_t) interpreter::GetExecutablePath;
+  std::string Path = interpreter::GetExecutablePath(argv[0], MainAddr);
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   TextDiagnosticPrinter *DiagClient =
 new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
 
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);
 
-  // Use ELF on windows for now.
-  std::string TripleStr = llvm::sys::getProcessTriple();
+  const std::string TripleStr = llvm::sys::getProcessTriple();
   llvm::Triple T(TripleStr);
+
+  // Use ELF on Windows-32 and MingW for now.
+#ifndef CLANG_INTERPRETER_COFF_FORMAT
   if (T.isOSBinFormatCOFF())
 T.setObjectFormat(llvm::Triple::ELF);
-
+#endif
+	
   Driver TheDriver(Path, T.str(), Diags);
   TheDriver.setTitle("clang interpreter");
   TheDriver.setCheckInputsExist(false);
@@ -163,12 +154,36 @@
   if (!Clang.ExecuteAction(*Act))
 return 1;
 
+  llvm::InitializeNativeTarget();
+  

[libcxx] r307972 - [libc++] class template -> template class. NFC

2017-07-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 13 15:08:59 2017
New Revision: 307972

URL: http://llvm.org/viewvc/llvm-project?rev=307972=rev
Log:
[libc++] class template -> template class. NFC

Modified:
libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=307972=307971=307972=diff
==
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Thu Jul 13 15:08:59 2017
@@ -104,7 +104,7 @@ Visibility Macros
 **_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS**
   Mark the member functions, typeinfo, and vtable of an explicit instantiation
   of a class template as being exported by the libc++ library. This attribute
-  must be specified on all template class explicit instantiations.
+  must be specified on all class template explicit instantiations.
 
   It is only necessary to mark the explicit instantiation itself (as opposed to
   the extern template declaration) as exported on Windows, as discussed above.


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


[PATCH] D35388: [libc++] Give extern templates default visibility on gcc

2017-07-13 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.

Contrary to the current visibility macro documentation, it appears that
gcc does handle visibility attribute on extern templates correctly, e.g.
https://godbolt.org/g/EejuV7. We need this so that extern template
instantiations of classes not marked _LIBCPP_TEMPLATE_VIS (e.g.
__vector_base_common) are correctly exported with gcc when building with
hidden visibility.


https://reviews.llvm.org/D35388

Files:
  docs/DesignDocs/VisibilityMacros.rst
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -708,7 +708,7 @@
 #endif
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && 
__has_attribute(__type_visibility__)
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ 
((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
Index: docs/DesignDocs/VisibilityMacros.rst
===
--- docs/DesignDocs/VisibilityMacros.rst
+++ docs/DesignDocs/VisibilityMacros.rst
@@ -83,12 +83,6 @@
   specified on the primary template and to export the member functions produced
   by the explicit instantiation in the dylib.
 
-  **GCC Behavior**: GCC ignores visibility attributes applied the type in
-  extern template declarations and applying an attribute results in a warning.
-  However since `_LIBCPP_TEMPLATE_VIS` is the same as
-  `__attribute__((visibility("default"))` the visibility is already correct.
-  The macro has an empty definition with GCC.
-
   **Windows Behavior**: `extern template` and `dllexport` are fundamentally
   incompatible *on a class template* on Windows; the former suppresses
   instantiation, while the latter forces it. Specifying both on the same


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -708,7 +708,7 @@
 #endif
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
+#  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
Index: docs/DesignDocs/VisibilityMacros.rst
===
--- docs/DesignDocs/VisibilityMacros.rst
+++ docs/DesignDocs/VisibilityMacros.rst
@@ -83,12 +83,6 @@
   specified on the primary template and to export the member functions produced
   by the explicit instantiation in the dylib.
 
-  **GCC Behavior**: GCC ignores visibility attributes applied the type in
-  extern template declarations and applying an attribute results in a warning.
-  However since `_LIBCPP_TEMPLATE_VIS` is the same as
-  `__attribute__((visibility("default"))` the visibility is already correct.
-  The macro has an empty definition with GCC.
-
   **Windows Behavior**: `extern template` and `dllexport` are fundamentally
   incompatible *on a class template* on Windows; the former suppresses
   instantiation, while the latter forces it. Specifying both on the same
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106539.
yawanng marked an inline comment as done.
Herald added subscribers: xazax.hun, JDevlieghere.

https://reviews.llvm.org/D35367

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecEpollCreateCheck.cpp
  clang-tidy/android/CloexecEpollCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-epoll-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-epoll-create.cpp

Index: test/clang-tidy/android-cloexec-epoll-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-epoll-create.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s android-cloexec-epoll-create %t
+
+extern "C" int epoll_create(int size);
+
+void f() {
+  epoll_create(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer epoll_create() to epoll_create1() because epoll_create1() allows EPOLL_CLOEXEC [android-cloexec-epoll-create]
+  // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC)
+}
+
+namespace i {
+int epoll_create(int size);
+void g() {
+  epoll_create(0);
+}
+} // namespace i
+
+class C {
+public:
+  int epoll_create(int size);
+  void h() {
+epoll_create(0);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
android-cloexec-creat
+   android-cloexec-epoll-create
android-cloexec-fopen
android-cloexec-open
android-cloexec-socket
Index: docs/clang-tidy/checks/android-cloexec-epoll-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-epoll-create.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - android-cloexec-epoll-create
+
+android-cloexec-epoll-create
+
+
+The usage of ``epoll_create()`` is not recommended, it's better to use
+``epoll_create1()``, which allows close-on-exec.
+
+Examples:
+
+.. code-block:: c++
+
+  epoll_create(size);
+
+  // becomes
+
+  epoll_create1(EPOLL_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -62,6 +62,11 @@
 
   Detect usage of ``creat()``.
 
+- New `android-cloexec-epoll-create
+  `_ check
+
+  Detects usage of ``epoll_create()``.
+
 - New `android-cloexec-open
   `_ check
 
Index: clang-tidy/android/CloexecEpollCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecEpollCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreateCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// epoll_create() is better to be replaced by epoll_create1().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-epoll-create.html
+class CloexecEpollCreateCheck : public ClangTidyCheck {
+public:
+  CloexecEpollCreateCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
Index: clang-tidy/android/CloexecEpollCreateCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecEpollCreateCheck.cpp
@@ -0,0 +1,42 @@
+//===--- CloexecEpollCreateCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecEpollCreateCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecEpollCreateCheck::registerMatchers(MatchFinder 

[libcxx] r307966 - [libc++] Mark string operator+ _LIBCPP_FUNC_VIS

2017-07-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 13 14:35:52 2017
New Revision: 307966

URL: http://llvm.org/viewvc/llvm-project?rev=307966=rev
Log:
[libc++] Mark string operator+ _LIBCPP_FUNC_VIS

It has an extern template instantiation declaration in the headers and a
corresponding instantiation definition in the library, so we must mark
it with _LIBCPP_FUNC_VIS to make it available outside the library.

This doesn't cause any ABI changes as-is since we don't build libc++
with hidden visibility (so the function is exported anyway). It's needed
for building libc++ with hidden visibility, however.

Clarify the Windows behavior for extern function templates while I'm
here, since this exercises that behavior.

Modified:
libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
libcxx/trunk/include/string

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=307966=307965=307966=diff
==
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Thu Jul 13 14:35:52 2017
@@ -98,7 +98,8 @@ Visibility Macros
   explicit instantiations themselves are marked as exported. Note that this
   applies *only* to extern *class* templates. Extern *function* templates obey
   regular import/export semantics, and applying `dllexport` directly to the
-  extern template declaration is the correct thing to do for them.
+  extern template declaration (i.e. using `_LIBCPP_FUNC_VIS`) is the correct
+  thing to do for them.
 
 **_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS**
   Mark the member functions, typeinfo, and vtable of an explicit instantiation

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307966=307965=307966=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Thu Jul 13 14:35:52 2017
@@ -4006,7 +4006,7 @@ basic_string<_CharT, _Traits, _Allocator
 
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
basic_string)
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
basic_string)
-_LIBCPP_EXTERN_TEMPLATE(string operator+(char const*, string const&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+(char const*, string const&))
 
 #if _LIBCPP_STD_VER > 11 
 // Literal suffixes for basic_string [basic.string.literals]


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


[PATCH] D35385: [Driver] Darwin: Link in the profile runtime archive first

2017-07-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

While building a project with code coverage enabled, we can link in
dependencies which export a weak definition of __llvm_profile_filename.

After r306710, linking in the profiling runtime could pull in a weak
definition of this symbol from a dependency, instead of from within the
runtime's archive.

This inconsistency causes issues during API verification, and is also a
practical problem (the symbol would go missing were the dependent dylib
to be switched out). Introduce a LinkFirst runtime link option to make
sure we always search the profiling runtime for this symbol first.

rdar://problem/33271080


https://reviews.llvm.org/D35385

Files:
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  test/Driver/darwin-ld.c

Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -341,3 +341,13 @@
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -fprofile-instr-use=blah -### -o foo/bar.out 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_HOTNESS %s < %t.log
 // PASS_REMARKS_WITH_HOTNESS: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-with-hotness"
+
+// RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
+// RUN: %clang -target i386-apple-darwin9 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
+// RUN: %clang -target arm64-apple-ios5.0 -miphoneos-version-min=5.0 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
+// LINK_PROFILE_FIRST: {{ld(.exe)?"}} "{{[^"]+}}libclang_rt.profile_{{[a-z]+}}.a"
Index: lib/Driver/ToolChains/Darwin.h
===
--- lib/Driver/ToolChains/Darwin.h
+++ lib/Driver/ToolChains/Darwin.h
@@ -152,8 +152,12 @@
   llvm::opt::ArgStringList ) const {}
 
   /// Add the linker arguments to link the compiler runtime library.
+  ///
+  /// FIXME: This API is intended for use with embedded libraries only, and is
+  /// misleadingly named.
   virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const;
+
   virtual void AddFuzzerLinkArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const;
 
@@ -171,10 +175,26 @@
   /// Is the target either iOS or an iOS simulator?
   bool isTargetIOSBased() const { return false; }
 
+  /// Options to control how a runtime library is linked.
+  enum RuntimeLinkOptions : unsigned {
+// Link the library in even if it can't be found in the VFS.
+RLO_AlwaysLink = 1 << 0,
+
+// Use the embedded runtime from the macho_embedded directory.
+RLO_IsEmbedded = 1 << 1,
+
+// Emit rpaths for @executable_path as well as the resource directory.
+RLO_AddRPath = 1 << 2,
+
+//< Link the library in before any others.
+RLO_FirstLink = 1 << 3,
+  };
+
+  /// Add a runtime library to the list of items to link.
   void AddLinkRuntimeLib(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ,
- StringRef DarwinLibName, bool AlwaysLink = false,
- bool IsEmbedded = false, bool AddRPath = false) const;
+ StringRef DarwinLibName,
+ RuntimeLinkOptions Opts = RuntimeLinkOptions()) const;
 
   /// Add any profiling runtime libraries that are needed. This is essentially a
   /// MachO specific version of addProfileRT in Tools.cpp.
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -493,7 +493,7 @@
   if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
 getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
   "libclang_rt.safestack_osx.a",
-  /*AlwaysLink=*/true);
+  toolchains::Darwin::RLO_AlwaysLink);
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -897,25 +897,31 @@
 }
 
 void MachO::AddLinkRuntimeLib(const ArgList , ArgStringList ,
-  StringRef DarwinLibName, bool AlwaysLink,
-  bool IsEmbedded, bool AddRPath) const {
+  StringRef DarwinLibName,
+  RuntimeLinkOptions Opts) const {
   SmallString<128> Dir(getDriver().ResourceDir);
-  

[libcxx] r307965 - [libc++] Remove unused _LIBCPP_FUNC_VIS_ONLY

2017-07-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 13 14:28:17 2017
New Revision: 307965

URL: http://llvm.org/viewvc/llvm-project?rev=307965=rev
Log:
[libc++] Remove unused _LIBCPP_FUNC_VIS_ONLY

This has been unused since r282644.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=307965=307964=307965=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Jul 13 14:28:17 2017
@@ -625,7 +625,6 @@ namespace std {
 #define _LIBCPP_HIDDEN
 #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 #define _LIBCPP_TEMPLATE_VIS
-#define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
 
 #if defined(_LIBCPP_COMPILER_MSVC)
@@ -684,10 +683,6 @@ namespace std {
 #  endif
 #endif
 
-#ifndef _LIBCPP_FUNC_VIS_ONLY
-# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
-#endif
-
 #ifndef _LIBCPP_EXTERN_VIS
 # define _LIBCPP_EXTERN_VIS
 #endif


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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808517, @mehdi_amini wrote:

> In https://reviews.llvm.org/D35081#808207, @tejohnson wrote:
>
> > My first option was if any copy is under the threshold, simply pick the 
> > prevailing copy (it may be over threshold, but assume we want that one 
> > anyway). Another possibility is to only allow importing of the prevailing 
> > copy, if it is over the inst limit, too bad. The main reason I think that 
> > could be better is when we have PGO - the prevailing copy would for sure 
> > have the matched PGO data, but the non-prevailing copies may not.
>
>
> Ah makes sense, both way are fine with me.
>
> I'd rather limit to the prevailing copy though and too bad if it is over the 
> limit, to avoid the possibility of too large importing just because there was 
> a small non-prevailing somewhere, but likely a rare case.


SGTM. That's also very simple to implement.  I've just been to swamped with 
other things so far to do it. Just chatted with Yunlian, he is not blocked.

> Limiting to the prevailing copy means that we could prune the index early 
> after symbol resolution to keep only the prevailing summary, which could 
> speed-up all the process (and possibly get more accurate dead-stripping if we 
> don't use the prevailing information there already?).

I think we want to keep the other copies so we can mark their new linkage types 
(e.g. demoted to available_externally) for use in the backends. Dead stripping 
should use prevailing info, think there is a todo there.


https://reviews.llvm.org/D35081



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


r307964 - [PS4] Disable LTO unit features under ThinLTO, like for Darwin.

2017-07-13 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Jul 13 14:25:47 2017
New Revision: 307964

URL: http://llvm.org/viewvc/llvm-project?rev=307964=rev
Log:
[PS4] Disable LTO unit features under ThinLTO, like for Darwin.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/lto-unit.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=307964=307963=307964=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 13 14:25:47 2017
@@ -2070,10 +2070,11 @@ void Clang::ConstructJob(Compilation ,
 if (D.isUsingLTO()) {
   Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
 
-  // The Darwin linker currently uses the legacy LTO API, which does not
-  // support LTO unit features (CFI, whole program vtable opt) under
-  // ThinLTO.
-  if (!getToolChain().getTriple().isOSDarwin() ||
+  // The Darwin and PS4 linkers currently use the legacy LTO API, which
+  // does not support LTO unit features (CFI, whole program vtable opt)
+  // under ThinLTO.
+  if (!(getToolChain().getTriple().isOSDarwin() ||
+getToolChain().getTriple().isPS4()) ||
   D.getLTOMode() == LTOK_Full)
 CmdArgs.push_back("-flto-unit");
 }

Modified: cfe/trunk/test/Driver/lto-unit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-unit.c?rev=307964=307963=307964=diff
==
--- cfe/trunk/test/Driver/lto-unit.c (original)
+++ cfe/trunk/test/Driver/lto-unit.c Thu Jul 13 14:25:47 2017
@@ -2,6 +2,8 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=full 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=full 2>&1 | FileCheck 
--check-prefix=UNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin 2>&1 | FileCheck 
--check-prefix=NOUNIT %s
 
 // UNIT: "-flto-unit"
 // NOUNIT-NOT: "-flto-unit"


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


Re: r305860 - Special-case handling of destructors in override lists when dumping ASTs.

2017-07-13 Thread Lang Hames via cfe-commits
FWIW: Replacing the call to getName with getNameAsString seems to fix the
destructor issue as well (i.e. I can remove the special case for
destructors) so I've committed this r307959.

If the getName failure for destructors is unexpected it may be worth
digging into as a separate issue.

Cheers,
Lang.

On Thu, Jul 13, 2017 at 2:00 PM, Lang Hames  wrote:

> Sure.
>
> Richard - is this likely to be related to your query? Calling getName() on
> at least one destructor in Sema/ms_class_layout triggers the assertion in
> NamedDecl::getName():
>
> (lldb)
> frame #4: 0x0001039600e2 
> clang`clang::NamedDecl::getName(this=0x000112897490)
> const at Decl.h:238
>235/// This requires that the declaration have a name and that it
> be a simple
>236/// identifier.
>237StringRef getName() const {
> -> 238  assert(Name.isIdentifier() && "Name is not a simple
> identifier");
>239  return getIdentifier() ? getIdentifier()->getName() : "";
>240}
>241
> (lldb) expr this->dump()
> CXXDestructorDecl 0x112897490  llvm-svn-tot/llvm/tools/clang/test/Sema/ms_class_layout.cpp:102:3,
> col:17> col:11 used ~IA 'void (void) __attribute__((thiscall))' virtual
> `-CompoundStmt 0x1128977f8 
>
> - Lang.
>
> On Wed, Jul 12, 2017 at 10:36 PM, Akira Hatanaka 
> wrote:
>
>> Hi Lang,
>>
>> clang crashes when I compile the following code with "-Xclang -ast-dump”:
>>
>> class Base {
>> public:
>>   virtual void operator()() {}
>> };
>>
>> class Derived : public Base {
>> public:
>>   void operator()() override {}
>> };
>>
>> If I change “OS << D->getName()” to “OS << D->getNameAsString()”, the
>> crash disappears.
>>
>> Can you take a look please?
>>
>> On Jun 20, 2017, at 2:30 PM, Lang Hames via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: lhames
>> Date: Tue Jun 20 16:30:43 2017
>> New Revision: 305860
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=305860=rev
>> Log:
>> Special-case handling of destructors in override lists when dumping ASTs.
>>
>> Fixes a bug in r305850: CXXDestructors don't have names, so we need to
>> handle
>> printing of them separately.
>>
>>
>> Modified:
>>cfe/trunk/lib/AST/ASTDumper.cpp
>>
>> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDum
>> per.cpp?rev=305860=305859=305860=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:30:43 2017
>> @@ -1189,9 +1189,12 @@ void ASTDumper::VisitFunctionDecl(const
>>   auto dumpOverride =
>> [=](const CXXMethodDecl *D) {
>>   SplitQualType T_split = D->getType().split();
>> -  OS << D << " " << D->getParent()->getName() << "::"
>> - << D->getName() << " '"
>> - << QualType::getAsString(T_split) << "'";
>> +  OS << D << " " << D->getParent()->getName() << "::";
>> +  if (isa(D))
>> +OS << "~" << D->getParent()->getName();
>> +  else
>> +OS << D->getName();
>>
>> +  OS << " '" << QualType::getAsString(T_split) << "'";
>> };
>>
>>   dumpChild([=] {
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307959 - Use getNameAsString instead of getName to get method names when dumping

2017-07-13 Thread Lang Hames via cfe-commits
Author: lhames
Date: Thu Jul 13 14:08:29 2017
New Revision: 307959

URL: http://llvm.org/viewvc/llvm-project?rev=307959=rev
Log:
Use getNameAsString instead of getName to get method names when dumping
overrides:  getName can fail if the decl's name isn't a simple identifier.

This is a more general replacement for the fix in r305860.


Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=307959=307958=307959=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Jul 13 14:08:29 2017
@@ -1189,12 +1189,8 @@ void ASTDumper::VisitFunctionDecl(const
   auto dumpOverride =
 [=](const CXXMethodDecl *D) {
   SplitQualType T_split = D->getType().split();
-  OS << D << " " << D->getParent()->getName() << "::";
-  if (isa(D))
-OS << "~" << D->getParent()->getName();
-  else
-OS << D->getName();
-  OS << " '" << QualType::getAsString(T_split) << "'";
+  OS << D << " " << D->getParent()->getName() << "::"
+ << D->getNameAsString() << " '" << QualType::getAsString(T_split) 
<< "'";
 };
 
   dumpChild([=] {


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


Re: r305860 - Special-case handling of destructors in override lists when dumping ASTs.

2017-07-13 Thread Lang Hames via cfe-commits
Sure.

Richard - is this likely to be related to your query? Calling getName() on
at least one destructor in Sema/ms_class_layout triggers the assertion in
NamedDecl::getName():

(lldb)
frame #4: 0x0001039600e2
clang`clang::NamedDecl::getName(this=0x000112897490) const at Decl.h:238
   235/// This requires that the declaration have a name and that it be
a simple
   236/// identifier.
   237StringRef getName() const {
-> 238  assert(Name.isIdentifier() && "Name is not a simple
identifier");
   239  return getIdentifier() ? getIdentifier()->getName() : "";
   240}
   241
(lldb) expr this->dump()
CXXDestructorDecl 0x112897490
 col:11 used ~IA 'void (void) __attribute__((thiscall))' virtual
`-CompoundStmt 0x1128977f8 

- Lang.

On Wed, Jul 12, 2017 at 10:36 PM, Akira Hatanaka 
wrote:

> Hi Lang,
>
> clang crashes when I compile the following code with "-Xclang -ast-dump”:
>
> class Base {
> public:
>   virtual void operator()() {}
> };
>
> class Derived : public Base {
> public:
>   void operator()() override {}
> };
>
> If I change “OS << D->getName()” to “OS << D->getNameAsString()”, the
> crash disappears.
>
> Can you take a look please?
>
> On Jun 20, 2017, at 2:30 PM, Lang Hames via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: lhames
> Date: Tue Jun 20 16:30:43 2017
> New Revision: 305860
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305860=rev
> Log:
> Special-case handling of destructors in override lists when dumping ASTs.
>
> Fixes a bug in r305850: CXXDestructors don't have names, so we need to
> handle
> printing of them separately.
>
>
> Modified:
>cfe/trunk/lib/AST/ASTDumper.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDum
> per.cpp?rev=305860=305859=305860=diff
> 
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:30:43 2017
> @@ -1189,9 +1189,12 @@ void ASTDumper::VisitFunctionDecl(const
>   auto dumpOverride =
> [=](const CXXMethodDecl *D) {
>   SplitQualType T_split = D->getType().split();
> -  OS << D << " " << D->getParent()->getName() << "::"
> - << D->getName() << " '"
> - << QualType::getAsString(T_split) << "'";
> +  OS << D << " " << D->getParent()->getName() << "::";
> +  if (isa(D))
> +OS << "~" << D->getParent()->getName();
> +  else
> +OS << D->getName();
>
> +  OS << " '" << QualType::getAsString(T_split) << "'";
> };
>
>   dumpChild([=] {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 106528.
thakis marked an inline comment as done.
thakis added a comment.

Document *, add example with multiple platforms


https://reviews.llvm.org/D35379

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/AttrDocs.td

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -910,13 +910,13 @@
 
   void f(void) __attribute__((availability(macos,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
 
-The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
-deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
+The availability attribute states that ``f`` was introduced in macOS 10.4,
+deprecated in macOS 10.6, and obsoleted in macOS 10.7.  This information
 is used by Clang to determine when it is safe to use ``f``: for example, if
-Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
-succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
+Clang is instructed to compile code for macOS 10.5, a call to ``f()``
+succeeds.  If Clang is instructed to compile code for macOS 10.6, the call
 succeeds but Clang emits a warning specifying that the function is deprecated.
-Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
+Finally, if Clang is instructed to compile code for macOS 10.7, the call
 fails because ``f()`` is no longer available.
 
 The availability attribute is a comma-separated list starting with the
@@ -961,7 +961,7 @@
   command-line arguments.
 
 ``macos``
-  Apple's Mac OS X operating system.  The minimum deployment target is
+  Apple's macOS operating system.  The minimum deployment target is
   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
   ``macosx`` is supported for backward-compatibility reasons, but it is
   deprecated.
@@ -1016,6 +1016,19 @@
   - (id)method __attribute__((availability(macos,introduced=10.5))); // error: this method was available via the base class in 10.4
   @end
   }];
+
+Starting with the macOS 10.12 SDK, the ``API_AVAILABLE`` macro from
+ can simplify the spelling:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method API_AVAILABLE(macos(10.11)));
+  - (id)otherMethod API_AVAILABLE(macos(10.11), ios(11.0));
+  @end
+
+Also see the documentation for `@available
+`_
 }
 
 def ExternalSourceSymbolDocs : Documentation {
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1271,7 +1271,103 @@
 Query for these features with ``__has_attribute(ns_consumed)``,
 ``__has_attribute(ns_returns_retained)``, etc.
 
+Objective-C @available
+--
 
+It is possible use the newest SDK but still build a program that can run on
+older macOS and iOS versions, by passing ``-mmacosx-version-info=`` /
+``--miphoneos-version-min=``.
+
+Before LLVM 5.0, when calling a function that exists only in the newest OS
+version, programmers had to carefully check if the function exists at runtime,
+using null checks for weakly-linked C functions, ``+class`` for Objective-C
+classes, and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
+Objective-C methods.  If such a check was missed, the program would compile
+fine, run fine on the new OS version, but crash on older OS versions.
+
+As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability attributes
+`_ together
+with the new ``@available()`` keyword to assist with this issue.  If a function
+is called that exists on new OS versions while the minimum deployment version
+is older, then ``-Wunguarded-availability`` will fire:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
+// built with -mmacosx-version-min=10.11, then this unconditional call
+// will emit a -Wunguarded-availability warning:
+[var fancyNewMethod];
+  }
+
+To fix the warning (and to make the call not crash on 10.11!), wrap it in
+``if(@available())``:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12, *)) {
+  [var fancyNewMethod];
+} else {
+  // Put fallback behavior for old macOS versions (and for non-mac
+  // platforms) here.
+}
+  }
+
+The ``*`` means that platforms not explicitly listed will take the true branch,
+and the compiler will emit ``-Wunguarded-availability`` warnings for unlisted
+platforms based on those platform's deployment target.  More than one platform
+can be listed in ``@available()``:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12, iOS 10, *)) {
+  

r307955 - [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-07-13 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jul 13 13:55:26 2017
New Revision: 307955

URL: http://llvm.org/viewvc/llvm-project?rev=307955=rev
Log:
[ubsan] Teach the pointer overflow check that "p -  <= p" (PR33430)

The pointer overflow check gives false negatives when dealing with
expressions in which an unsigned value is subtracted from a pointer.
This is summarized in PR33430 [1]: ubsan permits the result of the
subtraction to be greater than "p", but it should not.

To fix the issue, we should track whether or not the pointer expression
is a subtraction. If it is, and the indices are unsigned, we know to
expect "p -  <= p".

I've tested this by running check-{llvm,clang} with a stage2
ubsan-enabled build. I've also added some tests to compiler-rt, which
are in D34122.

[1] https://bugs.llvm.org/show_bug.cgi?id=33430

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=307955=307954=307955=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jul 13 13:55:26 2017
@@ -3052,7 +3052,9 @@ static llvm::Value *emitArraySubscriptGE
   SourceLocation loc,
 const llvm::Twine  = "arrayidx") {
   if (inbounds) {
-return CGF.EmitCheckedInBoundsGEP(ptr, indices, signedIndices, loc, name);
+return CGF.EmitCheckedInBoundsGEP(ptr, indices, signedIndices,
+  CodeGenFunction::NotSubtraction, loc,
+  name);
   } else {
 return CGF.Builder.CreateGEP(ptr, indices, name);
   }

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=307955=307954=307955=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jul 13 13:55:26 2017
@@ -1851,7 +1851,7 @@ ScalarExprEmitter::EmitScalarPrePostIncD
   llvm::Value *input;
 
   int amount = (isInc ? 1 : -1);
-  bool signedIndex = !isInc;
+  bool isSubtraction = !isInc;
 
   if (const AtomicType *atomicTy = type->getAs()) {
 type = atomicTy->getValueType();
@@ -1941,8 +1941,9 @@ ScalarExprEmitter::EmitScalarPrePostIncD
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, numElts, "vla.inc");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, numElts, signedIndex,
-   E->getExprLoc(), "vla.inc");
+value = CGF.EmitCheckedInBoundsGEP(
+value, numElts, /*SignedIndices=*/false, isSubtraction,
+E->getExprLoc(), "vla.inc");
 
 // Arithmetic on function pointers (!) is just +-1.
 } else if (type->isFunctionType()) {
@@ -1952,8 +1953,9 @@ ScalarExprEmitter::EmitScalarPrePostIncD
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, amt, "incdec.funcptr");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, amt, signedIndex,
-   E->getExprLoc(), "incdec.funcptr");
+value = CGF.EmitCheckedInBoundsGEP(value, amt, /*SignedIndices=*/false,
+   isSubtraction, E->getExprLoc(),
+   "incdec.funcptr");
   value = Builder.CreateBitCast(value, input->getType());
 
 // For everything else, we can just do a simple increment.
@@ -1962,8 +1964,9 @@ ScalarExprEmitter::EmitScalarPrePostIncD
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, amt, "incdec.ptr");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, amt, signedIndex,
-   E->getExprLoc(), "incdec.ptr");
+value = CGF.EmitCheckedInBoundsGEP(value, amt, /*SignedIndices=*/false,
+   isSubtraction, E->getExprLoc(),
+   "incdec.ptr");
 }
 
   // Vector increment/decrement.
@@ -2044,7 +2047,8 @@ ScalarExprEmitter::EmitScalarPrePostIncD
 if (CGF.getLangOpts().isSignedOverflowDefined())
   value = Builder.CreateGEP(value, sizeValue, "incdec.objptr");
 else
-  value = CGF.EmitCheckedInBoundsGEP(value, sizeValue, signedIndex,
+  value = CGF.EmitCheckedInBoundsGEP(value, sizeValue,
+ /*SignedIndices=*/false, 
isSubtraction,
  E->getExprLoc(), "incdec.objptr");
 value = 

[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-07-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307955: [ubsan] Teach the pointer overflow check that "p - 
 <= p" (PR33430) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D34121?vs=103606=106524#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34121

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m

Index: cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
===
--- cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
+++ cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
@@ -10,16 +10,20 @@
   ++p;
 
   // CHECK: ptrtoint i8* {{.*}} to i64, !nosanitize
-  // CHECK-NEXT: add i64 {{.*}}, -1, !nosanitize
-  // CHECK: select i1 false{{.*}}, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 {{.*}}, -1, !nosanitize
+  // CHECK: [[NEGVALID:%.*]] = icmp ule i64 [[COMPGEP]], {{.*}}, !nosanitize
+  // CHECK-NOT: select
+  // CHECK: br i1 [[NEGVALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   --p;
 
+  // CHECK: icmp uge i64
   // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   p++;
 
-  // CHECK: select
+  // CHECK: icmp ule i64
+  // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   p--;
 }
@@ -64,7 +68,8 @@
 
   // CHECK: [[OFFSET:%.*]] = sub i64 0, {{.*}}
   // CHECK-NEXT: getelementptr inbounds {{.*}} [[OFFSET]]
-  // CHECK: select
+  // CHECK: icmp ule i64
+  // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   p - i;
 }
@@ -121,8 +126,10 @@
 
 // CHECK-LABEL: define void @pointer_array_unsigned_indices
 void pointer_array_unsigned_indices(int **arr, unsigned k) {
+  // CHECK: icmp uge
   // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  // CHECK: icmp uge
   // CHECK-NOT: select
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   arr[k][k];
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -3589,12 +3589,19 @@
   /// nonnull, if \p LHS is marked _Nonnull.
   void EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, SourceLocation Loc);
 
+  /// An enumeration which makes it easier to specify whether or not an
+  /// operation is a subtraction.
+  enum { NotSubtraction = false, IsSubtraction = true };
+
   /// Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to
   /// detect undefined behavior when the pointer overflow sanitizer is enabled.
   /// \p SignedIndices indicates whether any of the GEP indices are signed.
+  /// \p IsSubtraction indicates whether the expression used to form the GEP
+  /// is a subtraction.
   llvm::Value *EmitCheckedInBoundsGEP(llvm::Value *Ptr,
   ArrayRef IdxList,
   bool SignedIndices,
+  bool IsSubtraction,
   SourceLocation Loc,
   const Twine  = "");
 
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -3052,7 +3052,9 @@
   SourceLocation loc,
 const llvm::Twine  = "arrayidx") {
   if (inbounds) {
-return CGF.EmitCheckedInBoundsGEP(ptr, indices, signedIndices, loc, name);
+return CGF.EmitCheckedInBoundsGEP(ptr, indices, signedIndices,
+  CodeGenFunction::NotSubtraction, loc,
+  name);
   } else {
 return CGF.Builder.CreateGEP(ptr, indices, name);
   }
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -1851,7 +1851,7 @@
   llvm::Value *input;
 
   int amount = (isInc ? 1 : -1);
-  bool signedIndex = !isInc;
+  bool isSubtraction = !isInc;
 
   if (const AtomicType *atomicTy = type->getAs()) {
 type = atomicTy->getValueType();
@@ -1941,8 +1941,9 @@
   if (CGF.getLangOpts().isSignedOverflowDefined())
 value = Builder.CreateGEP(value, numElts, "vla.inc");
   else
-value = CGF.EmitCheckedInBoundsGEP(value, numElts, signedIndex,
-   E->getExprLoc(), "vla.inc");
+value = CGF.EmitCheckedInBoundsGEP(
+value, numElts, /*SignedIndices=*/false, isSubtraction,
+E->getExprLoc(), "vla.inc");
 
 // Arithmetic on function pointers (!) is just +-1.
 } else 

[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106523.
yawanng marked 2 inline comments as done.

https://reviews.llvm.org/D35365

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecEpollCreate1Check.cpp
  clang-tidy/android/CloexecEpollCreate1Check.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-epoll-create1.cpp

Index: test/clang-tidy/android-cloexec-epoll-create1.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-epoll-create1.cpp
@@ -0,0 +1,59 @@
+// RUN: %check_clang_tidy %s android-cloexec-epoll-create1 %t
+
+#define __O_CLOEXEC 3
+#define EPOLL_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+
+extern "C" int epoll_create1(int flags);
+
+void a() {
+  epoll_create1(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'epoll_create1' should use EPOLL_CLOEXEC where possible [android-cloexec-epoll-create1]
+  // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC)
+  TEMP_FAILURE_RETRY(epoll_create1(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'epoll_create1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC))
+}
+
+void f() {
+  epoll_create1(3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'epoll_create1'
+  // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC)
+  TEMP_FAILURE_RETRY(epoll_create1(3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'epoll_create1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC))
+
+  int flag = 0;
+  epoll_create1(EPOLL_CLOEXEC);
+  TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+}
+
+namespace i {
+int epoll_create1(int flags);
+
+void d() {
+  epoll_create1(0);
+  TEMP_FAILURE_RETRY(epoll_create1(0));
+}
+
+} // namespace i
+
+void e() {
+  epoll_create1(EPOLL_CLOEXEC);
+  TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+}
+
+class G {
+public:
+  int epoll_create1(int flags);
+  void d() {
+epoll_create1(EPOLL_CLOEXEC);
+TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
android-cloexec-creat
+   android-cloexec-epoll-create1
android-cloexec-fopen
android-cloexec-open
android-cloexec-socket
Index: docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-epoll-create1
+
+android-cloexec-epoll-create1
+=
+
+``epoll_create1()`` should include ``EPOLL_CLOEXEC`` in its type argument to
+avoid the file descriptor leakage. Without this flag, an opened sensitive file
+would remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  epoll_create1(0);
+
+  // becomes
+
+  epoll_create1(EPOLL_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -62,6 +62,12 @@
 
   Detect usage of ``creat()``.
 
+- New `android-cloexec-epoll-create1
+  `_ check
+
+  Checks if the required file flag ``EPOLL_CLOEXEC`` is present in the argument of
+  ``epoll_create1()``.
+
 - New `android-cloexec-open
   `_ check
 
Index: clang-tidy/android/CloexecEpollCreate1Check.h
===
--- /dev/null
+++ clang-tidy/android/CloexecEpollCreate1Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreate1Check.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Finds code that uses epoll_create1() without using the EPOLL_CLOEXEC flag.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-epoll-create1.html
+class CloexecEpollCreate1Check : public ClangTidyCheck {
+public:
+  

[PATCH] D35368: [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106520.
yawanng marked an inline comment as done.
Herald added subscribers: xazax.hun, JDevlieghere.

https://reviews.llvm.org/D35368

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecInotifyInit1Check.cpp
  clang-tidy/android/CloexecInotifyInit1Check.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-inotify-init1.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-inotify-init1.cpp

Index: test/clang-tidy/android-cloexec-inotify-init1.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-inotify-init1.cpp
@@ -0,0 +1,64 @@
+// RUN: %check_clang_tidy %s android-cloexec-inotify-init1 %t
+
+#define IN_NONBLOCK 1
+#define __O_CLOEXEC 3
+#define IN_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+
+extern "C" int inotify_init1(int flags);
+
+void a() {
+  inotify_init1(IN_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'inotify_init1' should use IN_CLOEXEC where possible [android-cloexec-inotify-init1]
+  // CHECK-FIXES: inotify_init1(IN_NONBLOCK | IN_CLOEXEC)
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: 'inotify_init1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK | IN_CLOEXEC))
+}
+
+void f() {
+  inotify_init1(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'inotify_init1'
+  // CHECK-FIXES: inotify_init1(IN_CLOEXEC)
+  TEMP_FAILURE_RETRY(inotify_init1(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'inotify_init1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC))
+
+  int flag = 1;
+  inotify_init1(flag);
+  TEMP_FAILURE_RETRY(inotify_init1(flag));
+}
+
+namespace i {
+int inotify_init1(int flags);
+
+void d() {
+  inotify_init1(IN_NONBLOCK);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK));
+}
+
+} // namespace i
+
+void e() {
+  inotify_init1(IN_CLOEXEC);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC));
+  inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK | IN_CLOEXEC));
+}
+
+class G {
+public:
+  int inotify_init1(int flags);
+  void d() {
+inotify_init1(IN_CLOEXEC);
+TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC));
+inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK | IN_CLOEXEC));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-inotify-init1
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-inotify-init1.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-inotify-init1.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-inotify-init1
+
+android-cloexec-inotify-init1
+=
+
+``inotify_init1()`` should include ``IN_CLOEXEC`` in its type argument to avoid the
+file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  inotify_init1(IN_NONBLOCK);
+
+  // becomes
+
+  inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-inotify-init1
+  `_ check
+
+  Checks if the required file flag ``IN_CLOEXEC`` is present in the argument of
+  ``inotify_init1()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecInotifyInit1Check.h
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInit1Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecInotifyInit1Check.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT1_H
+#define 

[libcxx] r307954 - [libc++] Use proper template terminology. NFC

2017-07-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 13 13:47:24 2017
New Revision: 307954

URL: http://llvm.org/viewvc/llvm-project?rev=307954=rev
Log:
[libc++] Use proper template terminology. NFC

It's supposed to be "class template" and "function template" instead of
"template class" and "template function".

Modified:
libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=307954=307953=307954=diff
==
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Thu Jul 13 13:47:24 2017
@@ -90,13 +90,13 @@ Visibility Macros
   The macro has an empty definition with GCC.
 
   **Windows Behavior**: `extern template` and `dllexport` are fundamentally
-  incompatible *on a template class* on Windows; the former suppresses
+  incompatible *on a class template* on Windows; the former suppresses
   instantiation, while the latter forces it. Specifying both on the same
-  declaration makes the template class be instantiated, which is not desirable
+  declaration makes the class template be instantiated, which is not desirable
   inside headers. This macro therefore expands to `dllimport` outside of libc++
   but nothing inside of it (rather than expanding to `dllexport`); instead, the
   explicit instantiations themselves are marked as exported. Note that this
-  applies *only* to extern template *classes*. Extern template *functions* obey
+  applies *only* to extern *class* templates. Extern *function* templates obey
   regular import/export semantics, and applying `dllexport` directly to the
   extern template declaration is the correct thing to do for them.
 


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


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: docs/LanguageExtensions.rst:1309
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];

thakis wrote:
> erik.pilkington wrote:
> > Don't forget the '*', ie @available(macos 10.12, *)!
> Done, thanks. What does the `*` do, by the way? :-)
Its supposed to make explicit that if the platform isn't listed in the 
@available, the true branch is taken and diagnostics are emitted in the then 
stmt using the deployment target version. The idea is that if a new platform is 
introduced, it would use existing APIs and it would be unfortunate if it broke 
everything. 

Now that I think about it, this should probably be mentioned, as its probably 
the most counter-intuitive part of this feature. Maybe something like: "If the 
platform your running on isn't listed in the @available, then the the true 
branch of the if is taken and warnings are emitted against the current 
deployment target."? It might also be nice if you added another OS to this 
example, like `@available(macOS 10.12, iOS 10, *)`?


https://reviews.llvm.org/D35379



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


[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106517.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D35370

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecInotifyInitCheck.cpp
  clang-tidy/android/CloexecInotifyInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-inotify-init.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-inotify-init.cpp

Index: test/clang-tidy/android-cloexec-inotify-init.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-inotify-init.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s android-cloexec-inotify-init %t
+
+extern "C" int inotify_init();
+
+void f() {
+  inotify_init();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer inotify_init() to inotify_init1() because inotify_init1() allows IN_CLOEXEC [android-cloexec-inotify-init]
+  // CHECK-FIXES: inotify_init1(IN_CLOEXEC)
+}
+
+namespace i {
+int inotify_init();
+void g() {
+  inotify_init();
+}
+} // namespace i
+
+class C {
+public:
+  int inotify_init();
+  void h() {
+inotify_init();
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-inotify-init
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-inotify-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-inotify-init.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - android-cloexec-inotify-init
+
+android-cloexec-inotify-init
+
+
+The usage of ``inotify_init()`` is not recommended, it's better to use
+``inotify_init1()``.
+
+Examples:
+
+.. code-block:: c++
+
+  inotify_init();
+
+  // becomes
+
+  inotify_init1(IN_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,11 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-inotify-init
+  `_ check
+
+  Detects usage of ``inotify_init()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecInotifyInitCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInitCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecInotifyInitCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// inotify_init() is better to be replaced by inotify_init1().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-inotify-init.html
+class CloexecInotifyInitCheck : public ClangTidyCheck {
+public:
+  CloexecInotifyInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
Index: clang-tidy/android/CloexecInotifyInitCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInitCheck.cpp
@@ -0,0 +1,40 @@
+//===--- CloexecInotifyInitCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecInotifyInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecInotifyInitCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  

[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/android/CloexecEpollCreate1Check.cpp:21
+
+static constexpr const char *EPOLL_CLOEXEC = "EPOLL_CLOEXEC";
+

Please make this declaration consent across all checks. In some checks it 
declared inside namespaces, in some - outside.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-epoll-create1
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35365



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


[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 106515.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D35372

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecMemfdCreateCheck.cpp
  clang-tidy/android/CloexecMemfdCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-memfd-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-memfd-create.cpp

Index: test/clang-tidy/android-cloexec-memfd-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-memfd-create.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s android-cloexec-memfd-create %t
+
+#define MFD_ALLOW_SEALING 1
+#define __O_CLOEXEC 3
+#define MFD_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int memfd_create(const char *name, unsigned int flags);
+
+void a() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'memfd_create' should use MFD_CLOEXEC where possible [android-cloexec-memfd-create]
+  // CHECK-FIXES: memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC))
+}
+
+void f() {
+  memfd_create(NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'memfd_create'
+  // CHECK-FIXES: memfd_create(NULL, 3 | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, 3 | MFD_CLOEXEC))
+
+  int flag = 3;
+  memfd_create(NULL, flag);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, flag));
+}
+
+namespace i {
+int memfd_create(const char *name, unsigned int flags);
+
+void d() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+}
+
+} // namespace i
+
+void e() {
+  memfd_create(NULL, MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_CLOEXEC));
+  memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC));
+}
+
+class G {
+public:
+  int memfd_create(const char *name, unsigned int flags);
+  void d() {
+memfd_create(NULL, MFD_ALLOW_SEALING);
+TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-memfd-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-memfd-create.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-memfd-create
+
+android-cloexec-memfd-create
+
+
+``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
+the file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  memfd_create(name, MFD_ALLOW_SEALING);
+
+  // becomes
+
+  memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-memfd_create
+  `_ check
+
+  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument of
+  ``memfd_create()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecMemfdCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecMemfdCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecMemfdCreateCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef 

[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-epoll-create
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35367



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


[PATCH] D35368: [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-inotify-init1
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35368



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


[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-inotify-init
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35370



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


[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New `android-cloexec-memfd_create
+  
`_
 check

Please sort checks in alphabetical order.


Repository:
  rL LLVM

https://reviews.llvm.org/D35372



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


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: docs/LanguageExtensions.rst:1290
 
-.. _langext-overloading:
-

erik.pilkington wrote:
> did you mean to remove this?
I meant to move it above the "protocol-qualifier mangling of parameters" 
section; I think that's where it belongs. Did that.



Comment at: docs/LanguageExtensions.rst:1309
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];

erik.pilkington wrote:
> Don't forget the '*', ie @available(macos 10.12, *)!
Done, thanks. What does the `*` do, by the way? :-)


https://reviews.llvm.org/D35379



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


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 106513.
thakis marked an inline comment as done.
thakis added a comment.

comments


https://reviews.llvm.org/D35379

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/AttrDocs.td

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -910,13 +910,13 @@
 
   void f(void) __attribute__((availability(macos,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
 
-The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
-deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
+The availability attribute states that ``f`` was introduced in macOS 10.4,
+deprecated in macOS 10.6, and obsoleted in macOS 10.7.  This information
 is used by Clang to determine when it is safe to use ``f``: for example, if
-Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
-succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
+Clang is instructed to compile code for macOS 10.5, a call to ``f()``
+succeeds.  If Clang is instructed to compile code for macOS 10.6, the call
 succeeds but Clang emits a warning specifying that the function is deprecated.
-Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
+Finally, if Clang is instructed to compile code for macOS 10.7, the call
 fails because ``f()`` is no longer available.
 
 The availability attribute is a comma-separated list starting with the
@@ -961,7 +961,7 @@
   command-line arguments.
 
 ``macos``
-  Apple's Mac OS X operating system.  The minimum deployment target is
+  Apple's macOS operating system.  The minimum deployment target is
   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
   ``macosx`` is supported for backward-compatibility reasons, but it is
   deprecated.
@@ -1016,6 +1016,19 @@
   - (id)method __attribute__((availability(macos,introduced=10.5))); // error: this method was available via the base class in 10.4
   @end
   }];
+
+Starting with the macOS 10.12 SDK, the ``API_AVAILABLE`` macro from
+ can simplify the spelling:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method API_AVAILABLE(macos(10.11)));
+  - (id)otherMethod API_AVAILABLE(macos(10.11), ios(11.0));
+  @end
+
+Also see the documentation for `@available
+`_
 }
 
 def ExternalSourceSymbolDocs : Documentation {
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1271,7 +1271,90 @@
 Query for these features with ``__has_attribute(ns_consumed)``,
 ``__has_attribute(ns_returns_retained)``, etc.
 
+Objective-C @available
+--
 
+It is possible use the newest SDK but still build a program that can run on
+older macOS and iOS versions, by passing ``-mmacosx-version-info=`` /
+``--miphoneos-version-min=``.
+
+Before LLVM 5.0, when calling a function that exists only in the newest OS
+version, programmers had to carefully check if the function exists at runtime,
+using null checks for weakly-linked C functions, ``+class`` for Objective-C
+classes, and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
+Objective-C methods.  If such a check was missed, the program would compile
+fine, run fine on the new OS version, but crash on older OS versions.
+
+As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability attributes
+`_ together
+with the new ``@available()`` keyword to assist with this issue.  If a function
+is called that exists on new OS versions while the minimum deployment version
+is older, then ``-Wunguarded-availability`` will fire:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
+// built with -mmacosx-version-min=10.11, then this unconditional call
+// will emit a -Wunguarded-availability warning:
+[var fancyNewMethod];
+  }
+
+To fix the warning (and to make the call not crash on 10.11!), wrap it in
+``if(@available())``:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12, *)) {
+  [var fancyNewMethod];
+} else {
+  // Put fallback behavior for old macOS versions (and for non-mac
+  // platforms) here.
+}
+  }
+
+If the caller of ``my_fun()`` already checks that ``my_fun()`` is only called
+on 10.12, then add an `availability attributes
+`_ to it,
+which will also suppress the warning:
+
+.. code-block:: objc
+
+  API_AVAILABLE(macos(10.12)) void my_fun(NSSomeClass* var) {
+[var fancyNewMethod];  // Now ok.
+  }
+
+``@available()`` is only available in 

[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a reviewer: arphaman.
erik.pilkington added a subscriber: arphaman.
erik.pilkington added a comment.

This looks great, thanks for working on this! LGTM, but @arphaman might have 
some thoughts.




Comment at: docs/LanguageExtensions.rst:1290
 
-.. _langext-overloading:
-

did you mean to remove this?



Comment at: docs/LanguageExtensions.rst:1309
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];

Don't forget the '*', ie @available(macos 10.12, *)!


https://reviews.llvm.org/D35379



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


[PATCH] D35383: [coroutines] Add serialization/deserialization of coroutines

2017-07-13 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.
Herald added a subscriber: EricWF.

https://reviews.llvm.org/D35383

Files:
  include/clang/AST/StmtCXX.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtCXX.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/PCH/coroutines.cpp

Index: test/PCH/coroutines.cpp
===
--- /dev/null
+++ test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+suspend_always yield_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+int get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_value(int) noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template 
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template 
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -286,7 +286,7 @@
   }
 
   // Outputs
-  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {  
+  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
 Record.AddStmt(S->getOutputExpr(I));
 Record.AddString(S->getOutputConstraint(I));
   }
@@ -300,29 +300,49 @@
   Code = serialization::STMT_MSASM;
 }
 
-void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
+  VisitStmt(CoroStmt);
+  Record.push_back(CoroStmt->getParamMoves().size());
+  for (Stmt *S : CoroStmt->children())
+Record.AddStmt(S);
+  Code = serialization::STMT_COROUTINE_BODY;
 }
 
 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  Record.AddSourceLocation(S->getKeywordLoc());
+  Record.AddStmt(S->getOperand());
+  Record.AddStmt(S->getPromiseCall());
+  Record.push_back(S->isImplicit());
+  Code = serialization::STMT_CORETURN;
+}
+
+static void serializeSuspendExpr(ASTStmtWriter , ASTRecordWriter ,
+ CoroutineSuspendExpr *E) {
+  Writer.VisitExpr(E);
+  Record.AddSourceLocation(E->getKeywordLoc());
+  for (Stmt *S : E->children())
+Record.AddStmt(S);
+  Record.AddStmt(E->getOpaqueValue());
 }
 
-void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
+  serializeSuspendExpr(*this, Record, E);
+  Record.push_back(E->isImplicit());
+  Code = serialization::EXPR_COAWAIT;
 }
 
-void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
+  serializeSuspendExpr(*this, Record, E);
+  Code = serialization::EXPR_COYIELD;
 }
 
-void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void 

[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Martell Malone via Phabricator via cfe-commits
martell added inline comments.



Comment at: examples/clang-interpreter/Manager.cpp:18
+#define NOMINMAX
+#include 
+#endif

windows.h with lower case `w` to not break mingw


https://reviews.llvm.org/D35103



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


[PATCH] D35378: [clang] Add getSignedSizeType method

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D35378



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


[PATCH] D35103: Expand clang-interpreter with example of throwing in and from the JIT for Windows64.

2017-07-13 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

Just 2 small nits.




Comment at: examples/clang-interpreter/main.cpp:165
+  llvm::errs() << "'main' function not found in module.\n";
+  return 255;
+}

255 -> Res ?



Comment at: examples/clang-interpreter/main.cpp:173
+  llvm::errs() << "unable to make execution engine: " << Error << "\n";
+  return 255;
+}

255 -> Res


https://reviews.llvm.org/D35103



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:65
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")

mstorsjo wrote:
> rnk wrote:
> > I strongly suspect that Microsoft will never adopt a varargs calling 
> > convention that uses a complex, non-`char*` va_list.
> > 
> > I'm starting to think we should move this to the generic builtin list and 
> > make it available everywhere. The semantics are that you can only use 
> > __builtin_ms_va_start in ms_abi functions. It always produces a 
> > `char*`-style va_list.
> > 
> Yes, that seems probable.
> 
> I'm a little weary about making this available anywhere though, since it is 
> coupled with the x86_64/aarch64 specific calling convention for lowering 
> va_start, and there we only support it specifically on those two arches.
We should have Sema checking that rejects it when not targeting x64 or aarch64. 
Ultimately the codegen is shared and simple: just call llvm.va.start.


https://reviews.llvm.org/D34475



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:65
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")

rnk wrote:
> I strongly suspect that Microsoft will never adopt a varargs calling 
> convention that uses a complex, non-`char*` va_list.
> 
> I'm starting to think we should move this to the generic builtin list and 
> make it available everywhere. The semantics are that you can only use 
> __builtin_ms_va_start in ms_abi functions. It always produces a `char*`-style 
> va_list.
> 
Yes, that seems probable.

I'm a little weary about making this available anywhere though, since it is 
coupled with the x86_64/aarch64 specific calling convention for lowering 
va_start, and there we only support it specifically on those two arches.



Comment at: include/clang/Basic/Specifiers.h:239
 CC_X86Pascal,   // __attribute__((pascal))
 CC_X86_64Win64, // __attribute__((ms_abi))
 CC_X86_64SysV,  // __attribute__((sysv_abi))

rnk wrote:
> I think we might prefer to make this non-x86_64 specific. I suspect that this 
> pattern will arise again on ARM32 if anyone goes back there in seriousness. 
> We'll probably want sysv_abi as well as ms_abi, and all the logic should be 
> independent of the ISA: ms_abi is a no-op when the target OS is already 
> Windows, and sysv_abi is a no-op when the target OS isn't Windows.
FWIW, we already support ARM32 for windows, and there, varargs are identical to 
other platforms.

Extending this to all platforms probably also makes sense (although I'm a 
little weary about how it would work for signaling down to the LLVM IR).


https://reviews.llvm.org/D34475



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


[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-07-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D34121#808486, @dtzWill wrote:

> In https://reviews.llvm.org/D34121#806978, @vsk wrote:
>
> > @dtzWill do you have any further comments on this one?
> >
> > I'd like to get another 'lgtm' before committing, and it'd be nice to get 
> > this in before llvm 5.0 branches (7/19).
> >
> > FWIW we've been living on this for a few weeks internally without any 
> > issues:
> >  
> > https://github.com/apple/swift-clang/commit/3ebe7d87b9d545aebdd80452d0b79695ff871bce
>
>
> @vsk sorry for the delay.  Looks solid to me, seems to work well in my 
> testing.
>
> Unrelated to the suitability of the patch itself, but on the subject:
>  Interestingly there don''t seem to be any changes in observed errors, which 
> on one hand is great (yay no breakage and earlier results were mostly 
> correct) but on the other isn't what I expected.
>  Does this match your experiences?


Thanks for testing the patch out! Your results match my experiences with some 
Apple frameworks. The 'p - unsigned > p' case seems to be relatively uncommon.


https://reviews.llvm.org/D34121



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


[PATCH] D34475: [AArch64] Add support for __builtin_ms_va_list on aarch64

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/BuiltinsAArch64.def:65
+// Win64-compatible va_list functions
+BUILTIN(__builtin_ms_va_start, "vc*&.", "nt")
+BUILTIN(__builtin_ms_va_end, "vc*&", "n")

I strongly suspect that Microsoft will never adopt a varargs calling convention 
that uses a complex, non-`char*` va_list.

I'm starting to think we should move this to the generic builtin list and make 
it available everywhere. The semantics are that you can only use 
__builtin_ms_va_start in ms_abi functions. It always produces a `char*`-style 
va_list.




Comment at: include/clang/Basic/Specifiers.h:239
 CC_X86Pascal,   // __attribute__((pascal))
 CC_X86_64Win64, // __attribute__((ms_abi))
 CC_X86_64SysV,  // __attribute__((sysv_abi))

I think we might prefer to make this non-x86_64 specific. I suspect that this 
pattern will arise again on ARM32 if anyone goes back there in seriousness. 
We'll probably want sysv_abi as well as ms_abi, and all the logic should be 
independent of the ISA: ms_abi is a no-op when the target OS is already 
Windows, and sysv_abi is a no-op when the target OS isn't Windows.



Comment at: lib/CodeGen/CGBuiltin.cpp:5276
const CallExpr *E) {
+  if (BuiltinID == AArch64::BI__builtin_ms_va_start ||
+  BuiltinID == AArch64::BI__builtin_ms_va_end)

If we made __builtin_ms_va_start generic, that would also eliminate this 
duplicate code.



Comment at: lib/CodeGen/CGCall.cpp:223-224
   if (D->hasAttr())
-return IsWindows ? CC_C : CC_X86_64Win64;
+return IsWindows ? CC_C : Arch == llvm::Triple::aarch64 ? CC_AArch64Win64
+: CC_X86_64Win64;
 

Unifying the ms_abi CCs would remove the need for this.



Comment at: lib/Sema/SemaChecking.cpp:3625
 /// target and calling convention.
 static bool checkVAStartABI(Sema , unsigned BuiltinID, Expr *Fn) {
   const llvm::Triple  = S.Context.getTargetInfo().getTriple();

Oh dear, how can we keep this simple. I think unifying the CC's would improve 
things.



Comment at: lib/Sema/SemaDeclAttr.cpp:4283
+
+CC = Context.getTargetInfo().getTriple().isOSWindows()
+ ? CC_C

Ditto


https://reviews.llvm.org/D34475



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


[PATCH] D35379: Add documentation for @available

2017-07-13 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

Based on 
https://devstreaming-cdn.apple.com/videos/wwdc/2017/411a7o9phe4uekm/411/411_whats_new_in_llvm.pdf

(I couldn't find a way to play the corresponding video on linux, so I didn't 
look at that.)


https://reviews.llvm.org/D35379

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/AttrDocs.td

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -910,13 +910,13 @@
 
   void f(void) __attribute__((availability(macos,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
 
-The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
-deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
+The availability attribute states that ``f`` was introduced in macOS 10.4,
+deprecated in macOS 10.6, and obsoleted in macOS 10.7.  This information
 is used by Clang to determine when it is safe to use ``f``: for example, if
-Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
-succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
+Clang is instructed to compile code for macOS 10.5, a call to ``f()``
+succeeds.  If Clang is instructed to compile code for macOS 10.6, the call
 succeeds but Clang emits a warning specifying that the function is deprecated.
-Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
+Finally, if Clang is instructed to compile code for macOS 10.7, the call
 fails because ``f()`` is no longer available.
 
 The availability attribute is a comma-separated list starting with the
@@ -961,7 +961,7 @@
   command-line arguments.
 
 ``macos``
-  Apple's Mac OS X operating system.  The minimum deployment target is
+  Apple's macOS operating system.  The minimum deployment target is
   specified by the ``-mmacosx-version-min=*version*`` command-line argument.
   ``macosx`` is supported for backward-compatibility reasons, but it is
   deprecated.
@@ -1016,6 +1016,19 @@
   - (id)method __attribute__((availability(macos,introduced=10.5))); // error: this method was available via the base class in 10.4
   @end
   }];
+
+Starting with the macOS 10.12 SDK, the ``API_AVAILABLE`` macro from
+ can simplify the spelling:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method API_AVAILABLE(macos(10.11)));
+  - (id)otherMethod API_AVAILABLE(macos(10.11), ios(11.0));
+  @end
+
+Also see the documentation for `@available
+`_
 }
 
 def ExternalSourceSymbolDocs : Documentation {
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1271,7 +1271,88 @@
 Query for these features with ``__has_attribute(ns_consumed)``,
 ``__has_attribute(ns_returns_retained)``, etc.
 
+Objective-C @available
+--
 
+It is possible use the newest SDK but still build a program that can run on
+older macOS and iOS versions, by passing ``-mmacosx-version-info=`` /
+``--miphoneos-version-min=``.
+
+Before LLVM 5.0, when calling a function that exists only in the newest OS
+version, programmers had to carefully check if the function exists at runtime,
+using null checks for weakly-linked C functions, ``+class`` for Objective-C
+classes, and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
+Objective-C methods.  If such a check was missed, the program would compile
+fine, run fine on the new OS version, but crash on older OS versions.
+
+As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability attributes
+`_ together
+with the new ``@available()`` keyword to assist with this issue.  If a function
+is called that exists on new OS versions while the minimum deployment version
+is older, then ``-Wunguarded-availability`` will fire:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
+// built with -mmacosx-version-min=10.11, then this unconditional call
+// will emit a -Wunguarded-availability warning:
+[var fancyNewMethod];
+  }
+
+To fix the warning (and to make the call not crash on 10.11!), wrap it in
+``if(@available())``:
+
+.. code-block:: objc
+
+  void my_fun(NSSomeClass* var) {
+if (@available(macOS 10.12)) {
+  [var fancyNewMethod];
+} else {
+  // Put fallback behavior for old macOS versions (and for non-mac
+  // platforms) here.
+}
+  }
+
+If the caller of ``my_fun()`` already checks that ``my_fun()`` is only called
+on 10.12, then add an `availability attributes
+`_ to it,
+which will also suppress the warning:
+
+.. code-block:: objc
+
+  API_AVAILABLE(macos(10.12)) void 

[PATCH] D35378: [clang] Add getSignedSizeType method

2017-07-13 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 106496.
alexshap added a comment.

make comments consistent


Repository:
  rL LLVM

https://reviews.llvm.org/D35378

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,12 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed counterpart of the integer type 
+/// corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,12 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed counterpart of the integer type 
+/// corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35378: [clang] Add getSignedSizeType method

2017-07-13 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.

C11 standard refers to the signed counterpart of the size_t type in
the paragraph 7.21.6.1 where it defines d, i, o, u, x, or x conversion 
specifiers
(in printf format string).
In Clang there is a FIXME (in lib/Analysis/PrintfFormatString.cpp) for this case
(which is not handled correctly at the moment).
This diff adds getSignedSizeType method to TargetInfo and exposes it in 
ASTContext similarly to
how it is done for getSizeType.
lib/Analysis/PrintfFormatString.cpp is supposed to be changed in a follow-up 
commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D35378

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,11 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed integer type corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -4525,6 +4525,11 @@
   return getFromTargetType(Target->getSizeType());
 }
 
+/// Return the unique signed integer type corresponding to size_t.
+CanQualType ASTContext::getSignedSizeType() const {
+  return getFromTargetType(Target->getSignedSizeType());
+}
+
 /// getIntMaxType - Return the unique type for "intmax_t" (C99 7.18.1.5).
 CanQualType ASTContext::getIntMaxType() const {
   return getFromTargetType(Target->getIntMaxType());
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -226,6 +226,20 @@
 
 public:
   IntType getSizeType() const { return SizeType; }
+  IntType getSignedSizeType() const {
+switch (SizeType) {
+case UnsignedShort:
+  return SignedShort;
+case UnsignedInt:
+  return SignedInt;
+case UnsignedLong:
+  return SignedLong;
+case UnsignedLongLong:
+  return SignedLongLong;
+default:
+  llvm_unreachable("Invalid SizeType");
+}
+  }
   IntType getIntMaxType() const { return IntMaxType; }
   IntType getUIntMaxType() const {
 return getCorrespondingUnsignedType(IntMaxType);
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1441,6 +1441,10 @@
   /// The sizeof operator requires this (C99 6.5.3.4p4).
   CanQualType getSizeType() const;
 
+  /// \brief Return the unique signed counterpart of 
+  /// the integer type corresponding to size_t.
+  CanQualType getSignedSizeType() const;
+
   /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
   /// .
   CanQualType getIntMaxType() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r307941 - [demangler] Respect try_to_parse_template_args

2017-07-13 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Jul 13 12:37:37 2017
New Revision: 307941

URL: http://llvm.org/viewvc/llvm-project?rev=307941=rev
Log:
[demangler] Respect try_to_parse_template_args

Fixes an exponential parse found by oss-fuzz.

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=307941=307940=307941=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Jul 13 12:37:37 2017
@@ -2364,17 +2364,20 @@ parse_type(const char* first, const char
 first = t;
 // Parsed a substitution.  If the substitution 
is a
 //   it might be followed by 
.
-t = parse_template_args(first, last, db);
-if (t != first)
+if (db.try_to_parse_template_args)
 {
-if (db.names.size() < 2)
-return first;
-auto template_args = 
db.names.back().move_full();
-db.names.pop_back();
-db.names.back().first += template_args;
-// Need to create substitution for 
 
-db.subs.push_back(Db::sub_type(1, 
db.names.back(), db.names.get_allocator()));
-first = t;
+t = parse_template_args(first, last, db);
+if (t != first)
+{
+if (db.names.size() < 2)
+return first;
+auto template_args = 
db.names.back().move_full();
+db.names.pop_back();
+db.names.back().first += template_args;
+// Need to create substitution for 
 
+db.subs.push_back(Db::sub_type(1, 
db.names.back(), db.names.get_allocator()));
+first = t;
+}
 }
 }
 }

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=307941=307940=307941=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Thu Jul 13 12:37:37 2017
@@ -29669,6 +29669,7 @@ const char* invalid_cases[] =
 "_ZcvCiIJEEDvT__T_vT_v",
 "Z1JIJ1_T_EE3o00EUlT_E0",
 "___Z2i_D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D",
+
"ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_Dv_Dv_Dv_Dv_dZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_Dv_Dv_Dv_Dv_d",
 };
 
 const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);


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


[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

2017-07-13 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: tools/clang-format/ClangFormat.cpp:377
 break;
   case 1:
 Error = clang::format::format(FileNames[0]);

djasper wrote:
> I think we should restructure the code to not have to duplicate what you are 
> adding here. I think fundamentally, we should be able to change this to:
> 
>   if (FileNames.empty()) {
> Error = clang::format::format("-");
> return Error ? 1 : 0;
>   }
>   if (FileNames.size() == 1 && (!Offsets.empty() || !Lengths.empty() || 
> !LineRanges.empty())) {
> errs() << "error: -offset  "
> return 1;
>   }
>   for (const auto& FileName : FileNames) {
> if (Verbose.getNumOccurences() != 0)
>   errs() << "Formatting " << Filename << "\n";
> Error |= clang::format::format(FileName);
>   }
>   return Error ? 1 : 0;
This isn't correct.
You can have

```
bin/clang-format  -lines=1:1 foo-1.cpp foo-2.cpp 
```
we won't enter into the "error: -offset" error



https://reviews.llvm.org/D34824



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-07-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 106486.
yaxunl marked 6 inline comments as done.
yaxunl added a comment.

Revised by Anastasia's comments.


https://reviews.llvm.org/D35082

Files:
  include/clang/Basic/AddressSpaces.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/address-spaces-mangling.cl
  test/Index/opencl-types.cl
  test/Parser/opencl-astype.cl
  test/Parser/opencl-atomics-cl20.cl
  test/SemaOpenCL/access-qualifier.cl
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/arithmetic-conversions.cl
  test/SemaOpenCL/as_type.cl
  test/SemaOpenCL/cl20-device-side-enqueue.cl
  test/SemaOpenCL/event_t.cl
  test/SemaOpenCL/extension-begin.cl
  test/SemaOpenCL/half.cl
  test/SemaOpenCL/images.cl
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/null_literal.cl
  test/SemaOpenCL/null_queue.cl
  test/SemaOpenCL/queue_t_overload.cl
  test/SemaOpenCL/sampler_t.cl
  test/SemaOpenCL/shifts.cl
  test/SemaOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/vec_step.cl
  test/SemaOpenCL/vector_conv_invalid.cl

Index: test/SemaOpenCL/vector_conv_invalid.cl
===
--- test/SemaOpenCL/vector_conv_invalid.cl
+++ test/SemaOpenCL/vector_conv_invalid.cl
@@ -7,7 +7,7 @@
 
 void vector_conv_invalid() {
   uint4 u = (uint4)(1);
-  int4 i = u; // expected-error{{initializing 'int4' (vector of 4 'int' values) with an expression of incompatible type 'uint4' (vector of 4 'unsigned int' values)}}
+  int4 i = u; // expected-error{{initializing '__private int4' (vector of 4 'int' values) with an expression of incompatible type '__private uint4' (vector of 4 'unsigned int' values)}}
   int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' (vector of 4 'int' values) and 'uint4' (vector of 4 'unsigned int' values)}}
 
   uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' (vector of 3 'unsigned int' values) and 'uint4' (vector of 4 'unsigned int' values)}}
Index: test/SemaOpenCL/vec_step.cl
===
--- test/SemaOpenCL/vec_step.cl
+++ test/SemaOpenCL/vec_step.cl
@@ -26,7 +26,7 @@
   int res11[vec_step(int16) == 16 ? 1 : -1];
   int res12[vec_step(void) == 1 ? 1 : -1];
 
-  int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires built-in scalar or vector type, 'struct S' invalid}}
-  int res14 = vec_step(int16*); // expected-error {{'vec_step' requires built-in scalar or vector type, 'int16 *' invalid}}
+  int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires built-in scalar or vector type, '__private struct S' invalid}}
+  int res14 = vec_step(int16 *); // expected-error {{'vec_step' requires built-in scalar or vector type, '__private int16 *' invalid}}
   int res15 = vec_step(void(void)); // expected-error {{'vec_step' requires built-in scalar or vector type, 'void (void)' invalid}}
 }
Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -11,45 +11,45 @@
   glob = to_global(glob, loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
   // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
-  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+  // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
   // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
 #endif
 
   int x;
   glob = to_global(x);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
   // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
+  // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
 #else
   // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
 #endif
 
   glob = to_global(con_typedef);
 #if __OPENCL_C_VERSION__ 

[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D35081#808207, @tejohnson wrote:

> My first option was if any copy is under the threshold, simply pick the 
> prevailing copy (it may be over threshold, but assume we want that one 
> anyway). Another possibility is to only allow importing of the prevailing 
> copy, if it is over the inst limit, too bad. The main reason I think that 
> could be better is when we have PGO - the prevailing copy would for sure have 
> the matched PGO data, but the non-prevailing copies may not.


Ah makes sense, both way are fine with me.

I'd rather limit to the prevailing copy though and too bad if it is over the 
limit, to avoid the possibility of too large importing just because there was a 
small non-prevailing somewhere, but likely a rare case.

Limiting to the prevailing copy means that we could prune the index early after 
symbol resolution to keep only the prevailing summary, which could speed-up all 
the process (and possibly get more accurate dead-stripping if we don't use the 
prevailing information there already?).


https://reviews.llvm.org/D35081



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


[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-07-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 6 inline comments as done.
yaxunl added inline comments.



Comment at: lib/AST/Expr.cpp:3235
+// has non-default address space it is not treated as nullptr.
+bool PointeeHasDefaultAS = false;
+if (Ctx.getLangOpts().OpenCL)

Anastasia wrote:
> Would we still be accepting the following:
>   global int * ptr = (global void*)0;
Yes. There is a test SemaOpenCL/null_literal.cl



Comment at: lib/Sema/SemaDecl.cpp:7964
+PointeeType.getAddressSpace() == LangAS::opencl_private ||
 PointeeType.getAddressSpace() == 0)
   return InvalidAddrSpacePtrKernelParam;

Anastasia wrote:
> Could we use `LangAS::Default` instead?
done



Comment at: lib/Sema/SemaDecl.cpp:11846
   // an address space.
   if (T.getAddressSpace() != 0) {
 // OpenCL allows function arguments declared to be an array of a type

Anastasia wrote:
> Could we use `LangAS::Default` here too?
done



Comment at: lib/Sema/SemaDecl.cpp:11851
+  (T->isArrayType() ||
+   T.getAddressSpace() == LangAS::opencl_private))) {
   Diag(NameLoc, diag::err_arg_with_address_space);

Anastasia wrote:
> Would it be better to lift this into if condition of line 11846?
will do.



Comment at: lib/Sema/SemaType.cpp:6969
 
+  if (state.getSema().getLangOpts().OpenCL &&
+  !hasOpenCLAddressSpace && type.getAddressSpace() == 0 &&

Anastasia wrote:
> Would it be nicer to not append any address space at all neither here nor 
> down at the end of this function and keep it default instead until the 
> Codegen? If it's doable I would very much prefer that. It seems like it would 
> make the implementation potentially a bit cleaner to understand and easier to 
> improve semantical analysis. See one example of improving original type 
> printing in my comment to the test below.
> 
> Also there are at least these 3 related bugs open currently:
> https://bugs.llvm.org//show_bug.cgi?id=33418
> https://bugs.llvm.org//show_bug.cgi?id=33419
> https://bugs.llvm.org//show_bug.cgi?id=33420
> 
> Does your change address any of those?
On the contrary, I think using default address space for automatic variable and 
function parameter will cause ambiguity and inconsistency in AST, making it 
more difficult to understand and process, and making some bug (e.g. 
https://bugs.llvm.org//show_bug.cgi?id=33419) unfixable. For example, `private 
int f(void)` and `int f(void)` will be identical in AST, therefore we cannot 
diagnose `private int f(void)`.

With current representation I am able to fix the 3 bugs. I will update the diff.



Comment at: test/SemaOpenCL/access-qualifier.cl:23
 #else
-void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 
'read_write' can not be used for '__read_write image1d_t' prior to OpenCL 
version 2.0}}
+void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 
'read_write' can not be used for '__private __read_write image1d_t' prior to 
OpenCL version 2.0}}
 #endif

Anastasia wrote:
> Ok, I think that here it would be less confusing not to add any address space 
> since it's missing in the original source.
Although it looks strange at first sight, `__private __read_write image1d_t` is 
the true type of the argument. The function argument is allocated from stack 
and is an l-value. If we take its address, we get a private pointer.


https://reviews.llvm.org/D35082



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


[PATCH] D34121: [ubsan] Teach the pointer overflow check that "p - <= p" (PR33430)

2017-07-13 Thread Will Dietz via Phabricator via cfe-commits
dtzWill added a comment.

In https://reviews.llvm.org/D34121#806978, @vsk wrote:

> @dtzWill do you have any further comments on this one?
>
> I'd like to get another 'lgtm' before committing, and it'd be nice to get 
> this in before llvm 5.0 branches (7/19).
>
> FWIW we've been living on this for a few weeks internally without any issues:
>  
> https://github.com/apple/swift-clang/commit/3ebe7d87b9d545aebdd80452d0b79695ff871bce


@vsk sorry for the delay.  Looks solid to me, seems to work well in my testing.

Unrelated to the suitability of the patch itself, but on the subject:
Interestingly there don''t seem to be any changes in observed errors, which on 
one hand is great (yay no breakage and earlier results were mostly correct) but 
on the other isn't what I expected.
Does this match your experiences?


https://reviews.llvm.org/D34121



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


[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307933: [AArch64] Produce the right kind of va_arg for 
windows (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D35008?vs=105392=106471#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35008

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/aarch64-varargs-ms.c


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -4785,7 +4785,8 @@
 public:
   enum ABIKind {
 AAPCS = 0,
-DarwinPCS
+DarwinPCS,
+Win64
   };
 
 private:
@@ -4823,10 +4824,14 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override {
-return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
- : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
+ : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+ : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
 
+  Address EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+  QualType Ty) const override;
+
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
 ArrayRef scalars,
 bool asReturnValue) const override {
@@ -5332,6 +5337,14 @@
   TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false);
+}
+
 
//===--===//
 // ARM ABI Implementation
 
//===--===//
@@ -8494,6 +8507,8 @@
 AArch64ABIInfo::ABIKind Kind = AArch64ABIInfo::AAPCS;
 if (getTarget().getABI() == "darwinpcs")
   Kind = AArch64ABIInfo::DarwinPCS;
+else if (Triple.isOSWindows())
+  Kind = AArch64ABIInfo::Win64;
 
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }
Index: cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
===
--- cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
+++ cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK %s
+
+#include 
+
+int simple_int(va_list ap) {
+// CHECK-LABEL: define i32 @simple_int
+  return va_arg(ap, int);
+// CHECK: [[ADDR:%[a-z_0-9]+]] = bitcast i8* %argp.cur to i32*
+// CHECK: [[RESULT:%[a-z_0-9]+]] = load i32, i32* [[ADDR]]
+// CHECK: ret i32 [[RESULT]]
+}


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -4785,7 +4785,8 @@
 public:
   enum ABIKind {
 AAPCS = 0,
-DarwinPCS
+DarwinPCS,
+Win64
   };
 
 private:
@@ -4823,10 +4824,14 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override {
-return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
- : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
+ : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+ : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
 
+  Address EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+  QualType Ty) const override;
+
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
 ArrayRef scalars,
 bool asReturnValue) const override {
@@ -5332,6 +5337,14 @@
   TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false);
+}
+
 //===--===//
 // ARM ABI Implementation
 //===--===//
@@ -8494,6 +8507,8 @@
 

r307933 - [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Jul 13 10:59:14 2017
New Revision: 307933

URL: http://llvm.org/viewvc/llvm-project?rev=307933=rev
Log:
[AArch64] Produce the right kind of va_arg for windows

On windows on arm64, the va_list is a plain pointer.

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

Added:
cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=307933=307932=307933=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Jul 13 10:59:14 2017
@@ -4785,7 +4785,8 @@ class AArch64ABIInfo : public SwiftABIIn
 public:
   enum ABIKind {
 AAPCS = 0,
-DarwinPCS
+DarwinPCS,
+Win64
   };
 
 private:
@@ -4823,10 +4824,14 @@ private:
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override {
-return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
- : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
+ : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+ : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
 
+  Address EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+  QualType Ty) const override;
+
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
 ArrayRef scalars,
 bool asReturnValue) const override {
@@ -5332,6 +5337,14 @@ Address AArch64ABIInfo::EmitDarwinVAArg(
   TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+  CGF.getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(8),
+  /*allowHigherAlign*/ false);
+}
+
 
//===--===//
 // ARM ABI Implementation
 
//===--===//
@@ -8494,6 +8507,8 @@ const TargetCodeGenInfo ::
 AArch64ABIInfo::ABIKind Kind = AArch64ABIInfo::AAPCS;
 if (getTarget().getABI() == "darwinpcs")
   Kind = AArch64ABIInfo::DarwinPCS;
+else if (Triple.isOSWindows())
+  Kind = AArch64ABIInfo::Win64;
 
 return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
   }

Added: cfe/trunk/test/CodeGen/aarch64-varargs-ms.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-varargs-ms.c?rev=307933=auto
==
--- cfe/trunk/test/CodeGen/aarch64-varargs-ms.c (added)
+++ cfe/trunk/test/CodeGen/aarch64-varargs-ms.c Thu Jul 13 10:59:14 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple arm64-windows-msvc -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK %s
+
+#include 
+
+int simple_int(va_list ap) {
+// CHECK-LABEL: define i32 @simple_int
+  return va_arg(ap, int);
+// CHECK: [[ADDR:%[a-z_0-9]+]] = bitcast i8* %argp.cur to i32*
+// CHECK: [[RESULT:%[a-z_0-9]+]] = load i32, i32* [[ADDR]]
+// CHECK: ret i32 [[RESULT]]
+}


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


[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/CodeGen/TargetInfo.cpp:8463
   Kind = AArch64ABIInfo::DarwinPCS;
+else if (Triple.getOS() == llvm::Triple::Win32)
+  Kind = AArch64ABIInfo::Win64;

`Triple.isOSWindows()` is probably cleaner.


https://reviews.llvm.org/D35008



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


[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

2017-07-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ping - the dependency, https://reviews.llvm.org/D35006, has now been committed.


https://reviews.llvm.org/D35008



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


Re: [PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-07-13 Thread Nico Weber via cfe-commits
On Thu, Jul 13, 2017 at 1:38 PM, Roman Lebedev via Phabricator via
cfe-commits  wrote:

> lebedev.ri added a comment.
>
> PR #33771  filled.
> IMHO the problems with this diagnostic should be resolved before 5.0
>

iirc gcc warns in that case too (?) Also, the warning is off by default.


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


[PATCH] D32914: Introduce Wzero-as-null-pointer-constant.

2017-07-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

PR #33771  filled.
IMHO the problems with this diagnostic should be resolved before 5.0


https://reviews.llvm.org/D32914



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


r307932 - Fix spelling mistakes in comments. NFCI.

2017-07-13 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jul 13 10:34:44 2017
New Revision: 307932

URL: http://llvm.org/viewvc/llvm-project?rev=307932=rev
Log:
Fix spelling mistakes in comments. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=307932=307931=307932=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Jul 13 10:34:44 2017
@@ -108,7 +108,7 @@ struct OMPTaskDataTy final {
 /// Class intended to support codegen of all kind of the reduction clauses.
 class ReductionCodeGen {
 private:
-  /// Data requiored for codegen of reduction clauses.
+  /// Data required for codegen of reduction clauses.
   struct ReductionData {
 /// Reference to the original shared item.
 const Expr *Ref = nullptr;
@@ -158,18 +158,18 @@ public:
   /// \param PrivateAddr Address of the corresponding private item.
   /// \param DefaultInit Default initialization sequence that should be
   /// performed if no reduction specific initialization is found.
-  /// \param SharedLVal Addreiss of the original shared variable.
+  /// \param SharedLVal Address of the original shared variable.
   void
   emitInitialization(CodeGenFunction , unsigned N, Address PrivateAddr,
  LValue SharedLVal,
  llvm::function_ref DefaultInit);
-  /// ReturCns true if the private copy requires cleanups.
+  /// Returns true if the private copy requires cleanups.
   bool needCleanups(unsigned N);
-  /// Emits cleanup code nfor the reduction item.
+  /// Emits cleanup code for the reduction item.
   /// \param N Number of the reduction item.
   /// \param PrivateAddr Address of the corresponding private item.
   void emitCleanups(CodeGenFunction , unsigned N, Address PrivateAddr);
-  /// Adjusts \p PrivatedAddr for using ninstead of the original variable
+  /// Adjusts \p PrivatedAddr for using instead of the original variable
   /// address in normal operations.
   /// \param N Number of the reduction item.
   /// \param PrivateAddr Address of the corresponding private item.
@@ -200,7 +200,7 @@ protected:
   /// \param OutlinedFnID Outlined function ID value to be defined by this 
call.
   /// \param IsOffloadEntry True if the outlined function is an offload entry.
   /// \param CodeGen Lambda codegen specific to an accelerator device.
-  /// An oulined function may not be an entry if, e.g. the if clause always
+  /// An outlined function may not be an entry if, e.g. the if clause always
   /// evaluates to false.
   virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
,
 StringRef ParentName,
@@ -778,7 +778,7 @@ public:
   /// \param Loc Clang source location.
   /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
   /// \param IVSize Size of the iteration variable in bits.
-  /// \param IVSigned Sign of the interation variable.
+  /// \param IVSigned Sign of the iteration variable.
   /// \param Ordered true if loop is ordered, false otherwise.
   /// \param DispatchValues struct containing llvm values for lower bound, 
upper
   /// bound, and chunk expression.
@@ -802,7 +802,7 @@ public:
   /// \param Loc Clang source location.
   /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
   /// \param IVSize Size of the iteration variable in bits.
-  /// \param IVSigned Sign of the interation variable.
+  /// \param IVSigned Sign of the iteration variable.
   /// \param Ordered true if loop is ordered, false otherwise.
   /// \param IL Address of the output variable in which the flag of the
   /// last iteration is returned.
@@ -811,7 +811,7 @@ public:
   /// \param UB Address of the output variable in which the upper iteration
   /// number is returned.
   /// \param ST Address of the output variable in which the stride value is
-  /// returned nesessary to generated the static_chunked scheduled loop.
+  /// returned necessary to generated the static_chunked scheduled loop.
   /// \param Chunk Value of the chunk for the static_chunked scheduled loop.
   /// For the default (nullptr) value, the chunk 1 will be used.
   ///
@@ -826,7 +826,7 @@ public:
   /// \param Loc Clang source location.
   /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
   /// \param IVSize Size of the iteration variable in bits.
-  /// \param IVSigned Sign of the interation variable.
+  /// \param IVSigned Sign of the iteration variable.
   /// \param Ordered true if loop is ordered, false otherwise.
   /// \param IL Address of the output variable in which the flag of the
   /// last iteration is returned.
@@ -835,7 +835,7 @@ public:
   /// \param UB Address of the output variable in which the upper iteration
   /// 

r307931 - Fix -Wdocumentation warning. NFCI

2017-07-13 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jul 13 10:29:48 2017
New Revision: 307931

URL: http://llvm.org/viewvc/llvm-project?rev=307931=rev
Log:
Fix -Wdocumentation warning. NFCI

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=307931=307930=307931=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Jul 13 10:29:48 2017
@@ -159,7 +159,6 @@ public:
   /// \param DefaultInit Default initialization sequence that should be
   /// performed if no reduction specific initialization is found.
   /// \param SharedLVal Addreiss of the original shared variable.
-  /// \return true, if the initialization sequence was emitted, false 
otherwise.
   void
   emitInitialization(CodeGenFunction , unsigned N, Address PrivateAddr,
  LValue SharedLVal,


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


[PATCH] D35362: [clang-tidy] Add close-on-exec checks on several functions in Android module.

2017-07-13 Thread Yan Wang via Phabricator via cfe-commits
yawanng created this revision.
yawanng added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere, mgorny.

accept() is better to be replaced by accept4() with SOCK_CLOEXEC flag to avoid 
file descriptor leakage.

This is one of a bunch of similar APIs as below and they have very similar 
structures:


https://reviews.llvm.org/D35362

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecAcceptCheck.cpp
  clang-tidy/android/CloexecAcceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-accept.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-accept.cpp

Index: test/clang-tidy/android-cloexec-accept.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-accept.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s android-cloexec-accept %t
+
+struct sockaddr {};
+typedef int socklen_t;
+#define NULL 0
+
+extern "C" int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+
+void f() {
+  accept(0, NULL, NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC [android-cloexec-accept]
+  // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_CLOEXEC)
+}
+
+namespace i {
+int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+void g() {
+  accept(0, NULL, NULL);
+}
+} // namespace i
+
+class C {
+public:
+  int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+  void h() {
+accept(0, NULL, NULL);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   android-cloexec-accept
android-cloexec-creat
android-cloexec-fopen
android-cloexec-open
Index: docs/clang-tidy/checks/android-cloexec-accept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-accept.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-accept
+
+android-cloexec-accept
+==
+
+The usage of ``accept()`` is not recommended, it's better to use ``accept4()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  accept(sockfd, addr, addrlen);
+
+  // becomes
+
+  accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `android-cloexec-accept
+  `_ check
+
+  Detects usage of ``accept()``.
+
 - New `android-cloexec-creat
   `_ check
 
Index: clang-tidy/android/CloexecAcceptCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecAcceptCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecAcceptCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// accept() is better to be replaced by accept4().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
+class CloexecAcceptCheck : public ClangTidyCheck {
+public:
+  CloexecAcceptCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
Index: clang-tidy/android/CloexecAcceptCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecAcceptCheck.cpp
@@ -0,0 +1,64 @@
+//===--- CloexecAcceptCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread David L. Jones via Phabricator via cfe-commits
dlj accepted this revision.
dlj added a comment.

I think this change is structurally fine, but I'll defer to others on whether 
it's actually doing the right thing. (I'm pretty sure it is, but I'm far from 
an expert on Solaris or Sparc.)




Comment at: lib/Driver/ToolChains/Gnu.cpp:2467
   const Generic_GCC::GCCVersion  = GCCInstallation.getVersion();
   bool UseInitArrayDefault =
   getTriple().getArch() == llvm::Triple::aarch64 ||

fedor.sergeev wrote:
> davide wrote:
> > this is really a mess.
> Any suggestions on how to improve? :)
From my perspective, this is really no worse than what's already here. I tried 
to avoid changing logic in https://reviews.llvm.org/rL297250, but this function 
is an example of something that still can use a lot of work.

Since this variable depends on all the parts of the triple, it probably won't 
break down very cleanly among the various subclasses. That said, if you do want 
to refactor this, you'll of course want to spend some time to think through 
exactly how this should work, and spend some time gathering feedback from other 
Clang devs... so it's probably out of the scope of this patch. I would be happy 
to help review that change... but, more pragmatically, I'd say land this change 
first before starting any surgery.



Comment at: test/Driver/constructors.c:83
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1\
+// RUN: -target i386-pc-solaris2.11 \
+// RUN:   | FileCheck --check-prefix=CHECK-INIT-ARRAY %s

Thank you for adding these. :-D Most of the toolchain classes lack explanatory 
comments about which platform combinations are expected to work for different 
features, so test cases like this will be invaluable to anyone who wants to 
refactor parts of the driver.


https://reviews.llvm.org/D35337



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808204, @mehdi_amini wrote:

> In https://reviews.llvm.org/D35081#808189, @tejohnson wrote:
>
> > > Alternatively (and likely preferably from a compile-time point of view to 
> > > limit the list of import), we could keep a map of GUID->Summary and reuse 
> > > it before trying to select a new callee.
> >
> > Yep, that was my third option. I only hesitate because it seems like it 
> > might be better to select the prevailing copy when we can, but perhaps it 
> > doesn't matter much.
>
>
> I'm not sure I understand what is your first option? Always selecting the 
> prevailing copy? 
>  Unless doing a topological order for visiting (which I don't think we could 
> reasonably do), I don't see how you can ensure that:  on your first visit you 
> may see the prevailing not eligible, but it may become eligible on the second 
> visit, at which point you need to do something about the first copy you 
> already selected.


My first option was if any copy is under the threshold, simply pick the 
prevailing copy (it may be over threshold, but assume we want that one anyway). 
Another possibility is to only allow importing of the prevailing copy, if it is 
over the inst limit, too bad. The main reason I think that could be better is 
when we have PGO - the prevailing copy would for sure have the matched PGO 
data, but the non-prevailing copies may not.


https://reviews.llvm.org/D35081



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D35081#808189, @tejohnson wrote:

> > Alternatively (and likely preferably from a compile-time point of view to 
> > limit the list of import), we could keep a map of GUID->Summary and reuse 
> > it before trying to select a new callee.
>
> Yep, that was my third option. I only hesitate because it seems like it might 
> be better to select the prevailing copy when we can, but perhaps it doesn't 
> matter much.


I'm not sure I understand what is your first option? Always selecting the 
prevailing copy? 
Unless doing a topological order for visiting (which I don't think we could 
reasonably do), I don't see how you can ensure that:  on your first visit you 
may see the prevailing not eligible, but it may become eligible on the second 
visit, at which point you need to do something about the first copy you already 
selected.


https://reviews.llvm.org/D35081



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808158, @mehdi_amini wrote:

> Thanks, very clear :)
>
> I would expect that if we reprocess a GUID we invalidate the previous import 
> of the same GUID. Right now my impression is that the issue is that ` 
> ImportList[ExportModulePath][VI.getGUID()]` is indexed on the importing 
> module. So it'd require for every new import to loop over the ImportList map 
> and delete the GUID on each inner map.


Right, that was the processing I was hoping to avoid.

> Alternatively (and likely preferably from a compile-time point of view to 
> limit the list of import), we could keep a map of GUID->Summary and reuse it 
> before trying to select a new callee.

Yep, that was my third option. I only hesitate because it seems like it might 
be better to select the prevailing copy when we can, but perhaps it doesn't 
matter much.


https://reviews.llvm.org/D35081



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


r307924 - Extend -Wdeprecated-implementations to warn about unavailable methods

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 09:37:11 2017
New Revision: 307924

URL: http://llvm.org/viewvc/llvm-project?rev=307924=rev
Log:
Extend -Wdeprecated-implementations to warn about unavailable methods

rdar://22867595

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307924=307923=307924=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 13 09:37:11 
2017
@@ -4581,6 +4581,9 @@ def warn_deprecated_fwdclass_message : W
 def warn_deprecated_def : Warning<
   "implementing deprecated %select{method|class|category}0">,
   InGroup, DefaultIgnore;
+def warn_unavailable_def : Warning<
+  "implementing unavailable method">,
+  InGroup, DefaultIgnore;
 def err_unavailable : Error<"%0 is unavailable">;
 def err_property_method_unavailable :
 Error<"property access is using %0 method which is unavailable">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=307924=307923=307924=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 13 09:37:11 2017
@@ -253,7 +253,17 @@ static void DiagnoseObjCImplementedDepre
   if (!ND)
 return;
   bool IsCategory = false;
-  if (!ND->isDeprecated()) {
+  AvailabilityResult Availability = ND->getAvailability();
+  if (Availability != AR_Deprecated) {
+if (const auto *MD = dyn_cast(ND)) {
+  if (Availability != AR_Unavailable)
+return;
+  // Warn about implementing unavailable methods.
+  S.Diag(ImplLoc, diag::warn_unavailable_def);
+  S.Diag(ND->getLocation(), diag::note_method_declared_at)
+  << ND->getDeclName();
+  return;
+}
 if (const auto *CD = dyn_cast(ND)) {
   if (!CD->getClassInterface()->isDeprecated())
 return;

Modified: cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m?rev=307924=307923=307924=diff
==
--- cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m (original)
+++ cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m Thu Jul 13 
09:37:11 2017
@@ -1,9 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -Wdeprecated-implementations -verify 
-Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple=x86_64-apple-macos10.10 -fsyntax-only 
-Wdeprecated-implementations -verify -Wno-objc-root-class %s
 // rdar://8973810
 // rdar://12717705
 
 @protocol P
 - (void) D __attribute__((deprecated)); // expected-note {{method 'D' declared 
here}}
+
+- (void) unavailable __attribute__((__unavailable__)); // expected-note 
{{method 'unavailable' declared here}}
 @end
 
 @interface A 
@@ -18,6 +20,8 @@
 + (void)F { }  // No warning, implementing its own deprecated method
 - (void) D {} //  expected-warning {{implementing deprecated method}}
 - (void) E {} // No warning, implementing deprecated method in its class 
extension.
+
+- (void) unavailable { } // expected-warning {{implementing unavailable metho}}
 @end
 
 @interface A(CAT)
@@ -43,6 +47,8 @@ __attribute__((deprecated)) // expected-
 
 @interface BASE
 - (void) B __attribute__((deprecated)); // expected-note {{method 'B' declared 
here}}
+
++ (void) unavailable __attribute__((availability(macos, unavailable))); // 
expected-note {{method 'unavailable' declared here}}
 @end
 
 @interface SUB : BASE
@@ -50,6 +56,7 @@ __attribute__((deprecated)) // expected-
 
 @implementation SUB
 - (void) B {} // expected-warning {{implementing deprecated method}}
++ (void) unavailable { } // expected-warning {{implementing unavailable 
method}}
 @end
 
 @interface Test


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


r307923 - NFC, Cleanup the code for -Wdeprecated-implementations

2017-07-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Jul 13 09:35:59 2017
New Revision: 307923

URL: http://llvm.org/viewvc/llvm-project?rev=307923=rev
Log:
NFC, Cleanup the code for -Wdeprecated-implementations
and void capitalization of the warning message

rdar://22867595

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=307923=307922=307923=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 13 09:35:59 
2017
@@ -4579,8 +4579,8 @@ def warn_deprecated_fwdclass_message : W
 "%0 may be deprecated because the receiver type is unknown">,
 InGroup;
 def warn_deprecated_def : Warning<
-"Implementing deprecated %select{method|class|category}0">,
-InGroup, DefaultIgnore;
+  "implementing deprecated %select{method|class|category}0">,
+  InGroup, DefaultIgnore;
 def err_unavailable : Error<"%0 is unavailable">;
 def err_property_method_unavailable :
 Error<"property access is using %0 method which is unavailable">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=307923=307922=307923=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 13 09:35:59 2017
@@ -248,19 +248,31 @@ bool Sema::CheckARCMethodDecl(ObjCMethod
   return false;
 }
 
-static void DiagnoseObjCImplementedDeprecations(Sema ,
-NamedDecl *ND,
-SourceLocation ImplLoc,
-int select) {
-  if (ND && ND->isDeprecated()) {
-S.Diag(ImplLoc, diag::warn_deprecated_def) << select;
-if (select == 0)
-  S.Diag(ND->getLocation(), diag::note_method_declared_at)
-<< ND->getDeclName();
-else
-  S.Diag(ND->getLocation(), diag::note_previous_decl)
-  << (isa(ND) ? "category" : "class");
+static void DiagnoseObjCImplementedDeprecations(Sema , const NamedDecl *ND,
+SourceLocation ImplLoc) {
+  if (!ND)
+return;
+  bool IsCategory = false;
+  if (!ND->isDeprecated()) {
+if (const auto *CD = dyn_cast(ND)) {
+  if (!CD->getClassInterface()->isDeprecated())
+return;
+  ND = CD->getClassInterface();
+  IsCategory = true;
+} else
+  return;
   }
+  S.Diag(ImplLoc, diag::warn_deprecated_def)
+  << (isa(ND)
+  ? /*Method*/ 0
+  : isa(ND) || IsCategory ? /*Category*/ 2
+: /*Class*/ 1);
+  if (isa(ND))
+S.Diag(ND->getLocation(), diag::note_method_declared_at)
+<< ND->getDeclName();
+  else
+S.Diag(ND->getLocation(), diag::note_previous_decl)
+<< (isa(ND) ? "category" : "class");
 }
 
 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
@@ -385,9 +397,7 @@ void Sema::ActOnStartOfObjCMethodDef(Sco
   // No need to issue deprecated warning if deprecated mehod in 
class/category
   // is being implemented in its own implementation (no overriding is 
involved).
   if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
-DiagnoseObjCImplementedDeprecations(*this, 
-  dyn_cast(IMD), 
-  MDecl->getLocation(), 0);
+DiagnoseObjCImplementedDeprecations(*this, IMD, MDecl->getLocation());
 }
 
 if (MDecl->getMethodFamily() == OMF_init) {
@@ -1873,10 +1883,8 @@ Decl *Sema::ActOnStartCategoryImplementa
   CatIDecl->setImplementation(CDecl);
   // Warn on implementating category of deprecated class under 
   // -Wdeprecated-implementations flag.
-  DiagnoseObjCImplementedDeprecations(
-  *this,
-  CatIDecl->isDeprecated() ? CatIDecl : dyn_cast(IDecl),
-  CDecl->getLocation(), 2);
+  DiagnoseObjCImplementedDeprecations(*this, CatIDecl,
+  CDecl->getLocation());
 }
   }
 
@@ -1996,9 +2004,7 @@ Decl *Sema::ActOnStartClassImplementatio
 PushOnScopeChains(IMPDecl, TUScope);
 // Warn on implementating deprecated class under 
 // -Wdeprecated-implementations flag.
-DiagnoseObjCImplementedDeprecations(*this, 
-dyn_cast(IDecl), 
-IMPDecl->getLocation(), 1);
+DiagnoseObjCImplementedDeprecations(*this, IDecl, IMPDecl->getLocation());
   }
 
   // If the 

[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-07-13 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 106442.
Typz added a comment.

Move code out of optimizer, directly into 
ContinuationIndenter::breakProtrudingToken(), to minimize impact on performance.
Comment reflowing of breakable items which break the limit will be slightly 
slower, since we now consider the two options; however this change has no 
impact on the performance of processing non-breakable items, and may actually 
increase the operformance of processing breakable items which do not need to be 
reflowed.


https://reviews.llvm.org/D33589

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9393,6 +9393,60 @@
   EXPECT_EQ("#pragma option -C -A", format("#pragmaoption   -C   -A"));
 }
 
+TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 20;
+
+  verifyFormat("int a; // the\n"
+   "   // comment", Style);
+  EXPECT_EQ("int a; /* first line\n"
+"* second\n"
+"* line third\n"
+"* line\n"
+"*/",
+			format("int a; /* first line\n"
+   "* second\n"
+   "* line third\n"
+   "* line\n"
+   "*/", Style));
+  EXPECT_EQ("int a; // first line\n"
+"   // second\n"
+"   // line third\n"
+"   // line",
+format("int a; // first line\n"
+   "   // second line\n"
+   "   // third line",
+   Style));
+
+  Style.PenaltyExcessCharacter = 90;
+  verifyFormat("int a; // the comment", Style);
+  EXPECT_EQ("int a; // the\n"
+"   // comment aa",
+format("int a; // the comment aa", Style));
+  EXPECT_EQ("int a; /* first line\n"
+"* second line\n"
+"* third line\n"
+"*/",
+			format("int a; /* first line\n"
+	   "* second line\n"
+			   "* third line\n"
+	   "*/", Style));
+  EXPECT_EQ("int a; // first line\n"
+"   // second line\n"
+"   // third line",
+format("int a; // first line\n"
+   "   // second line\n"
+   "   // third line",
+   Style));
+  EXPECT_EQ("int a; /* first line\n"
+"* second\n"
+"* line third\n"
+"* line\n"
+"*/",
+format("int a; /* first line second line third line"
+   "\n*/", Style));
+}
+
 #define EXPECT_ALL_STYLES_EQUAL(Styles)\
   for (size_t i = 1; i < Styles.size(); ++i)   \
   EXPECT_EQ(Styles[0], Styles[i]) << "Style #" << i << " of " << Styles.size() \
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -866,6 +866,7 @@
 for (std::deque::iterator I = Path.begin(), E = Path.end();
  I != E; ++I) {
   unsigned Penalty = 0;
+  State.Reflow = (*I)->State.Reflow;
   formatChildren(State, (*I)->NewLine, /*DryRun=*/false, Penalty);
   Penalty += Indenter->addTokenToState(State, (*I)->NewLine, false);
 
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -27,6 +27,7 @@
 namespace format {
 
 class AnnotatedLine;
+class BreakableToken;
 struct FormatToken;
 struct LineState;
 struct ParenState;
@@ -100,6 +101,11 @@
   unsigned breakProtrudingToken(const FormatToken , LineState ,
 bool DryRun);
 
+  unsigned reflowProtrudingToken(const FormatToken & Current, LineState & State,
+ std::unique_ptr & Token,
+ unsigned ColumnLimit, bool DryRun);
+
+
   /// \brief Appends the next token to \p State and updates information
   /// necessary for indentation.
   ///
@@ -350,6 +356,8 @@
   /// \brief The indent of the first token.
   unsigned FirstIndent;
 
+  bool Reflow = true;
+
   /// \brief The line that is being formatted.
   ///
   /// Does not need to be considered for memoization because it doesn't change.
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1219,6 +1219,112 @@
   return 0;
 }
 
+unsigned 

[PATCH] D35000: [OpenCL] Added extended tests on metadata generation for half data type and arrays.

2017-07-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D35000#807674, @echuraev wrote:

> In https://reviews.llvm.org/D35000#801132, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D35000#799705, @Anastasia wrote:
> >
> > > Btw, is there any reason to add testing specifically for half? Is there 
> > > anything specific to half in the implementation of this?
> >
> >
> > Trying to understand the reason for this change though...
>
>
> Sorry for a delay in response. No it is not any reason to add testing 
> specifically for half. We can also do the same tests for other data types. 
> Here we just check that it is no any qualifiers in metadata.


Btw, if I read the spec then it feels like we should put the qualifiers of the 
pointee type instead:

`CL_KERNEL_ARG_TYPE_VOLATILE` is returned if the argument is a pointer and the 
referenced type is declared with the `volatile` qualifier. For example, a 
kernel argument declared as `global int volatile *x` returns 
`CL_KERNEL_ARG_TYPE_VOLATILE` but a kernel argument declared as `global int 
*volatile x` does not. Similarly, `CL_KERNEL_ARG_TYPE_RESTRICT` or 
`CL_KERNEL_ARG_TYPE_CONST` is returned if the argument is a pointer and the 
referenced type is declared with the `restrict` or `const` qualifier. For 
example, a kernel argument declared as `global int const *x` returns 
`CL_KERNEL_ARG_TYPE_CONST` but a kernel argument declared as `global int *const 
x` does not.

It seems that the function `foo` is attempting to test that too. Perhaps we 
could unify the testing and create all combinations of pointer and non pointer 
types which would have qualifier and not.

I don't feel that we should test all possible types though...


https://reviews.llvm.org/D35000



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Thanks, very clear :)

I would expect that if we reprocess a GUID we invalidate the previous import of 
the same GUID. Right now my impression is that the issue is that ` 
ImportList[ExportModulePath][VI.getGUID()]` is indexed on the importing module. 
So it'd require for every new import to loop over the ImportList map and delete 
the GUID on each inner map.

Alternatively (and likely preferably from a compile-time point of view to limit 
the list of import), we could keep a map of GUID->Summary and reuse it before 
trying to select a new callee.


https://reviews.llvm.org/D35081



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

**To discuss:**
This patch is required for correct integration //Clang-Tidy// with //CLion 
IDE//.
By this moment, we unable to use //CompilationDatabase.json// from //CLion 
//side which is widely used in //Clang-Tidy// and in other common tools.
Anyway, there are possibility to pass compiler options directly through command 
line.
But we cannot pass compiler options directly through command-line, due to 
command-line-length restrictions.
So, we decided to pass compiler options through //@ResponseFile //mechanism.
But there are some problems with this approach.
Before this patch, ///clang/lib/Tooling/CommonOptionsParser.cpp// worked in 
this way:

1. Load compilation database from command-line
2. Expand response files
3. Parse all other command line arguments

I think it's strange behavior? 
Why we try to load compilation database first? 
Maybe it's better to expand response files and only after that try to load 
compilation database and parse another options?
It's hard to refactor //cl::ParseCommandLineOptions// and 
//cl::ExpandResponseFiles// functions, due to high number of usages, so i 
copied some block directly into ///clang/lib/Tooling/CommonOptionsParser.cpp//
I don't think that is a best solution, but i don't have another one.




Comment at: unittests/Tooling/CommonOptionsParserTest.cpp:41
+  ~CommonOptionsParserTest() override {
+llvm::sys::fs::remove(ResponseFileName);
+llvm::sys::fs::remove(TestDir);

I moved test-cases to separate file.
But as i mentioned before, i don't see any options how to use VFS here.
All other test-cases related with response files expansion also don't use VFS 
for some reasons, e.g. `unittests/Support/CommandLineTest.cpp`


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:2467
   const Generic_GCC::GCCVersion  = GCCInstallation.getVersion();
   bool UseInitArrayDefault =
   getTriple().getArch() == llvm::Triple::aarch64 ||

davide wrote:
> this is really a mess.
Any suggestions on how to improve? :)


https://reviews.llvm.org/D35337



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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D35081#808124, @mehdi_amini wrote:

> Teresa: can you describe a bit more how we end up importing two summaries for 
> the same GUID? I would expect that after importing one, we don't even come to 
> try to import another since we already have one.


Because of this:
http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionImport.cpp#261

  /// Since the traversal of the call graph is DFS, we can revisit a function
  /// a second time with a higher threshold. In this case, it is added back to
  /// the worklist with the new threshold.

The goal is that if we revisit with a higher threshold (which we do in the test 
case), that we want to reconsider downstream callees again. E.g. if we have 
foo() calls bar() calls baz(), and we first decided to import bar() into foo's 
module, but the threshold was not high enough to import baz, if we later 
encounter this call from foo->bar again with a higher threshold (because we hit 
it on a path that was either hotter or shorter), we want to reconsider whether 
to import baz().

The issue here is that when we reconsider "foo" we pick a different copy 
(earlier in the list, but skipped initially due to having an instruction count 
above the first (lower) threshold).


https://reviews.llvm.org/D35081



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun updated this revision to Diff 106436.
vladimir.plyashkun added a comment.

- trailing period
- moved test-cases to separate file


Repository:
  rL LLVM

https://reviews.llvm.org/D34440

Files:
  lib/Tooling/CommonOptionsParser.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/CommonOptionsParserTest.cpp

Index: unittests/Tooling/CommonOptionsParserTest.cpp
===
--- /dev/null
+++ unittests/Tooling/CommonOptionsParserTest.cpp
@@ -0,0 +1,72 @@
+//===- unittests/Tooling/CommonOptionsParserTest.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+
+#include 
+
+namespace clang {
+namespace tooling {
+
+class CommonOptionsParserTest : public testing::Test {
+public:
+  SmallString<128> TestDir;
+  SmallString<128> ResponseFileName;
+
+  CommonOptionsParserTest() {
+std::error_code EC = llvm::sys::fs::createUniqueDirectory("unittest", TestDir);
+EXPECT_TRUE(!EC);
+llvm::sys::path::append(ResponseFileName, TestDir, "resp");
+  }
+
+  void setResponseFileContent(const std::string ) {
+std::ofstream File(ResponseFileName.c_str());
+EXPECT_TRUE(File.is_open());
+File << Content;
+File.close();
+  }
+
+  ~CommonOptionsParserTest() override {
+llvm::sys::fs::remove(ResponseFileName);
+llvm::sys::fs::remove(TestDir);
+  }
+};
+
+TEST_F(CommonOptionsParserTest, ExpandResponseFilesBeforeLoadingCompilationDatabase) {
+  setResponseFileContent("-- -a=true -b");
+  SmallString<128> ResponseFileRef;
+  ResponseFileRef.append(1, '@');
+  ResponseFileRef.append(ResponseFileName.c_str());
+  int Argc = 3;
+  const char *Argv[] = { "1", "2", ResponseFileRef.c_str() };
+  llvm::cl::OptionCategory Category("options");
+  llvm::cl::opt option1("a", llvm::cl::desc(""), llvm::cl::init(false),
+  llvm::cl::cat(Category));
+  llvm::cl::opt option2("b", llvm::cl::desc(""), llvm::cl::init(false),
+  llvm::cl::cat(Category));
+  CommonOptionsParser Parser(Argc, Argv, Category);
+  CompilationDatabase  = Parser.getCompilations();
+  std::vector ActualCC = Database.getCompileCommands("source");
+  ASSERT_EQ(1u, ActualCC.size());
+  std::vector ExpectedCmd;
+  ExpectedCmd.push_back("clang-tool");
+  ExpectedCmd.push_back("-a=true");
+  ExpectedCmd.push_back("-b");
+  ExpectedCmd.push_back("source");
+
+  ASSERT_EQ(ExpectedCmd, ActualCC[0].CommandLine);
+}
+	
+} // end namespace tooling
+} // end namespace clang
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -14,6 +14,7 @@
   CastExprTest.cpp
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  CommonOptionsParserTest.cpp
   DiagnosticsYamlTest.cpp
   FixItTest.cpp
   LookupTest.cpp
Index: lib/Tooling/CommonOptionsParser.cpp
===
--- lib/Tooling/CommonOptionsParser.cpp
+++ lib/Tooling/CommonOptionsParser.cpp
@@ -25,6 +25,7 @@
 //===--===//
 
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/StringSaver.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
@@ -116,6 +117,14 @@
 
   cl::HideUnrelatedOptions(Category);
 
+  // Expand response files before loading compilation database from command line.
+  SmallVector NewArgv(argv, argv + argc);
+  BumpPtrAllocator A;
+  StringSaver Saver(A);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, NewArgv);
+  argv = [0];
+  argc = static_cast(NewArgv.size());
+
   std::string ErrorMessage;
   Compilations =
   FixedCompilationDatabase::loadFromCommandLine(argc, argv, ErrorMessage);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Teresa: can you describe a bit more how we end up importing two summaries for 
the same GUID? I would expect that after importing one, we don't even come to 
try to import another since we already have one.


https://reviews.llvm.org/D35081



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko added a comment.

In https://reviews.llvm.org/D16403#808104, @NoQ wrote:

> I think the remaining switch-related code seems to be about C++17 switch 
> condition variables, i.e. `switch (int x = ...)`(?)


Yeah, exactly. I can remove it from this patch if it looks confusing.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-13 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added inline comments.



Comment at: unittests/Tooling/CompilationDatabaseTest.cpp:638-652
+  ParseCompilationDatabaseFromResponseFileTest() {
+std::error_code EC = llvm::sys::fs::createUniqueDirectory("unittest", 
TestDir);
+EXPECT_TRUE(!EC);
+llvm::sys::path::append(ResponseFileName, TestDir, "resp");
+  }
+  void setResponseFileContent(const std::string ) {
+std::ofstream File(ResponseFileName.c_str());

alexfh wrote:
> Can we do all this in the virtual file system 
> (include/clang/Basic/VirtualFileSystem.h) to avoid creating files from the 
> unit test?
Unfortunately, i don't see any options how to do it with VFS. 
All other tests related with response files expansion don't use VFS for some 
reasons, e.g. `unittests/Support/CommandLineTest.cpp`


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I think the remaining switch-related code seems to be about C++17 switch 
condition variables, i.e. `switch (int x = ...)`(?)


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-07-13 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33537#771159, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#770264, @aaron.ballman wrote:
> >
> > > I think we should try to get as much of this functionality in 
> > > https://reviews.llvm.org/D3 as possible; there is a considerable 
> > > amount of overlap between that functionality and this functionality. This 
> > > check can then cover only the parts that are not reasonably handled by 
> > > the frontend check instead of duplicating diagnostics the user already 
> > > receives.
> >
> >
> > I suppose that the frontend check will not travarse the call-graph just 
> > check direct throws. Should we only check indirect throws then?
>
>
> The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> checking direct throws.




In https://reviews.llvm.org/D33537#807997, @erichkeane wrote:

> In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
> >
> > > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > > checking direct throws.
> >
> >
> > I tested the latest revision (the fronted patch already included) on my 
> > test file. Disregarding of the not so important parameters 
> > (`EnabledFunctions` and `IgnoredExceptions`) I do not get warnings for any 
> > indirect throws (`indirect_implicit()` and `indirect_explicit()`). So for 
> > me it does not seem to be using the CFG. Furthermore, I do not get warning 
> > for `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` 
> > should not catch it. The same happens in `throw_catch_rethrow_the_rest()`, 
> > where `catch(int &)` should not catch `1.1`, but `catch(...)` should catch 
> > and rethrow it. This latter may be a bug.
>
>
> Jen Yu can clarify, but I believe it was decided to put the implementation in 
> the CFG, but not do a full analysis (leave that for a later implementation).  
> It is not doing 'catch' analysis, and I don't believe they decided to do 
> analysis on the function call itself, since the false-positive rate is 
> massive thanks to the C headers.


The catch  analys

In https://reviews.llvm.org/D33537#807997, @erichkeane wrote:

> In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
> >
> > > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > > checking direct throws.
> >
> >
> > I tested the latest revision (the fronted patch already included) on my 
> > test file. Disregarding of the not so important parameters 
> > (`EnabledFunctions` and `IgnoredExceptions`) I do not get warnings for any 
> > indirect throws (`indirect_implicit()` and `indirect_explicit()`). So for 
> > me it does not seem to be using the CFG. Furthermore, I do not get warning 
> > for `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` 
> > should not catch it. The same happens in `throw_catch_rethrow_the_rest()`, 
> > where `catch(int &)` should not catch `1.1`, but `catch(...)` should catch 
> > and rethrow it. This latter may be a bug.
>
>
> Jen Yu can clarify, but I believe it was decided to put the implementation in 
> the CFG, but not do a full analysis (leave that for a later implementation).  
> It is not doing 'catch' analysis, and I don't believe they decided to do 
> analysis on the function call itself, since the false-positive rate is 
> massive thanks to the C headers.




In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
>
> > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > checking direct throws.
>
>
> I tested the latest revision (the fronted patch already included) on my test 
> file. Disregarding of the not so important parameters (`EnabledFunctions` and 
> `IgnoredExceptions`) I do not get warnings for any indirect throws 
> (`indirect_implicit()` and `indirect_explicit()`). So for me it does not seem 
> to be using the CFG. Furthermore, I do not get warning for 
> `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` should 
> not catch it. The same happens in `throw_catch_rethrow_the_rest()`, where 
> `catch(int &)` should not catch `1.1`, but `catch(...)` should catch and 
> rethrow it. This latter may be a bug.




In https://reviews.llvm.org/D33537#807997, @erichkeane wrote:

> In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:
>
> > In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
> >
> > > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > > checking direct throws.
> >
> >
> > I tested the latest revision (the fronted patch already included) on my 
> > test file. Disregarding of the not so important parameters 
> > (`EnabledFunctions` and 

[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2017-07-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D34331#803452, @EricWF wrote:

> In https://reviews.llvm.org/D34331#803105, @dexonsmith wrote:
>
> > In https://reviews.llvm.org/D34331#802747, @EricWF wrote:
> >
> > > @dexonsmith Mind if I hijack this and check in your changes to 
> > > `` with my tests?
> >
> >
> > Not at all.
> >
> > In https://reviews.llvm.org/D34331#802821, @EricWF wrote:
> >
> > > @dexonsmith I'm not sure it's sane to allow reentrant behavior. Could you 
> > > explain why you think it is?
> >
> >
> > It didn't seem sane to me at first either, despite this being supported by 
> > `std::unique_ptr` and `std::shared_ptr`.  I found our user fairly 
> > convincing, though:
> >
> > - They had an underlying reference counted object, so only the destruction 
> > of the last copy of A nulled out the pointer (mimicked that with the `bool 
> > cancel`).
> > - They had a callback function intended to be called once, and dropping 
> > that function on cancellation (mimicked that with a global variable). The 
> > cancel operation nulled out a `std::function`, but destroying the objects 
> > captured in the lambda in that std::function also separately decided to 
> > perform a cancel, which should have been OK. The cancel function just 
> > contained `callback = nullptr`.
>
>
> According to [reentrancy] it is implementation defined what STL functions are 
> allowed to be recursively reentered. I'm not opposed to providing reentrancy 
> where it's useful, but we would have to provide it well.
>  This is where I was running into problems while I was writing tests. There 
> are so many different ways you can reenter std::function's special members 
> that it makes it impossible for an implementation
>  to truly support reentrancy as the standard would require.
>
> If you consider that every possible copy construction or destruction of a 
> user type is a potential reentrancy point, the complexity of having 
> well-defined reentrant behavior starts to become clear.
>  Any time a copy constructor or destructor is invoked you have a potential 
> reentrancy point which, in order to provide well defined behavior, must also 
> act as a sort of _sequence point_ where the side effects of the current call 
> are visible to the reentrant callers (For example your patches use of 
> `operator=(nullptr_t)`).
>
> The methods fixed in this patch are seemingly improvements; It's clear that 
> `operator=(nullptr)` can safely be made reentrant. On the other hand consider 
> `operator=(function const& rhs)`, which is specified as equivalent to 
> `function(rhs).swap(*this)`.
>  I posit `swap` is not the kind of thing that can easily be made reentrant, 
> but that making `std::function` assignment reentrant in general clearly 
> requires it.
>
> If fixing this bug is sufficiently important I'm willing to accept that, but 
> I don't think it improves the status quo; We may have fixed a specific users 
> bug, but we haven't made these functions safely reentrant (in fact most of 
> the special members are likely still full of reentrancy bugs).


IMO, `function::operator=(nullptr_t)` is a clear, restricted subset of 
reentrancy: it's the cutely-named `std::function` equivalent of 
`unique_ptr::reset()`.  I think it's worth supporting reentrancy here.

After my own experimentation creating a testcase (and iterating with our 
internal users on motivation), I agree that supporting reentrancy for anything 
else would be untenable.


https://reviews.llvm.org/D34331



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


[PATCH] D16403: Add scope information to CFG for If/While/For/Do/Compound/CXXRangeFor statements

2017-07-13 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment.

Hello Maxim!
Thanks for working on this!

> Ugh, yeah, SwitchStmt is tricky (thank you for pointing to Duff's device 
> example!). I've tried to resolve several issues with switch revealed by this 
> testcase, but didn't succeed for now :(. So, it was decided to remove 
> SwitchStmt support in this patch.

I think this is a great decision! It can build up incremental and the patch can 
be more easily reviewed. When do you plan to upload a patch wihtout casestmt 
support? (As far as I see there is switchstmt related code but maybe Im missing 
something.)


Repository:
  rL LLVM

https://reviews.llvm.org/D16403



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


[PATCH] D35118: [AArch64] Add support for handling the +sve target feature

2017-07-13 Thread Amara Emerson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307919: [AArch64] Add support for handling the +sve target 
feature. (authored by aemerson).

Changed prior to commit:
  https://reviews.llvm.org/D35118?vs=106386=106432#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35118

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/aarch64-target-features.c


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6251,7 +6251,8 @@
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6385,12 +6386,15 @@
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6426,7 +6430,8 @@
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector ,
@@ -6440,7 +6445,9 @@
 
 for (const auto  : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -84,6 +85,10 @@
 // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon"
 
 // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
+// CHECK-SVE: __ARM_FEATURE_SVE 1
+
 // == Check whether -mtune accepts mixed-case features.
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6251,7 +6251,8 @@
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6385,12 +6386,15 @@
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6426,7 +6430,8 @@
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector ,
@@ -6440,7 +6445,9 @@
 
 for (const auto  : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang 

r307919 - [AArch64] Add support for handling the +sve target feature.

2017-07-13 Thread Amara Emerson via cfe-commits
Author: aemerson
Date: Thu Jul 13 08:36:01 2017
New Revision: 307919

URL: http://llvm.org/viewvc/llvm-project?rev=307919=rev
Log:
[AArch64] Add support for handling the +sve target feature.

This also adds the appropriate predefine for SVE if enabled.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=307919=307918=307919=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul 13 08:36:01 2017
@@ -6251,7 +6251,8 @@ class AArch64TargetInfo : public TargetI
 
   enum FPUModeEnum {
 FPUMode,
-NeonMode
+NeonMode = (1 << 0),
+SveMode = (1 << 1)
   };
 
   unsigned FPU;
@@ -6385,12 +6386,15 @@ public:
 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM",
 Opts.ShortEnums ? "1" : "4");
 
-if (FPU == NeonMode) {
+if (FPU & NeonMode) {
   Builder.defineMacro("__ARM_NEON", "1");
   // 64-bit NEON supports half, single and double precision operations.
   Builder.defineMacro("__ARM_NEON_FP", "0xE");
 }
 
+if (FPU & SveMode)
+  Builder.defineMacro("__ARM_FEATURE_SVE", "1");
+
 if (CRC)
   Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
@@ -6426,7 +6430,8 @@ public:
 return Feature == "aarch64" ||
   Feature == "arm64" ||
   Feature == "arm" ||
-  (Feature == "neon" && FPU == NeonMode);
+  (Feature == "neon" && (FPU & NeonMode)) ||
+  (Feature == "sve" && (FPU & SveMode));
   }
 
   bool handleTargetFeatures(std::vector ,
@@ -6440,7 +6445,9 @@ public:
 
 for (const auto  : Features) {
   if (Feature == "+neon")
-FPU = NeonMode;
+FPU |= NeonMode;
+  if (Feature == "+sve")
+FPU |= SveMode;
   if (Feature == "+crc")
 CRC = 1;
   if (Feature == "+crypto")

Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=307919=307918=307919=diff
==
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Thu Jul 13 08:36:01 
2017
@@ -37,6 +37,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_FEATURE_SVE
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -84,6 +85,10 @@
 // CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon"
 
 // RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
+// CHECK-SVE: __ARM_FEATURE_SVE 1
+
 // == Check whether -mtune accepts mixed-case features.
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"


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


RE: D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-13 Thread Erik Schwiebert via cfe-commits
These hypothetical targets aren’t so hypothetical.  Office for Mac and iOS uses 
code ported from Windows but actually targeted at running on the Apple (Darwin) 
platform. We don’t have the MSVC CRT there.  

Schwieb

-Original Message-
From: Reid Kleckner via Phabricator [mailto:revi...@reviews.llvm.org] 
Sent: Thursday, July 13, 2017 8:31 AM
To: bruno.card...@gmail.com; e...@efcs.ca; mclow.li...@gmail.com; 
dexonsm...@apple.com; ben.cr...@gmail.com; smee...@fb.com; 
compn...@compnerd.org; david.majne...@gmail.com
Cc: geek4ci...@gmail.com; Erik Schwiebert ; 
cfe-commits@lists.llvm.org
Subject: [PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

> Some non-windows targets using MS extensions define _WIN32 for compatibility 
> with Windows but do not have MSVC compatibility.

So, these hypothetical targets have the Win32 API available, but they do not 
use the MSVC CRT, correct? They could use musl, or some custom C runtime, but 
they don't want libc++ to aim for MSVCRT compatibility.

---

In any case, checking _MSC_VER is the best thing I can think of for guessing if 
the MSVC CRT is going to be present, so this looks good.


https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD34588=02%7C01%7Ceriksc%40microsoft.com%7C55099ebc746b4a80da4408d4ca042b95%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636355566643019338=n7xbFct8h7QlnsjjZifZYX72qqpzSG%2FpUAZEKbRbVY0%3D=0



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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

> Some non-windows targets using MS extensions define _WIN32 for compatibility 
> with Windows but do not have MSVC compatibility.

So, these hypothetical targets have the Win32 API available, but they do not 
use the MSVC CRT, correct? They could use musl, or some custom C runtime, but 
they don't want libc++ to aim for MSVCRT compatibility.

---

In any case, checking _MSC_VER is the best thing I can think of for guessing if 
the MSVC CRT is going to be present, so this looks good.


https://reviews.llvm.org/D34588



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


[PATCH] D34588: Check for _MSC_VER before define _LIBCPP_MSVCRT

2017-07-13 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

In https://reviews.llvm.org/D34588#802533, @bruno wrote:

> > Thinking more about this, on Windows, is there a strong reason to default 
> > to a different libc by default on Windows?
>
> I'm mostly concerned with `-fms-extensions` + darwin, which doesn't apply to 
> this scenario, maybe someone else knows a better answer here.


Could something like _WIN32 && _MSC_VER make this better?  That would allow us 
to differentiate between the various environments.  It's kinda icky, but, does 
make sense in a round about way.

> 
> 
>> @bruno would reusing `-ffreestanding` work for you here?
> 
> I think forcing the use of `-ffreestanding` with Apple platforms just for 
> this is too restrictive.

Okay, was worth the shot anyways.

>> Or is there something else that we can identify about the target environment 
>> that can indicate that the MS CRT is unavailable?  I think that what is 
>> weird to me about this is that this is not about compatibility with Visual 
>> Studio but about the underlying libc.  It feels like it would be similar in 
>> spirit to say that libc++ defaults to libSystem as the underlying libc on 
>> Linux.
> 
> Right, makes total sense. I'm assuming that `-fms-extensions` for other 
> targets (Linux) will also rely in not using `_LIBCPP_MSVCRT`, however 
> #ifdefing for other platforms here doens't seem to add much because they 
> usually do not set `_MSC_VER` anyways. Additional ideas?

Another bad idea: -U_MSC_VER.  The undefine should come after the preprocessor 
is initialized and should have the same effect as not having it defined.


https://reviews.llvm.org/D34588



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


[PATCH] D35337: [Solaris] gcc runtime dropped support for .ctors, switch to .init_array

2017-07-13 Thread Davide Italiano via Phabricator via cfe-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: lib/Driver/ToolChains/Gnu.cpp:2467
   const Generic_GCC::GCCVersion  = GCCInstallation.getVersion();
   bool UseInitArrayDefault =
   getTriple().getArch() == llvm::Triple::aarch64 ||

this is really a mess.


https://reviews.llvm.org/D35337



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


r307916 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 08:15:25 2017
New Revision: 307916

URL: http://llvm.org/viewvc/llvm-project?rev=307916=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307916=307915=307916=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 08:15:25 2017
@@ -948,12 +948,8 @@ int main() {
 
 // CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
 // CHECK: store [2 x [[S_FLOAT_TY]]]* [[VAR3_ORIG]], [2 x [[S_FLOAT_TY]]]** 
[[VAR3_ORIG_ADDR:%.+]],
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VAR3_ORIG]], i64 0, i64 1
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VAR3_ORIG]], i64 0, i64 2
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint (float* 
getelementptr (float, float* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307916=307915=307916=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 08:15:25 2017
@@ -749,12 +749,8 @@ int main() {
 
 // CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
 // CHECK: store [2 x [[S_FLOAT_TY]]]* [[VAR3_ORIG]], [2 x [[S_FLOAT_TY]]]** 
[[VAR3_ORIG_ADDR:%.+]],
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VAR3_ORIG]], i64 0, i64 1
-// CHECK: [[VAR3_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VAR3_ORIG_ADDR]],
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VAR3_ORIG]], i64 0, i64 2
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint ([[S_FLOAT_TY]]* 
getelementptr ([[S_FLOAT_TY]], [[S_FLOAT_TY]]* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1


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


r307915 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 08:09:05 2017
New Revision: 307915

URL: http://llvm.org/viewvc/llvm-project?rev=307915=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307915=307914=307915=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 08:09:05 2017
@@ -921,7 +921,6 @@ int main() {
 // CHECK: [[VVAR2_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VVAR2_ORIG_ADDR]],
 
 // CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VVAR2_ORIG]], i64 0, i64 0
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VVAR2_ORIG]], i64 0, i64 4
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
 // CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307915=307914=307915=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 08:09:05 2017
@@ -722,7 +722,6 @@ int main() {
 // CHECK: [[VVAR2_ORIG:%.+]] = load [2 x [[S_FLOAT_TY]]]*, [2 x 
[[S_FLOAT_TY]]]** [[VVAR2_ORIG_ADDR]],
 
 // CHECK: [[LOW:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x 
[[S_FLOAT_TY]]]* [[VVAR2_ORIG]], i64 0, i64 0
-// CHECK: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* 
[[VVAR2_ORIG]], i64 0, i64 4
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
 // CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]


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


r307914 - [OPENMP] Further reduction test fix, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 08:02:27 2017
New Revision: 307914

URL: http://llvm.org/viewvc/llvm-project?rev=307914=rev
Log:
[OPENMP] Further reduction test fix, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307914=307913=307914=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 08:02:27 2017
@@ -892,16 +892,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
 // CHECK: [[VAR2_ORIG:%.+]] = load [[S_FLOAT_TY]]***, [[S_FLOAT_TY]] 
[[VAR2_ORIG_ADDR]],
 
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 0
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* 
%{{.+}}, i64 1
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 4
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* %{{.+}}, i64 6
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint (float* 
getelementptr (float, float* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307914=307913=307914=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 08:02:27 2017
@@ -693,16 +693,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
 // CHECK: [[VAR2_ORIG:%.+]] = load [[S_FLOAT_TY]]***, [[S_FLOAT_TY]] 
[[VAR2_ORIG_ADDR]],
 
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 0
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: [[LOW:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* 
%{{.+}}, i64 1
-// CHECK: load [[S_FLOAT_TY]]**, [[S_FLOAT_TY]]*** [[VAR2_ORIG]],
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %{{.+}}, 
i64 4
-// CHECK: load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
-// CHECK: getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* %{{.+}}, i64 6
 // CHECK: [[LAST:%.+]] = ptrtoint [[S_FLOAT_TY]]* %{{.+}} to i64
-// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW]] to i64
+// CHECK: [[FIRST:%.+]] = ptrtoint [[S_FLOAT_TY]]* [[LOW:%.+]] to i64
 // CHECK: [[BYTE_DIF:%.+]] = sub i64 [[LAST]], [[FIRST]]
 // CHECK: [[DIF:%.+]] = sdiv exact i64 [[BYTE_DIF]], ptrtoint ([[S_FLOAT_TY]]* 
getelementptr ([[S_FLOAT_TY]], [[S_FLOAT_TY]]* null, i32 1) to i64)
 // CHECK: [[SIZE:%.+]] = add nuw i64 [[DIF]], 1


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


r307912 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 07:54:42 2017
New Revision: 307912

URL: http://llvm.org/viewvc/llvm-project?rev=307912=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307912=307911=307912=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 07:54:42 2017
@@ -501,12 +501,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
 // CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
-// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
-// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64
+// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP:%.+]] to i64
+// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0:%.+]] to i64
 // CHECK: [[DIFF:%.+]] = sub i64 [[UB_CAST]], [[LB_CAST]]
 // CHECK: [[SIZE_1:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i32* 
getelementptr (i32, i32* null, i32 1) to i64)
 // CHECK: [[ARR_SIZE:%.+]] = add nuw i64 [[SIZE_1]], 1

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307912=307911=307912=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 07:54:42 2017
@@ -310,12 +310,8 @@ int main() {
 // CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
 // CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
-// CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
-// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
-// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64
+// CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP:%.+]] to i64
+// CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0:%.+]] to i64
 // CHECK: [[DIFF:%.+]] = sub i64 [[UB_CAST]], [[LB_CAST]]
 // CHECK: [[SIZE_1:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i32* 
getelementptr (i32, i32* null, i32 1) to i64)
 // CHECK: [[ARR_SIZE:%.+]] = add nuw i64 [[SIZE_1]], 1


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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-07-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D33537#801889, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#771274, @aaron.ballman wrote:
>
> > The check in https://reviews.llvm.org/D3 is using a CFG, not just 
> > checking direct throws.
>
>
> I tested the latest revision (the fronted patch already included) on my test 
> file. Disregarding of the not so important parameters (`EnabledFunctions` and 
> `IgnoredExceptions`) I do not get warnings for any indirect throws 
> (`indirect_implicit()` and `indirect_explicit()`). So for me it does not seem 
> to be using the CFG. Furthermore, I do not get warning for 
> `throw_and_catch_some()` where `1.1` is a `double` thus `catch(int &)` should 
> not catch it. The same happens in `throw_catch_rethrow_the_rest()`, where 
> `catch(int &)` should not catch `1.1`, but `catch(...)` should catch and 
> rethrow it. This latter may be a bug.


Jen Yu can clarify, but I believe it was decided to put the implementation in 
the CFG, but not do a full analysis (leave that for a later implementation).  
It is not doing 'catch' analysis, and I don't believe they decided to do 
analysis on the function call itself, since the false-positive rate is massive 
thanks to the C headers.


https://reviews.llvm.org/D33537



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-07-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I tested the latest revision (this fronted patch already included) on my test 
file in https://reviews.llvm.org/D33537. Disregarding of the (not so important) 
check-specific parameters (`EnabledFunctions` and `IgnoredExceptions`) I do not 
get warnings for any indirect throws (`indirect_implicit()` and 
`indirect_explicit()`). So for me this frontend check does not seem to be using 
the CFG. Furthermore, I do not get warning for `throw_and_catch_some()` where 
`1.1` is a `double` thus `catch(int &)` should not catch it. The same happens 
in `throw_catch_rethrow_the_rest()`, where `catch(int &)` should not catch 
`1.1`, but `catch(...)` should catch and rethrow it. Is this latter one a bug?


Repository:
  rL LLVM

https://reviews.llvm.org/D3



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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2017-07-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:511
+   SSE->getLHS()->getType()->isSignedIntegerOrEnumerationType() ||
+   SSE->getLHS()->getType()->isPointerType()) {
+  return negV->Negate(BV, F);

NoQ wrote:
> Pointer types are currently treated as unsigned, so i'm not sure you want 
> them here.
For me it seems that pointer differences are still pointer types and they are 
signed. (The range becomes negative upon negative assumption. From test 
`ptr-arith.c`:

```
void use_symbols(int *lhs, int *rhs) {
  clang_analyzer_eval(lhs < rhs); // expected-warning{{UNKNOWN}}
  if (lhs < rhs)
return;
  clang_analyzer_eval(lhs < rhs); // expected-warning{{FALSE}}

  clang_analyzer_eval(lhs - rhs); // expected-warning{{UNKNOWN}}
  if ((lhs - rhs) != 5)
return;
  clang_analyzer_eval((lhs - rhs) == 5); // expected-warning{{TRUE}}
}
```

If I put `clang_analyzer_printState()` into the empty line in the middle, I get 
the following range for the difference: `[-9223372036854775808, 0]`. If I 
replace `int*` with `unsigned`, this range becomes `[0, 0]`, so `int*` is 
handled as a signed type here.


https://reviews.llvm.org/D35110



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


r307911 - [OPENMP] Fix reduction tests, NFC.

2017-07-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 13 07:29:19 2017
New Revision: 307911

URL: http://llvm.org/viewvc/llvm-project?rev=307911=rev
Log:
[OPENMP] Fix reduction tests, NFC.

Modified:
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=307911=307910=307911=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Jul 13 07:29:19 2017
@@ -497,12 +497,13 @@ int main() {
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
 
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}**
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
+// CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
 // CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
 // CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp?rev=307911=307910=307911=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Thu Jul 13 07:29:19 2017
@@ -306,12 +306,13 @@ int main() {
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
 
 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** 
[[GTID_ADDR_ADDR:%.+]],
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}**
+// CHECK: store i{{[0-9]+}}* %{{.+}}, i{{[0-9]+}}** [[ARR_ADDR:%.+]],
+// CHECK: [[ARR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[ARR_ADDR]],
 
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
-// CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
-// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
+// CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* [[ARR]], i64
 // CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
 // CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
 // CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64


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


  1   2   >