r314831 - Revert r314820 "[Analyzer] More granular special casing in RetainCountChecker"

2017-10-03 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Oct  3 12:39:02 2017
New Revision: 314831

URL: http://llvm.org/viewvc/llvm-project?rev=314831&view=rev
Log:
Revert r314820 "[Analyzer] More granular special casing in RetainCountChecker"

The test retain-release.m fails with this patch.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=314831&r1=314830&r2=314831&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Oct  3 
12:39:02 2017
@@ -1062,7 +1062,6 @@ RetainSummaryManager::getFunctionSummary
 
 // Inspect the result type.
 QualType RetTy = FT->getReturnType();
-StringRef RetTyName = RetTy.getAsString();
 
 // FIXME: This should all be refactored into a chain of "summary lookup"
 //  filters.
@@ -1082,14 +1081,12 @@ RetainSummaryManager::getFunctionSummary
   AllowAnnotations = false;
 } else if (FName == "CFPlugInInstanceCreate") {
   S = getPersistentSummary(RetEffect::MakeNoRet());
-} else if (FName == "IORegistryEntrySearchCFProperty"
-|| (RetTyName == "CFMutableDictionaryRef" && (
-   FName == "IOBSDNameMatching" ||
+} else if (FName == "IOBSDNameMatching" ||
FName == "IOServiceMatching" ||
FName == "IOServiceNameMatching" ||
+   FName == "IORegistryEntrySearchCFProperty" ||
FName == "IORegistryEntryIDMatching" ||
-   FName == "IOOpenFirmwarePathMatching"
-))) {
+   FName == "IOOpenFirmwarePathMatching") {
   // Part of . (IOKit)
   // This should be addressed using a API table.
   S = getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF),

Modified: cfe/trunk/test/Analysis/retain-release.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.mm?rev=314831&r1=314830&r2=314831&view=diff
==
--- cfe/trunk/test/Analysis/retain-release.mm (original)
+++ cfe/trunk/test/Analysis/retain-release.mm Tue Oct  3 12:39:02 2017
@@ -463,10 +463,3 @@ void   radar13722286::PrepareBitmap() {
 
 // rdar://34210609
 void _() { _(); }; // no-warning
-
-// Do not assume that IOBSDNameMatching increments a reference counter,
-// unless return type is CFMutableDictionaryRef.
-void* IOBSDNameMatching();
-void rdar33832412() {
-  void* x = IOBSDNameMatching(); // no-warning
-}


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


r316411 - [test] Fix clang-test for FreeBSD and NetBSD

2017-10-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Oct 23 20:11:02 2017
New Revision: 316411

URL: http://llvm.org/viewvc/llvm-project?rev=316411&view=rev
Log:
[test] Fix clang-test for FreeBSD and NetBSD

Lit tries to inject the shared library paths, but no action is taken
when platform.system() is not recognized, results in an environment
variable with an empty name, which is illegal.

The patch fixes this mechanism for FreeBSD and NetBSD, and gives an
warning on other platforms, so that the latecomers don't have to spend
time on debugging lit.

Thanks Zhihao Yuan for the patch!

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

Modified:
cfe/trunk/test/Unit/lit.cfg.py

Modified: cfe/trunk/test/Unit/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg.py?rev=316411&r1=316410&r2=316411&view=diff
==
--- cfe/trunk/test/Unit/lit.cfg.py (original)
+++ cfe/trunk/test/Unit/lit.cfg.py Mon Oct 23 20:11:02 2017
@@ -35,17 +35,23 @@ for symbolizer in ['ASAN_SYMBOLIZER_PATH
 if symbolizer in os.environ:
 config.environment[symbolizer] = os.environ[symbolizer]
 
-shlibpath_var = ''
-if platform.system() == 'Linux':
-shlibpath_var = 'LD_LIBRARY_PATH'
-elif platform.system() == 'Darwin':
-shlibpath_var = 'DYLD_LIBRARY_PATH'
-elif platform.system() == 'Windows':
-shlibpath_var = 'PATH'
+def find_shlibpath_var():
+if platform.system() in ['Linux', 'FreeBSD', 'NetBSD']:
+yield 'LD_LIBRARY_PATH'
+elif platform.system() == 'Darwin':
+yield 'DYLD_LIBRARY_PATH'
+elif platform.system() == 'Windows':
+yield 'PATH'
 
-# in stand-alone builds, shlibdir is clang's build tree
-# while llvm_libs_dir is installed LLVM (and possibly older clang)
-shlibpath = os.path.pathsep.join((config.shlibdir, config.llvm_libs_dir,
- config.environment.get(shlibpath_var,'')))
-
-config.environment[shlibpath_var] = shlibpath
+for shlibpath_var in find_shlibpath_var():
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+shlibpath = os.path.pathsep.join(
+(config.shlibdir,
+ config.llvm_libs_dir,
+ config.environment.get(shlibpath_var, '')))
+config.environment[shlibpath_var] = shlibpath
+break
+else:
+lit_config.warning("unable to inject shared library path on '{}'"
+   .format(platform.system()))


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


r341418 - Revert r341373, since it fails on some targets.

2018-09-04 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Sep  4 15:20:11 2018
New Revision: 341418

URL: http://llvm.org/viewvc/llvm-project?rev=341418&view=rev
Log:
Revert r341373, since it fails on some targets.

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

Removed:
cfe/trunk/test/Driver/print-multi-directory.c
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=341418&r1=341417&r2=341418&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Sep  4 15:20:11 2018
@@ -149,7 +149,6 @@ private:
 
 protected:
   MultilibSet Multilibs;
-  Multilib SelectedMultilib;
 
   ToolChain(const Driver &D, const llvm::Triple &T,
 const llvm::opt::ArgList &Args);
@@ -228,8 +227,6 @@ public:
 
   const MultilibSet &getMultilibs() const { return Multilibs; }
 
-  const Multilib &getMultilib() const { return SelectedMultilib; }
-
   const SanitizerArgs& getSanitizerArgs() const;
 
   const XRayArgs& getXRayArgs() const;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=341418&r1=341417&r2=341418&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep  4 15:20:11 2018
@@ -1661,13 +1661,14 @@ bool Driver::HandleImmediateArgs(const C
   }
 
   if (C.getArgs().hasArg(options::OPT_print_multi_directory)) {
-const Multilib &Multilib = TC.getMultilib();
-if (Multilib.gccSuffix().empty())
-  llvm::outs() << ".\n";
-else {
-  StringRef Suffix(Multilib.gccSuffix());
-  assert(Suffix.front() == '/');
-  llvm::outs() << Suffix.substr(1) << "\n";
+for (const Multilib &Multilib : TC.getMultilibs()) {
+  if (Multilib.gccSuffix().empty())
+llvm::outs() << ".\n";
+  else {
+StringRef Suffix(Multilib.gccSuffix());
+assert(Suffix.front() == '/');
+llvm::outs() << Suffix.substr(1) << "\n";
+  }
 }
 return false;
   }

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=341418&r1=341417&r2=341418&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Sep  4 15:20:11 2018
@@ -210,7 +210,6 @@ Linux::Linux(const Driver &D, const llvm
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
   Multilibs = GCCInstallation.getMultilibs();
-  SelectedMultilib = GCCInstallation.getMultilib();
   llvm::Triple::ArchType Arch = Triple.getArch();
   std::string SysRoot = computeSysRoot();
 
@@ -300,14 +299,16 @@ Linux::Linux(const Driver &D, const llvm
   if (GCCInstallation.isValid()) {
 const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
 const std::string &LibPath = GCCInstallation.getParentLibPath();
+const Multilib &Multilib = GCCInstallation.getMultilib();
+const MultilibSet &Multilibs = GCCInstallation.getMultilibs();
 
 // Add toolchain / multilib specific file paths.
-addMultilibsFilePaths(D, Multilibs, SelectedMultilib,
+addMultilibsFilePaths(D, Multilibs, Multilib,
   GCCInstallation.getInstallPath(), Paths);
 
 // Sourcery CodeBench MIPS toolchain holds some libraries under
 // a biarch-like suffix of the GCC installation.
-addPathIfExists(D, GCCInstallation.getInstallPath() + 
SelectedMultilib.gccSuffix(),
+addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(),
 Paths);
 
 // GCC cross compiling toolchains will install target libraries which ship
@@ -329,7 +330,7 @@ Linux::Linux(const Driver &D, const llvm
 // Note that this matches the GCC behavior. See the below comment for where
 // Clang diverges from GCC's behavior.
 addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" +
-   OSLibDir + SelectedMultilib.osSuffix(),
+   OSLibDir + Multilib.osSuffix(),
 Paths);
 
 // If the GCC installation we found is inside of the sysroot, we want to

Removed: cfe/trunk/test/Driver/print-multi-directory.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-multi-directory.c?rev=341417&view=auto
==
--- cfe/trunk/test/Driver/print-multi-directory.c (original)
+++ cfe/trunk/test/Driver/print-multi-directory.c (removed)
@@ -1,28 +0,0 @@
-// RUN: %clang -no-canonical-prefi

[libcxx] r338309 - [libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.

2018-07-30 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Jul 30 14:23:13 2018
New Revision: 338309

URL: http://llvm.org/viewvc/llvm-project?rev=338309&view=rev
Log:
[libcxx] implement  ABI for Clang/GCC vector extension, constructors, 
copy_from and copy_to.

Summary:
This patch adds a new macro _LIBCPP_HAS_NO_VECTOR_EXTENSION for detecting
whether a vector extension (\_\_attribute\_\_((vector_size(num_bytes is
available.

On the top of that, this patch implements the following API:
* all constructors
* operator[]
* copy_from
* copy_to

It also defines simd_abi::native to use vector extension, if available.
In GCC and Clang, certain values with vector extension are passed by registers,
instead of memory.

Based on D41148.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits, MaskRay, lichray, sanjoy

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

Added:
libcxx/trunk/test/std/experimental/simd/simd.abi/
libcxx/trunk/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.access/
libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.mem/
libcxx/trunk/test/std/experimental/simd/simd.mem/load.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.mem/store.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp

libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338309&r1=338308&r2=338309&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jul 30 14:23:13 2018
@@ -620,6 +620,8 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __forceinline
 
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
 #elif defined(_LIBCPP_COMPILER_IBM)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -652,6 +654,8 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
 
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
 #if _LIBCPP_STD_VER >= 17

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=338309&r1=338308&r2=338309&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Jul 30 14:23:13 2018
@@ -64,4 +64,11 @@
 #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
+// TODO: support more targets
+#if defined(__AVX__)
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
+#else
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
+#endif
+
 #endif

Modified: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=338309&r1=338308&r2=338309&view=diff
==
--- libcxx/trunk/include/experimental/simd (original)
+++ libcxx/trunk/include/experimental/simd Mon Jul 30 14:23:13 2018
@@ -651,6 +651,7 @@ public:
 */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -664,23 +665,241 @@ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIM
 enum class _StorageKind {
   _Scalar,
   _Array,
+  _VecExt,
 };
 
 template <_StorageKind __kind, int _Np>
 struct __simd_abi {};
 
 template 
-struct __simd_storage_traits {};
+class __simd_storage {};
 
 template 
-struct __simd_storage_traits<_Tp,
- __simd_abi<_StorageKind::_Array, __num_element>> {
-  using type = std::array<_Tp, __num_element>;
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> {
+  std::array<_Tp, __num_element> __storage_;
+
+  template 
+  friend struct simd;
+
+  template 
+  friend struct simd_mask;
+
+public:
+  _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
+  void __set(size_t __index, _Tp __val) noexcept {
+__s

[libcxx] r338316 - Revert "[libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."

2018-07-30 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Jul 30 15:21:22 2018
New Revision: 338316

URL: http://llvm.org/viewvc/llvm-project?rev=338316&view=rev
Log:
Revert "[libcxx] implement  ABI for Clang/GCC vector extension, 
constructors, copy_from and copy_to."

This reverts commit r338309.

Removed:
libcxx/trunk/test/std/experimental/simd/simd.abi/
libcxx/trunk/test/std/experimental/simd/simd.access/
libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.mem/
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp

libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338316&r1=338315&r2=338316&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jul 30 15:21:22 2018
@@ -620,8 +620,6 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __forceinline
 
-#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
 #elif defined(_LIBCPP_COMPILER_IBM)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -654,8 +652,6 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
 
-#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
 #if _LIBCPP_STD_VER >= 17

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=338316&r1=338315&r2=338316&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Jul 30 15:21:22 2018
@@ -64,11 +64,4 @@
 #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
-// TODO: support more targets
-#if defined(__AVX__)
-#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
-#else
-#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
-#endif
-
 #endif

Modified: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=338316&r1=338315&r2=338316&view=diff
==
--- libcxx/trunk/include/experimental/simd (original)
+++ libcxx/trunk/include/experimental/simd Mon Jul 30 15:21:22 2018
@@ -651,7 +651,6 @@ public:
 */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -665,241 +664,23 @@ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIM
 enum class _StorageKind {
   _Scalar,
   _Array,
-  _VecExt,
 };
 
 template <_StorageKind __kind, int _Np>
 struct __simd_abi {};
 
 template 
-class __simd_storage {};
+struct __simd_storage_traits {};
 
 template 
-class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> {
-  std::array<_Tp, __num_element> __storage_;
-
-  template 
-  friend struct simd;
-
-  template 
-  friend struct simd_mask;
-
-public:
-  _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
-  void __set(size_t __index, _Tp __val) noexcept {
-__storage_[__index] = __val;
-  }
+struct __simd_storage_traits<_Tp,
+ __simd_abi<_StorageKind::_Array, __num_element>> {
+  using type = std::array<_Tp, __num_element>;
 };
 
 template 
-class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> {
-  _Tp __storage_;
-
-  template 
-  friend struct simd;
-
-  template 
-  friend struct simd_mask;
-
-public:
-  _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; };
-  void __set(size_t __index, _Tp __val) noexcept {
-(&__storage_)[__index] = __val;
-  }
-};
-
-#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
-constexpr size_t __floor_pow_of_2(size_t __val) {
-  return ((__val - 1) & __val) == 0 ? __val
-: __floor_pow_of_2((__val - 1) & __val);
-}
-
-constexpr size_t __ceil_pow_of_2(size_t __val) {
-  return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
-}
-
-template 
-struct __vec_ext_traits {
-#if !defined(_LIBCPP_COMPILER_CLANG)
-  typedef _Tp type __attribute__((vector_s

[libcxx] r338318 - Re-apply "[libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."

2018-07-30 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Jul 30 15:27:38 2018
New Revision: 338318

URL: http://llvm.org/viewvc/llvm-project?rev=338318&view=rev
Log:
Re-apply "[libcxx] implement  ABI for Clang/GCC vector extension, 
constructors, copy_from and copy_to."

...with proper guarding #ifdefs for unsupported C++11.

Added:
libcxx/trunk/test/std/experimental/simd/simd.abi/
libcxx/trunk/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.access/
libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.mem/
libcxx/trunk/test/std/experimental/simd/simd.mem/load.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.mem/store.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp

libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338318&r1=338317&r2=338318&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jul 30 15:27:38 2018
@@ -620,6 +620,8 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __forceinline
 
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
 #elif defined(_LIBCPP_COMPILER_IBM)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -652,6 +654,8 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
 
+#define _LIBCPP_HAS_NO_VECTOR_EXTENSION
+
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
 #if _LIBCPP_STD_VER >= 17

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=338318&r1=338317&r2=338318&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Jul 30 15:27:38 2018
@@ -64,4 +64,11 @@
 #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
+// TODO: support more targets
+#if defined(__AVX__)
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32
+#else
+#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16
+#endif
+
 #endif

Modified: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=338318&r1=338317&r2=338318&view=diff
==
--- libcxx/trunk/include/experimental/simd (original)
+++ libcxx/trunk/include/experimental/simd Mon Jul 30 15:27:38 2018
@@ -651,6 +651,7 @@ public:
 */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -661,26 +662,246 @@ public:
 
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
 
+#if _LIBCPP_STD_VER >= 17
+
 enum class _StorageKind {
   _Scalar,
   _Array,
+  _VecExt,
 };
 
 template <_StorageKind __kind, int _Np>
 struct __simd_abi {};
 
 template 
-struct __simd_storage_traits {};
+class __simd_storage {};
 
 template 
-struct __simd_storage_traits<_Tp,
- __simd_abi<_StorageKind::_Array, __num_element>> {
-  using type = std::array<_Tp, __num_element>;
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> {
+  std::array<_Tp, __num_element> __storage_;
+
+  template 
+  friend struct simd;
+
+  template 
+  friend struct simd_mask;
+
+public:
+  _Tp __get(size_t __index) const noexcept { return __storage_[__index]; };
+  void __set(size_t __index, _Tp __val) noexcept {
+__storage_[__index] = __val;
+  }
 };
 
 template 
-struct __simd_storage_traits<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> {
-  using type = _Tp;
+class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> {
+  _Tp __storage_;
+
+  template 
+  friend struct simd;
+
+  template 
+  friend struct simd_mask;
+
+public:
+  _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; };
+  void __set(size_t __index, _Tp __val) noexcept {
+(&__storage_)[__index] = __val;
+  }
+};
+
+#ifn

[libcxx] r338325 - [libcxx] fix `>> 42` UB in

2018-07-30 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Jul 30 16:05:40 2018
New Revision: 338325

URL: http://llvm.org/viewvc/llvm-project?rev=338325&view=rev
Log:
[libcxx] fix `>> 42` UB in 

Modified:
libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp

Modified: libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp?rev=338325&r1=338324&r2=338325&view=diff
==
--- libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp 
(original)
+++ libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp Mon 
Jul 30 16:05:40 2018
@@ -161,7 +161,7 @@ void test_access() {
 }
 {
   auto c = a;
-  (void)(a[0] + (c[0] >>= a[0]));
+  (void)(a[0] + (c[0] >>= b[0]));
 }
 {
   auto c = a;


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


r304496 - [ThinLTO] Wire up ThinLTO and new PM

2017-06-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  1 18:27:51 2017
New Revision: 304496

URL: http://llvm.org/viewvc/llvm-project?rev=304496&view=rev
Log:
[ThinLTO] Wire up ThinLTO and new PM

Summary: This patch teaches clang to use and propagate new PM in ThinLTO.

Reviewers: davide, chandlerc, tejohnson

Subscribers: mehdi_amini, Prazek, inglorion, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thin_link_bitcode.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=304496&r1=304495&r2=304496&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun  1 18:27:51 2017
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,6 +898,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
@@ -904,9 +906,24 @@ void EmitAssemblyHelper::EmitAssemblyWit
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  CodeGenOpts.EmitSummaryIndex,
-  CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output)
+  << CodeGenOpts.ThinLinkBitcodeFile << EC.message();
+  return;
+}
+  }
+  MPM.addPass(
+  ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));
+} else {
+  MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitSummaryIndex,
+CodeGenOpts.EmitSummaryIndex));
+}
 break;
 
   case Backend_EmitLL:
@@ -1029,6 +1046,7 @@ static void runThinLTOBackend(ModuleSumm
   Conf.CGOptLevel = getCGOptLevel(CGOpts);
   initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
   Conf.SampleProfile = std::move(SampleProfile);
+  Conf.UseNewPM = CGOpts.ExperimentalNewPassManager;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module &Mod) {

Modified: cfe/trunk/test/CodeGen/thin_link_bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thin_link_bitcode.c?rev=304496&r1=304495&r2=304496&view=diff
==
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c (original)
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c Thu Jun  1 18:27:51 2017
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s 
--check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }


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


r304501 - [ThinLTO] Add x86 requires to thin_link_bitcode. NFC.

2017-06-01 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  1 19:08:58 2017
New Revision: 304501

URL: http://llvm.org/viewvc/llvm-project?rev=304501&view=rev
Log:
[ThinLTO] Add x86 requires to thin_link_bitcode. NFC.

It already specifies the triples, so the intention was to test x86 for
now (or then).

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

Modified:
cfe/trunk/test/CodeGen/thin_link_bitcode.c

Modified: cfe/trunk/test/CodeGen/thin_link_bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thin_link_bitcode.c?rev=304501&r1=304500&r2=304501&view=diff
==
--- cfe/trunk/test/CodeGen/thin_link_bitcode.c (original)
+++ cfe/trunk/test/CodeGen/thin_link_bitcode.c Thu Jun  1 19:08:58 2017
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+//
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG


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


[libunwind] r321678 - Revert `rL321667: [PPC64] Port to ppc64le - initial version`

2018-01-02 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Jan  2 14:04:03 2018
New Revision: 321678

URL: http://llvm.org/viewvc/llvm-project?rev=321678&view=rev
Log:
Revert `rL321667: [PPC64] Port to ppc64le - initial version`

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

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/config.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=321678&r1=321677&r2=321678&view=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Tue Jan  2 14:04:03 2018
@@ -18,7 +18,6 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86   8
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_6432
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC   112
-#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64 110
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64 95
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  31
@@ -40,11 +39,6 @@
 #define _LIBUNWIND_CURSOR_SIZE 33
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64
-# elif defined(__powerpc64__)
-#  define _LIBUNWIND_TARGET_PPC64 1
-#  define _LIBUNWIND_CONTEXT_SIZE 136
-#  define _LIBUNWIND_CURSOR_SIZE 148
-#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC64
 # elif defined(__ppc__)
 #  define _LIBUNWIND_TARGET_PPC 1
 #  define _LIBUNWIND_CONTEXT_SIZE 117
@@ -90,14 +84,13 @@
 # define _LIBUNWIND_TARGET_I386
 # define _LIBUNWIND_TARGET_X86_64 1
 # define _LIBUNWIND_TARGET_PPC 1
-# define _LIBUNWIND_TARGET_PPC64 1
 # define _LIBUNWIND_TARGET_AARCH64 1
 # define _LIBUNWIND_TARGET_ARM 1
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_N64 1
-# define _LIBUNWIND_CONTEXT_SIZE 136
-# define _LIBUNWIND_CURSOR_SIZE 148
+# define _LIBUNWIND_CONTEXT_SIZE 128
+# define _LIBUNWIND_CURSOR_SIZE 140
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287
 #endif // _LIBUNWIND_IS_NATIVE_ONLY
 

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=321678&r1=321677&r2=321678&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Tue Jan  2 14:04:03 2018
@@ -325,120 +325,6 @@ enum {
   UNW_PPC_SPEFSCR = 112
 };
 
-// 64-bit ppc register numbers
-enum {
-  UNW_PPC64_R0  = 0,
-  UNW_PPC64_R1  = 1,
-  UNW_PPC64_R2  = 2,
-  UNW_PPC64_R3  = 3,
-  UNW_PPC64_R4  = 4,
-  UNW_PPC64_R5  = 5,
-  UNW_PPC64_R6  = 6,
-  UNW_PPC64_R7  = 7,
-  UNW_PPC64_R8  = 8,
-  UNW_PPC64_R9  = 9,
-  UNW_PPC64_R10 = 10,
-  UNW_PPC64_R11 = 11,
-  UNW_PPC64_R12 = 12,
-  UNW_PPC64_R13 = 13,
-  UNW_PPC64_R14 = 14,
-  UNW_PPC64_R15 = 15,
-  UNW_PPC64_R16 = 16,
-  UNW_PPC64_R17 = 17,
-  UNW_PPC64_R18 = 18,
-  UNW_PPC64_R19 = 19,
-  UNW_PPC64_R20 = 20,
-  UNW_PPC64_R21 = 21,
-  UNW_PPC64_R22 = 22,
-  UNW_PPC64_R23 = 23,
-  UNW_PPC64_R24 = 24,
-  UNW_PPC64_R25 = 25,
-  UNW_PPC64_R26 = 26,
-  UNW_PPC64_R27 = 27,
-  UNW_PPC64_R28 = 28,
-  UNW_PPC64_R29 = 29,
-  UNW_PPC64_R30 = 30,
-  UNW_PPC64_R31 = 31,
-  UNW_PPC64_F0  = 32,
-  UNW_PPC64_F1  = 33,
-  UNW_PPC64_F2  = 34,
-  UNW_PPC64_F3  = 35,
-  UNW_PPC64_F4  = 36,
-  UNW_PPC64_F5  = 37,
-  UNW_PPC64_F6  = 38,
-  UNW_PPC64_F7  = 39,
-  UNW_PPC64_F8  = 40,
-  UNW_PPC64_F9  = 41,
-  UNW_PPC64_F10 = 42,
-  UNW_PPC64_F11 = 43,
-  UNW_PPC64_F12 = 44,
-  UNW_PPC64_F13 = 45,
-  UNW_PPC64_F14 = 46,
-  UNW_PPC64_F15 = 47,
-  UNW_PPC64_F16 = 48,
-  UNW_PPC64_F17 = 49,
-  UNW_PPC64_F18 = 50,
-  UNW_PPC64_F19 = 51,
-  UNW_PPC64_F20 = 52,
-  UNW_PPC64_F21 = 53,
-  UNW_PPC64_F22 = 54,
-  UNW_PPC64_F23 = 55,
-  UNW_PPC64_F24 = 56,
-  UNW_PPC64_F25 = 57,
-  UNW_PPC64_F26 = 58,
-  UNW_PPC64_F27 = 59,
-  UNW_PPC64_F28 = 60,
-  UNW_PPC64_F29 = 61,
-  UNW_PPC64_F30 = 62,
-  UNW_PPC64_F31 = 63,
-  UNW_PPC64_LR  = 64,
-  UNW_PPC64_CTR = 65,
-  UNW_PPC64_CR0 = 66,
-  UNW_PPC64_CR1 = 67,
-  UNW_PPC64_CR2 = 68,
-  UNW_PPC64_CR3 = 69,
-  UNW_PPC64_CR4 = 70,
-  UNW_PPC64_CR5 = 71,
-  UNW_PPC64_CR6 = 72,
-  UNW_PPC64_CR7 = 73,
-  UNW_PPC64_XER = 74,
-  UNW_PPC64_V0  = 75,
-  UNW_PPC64_V1  = 76,
-  UNW_PPC64_V2  = 77,
-  UNW_PPC64_V3  = 78,
-  UNW_PPC64_V4  = 79,
-  UNW_PPC64_V5  = 80,
-  UNW_PPC64_V6  = 81,
-  UNW_PPC64_V7  = 82,
-  UNW_PPC64_V8  = 83,
-  UNW_PPC64_V9  = 84,
-  UNW_PPC64_V10 = 85,
-  UNW_PPC64_V11 = 86

r333617 - [X86] Fix wrong intrinsic semantic.

2018-05-30 Thread Tim Shen via cfe-commits
Author: timshen
Date: Wed May 30 18:51:07 2018
New Revision: 333617

URL: http://llvm.org/viewvc/llvm-project?rev=333617&view=rev
Log:
[X86] Fix wrong intrinsic semantic.

Modified:
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=333617&r1=333616&r2=333617&view=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Wed May 30 18:51:07 2018
@@ -3964,7 +3964,7 @@ _mm256_set_epi64x(long long __a, long lo
 static __inline __m256d __DEFAULT_FN_ATTRS
 _mm256_setr_pd(double __a, double __b, double __c, double __d)
 {
-  return _mm256_set_pd(__a, __b, __c, __d);
+  return _mm256_set_pd(__d, __c, __b, __a);
 }
 
 /// Constructs a 256-bit floating-point vector of [8 x float],
@@ -4005,7 +4005,7 @@ static __inline __m256 __DEFAULT_FN_ATTR
 _mm256_setr_ps(float __a, float __b, float __c, float __d,
float __e, float __f, float __g, float __h)
 {
-  return _mm256_set_ps(__a, __b, __c, __d, __e, __f, __g, __h);
+  return _mm256_set_ps(__h, __g, __f, __e, __d, __c, __b, __a);
 }
 
 /// Constructs a 256-bit integer vector, initialized in reverse order
@@ -4037,7 +4037,7 @@ static __inline __m256i __DEFAULT_FN_ATT
 _mm256_setr_epi32(int __i0, int __i1, int __i2, int __i3,
   int __i4, int __i5, int __i6, int __i7)
 {
-  return _mm256_set_epi32(__i0, __i1, __i2, __i3, __i4, __i5, __i6, __i7);
+  return _mm256_set_epi32(__i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0);
 }
 
 /// Constructs a 256-bit integer vector, initialized in reverse order
@@ -4087,10 +4087,10 @@ _mm256_setr_epi16(short __w15, short __w
short __w07, short __w06, short __w05, short __w04,
short __w03, short __w02, short __w01, short __w00)
 {
-  return _mm256_set_epi16(__w15, __w14, __w13, __w12,
-  __w11, __w10, __w09, __w08,
-  __w07, __w06, __w05, __w04,
-  __w03, __w02, __w01, __w00);
+  return _mm256_set_epi16(__w00, __w01, __w02, __w03,
+  __w04, __w05, __w06, __w07,
+  __w08, __w09, __w10, __w11,
+  __w12, __w13, __w14, __w15);
 }
 
 /// Constructs a 256-bit integer vector, initialized in reverse order
@@ -4176,10 +4176,10 @@ _mm256_setr_epi8(char __b31, char __b30,
  char __b07, char __b06, char __b05, char __b04,
  char __b03, char __b02, char __b01, char __b00)
 {
-  return _mm256_set_epi8(__b31, __b30, __b29, __b28, __b27, __b26, __b25, 
__b24,
- __b23, __b22, __b21, __b20, __b19, __b18, __b17, 
__b16,
- __b15, __b14, __b13, __b12, __b11, __b10, __b09, 
__b08,
- __b07, __b06, __b05, __b04, __b03, __b02, __b01, 
__b00);
+  return _mm256_set_epi8(__b00, __b01, __b02, __b03, __b04, __b05, __b06, 
__b07,
+ __b08, __b09, __b10, __b11, __b12, __b13, __b14, 
__b15,
+ __b16, __b17, __b18, __b19, __b20, __b21, __b22, 
__b23,
+ __b24, __b25, __b26, __b27, __b28, __b29, __b30, 
__b31);
 }
 
 /// Constructs a 256-bit integer vector, initialized in reverse order
@@ -4202,7 +4202,7 @@ _mm256_setr_epi8(char __b31, char __b30,
 static __inline __m256i __DEFAULT_FN_ATTRS
 _mm256_setr_epi64x(long long __a, long long __b, long long __c, long long __d)
 {
-  return _mm256_set_epi64x(__a, __b, __c, __d);
+  return _mm256_set_epi64x(__d, __c, __b, __a);
 }
 
 /* Create vectors with repeated elements */

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=333617&r1=333616&r2=333617&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Wed May 30 18:51:07 2018
@@ -3641,7 +3641,7 @@ _mm_set_epi64x(long long __q1, long long
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_set_epi64(__m64 __q1, __m64 __q0)
 {
-  return _mm_set_epi64x((long long)__q0, (long long)__q1);
+  return _mm_set_epi64x((long long)__q1, (long long)__q0);
 }
 
 /// Initializes the 32-bit values in a 128-bit vector of [4 x i32] with
@@ -3872,7 +3872,7 @@ _mm_set1_epi8(char __b)
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_setr_epi64(__m64 __q0, __m64 __q1)
 {
-  return _mm_set_epi64(__q0, __q1);
+  return _mm_set_epi64(__q1, __q0);
 }
 
 /// Constructs a 128-bit integer vector, initialized in reverse order
@@ -3895,7 +3895,7 @@ _mm_setr_epi64(__m64 __q0, __m64 __q1)
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_setr_epi32(int __i0, int __i1, int __i2, int __i3)
 {
-  return _mm_set_epi32(__i0, __i1, __i2, __i3);
+  return _mm_set_epi32(__i3, __i2, __i1, __i0);
 }
 
 /// Cons

[clang-tools-extra] r371773 - [ClangTidy] Adjust the name getCheckName to getCheckerName due to API change.

2019-09-12 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Sep 12 14:18:44 2019
New Revision: 371773

URL: http://llvm.org/viewvc/llvm-project?rev=371773&view=rev
Log:
[ClangTidy] Adjust the name getCheckName to getCheckerName due to API change.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=371773&r1=371772&r2=371773&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Sep 12 14:18:44 2019
@@ -72,7 +72,7 @@ public:
 FilesMade *filesMade) override {
 for (const ento::PathDiagnostic *PD : Diags) {
   SmallString<64> CheckName(AnalyzerCheckNamePrefix);
-  CheckName += PD->getCheckName();
+  CheckName += PD->getCheckerName();
   Context.diag(CheckName, PD->getLocation().asLocation(),
PD->getShortDescription())
   << PD->path.back()->getRanges();


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


r371897 - Fix test to use %t for newly created files.

2019-09-13 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Sep 13 14:06:47 2019
New Revision: 371897

URL: http://llvm.org/viewvc/llvm-project?rev=371897&view=rev
Log:
Fix test to use %t for newly created files.

This is both for consistency with other `mkdir`s in tests, and
fixing permission issues with the non-temporary cwd during testing (they
are not always writable).

Modified:
cfe/trunk/test/Driver/metadata-with-dots.c

Modified: cfe/trunk/test/Driver/metadata-with-dots.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/metadata-with-dots.c?rev=371897&r1=371896&r2=371897&view=diff
==
--- cfe/trunk/test/Driver/metadata-with-dots.c (original)
+++ cfe/trunk/test/Driver/metadata-with-dots.c Fri Sep 13 14:06:47 2019
@@ -1,10 +1,10 @@
 // REQUIRES: shell
-// RUN: mkdir -p out.dir
-// RUN: cat %s > out.dir/test.c
-// RUN: %clang -E -MMD %s -o out.dir/test
+// RUN: mkdir -p %t/out.dir
+// RUN: cat %s > %t/out.dir/test.c
+// RUN: %clang -E -MMD %s -o %t/out.dir/test
 // RUN: test ! -f %out.d
-// RUN: test -f out.dir/test.d
-// RUN: rm -rf out.dir/test.d out.dir/ out.d
+// RUN: test -f %t/out.dir/test.d
+// RUN: rm -rf %t/out.dir/test.d %t/out.dir/ out.d
 int main (void)
 {
 return 0;


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


[libcxx] r330627 - [libcxx] implement declarations based on P0214R7.

2018-04-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Apr 23 11:47:07 2018
New Revision: 330627

URL: http://llvm.org/viewvc/llvm-project?rev=330627&view=rev
Log:
[libcxx] implement  declarations based on P0214R7.

Summary:
The patch includes all declarations, and also implements the following features:
* ABI.
* narrowing-conversion related SFIANE, including simd<> ctors and 
(static_)simd_cast.

Reviewers: mclow.lists, EricWF

Subscribers: lichray, sanjoy, MaskRay, cfe-commits

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

Added:
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/
libcxx/trunk/test/std/experimental/simd/nothing_to_do.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/
libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/
libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/genertor.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/
libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp

libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
Modified:
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=330627&r1=330626&r2=330627&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Apr 23 11:47:07 2018
@@ -54,4 +54,16 @@
 
 #define _VSTD_FS ::std::experimental::filesystem::v1
 
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
+} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+
 #endif

Added: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=330627&view=auto
==
--- libcxx/trunk/include/experimental/simd (added)
+++ libcxx/trunk/include/experimental/simd Mon Apr 23 11:47:07 2018
@@ -0,0 +1,1285 @@
+// -*- C++ -*-
+//===--- simd 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef _LIBCPP_EXPERIMENTAL_SIMD
+#define _LIBCPP_EXPERIMENTAL_SIMD
+
+/*
+experimental/simd synopsis
+
+namespace std::experimental {
+
+inline namespace parallelism_v2 {
+
+namespace simd_abi {
+
+struct scalar {};
+template  struct fixed_size {};
+template  inline constexpr int max_fixed_size = 
implementation-defined;
+template  using compatible = implementation-defined;
+template  using native = implementation-defined;
+
+} // simd_abi
+
+struct element_aligned_tag {};
+struct vector_aligned_tag {};
+template  struct overaligned_tag {};
+inline constexpr element_aligned_tag element_aligned{};
+inline constexpr vector_aligned_tag vector_aligned{};
+template  inline constexpr overaligned_tag overaligned{};
+
+// traits [simd.traits]
+template  struct is_abi_tag;
+template  inline constexpr bool is_abi_tag_v = is_abi_tag::value;
+
+template  struct is_simd;
+template  inline constexpr bool is_simd_v = is_simd::value;
+
+template  struct is_simd_mask;
+template  inline constexpr bool is_simd_mask_v = 
is_simd_mask::value;
+
+template  struct is_simd_flag_type;
+template  inline constexpr bool is_simd_flag_type_v = 
is_simd_flag_type::value;
+
+template  struct abi_for_size { using type = see below; };
+template  using abi_for_size_t = typename abi_for_size::type;
+
+template > struct simd_size;
+template >
+inline constexpr size_t simd_size_v = simd_size::value;
+
+template  struct memory_alignment;
+template 
+inline constexpr size_t memory_alignment_v = memory_alignment::value;
+
+// class template simd [simd.class]
+template > class simd;
+template  using native_simd = simd>;
+template  using fixed_size

[libcxx] r330636 - Revert "[libcxx] implement declarations based on P0214R7."

2018-04-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Apr 23 12:56:20 2018
New Revision: 330636

URL: http://llvm.org/viewvc/llvm-project?rev=330636&view=rev
Log:
Revert "[libcxx] implement  declarations based on P0214R7."

This reverts commit r330627.

This causes several bots to freak out.

Removed:
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/
Modified:
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=330636&r1=330635&r2=330636&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Apr 23 12:56:20 2018
@@ -54,16 +54,4 @@
 
 #define _VSTD_FS ::std::experimental::filesystem::v1
 
-#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
-_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
-
-#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
-} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
-
-#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
-_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
-
-#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
-} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
-
 #endif

Removed: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=330635&view=auto
==
--- libcxx/trunk/include/experimental/simd (original)
+++ libcxx/trunk/include/experimental/simd (removed)
@@ -1,1285 +0,0 @@
-// -*- C++ -*-
-//===--- simd 
-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-#ifndef _LIBCPP_EXPERIMENTAL_SIMD
-#define _LIBCPP_EXPERIMENTAL_SIMD
-
-/*
-experimental/simd synopsis
-
-namespace std::experimental {
-
-inline namespace parallelism_v2 {
-
-namespace simd_abi {
-
-struct scalar {};
-template  struct fixed_size {};
-template  inline constexpr int max_fixed_size = 
implementation-defined;
-template  using compatible = implementation-defined;
-template  using native = implementation-defined;
-
-} // simd_abi
-
-struct element_aligned_tag {};
-struct vector_aligned_tag {};
-template  struct overaligned_tag {};
-inline constexpr element_aligned_tag element_aligned{};
-inline constexpr vector_aligned_tag vector_aligned{};
-template  inline constexpr overaligned_tag overaligned{};
-
-// traits [simd.traits]
-template  struct is_abi_tag;
-template  inline constexpr bool is_abi_tag_v = is_abi_tag::value;
-
-template  struct is_simd;
-template  inline constexpr bool is_simd_v = is_simd::value;
-
-template  struct is_simd_mask;
-template  inline constexpr bool is_simd_mask_v = 
is_simd_mask::value;
-
-template  struct is_simd_flag_type;
-template  inline constexpr bool is_simd_flag_type_v = 
is_simd_flag_type::value;
-
-template  struct abi_for_size { using type = see below; };
-template  using abi_for_size_t = typename abi_for_size::type;
-
-template > struct simd_size;
-template >
-inline constexpr size_t simd_size_v = simd_size::value;
-
-template  struct memory_alignment;
-template 
-inline constexpr size_t memory_alignment_v = memory_alignment::value;
-
-// class template simd [simd.class]
-template > class simd;
-template  using native_simd = simd>;
-template  using fixed_size_simd = simd>;
-
-// class template simd_mask [simd.mask.class]
-template > class simd_mask;
-template  using native_simd_mask = simd_mask>;
-template  using fixed_size_simd_mask = simd_mask>;
-
-// casts [simd.casts]
-template  see below simd_cast(const simd&);
-template  see below static_simd_cast(const 
simd&);
-
-template 
-fixed_size_simd> to_fixed_size(const simd&) 
noexcept;
-template 
-fixed_size_simd_mask> to_fixed_size(const simd_mask&) noexcept;
-template  native_simd to_native(const fixed_size_simd&) noexcept;
-template 
-native_simd_mask to_native(const fixed_size_simd_mask> &) noexcept;
-template  simd to_compatible(const fixed_size_simd&) noexcept;
-template  simd_mask to_compatible(const 
fixed_size_simd_mask&) noexcept;
-
-template 
-tuple>...> split(const simd&);
-template 
-tuple>...> split(const simd_mask&);
-template 
-array / V::size()> split(
-const simd&);
-template 
-array / V::size()> split(
-const simd_mask&);
-
-template 
-simd + ...)>> concat(const simd&...);
-template 
-simd_mask + ...)>> concat(const 
simd_mask&...);
-
-// reductions [simd.mask.reductions]
-template  bool all_of(const simd_mask&) noexcept;
-template  bool any_of(

[libcxx] r330655 - Re-commit r330627 "[libcxx] implement declarations based on P0214R7."

2018-04-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Apr 23 14:54:06 2018
New Revision: 330655

URL: http://llvm.org/viewvc/llvm-project?rev=330655&view=rev
Log:
Re-commit r330627 "[libcxx] implement  declarations based on 
P0214R7."

There are 3 changes:
* Renamed genertor.pass.cpp to generator.pass.cpp
* Removed nothing_to_do.pass.cpp
* Mark GCC 4.9 as UNSUPPORTED for the test files that have negative
  narrowing conversion SFINAE test (see GCC PR63723).

Added:
libcxx/trunk/include/experimental/simd
libcxx/trunk/test/std/experimental/simd/
libcxx/trunk/test/std/experimental/simd/simd.casts/
libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/
libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/
libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp

libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
Modified:
libcxx/trunk/include/experimental/__config
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/experimental/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=330655&r1=330654&r2=330655&view=diff
==
--- libcxx/trunk/include/experimental/__config (original)
+++ libcxx/trunk/include/experimental/__config Mon Apr 23 14:54:06 2018
@@ -54,4 +54,16 @@
 
 #define _VSTD_FS ::std::experimental::filesystem::v1
 
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \
+} _LIBCPP_END_NAMESPACE_EXPERIMENTAL
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi {
+
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \
+} _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
+
 #endif

Added: libcxx/trunk/include/experimental/simd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=330655&view=auto
==
--- libcxx/trunk/include/experimental/simd (added)
+++ libcxx/trunk/include/experimental/simd Mon Apr 23 14:54:06 2018
@@ -0,0 +1,1285 @@
+// -*- C++ -*-
+//===--- simd 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef _LIBCPP_EXPERIMENTAL_SIMD
+#define _LIBCPP_EXPERIMENTAL_SIMD
+
+/*
+experimental/simd synopsis
+
+namespace std::experimental {
+
+inline namespace parallelism_v2 {
+
+namespace simd_abi {
+
+struct scalar {};
+template  struct fixed_size {};
+template  inline constexpr int max_fixed_size = 
implementation-defined;
+template  using compatible = implementation-defined;
+template  using native = implementation-defined;
+
+} // simd_abi
+
+struct element_aligned_tag {};
+struct vector_aligned_tag {};
+template  struct overaligned_tag {};
+inline constexpr element_aligned_tag element_aligned{};
+inline constexpr vector_aligned_tag vector_aligned{};
+template  inline constexpr overaligned_tag overaligned{};
+
+// traits [simd.traits]
+template  struct is_abi_tag;
+template  inline constexpr bool is_abi_tag_v = is_abi_tag::value;
+
+template  struct is_simd;
+template  inline constexpr bool is_simd_v = is_simd::value;
+
+template  struct is_simd_mask;
+template  inline constexpr bool is_simd_mask_v = 
is_simd_mask::value;
+
+template  struct is_simd_flag_type;
+template  inline constexpr bool is_simd_flag_type_v = 
is_simd_flag_type::value;
+
+template  struct abi_for_size { using type = see below; };
+template  using abi_for_size_t = typename abi_for_size::type;
+
+template > struct simd_size;
+template >
+inline constexpr size_t simd_size_v = simd_size::value;
+
+template  struct memory_alignment;
+template 
+inline constexpr size_t memory_alignment_v = memory_alignment::value;
+
+// class template simd [simd.class]
+template > class simd;
+template  using native_simd = simd>;
+template  using fixed_size_simd = simd>;
+
+// class template simd_mask [simd.mask.class]
+template > class simd_mask;
+template  using native_simd_mask = simd_mask>;
+t

[PATCH] D25419: Use unique_ptr in LLVMContextImpl's constant maps.

2016-10-10 Thread Tim Shen via cfe-commits
timshen added inline comments.



Comment at: llvm/lib/IR/LLVMContextImpl.cpp:106
   for (auto &CDSConstant : CDSConstants)
 delete CDSConstant.second;
   CDSConstants.clear();

Do you want to change this one as well?


https://reviews.llvm.org/D25419



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


[PATCH] D25420: [AST] Convert MangleNumberingContext to a unique_ptr.

2016-10-10 Thread Tim Shen via cfe-commits
timshen accepted this revision.
timshen added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Sema/Sema.h:879
 /// do not have lambda expressions or block literals.
-IntrusiveRefCntPtr MangleNumbering;
+std::unique_ptr MangleNumbering;
 

Wait, what? 

This is awesome. :)


https://reviews.llvm.org/D25420



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


[PATCH] D25425: [AST] Convert Marshallers to use unique_ptr.

2016-10-10 Thread Tim Shen via cfe-commits
timshen added inline comments.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:514
+  MutableArrayRef> Callbacks)
+  : Overloads(std::make_move_iterator(Callbacks.begin()),
+  std::make_move_iterator(Callbacks.end())) {}

Notice that this is 2x slower, because move on unique_ptr resets the move-from 
side. But it is less likely to have an issue.



Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:501
   for (const auto &M : RegistryData->constructors()) {
-const auto *Matcher = M.getValue();
+const std::unique_ptr& Matcher = M.getValue();
 StringRef Name = M.getKey();

const MatcherDescriptor &Matcher = *M.getValue()?


https://reviews.llvm.org/D25425



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


[PATCH] D25427: [Analysis] Use unique_ptr for CallGraph::FunctionMap.

2016-10-10 Thread Tim Shen via cfe-commits
timshen added inline comments.



Comment at: clang/include/clang/Analysis/CallGraph.h:204
+  static clang::CallGraphNode *
+  CGGetValue(decltype(*std::declval()) &P) {
+return P.second.get();

Does clang::CallGraph::const_iterator::value_type work?


https://reviews.llvm.org/D25427



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


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-14 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added reviewers: mclow.lists, EricWF.
timshen added a subscriber: cfe-commits.

Fixes PR21597.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp


Index: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = 
regex_constants::match_default);
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.alg/re.alg.search/pr21597.pass.cpp
@@ -0,0 +1,39 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// bool
+// regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//  match_results& m,
+//  const basic_regex& e,
+//  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::re

r309908 - [Sema] Add a comment on an identified bug on default arguments.

2017-08-02 Thread Tim Shen via cfe-commits
Author: timshen
Date: Wed Aug  2 17:18:11 2017
New Revision: 309908

URL: http://llvm.org/viewvc/llvm-project?rev=309908&view=rev
Log:
[Sema] Add a comment on an identified bug on default arguments.

Summary:
The mis-compile is triggered by internal code, but I haven't reduced it to a 
small piece of code. Add a FIXME here, since a decent fix doesn't seem to be 
trivial.

The decent fix can be changing Decl::Init to PointerUnion, and make setUninstantiatedDefaultArg take a ParamVarDecl *, 
which contains the Expr * as the default argument. This way, 
getTemplateInstantiationArgs can take that ParamVarDecl and do the right thing.

Reviewers: rsmith

Subscribers: sanjoy, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=309908&r1=309907&r2=309908&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Aug  2 17:18:11 2017
@@ -4477,6 +4477,22 @@ bool Sema::CheckCXXDefaultArgExpr(Source
 *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
 
 // Instantiate the expression.
+//
+// FIXME: Pass in a correct Pattern argument, otherwise
+// getTemplateInstantiationArgs uses the lexical context of FD, e.g.
+//
+// template
+// struct A {
+//   static int FooImpl();
+//
+//   template
+//   // bug: default argument A::FooImpl() is evaluated with 2-level
+//   // template argument list [[T], [Tp]], should be [[Tp]].
+//   friend A Foo(int a);
+// };
+//
+// template
+// A Foo(int a = A::FooImpl());
 MultiLevelTemplateArgumentList MutiLevelArgList
   = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true);
 


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


r278746 - [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Aug 15 16:27:56 2016
New Revision: 278746

URL: http://llvm.org/viewvc/llvm-project?rev=278746&view=rev
Log:
[ADT] Change PostOrderIterator to use NodeRef. NFC.

Summary: Corresponding LLVM change: D23522

Reviewers: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Analysis/CallGraph.h

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=278746&r1=278745&r2=278746&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Aug 15 16:27:56 2016
@@ -999,6 +999,7 @@ template <> struct simplify_type< ::clan
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@ template <> struct GraphTraits< ::clang:
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@ template <> struct GraphTraits< const ::
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@ template <> struct GraphTraits struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=278746&r1=278745&r2=278746&view=diff
==
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Mon Aug 15 16:27:56 2016
@@ -172,6 +172,7 @@ public:
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@ template <> struct GraphTraits struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}


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


Re: [PATCH] D23523: [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278746: [ADT] Change PostOrderIterator to use NodeRef. NFC. 
(authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23523?vs=68070&id=68082#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23523

Files:
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/Analysis/CallGraph.h

Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}


Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; }
   static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23581: [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

2016-08-16 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.

Corresponding LLVM patch: D23580

https://reviews.llvm.org/D23581

Files:
  lib/Serialization/ModuleManager.cpp

Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 


Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278963 - [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

2016-08-17 Thread Tim Shen via cfe-commits
Author: timshen
Date: Wed Aug 17 15:02:38 2016
New Revision: 278963

URL: http://llvm.org/viewvc/llvm-project?rev=278963&view=rev
Log:
[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

Summary: Corresponding LLVM patch: D23580

Reviewers: dblaikie

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=278963&r1=278962&r2=278963&view=diff
==
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Wed Aug 17 15:02:38 2016
@@ -434,6 +434,7 @@ namespace llvm {
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 


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


Re: [PATCH] D23581: [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

2016-08-17 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278963: [GraphWriter] Change GraphWriter to use NodeRef in 
GraphTraits (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23581?vs=68258&id=68406#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23581

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

Index: cfe/trunk/lib/Serialization/ModuleManager.cpp
===
--- cfe/trunk/lib/Serialization/ModuleManager.cpp
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 


Index: cfe/trunk/lib/Serialization/ModuleManager.cpp
===
--- cfe/trunk/lib/Serialization/ModuleManager.cpp
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23705: [GraphTraits] Make nodes_iterator dereference to NodeRef

2016-08-18 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.

Currently nodes_iterator may dereference to a NodeType* or a NodeType&. Make 
them all dereference to NodeType*, which is NodeRef later. Corresponding LLVM 
change: D23704

https://reviews.llvm.org/D23705

Files:
  include/clang/Analysis/Analyses/Dominators.h
  include/clang/Analysis/CFG.h
  include/clang/Analysis/CallGraph.h

Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -205,7 +205,8 @@
 return CGN->getRoot();  // Start at the external node!
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function DerefFun;
+  typedef std::pointer_to_unary_function
+  DerefFun;
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
   typedef mapped_iterator nodes_iterator;
 
@@ -215,9 +216,7 @@
   static nodes_iterator nodes_end  (clang::CallGraph *CG) {
 return map_iterator(CG->end(), DerefFun(CGdereference));
   }
-  static clang::CallGraphNode &CGdereference(PairTy P) {
-return *(P.second);
-  }
+  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
 
   static unsigned size(clang::CallGraph *CG) {
 return CG->size();
@@ -230,7 +229,8 @@
 return CGN->getRoot();
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function DerefFun;
+  typedef std::pointer_to_unary_function
+  DerefFun;
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
   typedef mapped_iterator nodes_iterator;
@@ -241,9 +241,7 @@
   static nodes_iterator nodes_end(const clang::CallGraph *CG) {
 return map_iterator(CG->end(), DerefFun(CGdereference));
   }
-  static clang::CallGraphNode &CGdereference(PairTy P) {
-return *(P.second);
-  }
+  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
 
   static unsigned size(const clang::CallGraph *CG) {
 return CG->size();
Index: include/clang/Analysis/CFG.h
===
--- include/clang/Analysis/CFG.h
+++ include/clang/Analysis/CFG.h
@@ -761,55 +761,6 @@
 AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {}
   };
 
-  /// \brief Provides a custom implementation of the iterator class to have the
-  /// same interface as Function::iterator - iterator returns CFGBlock
-  /// (not a pointer to CFGBlock).
-  class graph_iterator {
-  public:
-typedef CFGBlockvalue_type;
-typedef value_type& reference;
-typedef value_type* pointer;
-typedef BumpVector::iterator ImplTy;
-
-graph_iterator(const ImplTy &i) : I(i) {}
-
-bool operator==(const graph_iterator &X) const { return I == X.I; }
-bool operator!=(const graph_iterator &X) const { return I != X.I; }
-
-reference operator*()const { return **I; }
-pointer operator->() const { return  *I; }
-operator CFGBlock* ()  { return  *I; }
-
-graph_iterator &operator++() { ++I; return *this; }
-graph_iterator &operator--() { --I; return *this; }
-
-  private:
-ImplTy I;
-  };
-
-  class const_graph_iterator {
-  public:
-typedef const CFGBlock  value_type;
-typedef value_type& reference;
-typedef value_type* pointer;
-typedef BumpVector::const_iterator ImplTy;
-
-const_graph_iterator(const ImplTy &i) : I(i) {}
-
-bool operator==(const const_graph_iterator &X) const { return I == X.I; }
-bool operator!=(const const_graph_iterator &X) const { return I != X.I; }
-
-reference operator*() const { return **I; }
-pointer operator->()  const { return  *I; }
-operator CFGBlock* () const { return  *I; }
-
-const_graph_iterator &operator++() { ++I; return *this; }
-const_graph_iterator &operator--() { --I; return *this; }
-
-  private:
-ImplTy I;
-  };
-
   /// buildCFG - Builds a CFG from an AST.
   static std::unique_ptr buildCFG(const Decl *D, Stmt *AST, ASTContext *C,
const BuildOptions &BO);
@@ -845,14 +796,10 @@
   const_iteratorbegin()   const{ return Blocks.begin(); }
   const_iteratorend() const{ return Blocks.end(); }
 
-  graph_iterator nodes_begin() { return graph_iterator(Blocks.begin()); }
-  graph_iterator nodes_end() { return graph_iterator(Blocks.end()); }
-  const_graph_iterator nodes_begin() const {
-return const_graph_iterator(Blocks.begin());
-  }
-  const_graph_iterator nodes_end() const {
-return const_graph_iterator(Blocks.end());
-  }
+  iterator nodes_begin() { return iterator(Blocks.begin()); }
+  iterator nodes_end() { return iterator(Blocks.end()); }
+  const_iterator nodes_begin() const { return const_iterator(Blocks.begin()); }
+  const_iter

Re: [PATCH] D23705: [GraphTraits] Make nodes_iterator dereference to NodeType*

2016-08-19 Thread Tim Shen via cfe-commits
timshen added inline comments.


Comment at: include/clang/Analysis/CallGraph.h:219
@@ -217,5 +218,3 @@
   }
-  static clang::CallGraphNode &CGdereference(PairTy P) {
-return *(P.second);
-  }
+  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
 

dblaikie wrote:
> I don't have enough context - but presumably this name should be changed now 
> that the function doesn't actually dereference? (perhaps this is just get<1, 
> PairTy::first_type, PairTy::second_type> - but could be useful to have a 
> generic utility, something like 'firster' and 'seconder' - I thought there 
> might already be, but couldn't find one. Could generalize it like get<> but 
> just allow the actual tuple/pair type to be passed, rather than having to 
> decompose it)
I'll add a GetNthFunctor or something to STLExtras.h in the next patch, so that 
we don't need to create a specific one.


https://reviews.llvm.org/D23705



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


r279326 - [GraphTraits] Make nodes_iterator dereference to NodeType*/NodeRef

2016-08-19 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Aug 19 16:20:13 2016
New Revision: 279326

URL: http://llvm.org/viewvc/llvm-project?rev=279326&view=rev
Log:
[GraphTraits] Make nodes_iterator dereference to NodeType*/NodeRef

Currently nodes_iterator may dereference to a NodeType* or a NodeType&. Make 
them all dereference to NodeType*, which is NodeRef later.

Differential Revision: https://reviews.llvm.org/D23704
Differential Revision: https://reviews.llvm.org/D23705

Modified:
cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Analysis/CallGraph.h

Modified: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Dominators.h?rev=279326&r1=279325&r2=279326&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h Fri Aug 19 16:20:13 
2016
@@ -181,14 +181,15 @@ template <> struct GraphTraits< ::clang:
 return N->end();
   }
 
-  typedef df_iterator< ::clang::DomTreeNode* > nodes_iterator;
+  typedef llvm::pointer_iterator>
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(::clang::DomTreeNode *N) {
-return df_begin(getEntryNode(N));
+return nodes_iterator(df_begin(getEntryNode(N)));
   }
 
   static nodes_iterator nodes_end(::clang::DomTreeNode *N) {
-return df_end(getEntryNode(N));
+return nodes_iterator(df_end(getEntryNode(N)));
   }
 };
 
@@ -199,11 +200,11 @@ template <> struct GraphTraits< ::clang:
   }
 
   static nodes_iterator nodes_begin(::clang::DominatorTree *N) {
-return df_begin(getEntryNode(N));
+return nodes_iterator(df_begin(getEntryNode(N)));
   }
 
   static nodes_iterator nodes_end(::clang::DominatorTree *N) {
-return df_end(getEntryNode(N));
+return nodes_iterator(df_end(getEntryNode(N)));
   }
 };
 } // end namespace llvm

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=279326&r1=279325&r2=279326&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Fri Aug 19 16:20:13 2016
@@ -761,55 +761,6 @@ public:
 AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {}
   };
 
-  /// \brief Provides a custom implementation of the iterator class to have the
-  /// same interface as Function::iterator - iterator returns CFGBlock
-  /// (not a pointer to CFGBlock).
-  class graph_iterator {
-  public:
-typedef CFGBlockvalue_type;
-typedef value_type& reference;
-typedef value_type* pointer;
-typedef BumpVector::iterator ImplTy;
-
-graph_iterator(const ImplTy &i) : I(i) {}
-
-bool operator==(const graph_iterator &X) const { return I == X.I; }
-bool operator!=(const graph_iterator &X) const { return I != X.I; }
-
-reference operator*()const { return **I; }
-pointer operator->() const { return  *I; }
-operator CFGBlock* ()  { return  *I; }
-
-graph_iterator &operator++() { ++I; return *this; }
-graph_iterator &operator--() { --I; return *this; }
-
-  private:
-ImplTy I;
-  };
-
-  class const_graph_iterator {
-  public:
-typedef const CFGBlock  value_type;
-typedef value_type& reference;
-typedef value_type* pointer;
-typedef BumpVector::const_iterator ImplTy;
-
-const_graph_iterator(const ImplTy &i) : I(i) {}
-
-bool operator==(const const_graph_iterator &X) const { return I == X.I; }
-bool operator!=(const const_graph_iterator &X) const { return I != X.I; }
-
-reference operator*() const { return **I; }
-pointer operator->()  const { return  *I; }
-operator CFGBlock* () const { return  *I; }
-
-const_graph_iterator &operator++() { ++I; return *this; }
-const_graph_iterator &operator--() { --I; return *this; }
-
-  private:
-ImplTy I;
-  };
-
   /// buildCFG - Builds a CFG from an AST.
   static std::unique_ptr buildCFG(const Decl *D, Stmt *AST, ASTContext *C,
const BuildOptions &BO);
@@ -845,14 +796,10 @@ public:
   const_iteratorbegin()   const{ return Blocks.begin(); }
   const_iteratorend() const{ return Blocks.end(); }
 
-  graph_iterator nodes_begin() { return graph_iterator(Blocks.begin()); }
-  graph_iterator nodes_end() { return graph_iterator(Blocks.end()); }
-  const_graph_iterator nodes_begin() const {
-return const_graph_iterator(Blocks.begin());
-  }
-  const_graph_iterator nodes_end() const {
-return const_graph_iterator(Blocks.end());
-  }
+  iterator nodes_begin() { return iterator(Blo

Re: [PATCH] D23705: [GraphTraits] Make nodes_iterator dereference to NodeType*

2016-08-19 Thread Tim Shen via cfe-commits
timshen closed this revision.
timshen added a comment.

Landed as r279326.


https://reviews.llvm.org/D23705



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


[PATCH] D23726: [CallGraph] Use decltype instead of pointer_to_unary_function. NFC.

2016-08-19 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.

https://reviews.llvm.org/D23726

Files:
  include/clang/Analysis/CallGraph.h

Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -173,26 +173,20 @@
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
   typedef clang::CallGraphNode *NodeRef;
-  typedef clang::CallGraphNode::CallRecord CallRecordTy;
-  typedef std::pointer_to_unary_function CGNDerefFun;
+  typedef NodeType::iterator ChildIteratorType;
+
   static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; }
-  typedef mapped_iterator ChildIteratorType;
   static inline ChildIteratorType child_begin(NodeType *N) {
-return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
-  }
-  static inline ChildIteratorType child_end  (NodeType *N) {
-return map_iterator(N->end(), CGNDerefFun(CGNDeref));
-  }
-  static clang::CallGraphNode *CGNDeref(CallRecordTy P) {
-return P;
+return N->begin();
   }
+  static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
 };
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
   typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
+
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}
   static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
@@ -205,18 +199,19 @@
 return CGN->getRoot();  // Start at the external node!
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function
-  DerefFun;
+
+  static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; }
+
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
-  typedef mapped_iterator nodes_iterator;
+  typedef mapped_iterator
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(clang::CallGraph *CG) {
-return map_iterator(CG->begin(), DerefFun(CGdereference));
+return nodes_iterator(CG->begin(), &CGGetValue);
   }
   static nodes_iterator nodes_end  (clang::CallGraph *CG) {
-return map_iterator(CG->end(), DerefFun(CGdereference));
+return nodes_iterator(CG->end(), &CGGetValue);
   }
-  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
 
   static unsigned size(clang::CallGraph *CG) {
 return CG->size();
@@ -229,20 +224,20 @@
 return CGN->getRoot();
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function
-  DerefFun;
+
+  static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; }
+
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
   typedef mapped_iterator nodes_iterator;
+  decltype(&CGGetValue)>
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(const clang::CallGraph *CG) {
-return map_iterator(CG->begin(), DerefFun(CGdereference));
+return nodes_iterator(CG->begin(), &CGGetValue);
   }
   static nodes_iterator nodes_end(const clang::CallGraph *CG) {
-return map_iterator(CG->end(), DerefFun(CGdereference));
+return nodes_iterator(CG->end(), &CGGetValue);
   }
-  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
-
   static unsigned size(const clang::CallGraph *CG) {
 return CG->size();
   }


Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -173,26 +173,20 @@
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
   typedef clang::CallGraphNode *NodeRef;
-  typedef clang::CallGraphNode::CallRecord CallRecordTy;
-  typedef std::pointer_to_unary_function CGNDerefFun;
+  typedef NodeType::iterator ChildIteratorType;
+
   static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; }
-  typedef mapped_iterator ChildIteratorType;
   static inline ChildIteratorType child_begin(NodeType *N) {
-return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
-  }
-  static inline ChildIteratorType child_end  (NodeType *N) {
-return map_iterator(N->end(), CGNDerefFun(CGNDeref));
-  }
-  static clang::CallGraphNode *CGNDeref(CallRecordTy P) {
-return P;
+return N->begin();
   }
+  static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
 };
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
   typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
+
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; }
   static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();}
   static inline ChildI

r279329 - [CallGraph] Use decltype instead of pointer_to_unary_function. NFC.

2016-08-19 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Aug 19 16:52:42 2016
New Revision: 279329

URL: http://llvm.org/viewvc/llvm-project?rev=279329&view=rev
Log:
[CallGraph] Use decltype instead of pointer_to_unary_function. NFC.

Reviewers: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Analysis/CallGraph.h

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=279329&r1=279328&r2=279329&view=diff
==
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Fri Aug 19 16:52:42 2016
@@ -173,26 +173,20 @@ namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
   typedef clang::CallGraphNode *NodeRef;
-  typedef clang::CallGraphNode::CallRecord CallRecordTy;
-  typedef std::pointer_to_unary_function CGNDerefFun;
+  typedef NodeType::iterator ChildIteratorType;
+
   static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; }
-  typedef mapped_iterator ChildIteratorType;
   static inline ChildIteratorType child_begin(NodeType *N) {
-return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
-  }
-  static inline ChildIteratorType child_end  (NodeType *N) {
-return map_iterator(N->end(), CGNDerefFun(CGNDeref));
-  }
-  static clang::CallGraphNode *CGNDeref(CallRecordTy P) {
-return P;
+return N->begin();
   }
+  static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
 };
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
   typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
+
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}
   static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
@@ -205,18 +199,19 @@ template <> struct GraphTraitsgetRoot();  // Start at the external node!
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function
-  DerefFun;
+
+  static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; }
+
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
-  typedef mapped_iterator nodes_iterator;
+  typedef mapped_iterator
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(clang::CallGraph *CG) {
-return map_iterator(CG->begin(), DerefFun(CGdereference));
+return nodes_iterator(CG->begin(), &CGGetValue);
   }
   static nodes_iterator nodes_end  (clang::CallGraph *CG) {
-return map_iterator(CG->end(), DerefFun(CGdereference));
+return nodes_iterator(CG->end(), &CGGetValue);
   }
-  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
 
   static unsigned size(clang::CallGraph *CG) {
 return CG->size();
@@ -229,20 +224,20 @@ template <> struct GraphTraitsgetRoot();
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function
-  DerefFun;
+
+  static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; }
+
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
   typedef mapped_iterator nodes_iterator;
+  decltype(&CGGetValue)>
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(const clang::CallGraph *CG) {
-return map_iterator(CG->begin(), DerefFun(CGdereference));
+return nodes_iterator(CG->begin(), &CGGetValue);
   }
   static nodes_iterator nodes_end(const clang::CallGraph *CG) {
-return map_iterator(CG->end(), DerefFun(CGdereference));
+return nodes_iterator(CG->end(), &CGGetValue);
   }
-  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
-
   static unsigned size(const clang::CallGraph *CG) {
 return CG->size();
   }


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


Re: [PATCH] D23726: [CallGraph] Use decltype instead of pointer_to_unary_function. NFC.

2016-08-19 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279329: [CallGraph] Use decltype instead of 
pointer_to_unary_function. NFC. (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23726?vs=68733&id=68736#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23726

Files:
  cfe/trunk/include/clang/Analysis/CallGraph.h

Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -173,26 +173,20 @@
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
   typedef clang::CallGraphNode *NodeRef;
-  typedef clang::CallGraphNode::CallRecord CallRecordTy;
-  typedef std::pointer_to_unary_function CGNDerefFun;
+  typedef NodeType::iterator ChildIteratorType;
+
   static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; }
-  typedef mapped_iterator ChildIteratorType;
   static inline ChildIteratorType child_begin(NodeType *N) {
-return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
-  }
-  static inline ChildIteratorType child_end  (NodeType *N) {
-return map_iterator(N->end(), CGNDerefFun(CGNDeref));
-  }
-  static clang::CallGraphNode *CGNDeref(CallRecordTy P) {
-return P;
+return N->begin();
   }
+  static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
 };
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
   typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
+
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}
   static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
@@ -205,18 +199,19 @@
 return CGN->getRoot();  // Start at the external node!
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function
-  DerefFun;
+
+  static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; }
+
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
-  typedef mapped_iterator nodes_iterator;
+  typedef mapped_iterator
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(clang::CallGraph *CG) {
-return map_iterator(CG->begin(), DerefFun(CGdereference));
+return nodes_iterator(CG->begin(), &CGGetValue);
   }
   static nodes_iterator nodes_end  (clang::CallGraph *CG) {
-return map_iterator(CG->end(), DerefFun(CGdereference));
+return nodes_iterator(CG->end(), &CGGetValue);
   }
-  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
 
   static unsigned size(clang::CallGraph *CG) {
 return CG->size();
@@ -229,20 +224,20 @@
 return CGN->getRoot();
   }
   typedef std::pair PairTy;
-  typedef std::pointer_to_unary_function
-  DerefFun;
+
+  static clang::CallGraphNode *CGGetValue(PairTy P) { return P.second; }
+
   // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
   typedef mapped_iterator nodes_iterator;
+  decltype(&CGGetValue)>
+  nodes_iterator;
 
   static nodes_iterator nodes_begin(const clang::CallGraph *CG) {
-return map_iterator(CG->begin(), DerefFun(CGdereference));
+return nodes_iterator(CG->begin(), &CGGetValue);
   }
   static nodes_iterator nodes_end(const clang::CallGraph *CG) {
-return map_iterator(CG->end(), DerefFun(CGdereference));
+return nodes_iterator(CG->end(), &CGGetValue);
   }
-  static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; }
-
   static unsigned size(const clang::CallGraph *CG) {
 return CG->size();
   }


Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -173,26 +173,20 @@
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
   typedef clang::CallGraphNode *NodeRef;
-  typedef clang::CallGraphNode::CallRecord CallRecordTy;
-  typedef std::pointer_to_unary_function CGNDerefFun;
+  typedef NodeType::iterator ChildIteratorType;
+
   static NodeType *getEntryNode(clang::CallGraphNode *CGN) { return CGN; }
-  typedef mapped_iterator ChildIteratorType;
   static inline ChildIteratorType child_begin(NodeType *N) {
-return map_iterator(N->begin(), CGNDerefFun(CGNDeref));
-  }
-  static inline ChildIteratorType child_end  (NodeType *N) {
-return map_iterator(N->end(), CGNDerefFun(CGNDeref));
-  }
-  static clang::CallGraphNode *CGNDeref(CallRecordTy P) {
-return P;
+return N->begin();
   }
+  static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
 };
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
   typedef const clang::CallGrap

[PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-19 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added subscribers: llvm-commits, cfe-commits.
Herald added subscribers: mzolotukhin, MatzeB.

This should finish the GraphTraits migration.

https://reviews.llvm.org/D23730

Files:
  cfe/trunk/include/clang/AST/StmtGraphTraits.h
  cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  cfe/trunk/lib/Serialization/ModuleManager.cpp
  llvm/trunk/include/llvm/ADT/GraphTraits.h
  llvm/trunk/include/llvm/Analysis/CallGraph.h
  llvm/trunk/include/llvm/Analysis/Interval.h
  llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
  llvm/trunk/include/llvm/Analysis/LoopInfo.h
  llvm/trunk/include/llvm/Analysis/PostDominators.h
  llvm/trunk/include/llvm/Analysis/RegionIterator.h
  llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/trunk/include/llvm/CodeGen/MachineDominators.h
  llvm/trunk/include/llvm/CodeGen/MachineFunction.h
  llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h
  llvm/trunk/include/llvm/CodeGen/MachineRegionInfo.h
  llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h
  llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/trunk/include/llvm/IR/CFG.h
  llvm/trunk/include/llvm/IR/Dominators.h
  llvm/trunk/include/llvm/IR/Type.h
  llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h
  llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
  llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
  llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/trunk/unittests/ADT/SCCIteratorTest.cpp
  llvm/trunk/unittests/Analysis/CallGraphTest.cpp

Index: llvm/trunk/unittests/Analysis/CallGraphTest.cpp
===
--- llvm/trunk/unittests/Analysis/CallGraphTest.cpp
+++ llvm/trunk/unittests/Analysis/CallGraphTest.cpp
@@ -17,29 +17,29 @@
 namespace {
 
 template  void canSpecializeGraphTraitsIterators(Ty *G) {
-  typedef typename GraphTraits::NodeType NodeTy;
+  typedef typename GraphTraits::NodeRef NodeRef;
 
   auto I = GraphTraits::nodes_begin(G);
   auto E = GraphTraits::nodes_end(G);
   auto X = ++I;
 
   // Should be able to iterate over all nodes of the graph.
-  static_assert(std::is_same::value,
+  static_assert(std::is_same::value,
 "Node type does not match");
-  static_assert(std::is_same::value,
+  static_assert(std::is_same::value,
 "Node type does not match");
-  static_assert(std::is_same::value,
+  static_assert(std::is_same::value,
 "Node type does not match");
 
-  NodeTy *N = GraphTraits::getEntryNode(G);
+  NodeRef N = GraphTraits::getEntryNode(G);
 
-  auto S = GraphTraits::child_begin(N);
-  auto F = GraphTraits::child_end(N);
+  auto S = GraphTraits::child_begin(N);
+  auto F = GraphTraits::child_end(N);
 
   // Should be able to iterate over immediate successors of a node.
-  static_assert(std::is_same::value,
+  static_assert(std::is_same::value,
 "Node type does not match");
-  static_assert(std::is_same::value,
+  static_assert(std::is_same::value,
 "Node type does not match");
 }
 
Index: llvm/trunk/unittests/ADT/SCCIteratorTest.cpp
===
--- llvm/trunk/unittests/ADT/SCCIteratorTest.cpp
+++ llvm/trunk/unittests/ADT/SCCIteratorTest.cpp
@@ -229,15 +229,16 @@
 
 template 
 struct GraphTraits > {
-  typedef typename Graph::NodeType NodeType;
   typedef typename Graph::NodeType *NodeRef;
   typedef typename Graph::ChildIterator ChildIteratorType;
 
- static inline NodeType *getEntryNode(const Graph &G) { return G.AccessNode(0); }
- static inline ChildIteratorType child_begin(NodeType *Node) {
-   return Graph::child_begin(Node);
+  static inline NodeRef getEntryNode(const Graph &G) {
+return G.AccessNode(0);
+  }
+  static inline ChildIteratorType child_begin(NodeRef Node) {
+return Graph::child_begin(Node);
  }
- static inline ChildIteratorType child_end(NodeType *Node) {
+ static inline ChildIteratorType child_end(NodeRef Node) {
return Graph::child_end(Node);
  }
 };
Index: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
===
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -332,23 +332,18 @@
 
 namespace llvm {
 template <> struct GraphTraits {
-  typedef ArgumentGraphNode NodeType;
   typedef ArgumentGraphNode *NodeRef;
   typedef SmallVectorImpl::iterator ChildIteratorType;
 
-  static inline NodeType *getEntryNode(NodeType *A) { return A; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline NodeRef getEntryNode(NodeRef A) { return A; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return N->Uses.begin();
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return

Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D23730#522396, @dblaikie wrote:

> Not all of these already had NodeRef implemented - that implies that some 
> algorithms weren't using NodeRef before this change, or that these traits are 
> unused? I thought the plan was to migrate each algorithm then just do a 
> strict cleanup. Did that not pan out/some other aspects I'm forgetting?


I think those traits are unused. Notice that by merely removing "NodeType *" 
declarations, the build/tests doesn't break, so at least they are not covered 
by the tests.


https://reviews.llvm.org/D23730



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


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
timshen added inline comments.


Comment at: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h:684-688
@@ -684,7 +683,7 @@
 typedef SUnitIterator ChildIteratorType;
-static inline NodeType *getEntryNode(SUnit *N) { return N; }
-static inline ChildIteratorType child_begin(NodeType *N) {
+static inline NodeRef getEntryNode(SUnit *N) { return N; }
+static inline ChildIteratorType child_begin(NodeRef N) {
   return SUnitIterator::begin(N);
 }
-static inline ChildIteratorType child_end(NodeType *N) {
+static inline ChildIteratorType child_end(NodeRef N) {
   return SUnitIterator::end(N);

dblaikie wrote:
> If you like you could probably (separate commit) drop the 'inline' from these 
> functions, they're implicitly inline anyway
Sure, I can do that in a following patch.


https://reviews.llvm.org/D23730



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


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D23730#522537, @dblaikie wrote:

> I'd sort of be inclined to remove them, then - but I leave that up to you.


It looks like people create some class, and add GraphTraits specialization for 
it, in the hope that others can use it, but didn't write a test. The right 
thing is to add the test, but I'm not going to be the one. :)

So I'll keep them.


https://reviews.llvm.org/D23730



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


r279475 - [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Aug 22 16:09:30 2016
New Revision: 279475

URL: http://llvm.org/viewvc/llvm-project?rev=279475&view=rev
Log:
[GraphTraits] Replace all NodeType usage with NodeRef

This should finish the GraphTraits migration.

Differential Revision: http://reviews.llvm.org/D23730

Modified:
cfe/trunk/include/clang/AST/StmtGraphTraits.h
cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/include/clang/AST/StmtGraphTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtGraphTraits.h?rev=279475&r1=279474&r2=279475&view=diff
==
--- cfe/trunk/include/clang/AST/StmtGraphTraits.h (original)
+++ cfe/trunk/include/clang/AST/StmtGraphTraits.h Mon Aug 22 16:09:30 2016
@@ -25,19 +25,18 @@ namespace llvm {
 
 
 template <> struct GraphTraits {
-  typedef clang::Stmt   NodeType;
   typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
-  static NodeType* getEntryNode(clang::Stmt* S) { return S; }
+  static NodeRef getEntryNode(clang::Stmt *S) { return S; }
 
-  static inline ChildIteratorType child_begin(NodeType* N) {
+  static inline ChildIteratorType child_begin(NodeRef N) {
 if (N) return N->child_begin();
 else return ChildIteratorType();
   }
 
-  static inline ChildIteratorType child_end(NodeType* N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 if (N) return N->child_end();
 else return ChildIteratorType();
   }
@@ -53,19 +52,18 @@ template <> struct GraphTraits struct GraphTraits {
-  typedef const clang::Stmt   NodeType;
   typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
-  static NodeType* getEntryNode(const clang::Stmt* S) { return S; }
+  static NodeRef getEntryNode(const clang::Stmt *S) { return S; }
 
-  static inline ChildIteratorType child_begin(NodeType* N) {
+  static inline ChildIteratorType child_begin(NodeRef N) {
 if (N) return N->child_begin();
 else return ChildIteratorType();
   }
 
-  static inline ChildIteratorType child_end(NodeType* N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 if (N) return N->child_end();
 else return ChildIteratorType();
   }

Modified: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Dominators.h?rev=279475&r1=279474&r2=279475&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h Mon Aug 22 16:09:30 
2016
@@ -167,19 +167,12 @@ private:
 ///
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
-  typedef ::clang::DomTreeNode NodeType;
   typedef ::clang::DomTreeNode *NodeRef;
-  typedef NodeType::iterator  ChildIteratorType;
+  typedef ::clang::DomTreeNode::iterator ChildIteratorType;
 
-  static NodeType *getEntryNode(NodeType *N) {
-return N;
-  }
-  static inline ChildIteratorType child_begin(NodeType *N) {
-return N->begin();
-  }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return N->end();
-  }
+  static NodeRef getEntryNode(NodeRef N) { return N; }
+  static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
+  static inline ChildIteratorType child_end(NodeRef N) { return N->end(); }
 
   typedef llvm::pointer_iterator>
   nodes_iterator;
@@ -195,7 +188,7 @@ template <> struct GraphTraits< ::clang:
 
 template <> struct GraphTraits< ::clang::DominatorTree* >
   : public GraphTraits< ::clang::DomTreeNode* > {
-  static NodeType *getEntryNode(::clang::DominatorTree *DT) {
+  static NodeRef getEntryNode(::clang::DominatorTree *DT) {
 return DT->getRootNode();
   }
 

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=279475&r1=279474&r2=279475&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Aug 22 16:09:30 2016
@@ -945,63 +945,59 @@ template <> struct simplify_type< ::clan
 // Traits for: CFGBlock
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
-  typedef ::clang::CFGBlock NodeType;
   typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
-  static NodeType* getEntryNode(::clang::CFGBlock *BB)
-  { return BB; }
+  s

Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279475: [GraphTraits] Replace all NodeType usage with 
NodeRef (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23730?vs=68748&id=68912#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23730

Files:
  cfe/trunk/include/clang/AST/StmtGraphTraits.h
  cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  cfe/trunk/lib/Serialization/ModuleManager.cpp
  llvm/trunk/include/llvm/ADT/GraphTraits.h
  llvm/trunk/include/llvm/Analysis/CallGraph.h
  llvm/trunk/include/llvm/Analysis/Interval.h
  llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
  llvm/trunk/include/llvm/Analysis/LoopInfo.h
  llvm/trunk/include/llvm/Analysis/PostDominators.h
  llvm/trunk/include/llvm/Analysis/RegionIterator.h
  llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/trunk/include/llvm/CodeGen/MachineDominators.h
  llvm/trunk/include/llvm/CodeGen/MachineFunction.h
  llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h
  llvm/trunk/include/llvm/CodeGen/MachineRegionInfo.h
  llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h
  llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/trunk/include/llvm/IR/CFG.h
  llvm/trunk/include/llvm/IR/Dominators.h
  llvm/trunk/include/llvm/IR/Type.h
  llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h
  llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
  llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
  llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/trunk/unittests/ADT/SCCIteratorTest.cpp
  llvm/trunk/unittests/Analysis/CallGraphTest.cpp

Index: llvm/trunk/include/llvm/IR/Type.h
===
--- llvm/trunk/include/llvm/IR/Type.h
+++ llvm/trunk/include/llvm/IR/Type.h
@@ -429,29 +429,27 @@
 // graph of sub types.
 
 template <> struct GraphTraits {
-  typedef Type NodeType;
   typedef Type *NodeRef;
   typedef Type::subtype_iterator ChildIteratorType;
 
-  static inline NodeType *getEntryNode(Type *T) { return T; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline NodeRef getEntryNode(Type *T) { return T; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return N->subtype_begin();
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 return N->subtype_end();
   }
 };
 
 template <> struct GraphTraits {
-  typedef const Type NodeType;
   typedef const Type *NodeRef;
   typedef Type::subtype_iterator ChildIteratorType;
 
-  static inline NodeType *getEntryNode(NodeType *T) { return T; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline NodeRef getEntryNode(NodeRef T) { return T; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return N->subtype_begin();
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 return N->subtype_end();
   }
 };
Index: llvm/trunk/include/llvm/IR/CFG.h
===
--- llvm/trunk/include/llvm/IR/CFG.h
+++ llvm/trunk/include/llvm/IR/CFG.h
@@ -154,65 +154,51 @@
 // graph of basic blocks...
 
 template <> struct GraphTraits {
-  typedef BasicBlock NodeType;
   typedef BasicBlock *NodeRef;
   typedef succ_iterator ChildIteratorType;
 
-  static NodeType *getEntryNode(BasicBlock *BB) { return BB; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static NodeRef getEntryNode(BasicBlock *BB) { return BB; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return succ_begin(N);
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return succ_end(N);
-  }
+  static inline ChildIteratorType child_end(NodeRef N) { return succ_end(N); }
 };
 
 template <> struct GraphTraits {
-  typedef const BasicBlock NodeType;
   typedef const BasicBlock *NodeRef;
   typedef succ_const_iterator ChildIteratorType;
 
-  static NodeType *getEntryNode(const BasicBlock *BB) { return BB; }
+  static NodeRef getEntryNode(const BasicBlock *BB) { return BB; }
 
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return succ_begin(N);
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return succ_end(N);
-  }
+  static inline ChildIteratorType child_end(NodeRef N) { return succ_end(N); }
 };
 
 // Provide specializations of GraphTraits to be able to treat a function as a
 // graph of basic blocks... and to walk it in inverse order.  Inverse order for
 // a function is considered to be when traversing the predecessor edges of a BB
 // instead of the successor edges.
 //
 template <> struct GraphTraits > {
-  typedef BasicBlock Node

[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-08-29 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added reviewers: rsmith, pirama.
timshen added a subscriber: cfe-commits.

https://reviews.llvm.org/D24010

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/Analysis/ReachableCode.cpp
  clang/test/SemaCXX/PR29152.cpp

Index: clang/test/SemaCXX/PR29152.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct Vector {
+  struct iterator {
+bool operator==(const iterator &) const;
+  };
+  iterator end();
+};
+
+void Bar();
+Vector::iterator Find(Vector &a);
+
+void Foo(Vector &a) {
+  if (False && Find(a) == a.end()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.


Index: clang/test/SemaCXX/PR29152.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct Vector {
+  struct iterator {
+bool operator==(const iterator &) const;
+  };
+  iterator end();
+};
+
+void Bar();
+Vector::iterator Find(Vector &a);
+
+void Foo(Vector &a) {
+  if (False && Find(a) == a.end()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip captured
   /// stmt at the top, if \a IgnoreCaptured is true.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r280257 - s/static inline/static/ for headers I have changed in r279475. NFC.

2016-08-31 Thread Tim Shen via cfe-commits
Author: timshen
Date: Wed Aug 31 11:48:13 2016
New Revision: 280257

URL: http://llvm.org/viewvc/llvm-project?rev=280257&view=rev
Log:
s/static inline/static/ for headers I have changed in r279475. NFC.

Modified:
cfe/trunk/include/clang/AST/StmtGraphTraits.h
cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h

Modified: cfe/trunk/include/clang/AST/StmtGraphTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtGraphTraits.h?rev=280257&r1=280256&r2=280257&view=diff
==
--- cfe/trunk/include/clang/AST/StmtGraphTraits.h (original)
+++ cfe/trunk/include/clang/AST/StmtGraphTraits.h Wed Aug 31 11:48:13 2016
@@ -31,12 +31,12 @@ template <> struct GraphTraitschild_begin();
 else return ChildIteratorType();
   }
 
-  static inline ChildIteratorType child_end(NodeRef N) {
+  static ChildIteratorType child_end(NodeRef N) {
 if (N) return N->child_end();
 else return ChildIteratorType();
   }
@@ -58,12 +58,12 @@ template <> struct GraphTraitschild_begin();
 else return ChildIteratorType();
   }
 
-  static inline ChildIteratorType child_end(NodeRef N) {
+  static ChildIteratorType child_end(NodeRef N) {
 if (N) return N->child_end();
 else return ChildIteratorType();
   }

Modified: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Dominators.h?rev=280257&r1=280256&r2=280257&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h Wed Aug 31 11:48:13 
2016
@@ -171,8 +171,8 @@ template <> struct GraphTraits< ::clang:
   typedef ::clang::DomTreeNode::iterator ChildIteratorType;
 
   static NodeRef getEntryNode(NodeRef N) { return N; }
-  static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
-  static inline ChildIteratorType child_end(NodeRef N) { return N->end(); }
+  static ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
+  static ChildIteratorType child_end(NodeRef N) { return N->end(); }
 
   typedef llvm::pointer_iterator>
   nodes_iterator;

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=280257&r1=280256&r2=280257&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Wed Aug 31 11:48:13 2016
@@ -950,11 +950,9 @@ template <> struct GraphTraits< ::clang:
 
   static NodeRef getEntryNode(::clang::CFGBlock *BB) { return BB; }
 
-  static inline ChildIteratorType child_begin(NodeRef N) {
-return N->succ_begin();
-  }
+  static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
 
-  static inline ChildIteratorType child_end(NodeRef N) { return N->succ_end(); 
}
+  static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
 };
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
@@ -963,11 +961,9 @@ template <> struct GraphTraits< const ::
 
   static NodeRef getEntryNode(const clang::CFGBlock *BB) { return BB; }
 
-  static inline ChildIteratorType child_begin(NodeRef N) {
-return N->succ_begin();
-  }
+  static ChildIteratorType child_begin(NodeRef N) { return N->succ_begin(); }
 
-  static inline ChildIteratorType child_end(NodeRef N) { return N->succ_end(); 
}
+  static ChildIteratorType child_end(NodeRef N) { return N->succ_end(); }
 };
 
 template <> struct GraphTraits > {
@@ -978,11 +974,9 @@ template <> struct GraphTraitspred_begin();
-  }
+  static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
 
-  static inline ChildIteratorType child_end(NodeRef N) { return N->pred_end(); 
}
+  static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
 };
 
 template <> struct GraphTraits > {
@@ -993,11 +987,9 @@ template <> struct GraphTraitspred_begin();
-  }
+  static ChildIteratorType child_begin(NodeRef N) { return N->pred_begin(); }
 
-  static inline ChildIteratorType child_end(NodeRef N) { return N->pred_end(); 
}
+  static ChildIteratorType child_end(NodeRef N) { return N->pred_end(); }
 };
 
 // Traits for: CFG

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=280257&r1=280256&r2=280257&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensiti

[PATCH] D24333: [CleanupInfo] Use cleanupsHaveSideEffects instead of exprNeedsCleanups in assertions

2016-09-08 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.

Before r272296, the assertion was !ExprNeedsCleanups, which means that there is 
no cleanups (with dtor calls). It should still check so after r272296. This 
fixes pr30306.

https://reviews.llvm.org/D24333

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/cleanup-side-effects-assert.cpp

Index: clang/test/SemaCXX/cleanup-side-effects-assert.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cleanup-side-effects-assert.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int f(int const &p) { return p; }
+
+struct A {
+  ~A();
+};
+
+template 
+void g(T) { int a[f(3)]; } // expected-no-diagnostics
+
+int main() {
+  g(2);
+  return 0;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5746,7 +5746,7 @@
 
   unsigned FirstCleanup = ExprEvalContexts.back().NumCleanupObjects;
   assert(ExprCleanupObjects.size() >= FirstCleanup);
-  assert(Cleanup.exprNeedsCleanups() ||
+  assert(Cleanup.cleanupsHaveSideEffects() ||
  ExprCleanupObjects.size() == FirstCleanup);
   if (!Cleanup.exprNeedsCleanups())
 return SubExpr;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11736,7 +11736,7 @@
 
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within StmtExpr not correctly bound!");
   PopExpressionEvaluationContext();
 
@@ -12204,7 +12204,7 @@
   // Leave the expression-evaluation context.
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within block not correctly bound!");
   PopExpressionEvaluationContext();
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11830,7 +11830,8 @@
 assert(ExprCleanupObjects.size() ==
ExprEvalContexts.back().NumCleanupObjects &&
"Leftover temporaries in function");
-assert(!Cleanup.exprNeedsCleanups() && "Unaccounted cleanups in function");
+assert(!Cleanup.cleanupsHaveSideEffects() &&
+   "Unaccounted cleanups in function");
 assert(MaybeODRUseExprs.empty() &&
"Leftover expressions for odr-use checking");
   }


Index: clang/test/SemaCXX/cleanup-side-effects-assert.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cleanup-side-effects-assert.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int f(int const &p) { return p; }
+
+struct A {
+  ~A();
+};
+
+template 
+void g(T) { int a[f(3)]; } // expected-no-diagnostics
+
+int main() {
+  g(2);
+  return 0;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5746,7 +5746,7 @@
 
   unsigned FirstCleanup = ExprEvalContexts.back().NumCleanupObjects;
   assert(ExprCleanupObjects.size() >= FirstCleanup);
-  assert(Cleanup.exprNeedsCleanups() ||
+  assert(Cleanup.cleanupsHaveSideEffects() ||
  ExprCleanupObjects.size() == FirstCleanup);
   if (!Cleanup.exprNeedsCleanups())
 return SubExpr;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11736,7 +11736,7 @@
 
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within StmtExpr not correctly bound!");
   PopExpressionEvaluationContext();
 
@@ -12204,7 +12204,7 @@
   // Leave the expression-evaluation context.
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within block not correctly bound!");
   PopExpressionEvaluationContext();
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11830,7 +11830,8 @@
 assert(ExprCleanupObjects.size() ==
ExprEvalContexts.back().NumCleanupObjects &&
"Leftover temporaries in function");
-ass

Re: [PATCH] D24333: [CleanupInfo] Use cleanupsHaveSideEffects instead of exprNeedsCleanups in assertions

2016-09-08 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 70667.
timshen added a comment.

Update the test file name and remove unused code.


https://reviews.llvm.org/D24333

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/pr30306.cpp

Index: clang/test/SemaCXX/pr30306.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr30306.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int f(int const &p) { return p; }
+
+template 
+void g(T) { int a[f(3)]; } // expected-no-diagnostics
+
+int main() {
+  g(2);
+  return 0;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5746,7 +5746,7 @@
 
   unsigned FirstCleanup = ExprEvalContexts.back().NumCleanupObjects;
   assert(ExprCleanupObjects.size() >= FirstCleanup);
-  assert(Cleanup.exprNeedsCleanups() ||
+  assert(Cleanup.cleanupsHaveSideEffects() ||
  ExprCleanupObjects.size() == FirstCleanup);
   if (!Cleanup.exprNeedsCleanups())
 return SubExpr;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11736,7 +11736,7 @@
 
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within StmtExpr not correctly bound!");
   PopExpressionEvaluationContext();
 
@@ -12204,7 +12204,7 @@
   // Leave the expression-evaluation context.
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within block not correctly bound!");
   PopExpressionEvaluationContext();
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11830,7 +11830,8 @@
 assert(ExprCleanupObjects.size() ==
ExprEvalContexts.back().NumCleanupObjects &&
"Leftover temporaries in function");
-assert(!Cleanup.exprNeedsCleanups() && "Unaccounted cleanups in function");
+assert(!Cleanup.cleanupsHaveSideEffects() &&
+   "Unaccounted cleanups in function");
 assert(MaybeODRUseExprs.empty() &&
"Leftover expressions for odr-use checking");
   }


Index: clang/test/SemaCXX/pr30306.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr30306.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int f(int const &p) { return p; }
+
+template 
+void g(T) { int a[f(3)]; } // expected-no-diagnostics
+
+int main() {
+  g(2);
+  return 0;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5746,7 +5746,7 @@
 
   unsigned FirstCleanup = ExprEvalContexts.back().NumCleanupObjects;
   assert(ExprCleanupObjects.size() >= FirstCleanup);
-  assert(Cleanup.exprNeedsCleanups() ||
+  assert(Cleanup.cleanupsHaveSideEffects() ||
  ExprCleanupObjects.size() == FirstCleanup);
   if (!Cleanup.exprNeedsCleanups())
 return SubExpr;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11736,7 +11736,7 @@
 
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within StmtExpr not correctly bound!");
   PopExpressionEvaluationContext();
 
@@ -12204,7 +12204,7 @@
   // Leave the expression-evaluation context.
   if (hasAnyUnrecoverableErrorsInThisFunction())
 DiscardCleanupsInEvaluationContext();
-  assert(!Cleanup.exprNeedsCleanups() &&
+  assert(!Cleanup.cleanupsHaveSideEffects() &&
  "cleanups within block not correctly bound!");
   PopExpressionEvaluationContext();
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11830,7 +11830,8 @@
 assert(ExprCleanupObjects.size() ==
ExprEvalContexts.back().NumCleanupObjects &&
"Leftover temporaries in function");
-assert(!Cleanup.exprNeedsCleanups() && "Unaccounted cleanups in function");
+assert(!Cleanup.cleanupsHaveSideEffects() &&
+   "Unaccounted cleanups in function");
 assert(MaybeODRUseExprs.empty() &&
"Leftover expressions for odr-use checking");
   }
_

r292659 - [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

2017-01-20 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Jan 20 16:05:33 2017
New Revision: 292659

URL: http://llvm.org/viewvc/llvm-project?rev=292659&view=rev
Log:
[Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))

For a << b (as original vec_sl does), if b >= sizeof(a) * 8, the
behavior is undefined. However, Power instructions do define the
behavior, which is equivalent to a << (b % (sizeof(a) * 8)).

This patch changes altivec.h to use a << (b % (sizeof(a) * 8)), to
ensure the consistent semantic of the instructions. Then it combines
the generated multiple instructions back to a single shift.

This patch handles left shift only. Right shift, on the other hand, is
more complicated, considering arithematic/logical right shift.

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

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=292659&r1=292658&r2=292659&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Fri Jan 20 16:05:33 2017
@@ -8045,45 +8045,51 @@ static __inline__ vector float __ATTRS_o
 
 /* vec_sl */
 
-static __inline__ vector signed char __ATTRS_o_ai
-vec_sl(vector signed char __a, vector unsigned char __b) {
-  return __a << (vector signed char)__b;
-}
-
+// vec_sl does modulo arithmetic on __b first, so __b is allowed to be more
+// than the length of __a.
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_sl(vector unsigned char __a, vector unsigned char __b) {
-  return __a << __b;
+  return __a << (__b %
+ (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
 }
 
-static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
-   vector unsigned short __b) {
-  return __a << (vector short)__b;
+static __inline__ vector signed char __ATTRS_o_ai
+vec_sl(vector signed char __a, vector unsigned char __b) {
+  return (vector signed char)vec_sl((vector unsigned char)__a, __b);
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_sl(vector unsigned short __a, vector unsigned short __b) {
-  return __a << __b;
+  return __a << (__b % (vector unsigned short)(sizeof(unsigned short) *
+   __CHAR_BIT__));
 }
 
-static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
- vector unsigned int __b) {
-  return __a << (vector int)__b;
+static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a,
+   vector unsigned short __b) {
+  return (vector short)vec_sl((vector unsigned short)__a, __b);
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_sl(vector unsigned int __a, vector unsigned int __b) {
-  return __a << __b;
+  return __a << (__b %
+ (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
 }
 
-#ifdef __POWER8_VECTOR__
-static __inline__ vector signed long long __ATTRS_o_ai
-vec_sl(vector signed long long __a, vector unsigned long long __b) {
-  return __a << (vector long long)__b;
+static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a,
+ vector unsigned int __b) {
+  return (vector int)vec_sl((vector unsigned int)__a, __b);
 }
 
+#ifdef __POWER8_VECTOR__
 static __inline__ vector unsigned long long __ATTRS_o_ai
 vec_sl(vector unsigned long long __a, vector unsigned long long __b) {
-  return __a << __b;
+  return __a << (__b % (vector unsigned long long)(sizeof(unsigned long long) *
+   __CHAR_BIT__));
+}
+
+static __inline__ vector long long __ATTRS_o_ai
+vec_sl(vector long long __a, vector unsigned long long __b) {
+  return (vector long long)vec_sl((vector unsigned long long)__a, __b);
 }
 #endif
 

Modified: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-altivec.c?rev=292659&r1=292658&r2=292659&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c Fri Jan 20 16:05:33 2017
@@ -3419,28 +3419,40 @@ void test6() {
 
   /* vec_sl */
   res_vsc = vec_sl(vsc, vuc);
-// CHECK: shl <16 x i8>
-// CHECK-LE: shl <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: shl <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_sl(vuc, vuc);
-// CHECK: shl <16 x i8>
-// CHECK-LE: shl <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHEC

r292839 - [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2017-01-23 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Jan 23 16:39:35 2017
New Revision: 292839

URL: http://llvm.org/viewvc/llvm-project?rev=292839&view=rev
Log:
[APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, 
IEEEdouble)

Summary:
This patch changes the layout of DoubleAPFloat, and adjust all
operations to do either:
1) (IEEEdouble, IEEEdouble) -> (uint64_t, uint64_t) -> PPCDoubleDoubleImpl,
   then run the old algorithm.
2) Do the right thing directly.

1) includes multiply, divide, remainder, mod, fusedMultiplyAdd, roundToIntegral,
   convertFromString, next, convertToInteger, convertFromAPInt,
   convertFromSignExtendedInteger, convertFromZeroExtendedInteger,
   convertToHexString, toString, getExactInverse.
2) includes makeZero, makeLargest, makeSmallest, makeSmallestNormalized,
   compare, bitwiseIsEqual, bitcastToAPInt, isDenormal, isSmallest,
   isLargest, isInteger, ilogb, scalbn, frexp, hash_value, Profile.

I could split this into two patches, e.g. use
1) for all operatoins first, then incrementally change some of them to
2). I didn't do that, because 1) involves code that converts data between
PPCDoubleDoubleImpl and (IEEEdouble, IEEEdouble) back and forth, and may
pessimize the compiler. Instead, I find easy functions and use
approach 2) for them directly.

Next step is to implement move multiply and divide from 1) to 2). I don't
have plans for other functions in 1).

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

Modified:
cfe/trunk/test/CodeGen/ppc64-complex-parms.c

Modified: cfe/trunk/test/CodeGen/ppc64-complex-parms.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc64-complex-parms.c?rev=292839&r1=292838&r2=292839&view=diff
==
--- cfe/trunk/test/CodeGen/ppc64-complex-parms.c (original)
+++ cfe/trunk/test/CodeGen/ppc64-complex-parms.c Mon Jan 23 16:39:35 2017
@@ -93,7 +93,7 @@ void bar_long_double(void) {
 // CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0
 // CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1
 // CHECK: store ppc_fp128 0xM4000, ppc_fp128* 
%[[VAR22]]
-// CHECK: store ppc_fp128 0xMC004, ppc_fp128* 
%[[VAR23]]
+// CHECK: store ppc_fp128 0xMC0048000, ppc_fp128* 
%[[VAR23]]
 // CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0
 // CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128, ppc_fp128* %[[VAR24]], 
align 16
 // CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1


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


r306756 - [ThinkLTO] Invoke build(Thin)?LTOPreLinkDefaultPipeline.

2017-06-29 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun 29 16:08:38 2017
New Revision: 306756

URL: http://llvm.org/viewvc/llvm-project?rev=306756&view=rev
Log:
[ThinkLTO] Invoke build(Thin)?LTOPreLinkDefaultPipeline.

Previously it doesn't actually invoke the designated new PM builder
functions.

This patch moves NameAnonGlobalPass out from PassBuilder, as Chandler
points out that PassBuilder is used for non-O0 builds, and for
optimizations only.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=306756&r1=306755&r2=306756&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 29 16:08:38 2017
@@ -54,6 +54,7 @@
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
+#include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
 using namespace clang;
@@ -881,17 +882,28 @@ void EmitAssemblyHelper::EmitAssemblyWit
   ModulePassManager MPM;
 
   if (!CodeGenOpts.DisableLLVMPasses) {
+bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
+bool IsLTO = CodeGenOpts.PrepareForLTO;
+
 if (CodeGenOpts.OptimizationLevel == 0) {
   // Build a minimal pipeline based on the semantics required by Clang,
   // which is just that always inlining occurs.
   MPM.addPass(AlwaysInlinerPass());
+  if (IsThinLTO)
+MPM.addPass(NameAnonGlobalPass());
 } else {
-  // Otherwise, use the default pass pipeline. We also have to map our
-  // optimization levels into one of the distinct levels used to configure
-  // the pipeline.
+  // Map our optimization levels into one of the distinct levels used to
+  // configure the pipeline.
   PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
-  MPM = PB.buildPerModuleDefaultPipeline(Level);
+  if (IsThinLTO) {
+MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
+MPM.addPass(NameAnonGlobalPass());
+  } else if (IsLTO) {
+MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
+  } else {
+MPM = PB.buildPerModuleDefaultPipeline(Level);
+  }
 }
   }
 


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


r306757 - [NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.

2017-06-29 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun 29 16:10:13 2017
New Revision: 306757

URL: http://llvm.org/viewvc/llvm-project?rev=306757&view=rev
Log:
[NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.

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

Added:
cfe/trunk/test/CodeGen/lto-newpm-pipeline.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=306757&r1=306756&r2=306757&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Jun 29 16:10:13 2017
@@ -323,6 +323,10 @@ def flto_unit: Flag<["-"], "flto-unit">,
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
+HelpText<"Prints debug information for the new pass manager">;
+def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
+HelpText<"Disables debug printing for the new pass manager">;
 
 
//===--===//
 // Dependency Output Options

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=306757&r1=306756&r2=306757&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Jun 29 16:10:13 2017
@@ -57,6 +57,8 @@ CODEGENOPT(DisableLifetimeMarkers, 1, 0)
 CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with 
optnone at O0
 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
  ///< pass manager.
+CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
+   ///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
 CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special metadata indicating what

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=306757&r1=306756&r2=306757&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 29 16:10:13 2017
@@ -879,7 +879,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   PB.registerLoopAnalyses(LAM);
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
-  ModulePassManager MPM;
+  ModulePassManager MPM(CodeGenOpts.DebugPassManager);
 
   if (!CodeGenOpts.DisableLLVMPasses) {
 bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
@@ -897,12 +897,15 @@ void EmitAssemblyHelper::EmitAssemblyWit
   PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
   if (IsThinLTO) {
-MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
+MPM = PB.buildThinLTOPreLinkDefaultPipeline(
+Level, CodeGenOpts.DebugPassManager);
 MPM.addPass(NameAnonGlobalPass());
   } else if (IsLTO) {
-MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
+MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
+CodeGenOpts.DebugPassManager);
   } else {
-MPM = PB.buildPerModuleDefaultPipeline(Level);
+MPM = PB.buildPerModuleDefaultPipeline(Level,
+   CodeGenOpts.DebugPassManager);
   }
 }
   }

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=306757&r1=306756&r2=306757&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun 29 16:10:13 2017
@@ -476,6 +476,10 @@ static bool ParseCodeGenArgs(CodeGenOpti
   OPT_fexperimental_new_pass_manager, 
OPT_fno_experimental_new_pass_manager,
   /* Default */ false);
 
+  Opts.DebugPassManager =
+  Args.hasFlag(OPT_fdebug_pass_manager, OPT_fno_debug_pass_manager,
+   /* Default */ false);
+
   if (Arg *A = Args.getLastArg(OPT_fveclib)) {
 StringRef Name = A->getValue();
 if (Name == "Accelerate")

Added

r294781 - [XRay] Implement powerpc64le xray.

2017-02-10 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Feb 10 15:03:24 2017
New Revision: 294781

URL: http://llvm.org/viewvc/llvm-project?rev=294781&view=rev
Log:
[XRay] Implement powerpc64le xray.

Summary:
powerpc64 big-endian is not supported, but I believe that most logic can
be shared, except for xray_powerpc64.cc.

Also add a function InvalidateInstructionCache to xray_util.h, which is
copied from llvm/Support/Memory.cpp. I'm not sure if I need to add a unittest,
and I don't know how.

Reviewers: dberris, echristo, iteratee, kbarton, hfinkel

Subscribers: mehdi_amini, nemanjai, mgorny, llvm-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=294781&r1=294780&r2=294781&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Feb 10 15:03:24 2017
@@ -5064,6 +5064,7 @@ void Clang::ConstructJob(Compilation &C,
   case llvm::Triple::x86_64:
   case llvm::Triple::arm:
   case llvm::Triple::aarch64:
+  case llvm::Triple::ppc64le:
 // Supported.
 break;
   default:


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


r295123 - [VLA] Handle VLA size expression in a full-expression context.

2017-02-14 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Feb 14 17:46:37 2017
New Revision: 295123

URL: http://llvm.org/viewvc/llvm-project?rev=295123&view=rev
Log:
[VLA] Handle VLA size expression in a full-expression context.

Summary: Previously the cleanups (e.g. dtor calls) are inserted into the
outer scope (e.g. function body scope), instead of it's own scope. After
the fix, the cleanups are inserted right after getting the size value.

This fixes pr30306.

Reviewers: rsmith

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Sema/pr30306.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=295123&r1=295122&r2=295123&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Feb 14 17:46:37 2017
@@ -3864,6 +3864,8 @@ void Sema::InstantiateFunctionDefinition
 if (Body.isInvalid())
   Function->setInvalidDecl();
 
+// FIXME: finishing the function body while in an expression evaluation
+// context seems wrong. Investigate more.
 ActOnFinishFunctionBody(Function, Body.get(),
 /*IsInstantiation=*/true);
 

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=295123&r1=295122&r2=295123&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Feb 14 17:46:37 2017
@@ -4603,8 +4603,15 @@ TreeTransform::TransformVariabl
   if (ElementType.isNull())
 return QualType();
 
-  ExprResult SizeResult
-= getDerived().TransformExpr(T->getSizeExpr());
+  ExprResult SizeResult;
+  {
+EnterExpressionEvaluationContext Context(SemaRef,
+ Sema::PotentiallyEvaluated);
+SizeResult = getDerived().TransformExpr(T->getSizeExpr());
+  }
+  if (SizeResult.isInvalid())
+return QualType();
+  SizeResult = SemaRef.ActOnFinishFullExpr(SizeResult.get());
   if (SizeResult.isInvalid())
 return QualType();
 

Added: cfe/trunk/test/Sema/pr30306.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pr30306.cpp?rev=295123&view=auto
==
--- cfe/trunk/test/Sema/pr30306.cpp (added)
+++ cfe/trunk/test/Sema/pr30306.cpp Tue Feb 14 17:46:37 2017
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++ -emit-llvm < %s | FileCheck %s
+
+struct A { A(int); ~A(); };
+int f(const A &);
+// CHECK: call void @_ZN1AC1Ei
+// CHECK-NEXT: call i32 @_Z1fRK1A
+// CHECK-NEXT: call void @_ZN1AD1Ev
+// CHECK: call void @_ZN1AC1Ei
+// CHECK-NEXT: call i32 @_Z1fRK1A
+// CHECK-NEXT: call void @_ZN1AD1Ev
+template void g() {
+  int a[f(3)];
+  int b[f(3)];
+}
+int main() { g(); }


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


r295127 - [VLA] Fix the test failure on msvc by specifying the triple.

2017-02-14 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Feb 14 18:01:12 2017
New Revision: 295127

URL: http://llvm.org/viewvc/llvm-project?rev=295127&view=rev
Log:
[VLA] Fix the test failure on msvc by specifying the triple.

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

Modified:
cfe/trunk/test/Sema/pr30306.cpp

Modified: cfe/trunk/test/Sema/pr30306.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pr30306.cpp?rev=295127&r1=295126&r2=295127&view=diff
==
--- cfe/trunk/test/Sema/pr30306.cpp (original)
+++ cfe/trunk/test/Sema/pr30306.cpp Tue Feb 14 18:01:12 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x c++ -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux-gnu -emit-llvm < %s | 
FileCheck %s
 
 struct A { A(int); ~A(); };
 int f(const A &);


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


Re: r295156 - Add a definition for __STRUCT_PARM_ALIGN__ for elfv2 and 64-bit darwin platforms to match what other compilers produce.

2017-02-15 Thread Tim Shen via cfe-commits
On Wed, Feb 15, 2017, 00:01 Eric Christopher via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echristo
> Date: Wed Feb 15 01:50:11 2017
> New Revision: 295156
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295156&view=rev
> Log:
> Add a definition for __STRUCT_PARM_ALIGN__ for elfv2 and 64-bit darwin
> platforms to match what other compilers produce.
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/test/Preprocessor/init.c
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=295156&r1=295155&r2=295156&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Wed Feb 15 01:50:11 2017
> @@ -1232,6 +1232,11 @@ void PPCTargetInfo::getTargetDefines(con
>if (LongDoubleWidth == 128)
>  Builder.defineMacro("__LONG_DOUBLE_128__");
>
> +  // Define this for elfv2 (64-bit only) or 64-bit darwin.
> +  if (ABI == "elfv2" ||
> +  (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))
>

I also see a "DarwinTargetInfo". Maybe this should be put there as well?

+Builder.defineMacro("__STRUCT_PARM_ALIGN__", "16");
> +
>if (Opts.AltiVec) {
>  Builder.defineMacro("__VEC__", "10206");
>  Builder.defineMacro("__ALTIVEC__");
>
> Modified: cfe/trunk/test/Preprocessor/init.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=295156&r1=295155&r2=295156&view=diff
>
> ==
> --- cfe/trunk/test/Preprocessor/init.c (original)
> +++ cfe/trunk/test/Preprocessor/init.c Wed Feb 15 01:50:11 2017
> @@ -5635,6 +5635,7 @@
>  // PPC64LE:#define __SIZE_MAX__ 18446744073709551615UL
>  // PPC64LE:#define __SIZE_TYPE__ long unsigned int
>  // PPC64LE:#define __SIZE_WIDTH__ 64
> +// PPC64LE:#define __STRUCT_PARM_ALIGN__ 16
>  // PPC64LE:#define __UINT16_C_SUFFIX__
>  // PPC64LE:#define __UINT16_MAX__ 65535
>  // PPC64LE:#define __UINT16_TYPE__ unsigned short
>
>
> ___
> 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


r295778 - [XRay] Merge xray clang flag tests, and add powerpc64le.

2017-02-21 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Feb 21 16:30:00 2017
New Revision: 295778

URL: http://llvm.org/viewvc/llvm-project?rev=295778&view=rev
Log:
[XRay] Merge xray clang flag tests, and add powerpc64le.

Summary: I'm not sure why they were in different files, but it's kind of harder 
to maintain. I create this patch partially for initiate a discussion.

Reviewers: dberris

Subscribers: nemanjai, cfe-commits

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

Removed:
cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
Modified:
cfe/trunk/test/CodeGen/xray-attributes-supported.cpp

Removed: cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp?rev=295777&view=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-arm.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"

Removed: cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp?rev=295777&view=auto
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported-mips.cpp (removed)
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"

Modified: cfe/trunk/test/CodeGen/xray-attributes-supported.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-attributes-supported.cpp?rev=295778&r1=295777&r2=295778&view=diff
==
--- cfe/trunk/test/CodeGen/xray-attributes-supported.cpp (original)
+++ cfe/trunk/test/CodeGen/xray-attributes-supported.cpp Tue Feb 21 16:30:00 
2017
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
 [[clang::xray_always_instrument]] void foo() {


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


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-17 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 74894.
timshen marked an inline comment as done.
timshen added a comment.

Updated file location and documentation.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+}
Index: libcxx/include/regex

[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-17 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D25595#571171, @mclow.lists wrote:

> I like the fix. :-)
>
> However, I think that the test, rather than going in a bug specific file 
> (pr21597.pass.cpp), should be added to the existing tests - where it should 
> have been in the first place.  (If this test had been there in the first 
> place, we would have realized that this feature didn't work)


Agree.

> Also, putting the test in as 
> `test/std/re/re.const/re.matchflag/match_not_null.pass.cpp` might cause 
> someone to look at the contents of that directory and say "Crap! We're 
> missing tests for `match_not_bow`, `match_not_eow`, `match_any`, 
> `match_continuous` and `match_prev_avail` as well" (and probably others).

Making people realize the fact that we don't have tests for `match_not_bow`, 
etc. isn't bad, is it? Hopefully it motivates people to add tests. So I'll move 
the file to `re.const/re.matchflag/match_not_null.pass.cpp` for now.

BTW, `re.const/re.matchflag/match_flag_type.pass.cpp` contains match_not_bow, 
but it doesn't actually test the functionality.


https://reviews.llvm.org/D25595



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


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D25595#574364, @mclow.lists wrote:

> Do we need to test calling `regex_match` with `match_not_null`?
>  If not, then I think this is good to go.


Done.

> Do you have commit access, or would you rather I committed it?

Yes, I have the commit access.

Thanks for reviewing!


https://reviews.llvm.org/D25595



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


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-19 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 75186.
timshen added a comment.

Add tests for regex_match.


https://reviews.llvm.org/D25595

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  assert(!std::regex_match("", m, std::regex("a*"),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match("", m, std::regex("a*", std::regex::extended),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match(
+  "", m,
+  std::regex("a*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  return 0;
+}
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;


Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_n

[libcxx] r284881 - [libcxx] Support std::regex_constants::match_not_null

2016-10-21 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Oct 21 15:41:47 2016
New Revision: 284881

URL: http://llvm.org/viewvc/llvm-project?rev=284881&view=rev
Log:
[libcxx] Support std::regex_constants::match_not_null

Summary: Fixes PR21597.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

Added:
libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
Modified:
libcxx/trunk/include/regex

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=284881&r1=284880&r2=284881&view=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Fri Oct 21 15:41:47 2016
@@ -,6 +,12 @@ basic_regex<_CharT, _Traits>::__match_at
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@ basic_regex<_CharT, _Traits>::__match_at
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@ basic_regex<_CharT, _Traits>::__match_at
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;

Added: libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp?rev=284881&view=auto
==
--- libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp 
(added)
+++ libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp Fri 
Oct 21 15:41:47 2016
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  assert(!std::regex_match("", m, std::regex("a*"),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match("", m, std::regex("a*", std::regex::extended),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match(
+  "", m,
+  std::regex("a*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  return 0;
+}


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


[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null

2016-10-21 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284881: [libcxx] Support 
std::regex_constants::match_not_null (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D25595?vs=75186&id=75480#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25595

Files:
  libcxx/trunk/include/regex
  libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp


Index: libcxx/trunk/include/regex
===
--- libcxx/trunk/include/regex
+++ libcxx/trunk/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5703,6 +5715,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;
Index: libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
===
--- libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
+++ libcxx/trunk/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// match_not_null:
+// The regular expression shall not match an empty sequence.
+
+#include "test_macros.h"
+#include 
+#include 
+
+int main()
+{
+  // When match_not_null is on, the regex engine should reject empty matches 
and
+  // move on to try other solutions.
+  std::cmatch m;
+  assert(!std::regex_search("a", m, std::regex("b*"),
+std::regex_constants::match_not_null));
+  assert(std::regex_search("aa", m, std::regex("a*?"),
+   std::regex_constants::match_not_null));
+  assert(m[0].length() == 1);
+  assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended),
+std::regex_constants::match_not_null));
+  assert(!std::regex_search(
+  "a", m,
+  std::regex("b*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  assert(!std::regex_match("", m, std::regex("a*"),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match("", m, std::regex("a*", std::regex::extended),
+   std::regex_constants::match_not_null));
+  assert(!std::regex_match(
+  "", m,
+  std::regex("a*", std::regex::extended | std::regex_constants::nosubs),
+  std::regex_constants::match_not_null));
+
+  return 0;
+}


Index: libcxx/trunk/include/regex
===
--- libcxx/trunk/include/regex
+++ libcxx/trunk/include/regex
@@ -,6 +,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_not_null &&
+__s.__current_ == __first)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
 __m.__matches_[0].matched = true;
@@ -5618,6 +5624,12 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
+if (__flags & regex_constants::match_no

[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 75644.
timshen added a comment.

Simplified the test.


https://reviews.llvm.org/D24010

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/Analysis/ReachableCode.cpp
  clang/test/SemaCXX/PR29152.cpp


Index: clang/test/SemaCXX/PR29152.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.


Index: clang/test/SemaCXX/PR29152.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip captured
   /// stmt at the top, if \a IgnoreCaptured is true.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread Tim Shen via cfe-commits
On Mon, Oct 24, 2016 at 10:33 AM David Blaikie  wrote:

> On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>
>
> What are the relevant parts of this test for this change?
>
> Is it the static const bool False that's interesting?
>
> Is it the op==/other interesting side effects on the RHS that are
> interesting?
>
> I'd be surprised if it were both (& if it isn't both, I'm guessing it's
> the former rather than the latter - in which case the latter can probably
> be reduced to just an arbitrary function call to, say: bool Baz())
>

It's the static const bool False. I actually managed to simplify the code
to remove the operator==() call.


>
>
> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> 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


Re: [PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-24 Thread Tim Shen via cfe-commits
On Mon, Oct 24, 2016 at 2:38 PM David Blaikie  wrote:

> Simplify it further by replacing A() with just a function instead of a
> class? Or does that break the repro?
>
> bool Foo();
> void Bar();
> void Baz() {
>   if (False && Foo())
> Bar();
> }
>

This actually breaks the repro. My test introduces a non-trivially
destructible temporary object in the condition expression, which creates a
ExprWithCleanups node at the full expression entry.


>
> On Mon, Oct 24, 2016 at 1:38 PM Tim Shen  wrote:
>
> On Mon, Oct 24, 2016 at 10:33 AM David Blaikie  wrote:
>
> On Mon, Aug 29, 2016 at 3:45 PM Tim Shen via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> timshen created this revision.
> timshen added reviewers: rsmith, pirama.
> timshen added a subscriber: cfe-commits.
>
> https://reviews.llvm.org/D24010
>
> Files:
>   clang/include/clang/AST/Stmt.h
>   clang/lib/Analysis/ReachableCode.cpp
>   clang/test/SemaCXX/PR29152.cpp
>
> Index: clang/test/SemaCXX/PR29152.cpp
> ===
> --- /dev/null
> +++ clang/test/SemaCXX/PR29152.cpp
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
> +
> +static const bool False = false;
> +
> +struct Vector {
> +  struct iterator {
> +bool operator==(const iterator &) const;
> +  };
> +  iterator end();
> +};
> +
> +void Bar();
> +Vector::iterator Find(Vector &a);
> +
> +void Foo(Vector &a) {
> +  if (False && Find(a) == a.end()) {
> +Bar(); // expected-no-diagnostics
> +  }
> +}
>
>
> What are the relevant parts of this test for this change?
>
> Is it the static const bool False that's interesting?
>
> Is it the op==/other interesting side effects on the RHS that are
> interesting?
>
> I'd be surprised if it were both (& if it isn't both, I'm guessing it's
> the former rather than the latter - in which case the latter can probably
> be reduced to just an arbitrary function call to, say: bool Baz())
>
>
> It's the static const bool False. I actually managed to simplify the code
> to remove the operator==() call.
>
>
>
>
> Index: clang/lib/Analysis/ReachableCode.cpp
> ===
> --- clang/lib/Analysis/ReachableCode.cpp
> +++ clang/lib/Analysis/ReachableCode.cpp
> @@ -164,6 +164,8 @@
>if (!S)
>  return false;
>
> +  S = S->IgnoreImplicit();
> +
>if (const Expr *Ex = dyn_cast(S))
>  S = Ex->IgnoreCasts();
>
> Index: clang/include/clang/AST/Stmt.h
> ===
> --- clang/include/clang/AST/Stmt.h
> +++ clang/include/clang/AST/Stmt.h
> @@ -387,6 +387,9 @@
>/// Skip past any implicit AST nodes which might surround this
>/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
>Stmt *IgnoreImplicit();
> +  const Stmt *IgnoreImplicit() const {
> +return const_cast(this)->IgnoreImplicit();
> +  }
>
>/// \brief Skip no-op (attributed, compound) container stmts and skip
> captured
>/// stmt at the top, if \a IgnoreCaptured is true.
>
>
> ___
> 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] D26026: [libcxx] Make regex_match backtrack when search fails

2016-10-27 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
timshen added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

Fixes PR19851.
alg.re.match/ecma.pass.cpp still XFAILS on linux, but after commenting out
locale-related tests, it passes. I don't have a freebsd machine to produce a
full pass.


https://reviews.llvm.org/D26026

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp

Index: libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
===
--- libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
+++ libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -372,15 +372,34 @@
 {
 std::cmatch m;
 const char s[] = "tournament";
-assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
-assert(m.size() == 0);
+assert(std::regex_match(s, m, std::regex("tour|to|tournament")));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::cmatch m;
 const char s[] = "tournamenttotour";
-assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
-   std::regex_constants::nosubs)));
-assert(m.size() == 0);
+assert(
+std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+  std::regex_constants::nosubs)));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::cmatch m;
@@ -1037,15 +1056,34 @@
 {
 std::wcmatch m;
 const wchar_t s[] = L"tournament";
-assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
-assert(m.size() == 0);
+assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::wcmatch m;
 const wchar_t s[] = L"tournamenttotour";
-assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
-   std::regex_constants::nosubs)));
-assert(m.size() == 0);
+assert(
+std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+   std::regex_constants::nosubs)));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::wcmatch m;
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -865,7 +865,8 @@
 format_sed= 1 << 8,
 format_no_copy= 1 << 9,
 format_first_only = 1 << 10,
-__no_update_pos   = 1 << 11
+__no_update_pos   = 1 << 11,
+__full_match  = 1 << 12
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -2984,10 +2985,12 @@
 {
 match_results __m;
 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
-bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
-  __m,
-  __s.__flags_ | regex_constants::match_continuous,
-  __s.__at_first_ && __s.__current_ == __s.__first_);
+bool __matched = __exp_.__match_at_start_ecma(
+__s.__current_, __s.__last_,
+__m,
+(__s.__flags_ | regex_constants::match_continuous) &
+~regex_constants::__full_match,
+__s.__at_first_ && __s.__current_ == __s.

[PATCH] D26026: [libcxx] Make regex_match backtrack when search fails

2016-10-27 Thread Tim Shen via cfe-commits
timshen marked an inline comment as done.
timshen added inline comments.



Comment at: libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp:374
 std::cmatch m;
 const char s[] = "tournament";
+assert(std::regex_match(s, m, std::regex("tour|to|tournament")));

mclow.lists wrote:
> I would be tempted to put a reference to http://wg21.link/LWG2273 here. (in a 
> comment)
For consistency with other LWG defects references, I used the open-std.org link.


https://reviews.llvm.org/D26026



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


[PATCH] D26026: [libcxx] Make regex_match backtrack when search fails

2016-10-27 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 76088.
timshen added a comment.

Added http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273 as 
comments.


https://reviews.llvm.org/D26026

Files:
  libcxx/include/regex
  libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp

Index: libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
===
--- libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
+++ libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -371,16 +371,37 @@
 }
 {
 std::cmatch m;
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
 const char s[] = "tournament";
-assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
-assert(m.size() == 0);
+assert(std::regex_match(s, m, std::regex("tour|to|tournament")));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::cmatch m;
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
 const char s[] = "tournamenttotour";
-assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
-   std::regex_constants::nosubs)));
-assert(m.size() == 0);
+assert(
+std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+  std::regex_constants::nosubs)));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::cmatch m;
@@ -1036,16 +1057,37 @@
 }
 {
 std::wcmatch m;
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
 const wchar_t s[] = L"tournament";
-assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
-assert(m.size() == 0);
+assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::wcmatch m;
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2273
 const wchar_t s[] = L"tournamenttotour";
-assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
-   std::regex_constants::nosubs)));
-assert(m.size() == 0);
+assert(
+std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+   std::regex_constants::nosubs)));
+assert(m.size() == 1);
+assert(!m.prefix().matched);
+assert(m.prefix().first == s);
+assert(m.prefix().second == m[0].first);
+assert(!m.suffix().matched);
+assert(m.suffix().first == m[0].second);
+assert(m.suffix().second == m[0].second);
+assert(m.length(0) == std::char_traits::length(s));
+assert(m.position(0) == 0);
+assert(m.str(0) == s);
 }
 {
 std::wcmatch m;
Index: libcxx/include/regex
===
--- libcxx/include/regex
+++ libcxx/include/regex
@@ -865,7 +865,8 @@
 format_sed= 1 << 8,
 format_no_copy= 1 << 9,
 format_first_only = 1 << 10,
-__no_update_pos   = 1 << 11
+__no_update_pos   = 1 << 11,
+__full_match  = 1 << 12
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -2984,10 +2985,12 @@
 {
 match_results __m;
 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
-bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
-  __m,
-  __s.__flags_ | regex_constants::match_continuous,
-  __s.__at_first_ && __s.__current_ == __s.__first_);
+bool __matched = __exp_.__match_at_start_ecma(
+__s.__current_, __s.__last_,
+

[PATCH] D26026: [libcxx] Make regex_match backtrack when search fails

2016-10-27 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
timshen marked an inline comment as done.
Closed by commit rL285352: [libcxx] Make regex_match backtrack when search 
fails (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D26026?vs=76088&id=76109#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26026

Files:
  libcxx/trunk/include/regex
  libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp

Index: libcxx/trunk/include/regex
===
--- libcxx/trunk/include/regex
+++ libcxx/trunk/include/regex
@@ -865,7 +865,8 @@
 format_sed= 1 << 8,
 format_no_copy= 1 << 9,
 format_first_only = 1 << 10,
-__no_update_pos   = 1 << 11
+__no_update_pos   = 1 << 11,
+__full_match  = 1 << 12
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -2984,10 +2985,12 @@
 {
 match_results __m;
 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
-bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
-  __m,
-  __s.__flags_ | regex_constants::match_continuous,
-  __s.__at_first_ && __s.__current_ == __s.__first_);
+bool __matched = __exp_.__match_at_start_ecma(
+__s.__current_, __s.__last_,
+__m,
+(__s.__flags_ | regex_constants::match_continuous) &
+~regex_constants::__full_match,
+__s.__at_first_ && __s.__current_ == __s.__first_);
 if (__matched != __invert_)
 {
 __s.__do_ = __state::__accept_but_not_consume;
@@ -,12 +5558,18 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
-if (__flags & regex_constants::match_not_null &&
+if ((__flags & regex_constants::match_not_null) &&
 __s.__current_ == __first)
 {
   __states.pop_back();
   break;
 }
+if ((__flags & regex_constants::__full_match) &&
+__s.__current_ != __last)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
 __m.__matches_[0].matched = true;
@@ -5624,12 +5633,18 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
-if (__flags & regex_constants::match_not_null &&
+if ((__flags & regex_constants::match_not_null) &&
 __s.__current_ == __first)
 {
   __states.pop_back();
   break;
 }
+if ((__flags & regex_constants::__full_match) &&
+__s.__current_ != __last)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5715,12 +5730,18 @@
 switch (__s.__do_)
 {
 case __state::__end_state:
-if (__flags & regex_constants::match_not_null &&
+if ((__flags & regex_constants::match_not_null) &&
 __s.__current_ == __first)
 {
   __states.pop_back();
   break;
 }
+if ((__flags & regex_constants::__full_match) &&
+__s.__current_ != __last)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;
@@ -5951,8 +5972,10 @@
 const basic_regex<_CharT, _Traits>& __e,
 regex_constants::match_flag_type __flags = regex_constants::match_default)
 {
-bool __r = _VSTD::regex_search(__first, __last, __m, __e,
-__flags | regex_constants::match_continuous);
+bool __r = _VSTD::regex_search(
+__first, __last, __m, __e,
+__flags | regex_constants::match_continuous |
+regex_constants::__full_match);
 if (__r)
 {
 __r = !__m.suffix().matched;
Index: libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
===
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -371,16 +371,37 @@
 }
 {
 std::cmatch m;
+// http://www.open-std.org/jtc1/sc22/wg21/doc

[libcxx] r285352 - [libcxx] Make regex_match backtrack when search fails

2016-10-27 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Oct 27 16:40:34 2016
New Revision: 285352

URL: http://llvm.org/viewvc/llvm-project?rev=285352&view=rev
Log:
[libcxx] Make regex_match backtrack when search fails

Summary:
Fixes PR19851.
alg.re.match/ecma.pass.cpp still XFAILS on linux, but after commenting out
locale-related tests, it passes. I don't have a freebsd machine to produce a
full pass.

Reviewers: mclow.lists

Subscribers: cfe-commits, emaste

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

Modified:
libcxx/trunk/include/regex
libcxx/trunk/test/std/re/re.alg/re.alg.match/ecma.pass.cpp

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=285352&r1=285351&r2=285352&view=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Thu Oct 27 16:40:34 2016
@@ -865,7 +865,8 @@ enum match_flag_type
 format_sed= 1 << 8,
 format_no_copy= 1 << 9,
 format_first_only = 1 << 10,
-__no_update_pos   = 1 << 11
+__no_update_pos   = 1 << 11,
+__full_match  = 1 << 12
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -2984,10 +2985,12 @@ __lookahead<_CharT, _Traits>::__exec(__s
 {
 match_results __m;
 __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
-bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
-  __m,
-  __s.__flags_ | 
regex_constants::match_continuous,
-  __s.__at_first_ && 
__s.__current_ == __s.__first_);
+bool __matched = __exp_.__match_at_start_ecma(
+__s.__current_, __s.__last_,
+__m,
+(__s.__flags_ | regex_constants::match_continuous) &
+~regex_constants::__full_match,
+__s.__at_first_ && __s.__current_ == __s.__first_);
 if (__matched != __invert_)
 {
 __s.__do_ = __state::__accept_but_not_consume;
@@ -,12 +5558,18 @@ basic_regex<_CharT, _Traits>::__match_at
 switch (__s.__do_)
 {
 case __state::__end_state:
-if (__flags & regex_constants::match_not_null &&
+if ((__flags & regex_constants::match_not_null) &&
 __s.__current_ == __first)
 {
   __states.pop_back();
   break;
 }
+if ((__flags & regex_constants::__full_match) &&
+__s.__current_ != __last)
+{
+  __states.pop_back();
+  break;
+}
 __m.__matches_[0].first = __first;
 __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ 
- __first);
 __m.__matches_[0].matched = true;
@@ -5624,12 +5633,18 @@ basic_regex<_CharT, _Traits>::__match_at
 switch (__s.__do_)
 {
 case __state::__end_state:
-if (__flags & regex_constants::match_not_null &&
+if ((__flags & regex_constants::match_not_null) &&
 __s.__current_ == __first)
 {
   __states.pop_back();
   break;
 }
+if ((__flags & regex_constants::__full_match) &&
+__s.__current_ != __last)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 __highest_j = __s.__current_ - __s.__first_;
 __matched = true;
@@ -5715,12 +5730,18 @@ basic_regex<_CharT, _Traits>::__match_at
 switch (__s.__do_)
 {
 case __state::__end_state:
-if (__flags & regex_constants::match_not_null &&
+if ((__flags & regex_constants::match_not_null) &&
 __s.__current_ == __first)
 {
   __states.pop_back();
   break;
 }
+if ((__flags & regex_constants::__full_match) &&
+__s.__current_ != __last)
+{
+  __states.pop_back();
+  break;
+}
 if (!__matched || __highest_j < __s.__current_ - __s.__first_)
 {
 __highest_j = __s.__current_ - __s.__first_;
@@ -5951,8 +5972,10 @@ regex_match(_BidirectionalIterator __fir
 const basic_regex<_CharT, _Traits>& __e,
 regex_constants::match_flag_type __flags = 
regex_constants::match_default)
 {
-bool __r = _VSTD::regex_search(__first, __last, __m, __e,
-__flags | regex_constants::match_continuous);
+bool __r = _VSTD::regex_search(
+__first, __last, __m, __e,

r285657 - [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-31 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Oct 31 19:19:04 2016
New Revision: 285657

URL: http://llvm.org/viewvc/llvm-project?rev=285657&view=rev
Log:
[ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

Summary: Fixes pr29152.

Reviewers: rsmith, pirama, krememek

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/PR29152.cpp
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/Analysis/ReachableCode.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=285657&r1=285656&r2=285657&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Oct 31 19:19:04 2016
@@ -387,6 +387,9 @@ public:
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.

Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=285657&r1=285656&r2=285657&view=diff
==
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Mon Oct 31 19:19:04 2016
@@ -164,6 +164,8 @@ static bool isConfigurationValue(const S
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 

Added: cfe/trunk/test/SemaCXX/PR29152.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR29152.cpp?rev=285657&view=auto
==
--- cfe/trunk/test/SemaCXX/PR29152.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR29152.cpp Mon Oct 31 19:19:04 2016
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}


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


[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue

2016-10-31 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285657: [ReachableCode] Skip over ExprWithCleanups in 
isConfigurationValue (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D24010?vs=75644&id=76508#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24010

Files:
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/lib/Analysis/ReachableCode.cpp
  cfe/trunk/test/SemaCXX/PR29152.cpp


Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip 
captured
   /// stmt at the top, if \a IgnoreCaptured is true.
Index: cfe/trunk/test/SemaCXX/PR29152.cpp
===
--- cfe/trunk/test/SemaCXX/PR29152.cpp
+++ cfe/trunk/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: cfe/trunk/lib/Analysis/ReachableCode.cpp
===
--- cfe/trunk/lib/Analysis/ReachableCode.cpp
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 


Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
   /// Skip past any implicit AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
   Stmt *IgnoreImplicit();
+  const Stmt *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
 
   /// \brief Skip no-op (attributed, compound) container stmts and skip captured
   /// stmt at the top, if \a IgnoreCaptured is true.
Index: cfe/trunk/test/SemaCXX/PR29152.cpp
===
--- cfe/trunk/test/SemaCXX/PR29152.cpp
+++ cfe/trunk/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+  ~A();
+  operator bool();
+};
+void Bar();
+
+void Foo() {
+  if (False && A()) {
+Bar(); // expected-no-diagnostics
+  }
+}
Index: cfe/trunk/lib/Analysis/ReachableCode.cpp
===
--- cfe/trunk/lib/Analysis/ReachableCode.cpp
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
   if (!S)
 return false;
 
+  S = S->IgnoreImplicit();
+
   if (const Expr *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23147: [ADT] Migrate DepthFirstIterator to use NodeRef

2016-08-03 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added reviewers: dblaikie, chandlerc.
timshen added a subscriber: cfe-commits.

The corresponding LLVM change is D23146.

https://reviews.llvm.org/D23147

Files:
  include/clang/AST/StmtGraphTraits.h
  include/clang/Analysis/Analyses/Dominators.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h

Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -451,6 +451,7 @@
 namespace llvm {
   template<> struct GraphTraits {
 typedef clang::ento::ExplodedNode NodeType;
+typedef clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::succ_iterator  ChildIteratorType;
 typedef llvm::df_iterator  nodes_iterator;
 
@@ -477,6 +478,7 @@
 
   template<> struct GraphTraits {
 typedef const clang::ento::ExplodedNode NodeType;
+typedef const clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::const_succ_iterator   ChildIteratorType;
 typedef llvm::df_iterator   nodes_iterator;
 
Index: include/clang/Analysis/Analyses/Dominators.h
===
--- include/clang/Analysis/Analyses/Dominators.h
+++ include/clang/Analysis/Analyses/Dominators.h
@@ -168,6 +168,7 @@
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
   typedef ::clang::DomTreeNode NodeType;
+  typedef ::clang::DomTreeNode *NodeRef;
   typedef NodeType::iterator  ChildIteratorType;
 
   static NodeType *getEntryNode(NodeType *N) {
Index: include/clang/AST/StmtGraphTraits.h
===
--- include/clang/AST/StmtGraphTraits.h
+++ include/clang/AST/StmtGraphTraits.h
@@ -26,6 +26,7 @@
 
 template <> struct GraphTraits {
   typedef clang::Stmt   NodeType;
+  typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
@@ -53,6 +54,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::Stmt   NodeType;
+  typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 


Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -451,6 +451,7 @@
 namespace llvm {
   template<> struct GraphTraits {
 typedef clang::ento::ExplodedNode NodeType;
+typedef clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::succ_iterator  ChildIteratorType;
 typedef llvm::df_iterator  nodes_iterator;
 
@@ -477,6 +478,7 @@
 
   template<> struct GraphTraits {
 typedef const clang::ento::ExplodedNode NodeType;
+typedef const clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::const_succ_iterator   ChildIteratorType;
 typedef llvm::df_iterator   nodes_iterator;
 
Index: include/clang/Analysis/Analyses/Dominators.h
===
--- include/clang/Analysis/Analyses/Dominators.h
+++ include/clang/Analysis/Analyses/Dominators.h
@@ -168,6 +168,7 @@
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
   typedef ::clang::DomTreeNode NodeType;
+  typedef ::clang::DomTreeNode *NodeRef;
   typedef NodeType::iterator  ChildIteratorType;
 
   static NodeType *getEntryNode(NodeType *N) {
Index: include/clang/AST/StmtGraphTraits.h
===
--- include/clang/AST/StmtGraphTraits.h
+++ include/clang/AST/StmtGraphTraits.h
@@ -26,6 +26,7 @@
 
 template <> struct GraphTraits {
   typedef clang::Stmt   NodeType;
+  typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
@@ -53,6 +54,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::Stmt   NodeType;
+  typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r277783 - [ADT] Migrate DepthFirstIterator to use NodeRef

2016-08-04 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Aug  4 18:03:44 2016
New Revision: 277783

URL: http://llvm.org/viewvc/llvm-project?rev=277783&view=rev
Log:
[ADT] Migrate DepthFirstIterator to use NodeRef

Summary: The corresponding LLVM change is D23146.

Reviewers: dblaikie, chandlerc

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/StmtGraphTraits.h
cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h

Modified: cfe/trunk/include/clang/AST/StmtGraphTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtGraphTraits.h?rev=277783&r1=277782&r2=277783&view=diff
==
--- cfe/trunk/include/clang/AST/StmtGraphTraits.h (original)
+++ cfe/trunk/include/clang/AST/StmtGraphTraits.h Thu Aug  4 18:03:44 2016
@@ -26,6 +26,7 @@ namespace llvm {
 
 template <> struct GraphTraits {
   typedef clang::Stmt   NodeType;
+  typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
@@ -53,6 +54,7 @@ template <> struct GraphTraits struct GraphTraits {
   typedef const clang::Stmt   NodeType;
+  typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 

Modified: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Dominators.h?rev=277783&r1=277782&r2=277783&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h Thu Aug  4 18:03:44 
2016
@@ -168,6 +168,7 @@ private:
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
   typedef ::clang::DomTreeNode NodeType;
+  typedef ::clang::DomTreeNode *NodeRef;
   typedef NodeType::iterator  ChildIteratorType;
 
   static NodeType *getEntryNode(NodeType *N) {

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=277783&r1=277782&r2=277783&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h 
Thu Aug  4 18:03:44 2016
@@ -451,6 +451,7 @@ public:
 namespace llvm {
   template<> struct GraphTraits {
 typedef clang::ento::ExplodedNode NodeType;
+typedef clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::succ_iterator  ChildIteratorType;
 typedef llvm::df_iterator  nodes_iterator;
 
@@ -477,6 +478,7 @@ namespace llvm {
 
   template<> struct GraphTraits {
 typedef const clang::ento::ExplodedNode NodeType;
+typedef const clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::const_succ_iterator   ChildIteratorType;
 typedef llvm::df_iterator   nodes_iterator;
 


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


Re: [PATCH] D23147: [ADT] Migrate DepthFirstIterator to use NodeRef

2016-08-04 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277783: [ADT] Migrate DepthFirstIterator to use NodeRef 
(authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23147?vs=66745&id=66872#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23147

Files:
  cfe/trunk/include/clang/AST/StmtGraphTraits.h
  cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h

Index: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
===
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
@@ -168,6 +168,7 @@
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
   typedef ::clang::DomTreeNode NodeType;
+  typedef ::clang::DomTreeNode *NodeRef;
   typedef NodeType::iterator  ChildIteratorType;
 
   static NodeType *getEntryNode(NodeType *N) {
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -451,6 +451,7 @@
 namespace llvm {
   template<> struct GraphTraits {
 typedef clang::ento::ExplodedNode NodeType;
+typedef clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::succ_iterator  ChildIteratorType;
 typedef llvm::df_iterator  nodes_iterator;
 
@@ -477,6 +478,7 @@
 
   template<> struct GraphTraits {
 typedef const clang::ento::ExplodedNode NodeType;
+typedef const clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::const_succ_iterator   ChildIteratorType;
 typedef llvm::df_iterator   nodes_iterator;
 
Index: cfe/trunk/include/clang/AST/StmtGraphTraits.h
===
--- cfe/trunk/include/clang/AST/StmtGraphTraits.h
+++ cfe/trunk/include/clang/AST/StmtGraphTraits.h
@@ -26,6 +26,7 @@
 
 template <> struct GraphTraits {
   typedef clang::Stmt   NodeType;
+  typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
@@ -53,6 +54,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::Stmt   NodeType;
+  typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 


Index: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
===
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
@@ -168,6 +168,7 @@
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
   typedef ::clang::DomTreeNode NodeType;
+  typedef ::clang::DomTreeNode *NodeRef;
   typedef NodeType::iterator  ChildIteratorType;
 
   static NodeType *getEntryNode(NodeType *N) {
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -451,6 +451,7 @@
 namespace llvm {
   template<> struct GraphTraits {
 typedef clang::ento::ExplodedNode NodeType;
+typedef clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::succ_iterator  ChildIteratorType;
 typedef llvm::df_iterator  nodes_iterator;
 
@@ -477,6 +478,7 @@
 
   template<> struct GraphTraits {
 typedef const clang::ento::ExplodedNode NodeType;
+typedef const clang::ento::ExplodedNode *NodeRef;
 typedef NodeType::const_succ_iterator   ChildIteratorType;
 typedef llvm::df_iterator   nodes_iterator;
 
Index: cfe/trunk/include/clang/AST/StmtGraphTraits.h
===
--- cfe/trunk/include/clang/AST/StmtGraphTraits.h
+++ cfe/trunk/include/clang/AST/StmtGraphTraits.h
@@ -26,6 +26,7 @@
 
 template <> struct GraphTraits {
   typedef clang::Stmt   NodeType;
+  typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
@@ -53,6 +54,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::Stmt   NodeType;
+  typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lis

[PATCH] D23218: [ADT] Change iterator_adaptor_base's default template arguments to forward more underlying typedefs

2016-08-05 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added reviewers: chandlerc, bkramer.
timshen added a subscriber: cfe-commits.

The corresponding LLVM change: D23217.

LazyVector::iterator breaks, because int isn't an iterator type.
Since iterator_adaptor_base shouldn't be blamed to break at the call to
iterator_traits::xxx, I'd rather "fix" LazyVector::iterator.

The perfect solution is to model "relative pointer", but it's beyond the goal 
of this patch.

https://reviews.llvm.org/D23218

Files:
  include/clang/AST/ExternalASTSource.h

Index: include/clang/AST/ExternalASTSource.h
===
--- include/clang/AST/ExternalASTSource.h
+++ include/clang/AST/ExternalASTSource.h
@@ -503,8 +503,9 @@
   /// We define this as a wrapping iterator around an int. The
   /// iterator_adaptor_base class forwards the iterator methods to basic 
integer
   /// arithmetic.
-  class iterator : public llvm::iterator_adaptor_base<
-   iterator, int, std::random_access_iterator_tag, T, int> 
{
+  class iterator
+  : public llvm::iterator_adaptor_base<
+iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
 LazyVector *Self;
 
 iterator(LazyVector *Self, int Position)


Index: include/clang/AST/ExternalASTSource.h
===
--- include/clang/AST/ExternalASTSource.h
+++ include/clang/AST/ExternalASTSource.h
@@ -503,8 +503,9 @@
   /// We define this as a wrapping iterator around an int. The
   /// iterator_adaptor_base class forwards the iterator methods to basic integer
   /// arithmetic.
-  class iterator : public llvm::iterator_adaptor_base<
-   iterator, int, std::random_access_iterator_tag, T, int> {
+  class iterator
+  : public llvm::iterator_adaptor_base<
+iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
 LazyVector *Self;
 
 iterator(LazyVector *Self, int Position)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278156 - [ADT] Change iterator_adaptor_base's default template arguments to forward more underlying typedefs

2016-08-09 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Aug  9 15:22:55 2016
New Revision: 278156

URL: http://llvm.org/viewvc/llvm-project?rev=278156&view=rev
Log:
[ADT] Change iterator_adaptor_base's default template arguments to forward more 
underlying typedefs

Summary:
The corresponding LLVM change: D23217.

LazyVector::iterator breaks, because int isn't an iterator type.
Since iterator_adaptor_base shouldn't be blamed to break at the call to
iterator_traits::xxx, I'd rather "fix" LazyVector::iterator.

The perfect solution is to model "relative pointer", but it's beyond the goal 
of this patch.

Reviewers: chandlerc, bkramer

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=278156&r1=278155&r2=278156&view=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Tue Aug  9 15:22:55 2016
@@ -503,8 +503,9 @@ public:
   /// We define this as a wrapping iterator around an int. The
   /// iterator_adaptor_base class forwards the iterator methods to basic 
integer
   /// arithmetic.
-  class iterator : public llvm::iterator_adaptor_base<
-   iterator, int, std::random_access_iterator_tag, T, int> 
{
+  class iterator
+  : public llvm::iterator_adaptor_base<
+iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
 LazyVector *Self;
 
 iterator(LazyVector *Self, int Position)


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


Re: [PATCH] D23218: [ADT] Change iterator_adaptor_base's default template arguments to forward more underlying typedefs

2016-08-09 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278156: [ADT] Change iterator_adaptor_base's default 
template arguments to forward… (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23218?vs=66984&id=67408#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23218

Files:
  cfe/trunk/include/clang/AST/ExternalASTSource.h

Index: cfe/trunk/include/clang/AST/ExternalASTSource.h
===
--- cfe/trunk/include/clang/AST/ExternalASTSource.h
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h
@@ -503,8 +503,9 @@
   /// We define this as a wrapping iterator around an int. The
   /// iterator_adaptor_base class forwards the iterator methods to basic 
integer
   /// arithmetic.
-  class iterator : public llvm::iterator_adaptor_base<
-   iterator, int, std::random_access_iterator_tag, T, int> 
{
+  class iterator
+  : public llvm::iterator_adaptor_base<
+iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
 LazyVector *Self;
 
 iterator(LazyVector *Self, int Position)


Index: cfe/trunk/include/clang/AST/ExternalASTSource.h
===
--- cfe/trunk/include/clang/AST/ExternalASTSource.h
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h
@@ -503,8 +503,9 @@
   /// We define this as a wrapping iterator around an int. The
   /// iterator_adaptor_base class forwards the iterator methods to basic integer
   /// arithmetic.
-  class iterator : public llvm::iterator_adaptor_base<
-   iterator, int, std::random_access_iterator_tag, T, int> {
+  class iterator
+  : public llvm::iterator_adaptor_base<
+iterator, int, std::random_access_iterator_tag, T, int, T *, T &> {
 LazyVector *Self;
 
 iterator(LazyVector *Self, int Position)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23523: [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.

Corresponding LLVM change: D23522

https://reviews.llvm.org/D23523

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/CallGraph.h

Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}
Index: include/clang/Analysis/CFG.h
===
--- include/clang/Analysis/CFG.h
+++ include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)


Index: include/clang/Analysis/CallGraph.h
===
--- include/clang/Analysis/CallGraph.h
+++ include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; }
   static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();}
Index: include/clang/Analysis/CFG.h
===
--- include/clang/Analysis/CFG.h
+++ include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19930: [Lifetime] Add lifetime markers for C++ lifetime-extended temporaries

2016-05-04 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.

Use pushCleanupAfterFullExpr to add lifetime.end markers for 
lifetime-extended temporaries, similar to the way destructor calls get 
generated.

It does not change the AST representation. It doesn't generate normal temporary
lifetime markers, since normal temporaries appear in substantially different
places, which could be done in a separate patch.

http://reviews.llvm.org/D19930

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  test/CodeGen/lifetime-extended-temporaries.cpp

Index: test/CodeGen/lifetime-extended-temporaries.cpp
===
--- /dev/null
+++ test/CodeGen/lifetime-extended-temporaries.cpp
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 %s -std=c++11 -O1 -DWITH_DTOR -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-DTOR %s
+// RUN: %clang_cc1 %s -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-NO-DTOR %s
+
+struct A {
+  A();
+#ifdef WITH_DTOR
+  ~A();
+#endif
+  char a[1024];
+  operator bool() const;
+};
+
+template 
+void Foo(T &&);
+
+template 
+void Bar(T &&);
+
+template 
+T Baz();
+
+void Test1() {
+  // CHECK-DTOR-LABEL: Test1
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test1
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: }
+  {
+const A &a = A{};
+Foo(a);
+  }
+  {
+const A &a = A{};
+Foo(a);
+  }
+}
+
+void Test2() {
+  // CHECK-DTOR-LABEL: Test2
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test2
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-NO-DTOR: }
+  const A &a = A{};
+  Foo(a);
+  const A &b = A{};
+  Foo(b);
+}
+
+void Test3() {
+  // CHECK-DTOR-LABEL: Test3
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: if.then:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: }
+  const A &a = A{};
+  if (const A &b = A(a)) {
+Foo(b);
+return;
+  }
+  Bar(a);
+}
+
+void Test4() {
+  // CHECK-DTOR-LABEL: Test4
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: for.cond.cleanup:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: for.body:
+ 

[PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-05-20 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

These ExprWithCleanups are added for holding a RunCleanupsScope not
for destructor calls; rather, they are for lifetime marks. This requires
ExprWithCleanups to keep a bit to indicate whether it have cleanups with
side effects (e.g. dtor calls).

http://reviews.llvm.org/D20498

Files:
  include/clang/AST/ExprCXX.h
  include/clang/Sema/CleanupInfo.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/Analysis/Consumed.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -999,8 +999,8 @@
   EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
 "const Foo f = Foo();",
   varDecl(hasInitializer(exprWithCleanups();
-  EXPECT_FALSE(matches("struct Foo { };"
- "const Foo f = Foo();",
+  EXPECT_FALSE(matches("struct Foo { }; Foo a;"
+   "const Foo f = a;",
varDecl(hasInitializer(exprWithCleanups();
 }
 
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1430,7 +1430,8 @@
   Record.push_back(E->getNumObjects());
   for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
 Record.AddDeclRef(E->getObject(i));
-  
+
+  Record.push_back(E->cleanupsHaveSideEffects());
   Record.AddStmt(E->getSubExpr());
   Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
 }
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1448,6 +1448,7 @@
 E->getTrailingObjects()[i] =
 ReadDeclAs(Record, Idx);
 
+  E->CleanupsHaveSideEffects = Record[Idx++];
   E->SubExpr = Reader.ReadSubExpr();
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1518,6 +1518,10 @@
   // variables Increment and DRE.
   bool ProcessIterationStmt(Sema &S, Stmt* Statement, bool &Increment,
 DeclRefExpr *&DRE) {
+if (auto Cleanups = dyn_cast(Statement))
+  if (!Cleanups->cleanupsHaveSideEffects())
+Statement = Cleanups->getSubExpr();
+
 if (UnaryOperator *UO = dyn_cast(Statement)) {
   switch (UO->getOpcode()) {
 default: return false;
@@ -2472,6 +2476,10 @@
 
   QualType VariableType = VD->getType();
 
+  if (auto Cleanups = dyn_cast(InitExpr))
+if (!Cleanups->cleanupsHaveSideEffects())
+  InitExpr = Cleanups->getSubExpr();
+
   const MaterializeTemporaryExpr *MTE =
   dyn_cast(InitExpr);
 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -3769,6 +3769,10 @@
 }
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   InitSrcRange = S->getSourceRange();
   if (Expr *E = dyn_cast(S))
 S = E->IgnoreParens();
@@ -3956,6 +3960,10 @@
 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_incr) << LCDecl;
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   IncrementSrcRange = S->getSourceRange();
   S = S->IgnoreParens();
   if (auto UO = dyn_cast(S)) {
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1500,7 +1500,7 @@
   SourceRange IntroducerRange;
   bool ExplicitParams;
   bool ExplicitResultType;
-  bool LambdaExprNeedsCleanups;
+  CleanupInfo LambdaCleanup;
   bool ContainsUnexpandedParameterPack;
   SmallVector ArrayIndexVars;
   SmallVector ArrayIndexStarts;
@@ -1510,7 +1510,7 @@
 IntroducerRange = LSI->IntroducerRange;
 ExplicitParams = LSI->ExplicitParams;
 ExplicitResultType = !LSI->HasImplicitReturnType;
-LambdaExprNeedsCleanups = LSI->ExprNeedsCleanups;
+LambdaCleanup = LSI->Cleanup;
 ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack;

[PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-05-20 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.

With all MaterializeTemporaryExprs coming with a ExprWithCleanups, it's
easy to add correct lifetime.end marks into the right RunCleanupsScope.

http://reviews.llvm.org/D20499

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  test/CodeGen/temporary-lifetime.cpp

Index: test/CodeGen/temporary-lifetime.cpp
===
--- /dev/null
+++ test/CodeGen/temporary-lifetime.cpp
@@ -0,0 +1,165 @@
+// RUN: %clang_cc1 %s -std=c++11 -O1 -DWITH_DTOR -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-DTOR %s
+// RUN: %clang_cc1 %s -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-NO-DTOR %s
+
+struct A {
+  A();
+#ifdef WITH_DTOR
+  ~A();
+#endif
+  char a[1024];
+  operator bool() const;
+};
+
+template 
+void Foo(T &&);
+
+template 
+void Bar(T &&);
+
+template 
+T Baz();
+
+void Test1() {
+  // CHECK-DTOR-LABEL: Test1
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test1
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: }
+  {
+const A &a = A{};
+Foo(a);
+  }
+  {
+const A &a = A{};
+Foo(a);
+  }
+}
+
+void Test2() {
+  // CHECK-DTOR-LABEL: Test2
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test2
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-NO-DTOR: }
+  const A &a = A{};
+  Foo(a);
+  const A &b = A{};
+  Foo(b);
+}
+
+void Test3() {
+  // CHECK-DTOR-LABEL: Test3
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: if.then:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: }
+  const A &a = A{};
+  if (const A &b = A(a)) {
+Foo(b);
+return;
+  }
+  Bar(a);
+}
+
+void Test4() {
+  // CHECK-DTOR-LABEL: Test4
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: for.cond.cleanup:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: for.body:
+  // CHECK-DTOR: }
+  for (const A &a = A{}; a;) {
+Foo(a);
+  }
+}
+
+int Test5() {
+  // CHECK-DTOR-LABEL: Test5
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: call i32 @_Z3BazIiET_v()
+  // CHECK-DTOR: store
+  // C

Re: [PATCH] D19930: [Lifetime] Add lifetime markers for C++ lifetime-extended temporaries

2016-05-20 Thread Tim Shen via cfe-commits
timshen abandoned this revision.
timshen added a comment.

Abandon this change, since http://reviews.llvm.org/D20498 and 
http://reviews.llvm.org/D20499 handle all temporaries.


http://reviews.llvm.org/D19930



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


Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-05-26 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 58676.
timshen added a comment.

Update to reflect the comments.


http://reviews.llvm.org/D20498

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Sema/CleanupInfo.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/Analysis/Consumed.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -999,8 +999,8 @@
   EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
 "const Foo f = Foo();",
   varDecl(hasInitializer(exprWithCleanups();
-  EXPECT_FALSE(matches("struct Foo { };"
- "const Foo f = Foo();",
+  EXPECT_FALSE(matches("struct Foo { }; Foo a;"
+   "const Foo f = a;",
varDecl(hasInitializer(exprWithCleanups();
 }
 
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1430,7 +1430,8 @@
   Record.push_back(E->getNumObjects());
   for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
 Record.AddDeclRef(E->getObject(i));
-  
+
+  Record.push_back(E->cleanupsHaveSideEffects());
   Record.AddStmt(E->getSubExpr());
   Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
 }
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1448,6 +1448,7 @@
 E->getTrailingObjects()[i] =
 ReadDeclAs(Record, Idx);
 
+  E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
   E->SubExpr = Reader.ReadSubExpr();
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1518,6 +1518,10 @@
   // variables Increment and DRE.
   bool ProcessIterationStmt(Sema &S, Stmt* Statement, bool &Increment,
 DeclRefExpr *&DRE) {
+if (auto Cleanups = dyn_cast(Statement))
+  if (!Cleanups->cleanupsHaveSideEffects())
+Statement = Cleanups->getSubExpr();
+
 if (UnaryOperator *UO = dyn_cast(Statement)) {
   switch (UO->getOpcode()) {
 default: return false;
@@ -2472,6 +2476,10 @@
 
   QualType VariableType = VD->getType();
 
+  if (auto Cleanups = dyn_cast(InitExpr))
+if (!Cleanups->cleanupsHaveSideEffects())
+  InitExpr = Cleanups->getSubExpr();
+
   const MaterializeTemporaryExpr *MTE =
   dyn_cast(InitExpr);
 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -3792,6 +3792,10 @@
 }
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   InitSrcRange = S->getSourceRange();
   if (Expr *E = dyn_cast(S))
 S = E->IgnoreParens();
@@ -3979,6 +3983,10 @@
 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_incr) << LCDecl;
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   IncrementSrcRange = S->getSourceRange();
   S = S->IgnoreParens();
   if (auto UO = dyn_cast(S)) {
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1500,7 +1500,7 @@
   SourceRange IntroducerRange;
   bool ExplicitParams;
   bool ExplicitResultType;
-  bool LambdaExprNeedsCleanups;
+  CleanupInfo LambdaCleanup;
   bool ContainsUnexpandedParameterPack;
   SmallVector ArrayIndexVars;
   SmallVector ArrayIndexStarts;
@@ -1510,7 +1510,7 @@
 IntroducerRange = LSI->IntroducerRange;
 ExplicitParams = LSI->ExplicitParams;
 ExplicitResultType = !LSI->HasImplicitReturnType;
-LambdaExprNeedsCleanups = LSI->ExprNeedsCleanups;
+LambdaCleanup = LSI->Cleanup;
 ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack;
 
 CallOperator->setLexicalDeclContext(Class);
@@ -1591,9 +1591,8 @@
 CheckCompletedCXXClass(Class);
   }
 
-  if (LambdaExprNeedsCleanups)
-ExprNeedsCleanups = true;
-  
+  Cleanup.mergeFrom(LambdaCleanup);
+
   Lambda

Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-05-26 Thread Tim Shen via cfe-commits
timshen marked 7 inline comments as done.


Comment at: lib/Sema/SemaInit.cpp:6190-6191
@@ +6189,4 @@
+  MaterializeTemporaryExpr(T, Temporary, BoundToLvalueReference);
+
+  // Order an ExprWithCleanups for lifetime marks.
+  //

> Please also sink the calls to mark the destructor referenced and check its 
> access into here too. We should keep the checks for a usable destructor and 
> the triggering of an ExprWithCleanups for the destructor together.

As discussed, MaybeBindToTemporary more or less overlaps with this in the 
access checking perspective. Added a TODO for a potential merge of 
MaterializeTemporaryExpr and BindToCXXTemporary in the future.

> I think this may set ExprNeedsCleanups even when unnecessary, if the MTE is 
> lifetime-extended (I think you only actually want an ExprWithCleanups if the 
> storage duration is SD_Automatic). We can't really deal with that here, 
> because we don't know the storage duration of the MTE yet, but please add a 
> FIXME here to not set ExprNeedsCleanups if the temporary is lifetime-extended.

Due to the use of pushCleanupAfterFullExpr in 
CodeGen::EmitMaterializeTemporaryExpr, there has to have a RunCleanupsScope at 
FullExpr level to delay and forward the cleanups to its upper level. So even 
for lifetime-extended variables, the cleanup scope is necessary.


http://reviews.llvm.org/D20498



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


Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-05-26 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 58694.
timshen marked 2 inline comments as done.
timshen added a comment.

Removed C++ constrain and added back the missing comment line.


http://reviews.llvm.org/D20498

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Sema/CleanupInfo.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/Analysis/Consumed.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -999,8 +999,8 @@
   EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
 "const Foo f = Foo();",
   varDecl(hasInitializer(exprWithCleanups();
-  EXPECT_FALSE(matches("struct Foo { };"
- "const Foo f = Foo();",
+  EXPECT_FALSE(matches("struct Foo { }; Foo a;"
+   "const Foo f = a;",
varDecl(hasInitializer(exprWithCleanups();
 }
 
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1430,7 +1430,8 @@
   Record.push_back(E->getNumObjects());
   for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
 Record.AddDeclRef(E->getObject(i));
-  
+
+  Record.push_back(E->cleanupsHaveSideEffects());
   Record.AddStmt(E->getSubExpr());
   Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
 }
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1448,6 +1448,7 @@
 E->getTrailingObjects()[i] =
 ReadDeclAs(Record, Idx);
 
+  E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
   E->SubExpr = Reader.ReadSubExpr();
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1518,6 +1518,10 @@
   // variables Increment and DRE.
   bool ProcessIterationStmt(Sema &S, Stmt* Statement, bool &Increment,
 DeclRefExpr *&DRE) {
+if (auto Cleanups = dyn_cast(Statement))
+  if (!Cleanups->cleanupsHaveSideEffects())
+Statement = Cleanups->getSubExpr();
+
 if (UnaryOperator *UO = dyn_cast(Statement)) {
   switch (UO->getOpcode()) {
 default: return false;
@@ -2472,6 +2476,10 @@
 
   QualType VariableType = VD->getType();
 
+  if (auto Cleanups = dyn_cast(InitExpr))
+if (!Cleanups->cleanupsHaveSideEffects())
+  InitExpr = Cleanups->getSubExpr();
+
   const MaterializeTemporaryExpr *MTE =
   dyn_cast(InitExpr);
 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -3792,6 +3792,10 @@
 }
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   InitSrcRange = S->getSourceRange();
   if (Expr *E = dyn_cast(S))
 S = E->IgnoreParens();
@@ -3979,6 +3983,10 @@
 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_incr) << LCDecl;
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   IncrementSrcRange = S->getSourceRange();
   S = S->IgnoreParens();
   if (auto UO = dyn_cast(S)) {
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1500,7 +1500,7 @@
   SourceRange IntroducerRange;
   bool ExplicitParams;
   bool ExplicitResultType;
-  bool LambdaExprNeedsCleanups;
+  CleanupInfo LambdaCleanup;
   bool ContainsUnexpandedParameterPack;
   SmallVector ArrayIndexVars;
   SmallVector ArrayIndexStarts;
@@ -1510,7 +1510,7 @@
 IntroducerRange = LSI->IntroducerRange;
 ExplicitParams = LSI->ExplicitParams;
 ExplicitResultType = !LSI->HasImplicitReturnType;
-LambdaExprNeedsCleanups = LSI->ExprNeedsCleanups;
+LambdaCleanup = LSI->Cleanup;
 ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack;
 
 CallOperator->setLexicalDeclContext(Class);
@@ -1591,9 +1591,8 @@
 CheckCompletedCXXClass(Class);
   }
 
-  if (LambdaExprNeedsCleanups)
-ExprN

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-05-26 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 58734.
timshen added a comment.
Herald added a subscriber: klimek.

Used pushFullExprCleanup.

microsoft-abi-eh-cleanups.cpp fails because each pushFullExprCleanup introduces 
a new cleanup.cond variable, even if that pushFullExprCleanup is just for 
lifetime marks. With LLVM optimizations turned on (e.g. -O1), these 
cleanup.conds get eliminated; -O0 doesn't generate lifetime marks. So there is 
no practical affect unless "-disable-llvm-optzns -O3" -- as the test does -- 
are passed together.


http://reviews.llvm.org/D20499

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Sema/CleanupInfo.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/Analysis/Consumed.cpp
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGen/temporary-lifetime.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -999,8 +999,8 @@
   EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
 "const Foo f = Foo();",
   varDecl(hasInitializer(exprWithCleanups();
-  EXPECT_FALSE(matches("struct Foo { };"
- "const Foo f = Foo();",
+  EXPECT_FALSE(matches("struct Foo { }; Foo a;"
+   "const Foo f = a;",
varDecl(hasInitializer(exprWithCleanups();
 }
 
Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm -O3 -disable-llvm-optzns %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-LIFETIME %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-O0 %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -O3 -disable-llvm-optzns %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-O3 -check-prefix WIN32-LIFETIME %s
 
 struct A {
   A();
@@ -95,40 +95,78 @@
   return (cond ? TakesTwo((TakeRef(A()), A()), (TakeRef(A()), A())) : CouldThrow());
 }
 
-// WIN32-LABEL: define i32 @"\01?HasConditionalDeactivatedCleanups@@YAH_N@Z"{{.*}} {
-// WIN32:   alloca i1
-// WIN32:   %[[arg1_cond:.*]] = alloca i1
+// WIN32-O0-LABEL: define i32 @"\01?HasConditionalDeactivatedCleanups@@YAH_N@Z"{{.*}} {
+// WIN32-O0:   alloca i1
+// WIN32-O0:   %[[arg1_cond:.*]] = alloca i1
 //Start all four cleanups as deactivated.
-// WIN32:   store i1 false
-// WIN32:   store i1 false
-// WIN32:   store i1 false
-// WIN32:   store i1 false
-// WIN32:   br i1
+// WIN32-O0:   store i1 false
+// WIN32-O0:   store i1 false
+// WIN32-O0:   store i1 false
+// WIN32-O0:   store i1 false
+// WIN32-O0:   br i1
 //True condition.
-// WIN32:   call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true
-// WIN32:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
-// WIN32:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true, i1* %[[arg1_cond]]
-// WIN32:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true
-// WIN32:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
-// WIN32:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true
-// WIN32:   store i1 false, i1* %[[arg1_cond]]
-// WIN32:   invoke i32 @"\01?TakesTwo@@YAHUA@@0@Z"
+// WIN32-O0:   call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true
+// WIN32-O0:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
+// WIN32-O0:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true, i1* %[[arg1_cond]]
+// WIN32-O0:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true
+// WIN32-O0:   invoke void @"\01?TakeRef@

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-05-26 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 58738.
timshen added a comment.

Upload the rebased patch.


http://reviews.llvm.org/D20499

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  test/CodeGen/temporary-lifetime.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm -O3 -disable-llvm-optzns %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-LIFETIME %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-O0 %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -O3 -disable-llvm-optzns %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-O3 -check-prefix WIN32-LIFETIME %s
 
 struct A {
   A();
@@ -95,40 +95,78 @@
   return (cond ? TakesTwo((TakeRef(A()), A()), (TakeRef(A()), A())) : CouldThrow());
 }
 
-// WIN32-LABEL: define i32 @"\01?HasConditionalDeactivatedCleanups@@YAH_N@Z"{{.*}} {
-// WIN32:   alloca i1
-// WIN32:   %[[arg1_cond:.*]] = alloca i1
+// WIN32-O0-LABEL: define i32 @"\01?HasConditionalDeactivatedCleanups@@YAH_N@Z"{{.*}} {
+// WIN32-O0:   alloca i1
+// WIN32-O0:   %[[arg1_cond:.*]] = alloca i1
 //Start all four cleanups as deactivated.
-// WIN32:   store i1 false
-// WIN32:   store i1 false
-// WIN32:   store i1 false
-// WIN32:   store i1 false
-// WIN32:   br i1
+// WIN32-O0:   store i1 false
+// WIN32-O0:   store i1 false
+// WIN32-O0:   store i1 false
+// WIN32-O0:   store i1 false
+// WIN32-O0:   br i1
 //True condition.
-// WIN32:   call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true
-// WIN32:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
-// WIN32:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true, i1* %[[arg1_cond]]
-// WIN32:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true
-// WIN32:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
-// WIN32:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
-// WIN32:   store i1 true
-// WIN32:   store i1 false, i1* %[[arg1_cond]]
-// WIN32:   invoke i32 @"\01?TakesTwo@@YAHUA@@0@Z"
+// WIN32-O0:   call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true
+// WIN32-O0:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
+// WIN32-O0:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true, i1* %[[arg1_cond]]
+// WIN32-O0:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true
+// WIN32-O0:   invoke void @"\01?TakeRef@@YAXABUA@@@Z"
+// WIN32-O0:   invoke x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O0:   store i1 true
+// WIN32-O0:   store i1 false, i1* %[[arg1_cond]]
+// WIN32-O0:   invoke i32 @"\01?TakesTwo@@YAHUA@@0@Z"
 //False condition.
-// WIN32:   invoke i32 @"\01?CouldThrow@@YAHXZ"()
+// WIN32-O0:   invoke i32 @"\01?CouldThrow@@YAHXZ"()
 //Two normal cleanups for TakeRef args.
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
-// WIN32-NOT:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"
-// WIN32:   ret i32
+// WIN32-O0:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
+// WIN32-O0-NOT:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"
+// WIN32-O0:   ret i32
 //
 //Somewhere in the landing pad soup, we conditionally destroy arg1.
-// WIN32:   %[[isactive:.*]] = load i1, i1* %[[arg1_cond]]
-// WIN32:   br i1 %[[isactive]]
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
-// WIN32: }
+// WIN32-O0:   %[[isactive:.*]] = load i1, i1* %[[arg1_cond]]
+// WIN32-O0:   br i1 %[[isactive]]
+// WIN32-O0:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
+// WIN32-O0: }
+
+// WIN32-O3-LABEL: define i32 @"\01?HasConditionalDeactivatedCleanups@@YAH_N@Z"{{.*}} {
+// WIN32-O3:   alloca i1
+// WIN32-O3:   alloca i1
+// WIN32-O3:   %[[arg1_cond:.*]] = alloca i1
+//Start all four cleanups as deactivated.
+// WIN32-O3:   store i1 false
+// WIN32-O3:   store i1 false
+// WIN32-O3:   store i1 false
+// WIN32-O3:   store i1 false
+// WIN32-O3:   store i1 false
+// WIN32-O3:   store i1 false
+// WIN32-O3:   br i1
+//True condition.
+// WIN32-O3:   call x86_thiscallcc %struct.A* @"\01??0A@@QAE@XZ"
+// WIN32-O3:   store i1 true
+// WIN32-O3:   invoke void @"\01?TakeRef@@YAXABUA@@

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-05-26 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 58737.
timshen added a comment.

Upload the rebased patch.


http://reviews.llvm.org/D20499

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Sema/CleanupInfo.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/Analysis/Consumed.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -999,8 +999,8 @@
   EXPECT_TRUE(matches("struct Foo { ~Foo(); };"
 "const Foo f = Foo();",
   varDecl(hasInitializer(exprWithCleanups();
-  EXPECT_FALSE(matches("struct Foo { };"
- "const Foo f = Foo();",
+  EXPECT_FALSE(matches("struct Foo { }; Foo a;"
+   "const Foo f = a;",
varDecl(hasInitializer(exprWithCleanups();
 }
 
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1430,7 +1430,8 @@
   Record.push_back(E->getNumObjects());
   for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
 Record.AddDeclRef(E->getObject(i));
-  
+
+  Record.push_back(E->cleanupsHaveSideEffects());
   Record.AddStmt(E->getSubExpr());
   Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
 }
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1448,6 +1448,7 @@
 E->getTrailingObjects()[i] =
 ReadDeclAs(Record, Idx);
 
+  E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
   E->SubExpr = Reader.ReadSubExpr();
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1518,6 +1518,10 @@
   // variables Increment and DRE.
   bool ProcessIterationStmt(Sema &S, Stmt* Statement, bool &Increment,
 DeclRefExpr *&DRE) {
+if (auto Cleanups = dyn_cast(Statement))
+  if (!Cleanups->cleanupsHaveSideEffects())
+Statement = Cleanups->getSubExpr();
+
 if (UnaryOperator *UO = dyn_cast(Statement)) {
   switch (UO->getOpcode()) {
 default: return false;
@@ -2472,6 +2476,10 @@
 
   QualType VariableType = VD->getType();
 
+  if (auto Cleanups = dyn_cast(InitExpr))
+if (!Cleanups->cleanupsHaveSideEffects())
+  InitExpr = Cleanups->getSubExpr();
+
   const MaterializeTemporaryExpr *MTE =
   dyn_cast(InitExpr);
 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -3792,6 +3792,10 @@
 }
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   InitSrcRange = S->getSourceRange();
   if (Expr *E = dyn_cast(S))
 S = E->IgnoreParens();
@@ -3979,6 +3983,10 @@
 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_incr) << LCDecl;
 return true;
   }
+  if (auto *ExprTemp = dyn_cast(S))
+if (!ExprTemp->cleanupsHaveSideEffects())
+  S = ExprTemp->getSubExpr();
+
   IncrementSrcRange = S->getSourceRange();
   S = S->IgnoreParens();
   if (auto UO = dyn_cast(S)) {
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1500,7 +1500,7 @@
   SourceRange IntroducerRange;
   bool ExplicitParams;
   bool ExplicitResultType;
-  bool LambdaExprNeedsCleanups;
+  CleanupInfo LambdaCleanup;
   bool ContainsUnexpandedParameterPack;
   SmallVector ArrayIndexVars;
   SmallVector ArrayIndexStarts;
@@ -1510,7 +1510,7 @@
 IntroducerRange = LSI->IntroducerRange;
 ExplicitParams = LSI->ExplicitParams;
 ExplicitResultType = !LSI->HasImplicitReturnType;
-LambdaExprNeedsCleanups = LSI->ExprNeedsCleanups;
+LambdaCleanup = LSI->Cleanup;
 ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack;
 
 CallOperator->setLexicalDeclContext(Class);
@@ -1591,9 +1591,8 @@
 CheckCompletedCXXClass(Class);
   }
 
-  if (LambdaExprNeedsCleanups)
-ExprNeedsCleanups = true;
-  
+  Cleanup.mergeFrom(LambdaCleanup);
+
   LambdaExpr *

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-05-26 Thread Tim Shen via cfe-commits
timshen marked an inline comment as done.
timshen added a comment.

http://reviews.llvm.org/D20499



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


Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-06-06 Thread Tim Shen via cfe-commits
timshen added a comment.

I'm looking at some internal test failures caused by this patch.


http://reviews.llvm.org/D20499



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


Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-06-09 Thread Tim Shen via cfe-commits
timshen marked an inline comment as done.
timshen added a comment.

Ping? :)


http://reviews.llvm.org/D20498



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


r272296 - [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.

2016-06-09 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  9 14:54:46 2016
New Revision: 272296

URL: http://llvm.org/viewvc/llvm-project?rev=272296&view=rev
Log:
[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.

These ExprWithCleanups are added for holding a RunCleanupsScope not
for destructor calls; rather, they are for lifetime marks. This requires
ExprWithCleanups to keep a bit to indicate whether it have cleanups with
side effects (e.g. dtor calls).

Differential Revision: http://reviews.llvm.org/D20498

Added:
cfe/trunk/include/clang/Sema/CleanupInfo.h
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Analysis/Consumed.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=272296&r1=272295&r2=272296&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Jun  9 14:54:46 2016
@@ -2877,7 +2877,8 @@ private:
   Stmt *SubExpr;
 
   ExprWithCleanups(EmptyShell, unsigned NumObjects);
-  ExprWithCleanups(Expr *SubExpr, ArrayRef Objects);
+  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
+   ArrayRef Objects);
 
   friend TrailingObjects;
   friend class ASTStmtReader;
@@ -2887,6 +2888,7 @@ public:
   unsigned numObjects);
 
   static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
+  bool CleanupsHaveSideEffects,
   ArrayRef objects);
 
   ArrayRef getObjects() const {
@@ -2903,6 +2905,9 @@ public:
 
   Expr *getSubExpr() { return cast(SubExpr); }
   const Expr *getSubExpr() const { return cast(SubExpr); }
+  bool cleanupsHaveSideEffects() const {
+return ExprWithCleanupsBits.CleanupsHaveSideEffects;
+  }
 
   /// As with any mutator of the AST, be very careful
   /// when modifying an existing AST to preserve its invariants.

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=272296&r1=272295&r2=272296&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun  9 14:54:46 2016
@@ -192,7 +192,10 @@ protected:
 
 unsigned : NumExprBits;
 
-unsigned NumObjects : 32 - NumExprBits;
+// When false, it must not have side effects.
+bool CleanupsHaveSideEffects : 1;
+
+unsigned NumObjects : 32 - 1 - NumExprBits;
   };
 
   class PseudoObjectExprBitfields {

Added: cfe/trunk/include/clang/Sema/CleanupInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CleanupInfo.h?rev=272296&view=auto
==
--- cfe/trunk/include/clang/Sema/CleanupInfo.h (added)
+++ cfe/trunk/include/clang/Sema/CleanupInfo.h Thu Jun  9 14:54:46 2016
@@ -0,0 +1,47 @@
+//===--- CleanupInfo.cpp - Cleanup Control in Sema 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file implements a set of operations on whether generating an
+//  ExprWithCleanups in a full expression.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_SEMA_CLEANUP_INFO_H
+#define LLVM_CLANG_SEMA_CLEANUP_INFO_H
+
+namespace clang {
+
+class CleanupInfo {
+  bool ExprNeedsCleanups = false;
+  bool CleanupsHaveSideEffects = false;
+
+public:
+  bool exprNeedsCleanups() const { return ExprNeedsCleanups; }
+
+  bool cleanupsHaveSideEffects() const { return CleanupsHaveSideEffects; }
+
+  void setExprNeedsCleanups(bool SideEffects) {
+ExprNeedsCleanups = true;
+CleanupsHaveSideEffects |= SideEffects;
+  }
+
+  void reset() {
+ExprNeedsCleanups = false;
+CleanupsHaveSideEffects = false;

Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-06-09 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL272296: [Temporary] Add an ExprWithCleanups for each C++ 
MaterializeTemporaryExpr. (authored by timshen).

Changed prior to commit:
  http://reviews.llvm.org/D20498?vs=58694&id=60227#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20498

Files:
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/Sema/CleanupInfo.h
  cfe/trunk/include/clang/Sema/ScopeInfo.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprCXX.cpp
  cfe/trunk/lib/Analysis/Consumed.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -764,6 +764,12 @@
 return Visit(DIE->getExpr());
   }
 
+  llvm::Constant *VisitExprWithCleanups(ExprWithCleanups *E) {
+if (!E->cleanupsHaveSideEffects())
+  return Visit(E->getSubExpr());
+return nullptr;
+  }
+
   llvm::Constant *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
 return Visit(E->GetTemporaryExpr());
   }
Index: cfe/trunk/lib/AST/ExprCXX.cpp
===
--- cfe/trunk/lib/AST/ExprCXX.cpp
+++ cfe/trunk/lib/AST/ExprCXX.cpp
@@ -1039,23 +1039,27 @@
 }
 
 ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
+   bool CleanupsHaveSideEffects,
ArrayRef objects)
   : Expr(ExprWithCleanupsClass, subexpr->getType(),
  subexpr->getValueKind(), subexpr->getObjectKind(),
  subexpr->isTypeDependent(), subexpr->isValueDependent(),
  subexpr->isInstantiationDependent(),
  subexpr->containsUnexpandedParameterPack()),
 SubExpr(subexpr) {
+  ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
   ExprWithCleanupsBits.NumObjects = objects.size();
   for (unsigned i = 0, e = objects.size(); i != e; ++i)
 getTrailingObjects()[i] = objects[i];
 }
 
 ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr,
+   bool CleanupsHaveSideEffects,
ArrayRef objects) {
   void *buffer = C.Allocate(totalSizeToAlloc(objects.size()),
 llvm::alignOf());
-  return new (buffer) ExprWithCleanups(subexpr, objects);
+  return new (buffer)
+  ExprWithCleanups(subexpr, CleanupsHaveSideEffects, objects);
 }
 
 ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -2890,7 +2890,6 @@
   case CXXThrowExprClass:
   case CXXNewExprClass:
   case CXXDeleteExprClass:
-  case ExprWithCleanupsClass:
   case CoawaitExprClass:
   case CoyieldExprClass:
 // These always have a side-effect.
@@ -2903,6 +2902,12 @@
 return Finder.hasSideEffects();
   }
 
+  case ExprWithCleanupsClass:
+if (IncludePossibleEffects)
+  if (cast(this)->cleanupsHaveSideEffects())
+return true;
+break;
+
   case ParenExprClass:
   case ArraySubscriptExprClass:
   case OMPArraySectionExprClass:
Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -1518,6 +1518,10 @@
   // variables Increment and DRE.
   bool ProcessIterationStmt(Sema &S, Stmt* Statement, bool &Increment,
 DeclRefExpr *&DRE) {
+if (auto Cleanups = dyn_cast(Statement))
+  if (!Cleanups->cleanupsHaveSideEffects())
+Statement = Cleanups->getSubExpr();
+
 if (UnaryOperator *UO = dyn_cast(Statement)) {
   switch (UO->getOpcode()) {
 default: return false;
@@ -2472,6 +2476,10 @@
 
   QualType VariableType = VD->getType();
 
+  if (auto Cleanups = dyn_cast(InitExpr))
+if (!Cleanups->cleanupsHaveSideEffects())
+  InitExpr = Cleanups->getSubExpr();
+
   const MaterializeTemporaryExpr *MTE =
   dyn_cast(InitExpr);
 
Index: cfe/trunk/lib/Sema/SemaLambda.cpp
===
--- cfe/trunk/lib/Sema/SemaLambda

r272310 - Revert "[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr."

2016-06-09 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Jun  9 16:13:39 2016
New Revision: 272310

URL: http://llvm.org/viewvc/llvm-project?rev=272310&view=rev
Log:
Revert "[Temporary] Add an ExprWithCleanups for each C++ 
MaterializeTemporaryExpr."

This reverts r272296, since there are clang-tidy failures that appear to
be caused by this change.

Removed:
cfe/trunk/include/clang/Sema/CleanupInfo.h
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Analysis/Consumed.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=272310&r1=272309&r2=272310&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Jun  9 16:13:39 2016
@@ -2877,8 +2877,7 @@ private:
   Stmt *SubExpr;
 
   ExprWithCleanups(EmptyShell, unsigned NumObjects);
-  ExprWithCleanups(Expr *SubExpr, bool CleanupsHaveSideEffects,
-   ArrayRef Objects);
+  ExprWithCleanups(Expr *SubExpr, ArrayRef Objects);
 
   friend TrailingObjects;
   friend class ASTStmtReader;
@@ -2888,7 +2887,6 @@ public:
   unsigned numObjects);
 
   static ExprWithCleanups *Create(const ASTContext &C, Expr *subexpr,
-  bool CleanupsHaveSideEffects,
   ArrayRef objects);
 
   ArrayRef getObjects() const {
@@ -2905,9 +2903,6 @@ public:
 
   Expr *getSubExpr() { return cast(SubExpr); }
   const Expr *getSubExpr() const { return cast(SubExpr); }
-  bool cleanupsHaveSideEffects() const {
-return ExprWithCleanupsBits.CleanupsHaveSideEffects;
-  }
 
   /// As with any mutator of the AST, be very careful
   /// when modifying an existing AST to preserve its invariants.

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=272310&r1=272309&r2=272310&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun  9 16:13:39 2016
@@ -192,10 +192,7 @@ protected:
 
 unsigned : NumExprBits;
 
-// When false, it must not have side effects.
-bool CleanupsHaveSideEffects : 1;
-
-unsigned NumObjects : 32 - 1 - NumExprBits;
+unsigned NumObjects : 32 - NumExprBits;
   };
 
   class PseudoObjectExprBitfields {

Removed: cfe/trunk/include/clang/Sema/CleanupInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CleanupInfo.h?rev=272309&view=auto
==
--- cfe/trunk/include/clang/Sema/CleanupInfo.h (original)
+++ cfe/trunk/include/clang/Sema/CleanupInfo.h (removed)
@@ -1,47 +0,0 @@
-//===--- CleanupInfo.cpp - Cleanup Control in Sema 
===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-//  This file implements a set of operations on whether generating an
-//  ExprWithCleanups in a full expression.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_SEMA_CLEANUP_INFO_H
-#define LLVM_CLANG_SEMA_CLEANUP_INFO_H
-
-namespace clang {
-
-class CleanupInfo {
-  bool ExprNeedsCleanups = false;
-  bool CleanupsHaveSideEffects = false;
-
-public:
-  bool exprNeedsCleanups() const { return ExprNeedsCleanups; }
-
-  bool cleanupsHaveSideEffects() const { return CleanupsHaveSideEffects; }
-
-  void setExprNeedsCleanups(bool SideEffects) {
-ExprNeedsCleanups = true;
-CleanupsHaveSideEffects |= SideEffects;
-  }
-
-  void reset() {
-ExprNeedsCleanups = false;
-CleanupsHaveSideEffects = false;
-  }
-
-  void mergeFrom(CleanupInfo Rhs) {
-ExprNeedsCleanups |= Rhs.ExprNeedsCleanups;
-CleanupsHaveSideEffects |= Rhs.CleanupsHaveSideEffects;
-  }
-};
-
-} // end namespace clang
-
-#endi

[PATCH] D21241: Add an ASTMatcher for ignoring ExprWithCleanups.

2016-06-10 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This is part of the fix of clang-tidy patterns to adapt to newly added 
ExprWithCleanups node.

http://reviews.llvm.org/D21241

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -625,6 +625,16 @@
   return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
 }
 
+/// \brief Matches expressions that match InnerMatcher after ExprWithCleanups
+/// are stripped off.
+AST_MATCHER_P(Expr, ignoringExprWithCleanups, internal::Matcher,
+  InnerMatcher) {
+  auto E = &Node;
+  if (auto Cleanups = dyn_cast(E))
+E = Cleanups->getSubExpr();
+  return InnerMatcher.matches(*E, Finder, Builder);
+}
+
 /// \brief Matches types that match InnerMatcher after any parens are stripped.
 ///
 /// Given


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -625,6 +625,16 @@
   return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
 }
 
+/// \brief Matches expressions that match InnerMatcher after ExprWithCleanups
+/// are stripped off.
+AST_MATCHER_P(Expr, ignoringExprWithCleanups, internal::Matcher,
+  InnerMatcher) {
+  auto E = &Node;
+  if (auto Cleanups = dyn_cast(E))
+E = Cleanups->getSubExpr();
+  return InnerMatcher.matches(*E, Finder, Builder);
+}
+
 /// \brief Matches types that match InnerMatcher after any parens are stripped.
 ///
 /// Given
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21243: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-10 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.

This is a fix for the new ExprWithCleanups introduced by clang's temporary 
variable lifetime marks change.

http://reviews.llvm.org/D21243

Files:
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/readability/RedundantStringInitCheck.cpp

Index: clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -48,12 +48,13 @@
   // string foo = "";
   // string bar("");
   Finder->addMatcher(
-  namedDecl(varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
-hasInitializer(
-expr(anyOf(EmptyStringCtorExpr,
-   EmptyStringCtorExprWithTemporaries))
-.bind("expr"))),
-unless(parmVarDecl()))
+  namedDecl(
+  varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
+  hasInitializer(expr(ignoringExprWithCleanups(anyOf(
+  EmptyStringCtorExpr,
+  EmptyStringCtorExprWithTemporaries)))
+ .bind("expr"))),
+  unless(parmVarDecl()))
   .bind("decl"),
   this);
 }
Index: clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tidy/modernize/UseAutoCheck.cpp
@@ -42,6 +42,9 @@
   if (!Init)
 return false;
 
+  if (const auto *E = dyn_cast(Init))
+Init = E->getSubExpr();
+
   // The following test is based on DeclPrinter::VisitVarDecl() to find if an
   // initializer is implicit or not.
   if (const auto *Construct = dyn_cast(Init)) {
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -156,6 +156,8 @@
 const Expr *digThroughConstructors(const Expr *E) {
   if (!E)
 return nullptr;
+  if (auto Cleanups = dyn_cast(E))
+E = Cleanups->getSubExpr();
   E = E->IgnoreParenImpCasts();
   if (const auto *ConstructExpr = dyn_cast(E)) {
 // The initial constructor must take exactly one parameter, but base class
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -141,10 +141,10 @@
   StatementMatcher IteratorComparisonMatcher = expr(
   ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  StatementMatcher OverloadedNEQMatcher = ignoringExprWithCleanups(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by
Index: clang-tidy/misc/DanglingHandleCheck.cpp
===
--- clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tidy/misc/DanglingHandleCheck.cpp
@@ -135,15 +135,15 @@
   //   1. Value to Handle conversion.
   //   2. Handle copy construction.
   // We have to match both.
-  has(ignoringParenImpCasts(handleFrom(
+  has(ignoringExprWithCleanups(ignoringParenImpCasts(handleFrom(
   IsAHandle,
   handleFrom(IsAHandle, declRefExpr(to(varDecl(
 // Is function scope ...
 hasAutomaticStorageDuration(),
 // ... and it is a local array or Value.
 anyOf(hasType(arrayType()),
   hasType(recordDecl(
-  unless(IsAHandle))),
+  unless(IsAHandle,
   // Temporary fix for false positives inside lambdas.
   unless(hasAncestor(lambdaExpr(
   .bind("bad_stmt"),
Index: clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tidy/llvm/TwineLocalCheck.cpp
@@ -34,6

Re: [PATCH] D20498: [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr

2016-06-10 Thread Tim Shen via cfe-commits
timshen reopened this revision.
timshen added a comment.
This revision is now accepted and ready to land.

Clang-tidy is broken by this change. Dependency is added to track the fix.


Repository:
  rL LLVM

http://reviews.llvm.org/D20498



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


Re: [PATCH] D21243: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-13 Thread Tim Shen via cfe-commits
timshen added a comment.

In http://reviews.llvm.org/D21243#455999, @alexfh wrote:

> Does this just fix the tests broken with http://reviews.llvm.org/D20498 or 
> have you looked at other checks that might be broken by 
> http://reviews.llvm.org/D20498, but don't have relevant tests?


This just fixes the tests broken by http://reviews.llvm.org/D20498. I didn't 
look at other patterns.

> Actually, the more interesting question is what patterns in the analyzed code 
> generate `ExprWithCleanups`?


A MaterializeTemporaryExpr now will always generate an ExprWithCleanups at 
full-expr entry. That is to say, there must be an ExprWithCleanups as an 
ancestor node of a MaterializeTemporaryExpr.

For example, the previous pattern:

  fooStmt(has(
barExpr(
  hasDescendant(
materializeTemporaryExpr()

should be changed to:

  fooStmt(has(
exprWithCleanups(
  barExpr(
hasDescendant(
  materializeTemporaryExpr(

There are patterns around that are not explicitly checking for a 
MaterializeTemporaryExpr. If in the checked AST there is a 
MaterializeTemporaryExpr, an ignoringExprWithCleanups should be added to each 
of these patterns.

Does this help?


http://reviews.llvm.org/D21243



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


Re: [PATCH] D21241: Add an ASTMatcher for ignoring ExprWithCleanups.

2016-06-14 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 60704.
timshen added a comment.

Done.


http://reviews.llvm.org/D21241

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1997,5 +1997,34 @@
   EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
 }
 
+TEST(IgnoringExprWithCleanups, MatchesExprWithCleanups) {
+  EXPECT_TRUE(
+  matches("struct A { ~A(); }; A Foo(); A x = Foo();",
+  varDecl(hasInitializer(ignoringExprWithCleanups(
+  cxxConstructExpr(has(materializeTemporaryExpr(;
+}
+
+TEST(IgnoringExprWithCleanups, MatchesWithoutExprWithCleanups) {
+  EXPECT_TRUE(matches(
+  "int x = 0; const int y = x;",
+  varDecl(hasInitializer(ignoringExprWithCleanups(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("x"));
+}
+
+TEST(IgnoringExprWithCleanups, DoesNotMatchIncorrectly) {
+  EXPECT_TRUE(notMatches("char c = ((3));",
+ varDecl(hasInitializer(ignoringExprWithCleanups(
+ ignoringParenImpCasts(unless(anything(;
+  EXPECT_TRUE(notMatches("float y = (float(0));",
+ varDecl(hasInitializer(ignoringExprWithCleanups(
+ ignoringParenImpCasts(integerLiteral()));
+  EXPECT_TRUE(notMatches("float y = (float)0;",
+ varDecl(hasInitializer(ignoringExprWithCleanups(
+ ignoringParenImpCasts(integerLiteral()));
+  EXPECT_TRUE(notMatches("char* p = static_cast(0);",
+ varDecl(hasInitializer(ignoringExprWithCleanups(
+ ignoringParenImpCasts(integerLiteral()));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -265,6 +265,7 @@
   REGISTER_MATCHER(hasUnarySelector);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
+  REGISTER_MATCHER(ignoringExprWithCleanups);
   REGISTER_MATCHER(ignoringImpCasts);
   REGISTER_MATCHER(ignoringParenCasts);
   REGISTER_MATCHER(ignoringParenImpCasts);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -625,6 +625,16 @@
   return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
 }
 
+/// \brief Matches expressions that match InnerMatcher after ExprWithCleanups
+/// are stripped off.
+AST_MATCHER_P(Expr, ignoringExprWithCleanups, internal::Matcher,
+  InnerMatcher) {
+  auto E = &Node;
+  if (auto Cleanups = dyn_cast(E))
+E = Cleanups->getSubExpr();
+  return InnerMatcher.matches(*E, Finder, Builder);
+}
+
 /// \brief Matches types that match InnerMatcher after any parens are stripped.
 ///
 /// Given
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2347,7 +2347,7 @@
   private:   int c;
   };
 fieldDecl(isPrivate())
-  matches 'int c;' 
+  matches 'int c;'
 
 
 
@@ -2361,7 +2361,7 @@
   private:   int c;
   };
 fieldDecl(isProtected())
-  matches 'int b;' 
+  matches 'int b;'
 
 
 
@@ -2375,7 +2375,7 @@
   private:   int c;
   };
 fieldDecl(isPublic())
-  matches 'int a;' 
+  matches 'int a;'
 
 
 
@@ -4432,6 +4432,12 @@
 
 
 
+MatcherExpr>ignoringExprWithCleanupsMatcherExpr> InnerMatcher
+Matches expressions that match InnerMatcher after ExprWithCleanups
+are stripped off.
+
+
+
 MatcherExpr>ignoringImpCastsMatcherExpr> InnerMatcher
 Matches expressions that match InnerMatcher after any implicit casts
 are stripped off.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21243: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-16 Thread Tim Shen via cfe-commits
timshen updated this revision to Diff 60992.
timshen added a comment.

Updated the patch to use ignorngImplicit/Expr::IgnoreImplicit matcher.

I think there is a systematic way to do this change:
Look at every ignoringImpCasts, ignoringParenCasts, ignoringParenImpCasts, 
ignoringParens, and 
Expr::IgnoreImpCasts, Expr::IgnoreParenCasts, Expr::IgnoreParenImpCasts, 
Expr::IgnoreParens to
see if they can be changed to ignoringImplicit or Expr::IgnoreImplicit (which 
also ignores
ExprWithCleanups).

I'd say for most of the cases ExprWithCleanups should be ignored, but I'm not 
sure if I'm the
right person to look at these patterns.


http://reviews.llvm.org/D21243

Files:
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/readability/RedundantStringInitCheck.cpp

Index: clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -39,21 +39,21 @@
  stringLiteral(hasSize(0);
 
   const auto EmptyStringCtorExprWithTemporaries =
-  expr(ignoringImplicit(
-  cxxConstructExpr(StringConstructorExpr,
-  hasArgument(0, ignoringImplicit(EmptyStringCtorExpr);
+  cxxConstructExpr(StringConstructorExpr,
+   hasArgument(0, ignoringImplicit(EmptyStringCtorExpr)));
 
   // Match a variable declaration with an empty string literal as initializer.
   // Examples:
   // string foo = "";
   // string bar("");
   Finder->addMatcher(
-  namedDecl(varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
-hasInitializer(
-expr(anyOf(EmptyStringCtorExpr,
-   EmptyStringCtorExprWithTemporaries))
-.bind("expr"))),
-unless(parmVarDecl()))
+  namedDecl(
+  varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
+  hasInitializer(expr(ignoringImplicit(anyOf(
+  EmptyStringCtorExpr,
+  EmptyStringCtorExprWithTemporaries)))
+ .bind("expr"))),
+  unless(parmVarDecl()))
   .bind("decl"),
   this);
 }
Index: clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tidy/modernize/UseAutoCheck.cpp
@@ -42,6 +42,8 @@
   if (!Init)
 return false;
 
+  Init = Init->IgnoreImplicit();
+
   // The following test is based on DeclPrinter::VisitVarDecl() to find if an
   // initializer is implicit or not.
   if (const auto *Construct = dyn_cast(Init)) {
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -156,7 +156,7 @@
 const Expr *digThroughConstructors(const Expr *E) {
   if (!E)
 return nullptr;
-  E = E->IgnoreParenImpCasts();
+  E = E->IgnoreImplicit();
   if (const auto *ConstructExpr = dyn_cast(E)) {
 // The initial constructor must take exactly one parameter, but base class
 // and deferred constructors can take more.
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@
   StatementMatcher IteratorComparisonMatcher = expr(
   ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by
Index: clang-tidy/misc/DanglingHandleCheck.cpp
===
--- clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tidy/misc/DanglingHandleCheck.cpp
@@ -8,11 +8,13 @@
 //===--===//

Re: [PATCH] D21243: Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-21 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273310: Fix clang-tidy patterns to adapt to newly added 
ExprWithCleanups nodes. (authored by timshen).

Changed prior to commit:
  http://reviews.llvm.org/D21243?vs=60992&id=61434#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21243

Files:
  clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -156,7 +156,7 @@
 const Expr *digThroughConstructors(const Expr *E) {
   if (!E)
 return nullptr;
-  E = E->IgnoreParenImpCasts();
+  E = E->IgnoreImplicit();
   if (const auto *ConstructExpr = dyn_cast(E)) {
 // The initial constructor must take exactly one parameter, but base class
 // and deferred constructors can take more.
Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@
   StatementMatcher IteratorComparisonMatcher = expr(
   ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
@@ -42,6 +42,8 @@
   if (!Init)
 return false;
 
+  Init = Init->IgnoreImplicit();
+
   // The following test is based on DeclPrinter::VisitVarDecl() to find if an
   // initializer is implicit or not.
   if (const auto *Construct = dyn_cast(Init)) {
Index: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
@@ -8,11 +8,13 @@
 //===--===//
 
 #include "DanglingHandleCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
@@ -135,7 +137,7 @@
   //   1. Value to Handle conversion.
   //   2. Handle copy construction.
   // We have to match both.
-  has(ignoringParenImpCasts(handleFrom(
+  has(ignoringImplicit(handleFrom(
   IsAHandle,
   handleFrom(IsAHandle, declRefExpr(to(varDecl(
 // Is function scope ...
Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -39,21 +39,21 @@
  stringLiteral(hasSize(0);
 
   const auto EmptyStringCtorExprWithTemporaries =
-  expr(ignoringImplicit(
-  cxxConstructExpr(StringConstructorExpr,
-  hasArgument(0, ignoringImplicit(EmptyStringCtorExpr);
+  cxxConstructExpr(StringConstructorExpr,
+   hasArgument(0, ignoringImplicit(EmptyStringCtorExpr)));
 
   // Match a variable declaration with an empty string literal as in

[clang-tools-extra] r273310 - Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

2016-06-21 Thread Tim Shen via cfe-commits
Author: timshen
Date: Tue Jun 21 15:11:20 2016
New Revision: 273310

URL: http://llvm.org/viewvc/llvm-project?rev=273310&view=rev
Log:
Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes.

Summary: This is a fix for the new ExprWithCleanups introduced by clang's 
temporary variable lifetime marks change.

Reviewers: bkramer, sbenza, angelgarcia, alexth

Subscribers: rsmith, cfe-commits

Differential Revision: http://reviews.llvm.org/D21243

Modified:
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Tue Jun 21 
15:11:20 2016
@@ -33,7 +33,8 @@ void TwineLocalCheck::check(const MatchF
   if (VD->hasInit()) {
 // Peel away implicit constructors and casts so we can see the actual type
 // of the initializer.
-const Expr *C = VD->getInit();
+const Expr *C = VD->getInit()->IgnoreImplicit();
+
 while (isa(C))
   C = cast(C)->getArg(0)->IgnoreParenImpCasts();
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp Tue Jun 21 
15:11:20 2016
@@ -8,11 +8,13 @@
 
//===--===//
 
 #include "DanglingHandleCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 
 namespace clang {
 namespace tidy {
@@ -135,7 +137,7 @@ void DanglingHandleCheck::registerMatche
   //   1. Value to Handle conversion.
   //   2. Handle copy construction.
   // We have to match both.
-  has(ignoringParenImpCasts(handleFrom(
+  has(ignoringImplicit(handleFrom(
   IsAHandle,
   handleFrom(IsAHandle, declRefExpr(to(varDecl(
 // Is function scope ...

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Jun 
21 15:11:20 2016
@@ -8,6 +8,7 @@
 
//===--===//
 
 #include "LoopConvertCheck.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 
@@ -141,10 +142,10 @@ StatementMatcher makeIteratorLoopMatcher
   StatementMatcher IteratorComparisonMatcher = expr(
   
ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ConditionVarName);
 
-  StatementMatcher OverloadedNEQMatcher =
+  auto OverloadedNEQMatcher = matchers::ignoringImplicit(
   cxxOperatorCallExpr(hasOverloadedOperatorName("!="), argumentCountIs(2),
   hasArgument(0, IteratorComparisonMatcher),
-  hasArgument(1, IteratorBoundMatcher));
+  hasArgument(1, IteratorBoundMatcher)));
 
   // This matcher tests that a declaration is a CXXRecordDecl that has an
   // overloaded operator*(). If the operator*() returns by value instead of by

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=273310&r1=273309&r2=273310&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Tue Jun 
21 15:11:20 2016
@@ -156,7 +156,7 @

  1   2   >