Re: [PATCH] D24752: [Modules] Add missing dependencies to clang builtins modulemap

2016-09-28 Thread Elad Cohen via cfe-commits
eladcohen added inline comments.


Comment at: lib/Headers/module.modulemap:133
@@ -131,2 +132,3 @@
 explicit module aes {
+  export sse2
   header "__wmmintrin_aes.h"

bruno wrote:
> The mmx case above makes sense to me, but I find conceptually odd that we 
> need to re-export sse2 in aes module, why not explicitly #include 
>  in the source file?
emmintrin.h is already included explicitly in wmmintrin.h & __wmmintrin_aes.h.

If a user includes / there is no problem, since the 
intel submodule has an 'export *' directive and both aes & sse2 will be 
imported.

However, if the user only includes  (like in the 2nd half of the 
test I added), and uses modules, then any use of the '___m128i' type (which is 
used in the aes intrinsics and declared in sse2) will result with the error:
"File tst.c Line 11: missing '#include '; declaration of 
'___m128i' must be imported from module '_Builtin_intrinsics.intel.sse2' before 
it is required"

IIUC the possible fixes for this are adding 'export *' or 'export sse2' to the 
aes submodule.



https://reviews.llvm.org/D24752



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


[PATCH] D25003: [libcxxabi] [cmake] Update LLVM_CMAKE_PATH following install layout change

2016-09-28 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: danalbert, EricWF.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Update LLVM_CMAKE_PATH in stand-alone builds to match the new install layout 
used by LLVM 3.9+ where CMake files are installed into lib*/cmake/llvm rather 
than share/llvm/cmake.


https://reviews.llvm.org/D25003

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -49,7 +49,7 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
tree")
-set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
+set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not 
defined. "


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -49,7 +49,7 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
+set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-28 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg



Comment at: lib/Tooling/Core/Replacement.cpp:179-181
@@ +178,5 @@
+// `R` and `Replaces` are order-independent if applying them in either order
+// has the same effect, so we need to compare replacements associated to
+// applying them in either order.
+llvm::Expected
+Replacements::mergeIfOrderIndependent(const Replacement &R) const {

Much better. Thanks.


https://reviews.llvm.org/D24800



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


[PATCH] D25006: Make FilePath of Replacement an absolute file path when possible.

2016-09-28 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added reviewers: klimek, djasper, ioeric.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

The FilePath of the Replacement constructed from a SourceManager can be
an absolute file path or a file path relative to the build directory (It
depends on the compliation commands).

If the FilePath is a relative path, it may caused crash issues
when applying the Replacement if the running directory of the binary is
not the same with the build directory. Have verified the crashes in
several clang-tools, e.g. clang-rename, clang-move, clang-change-name,
clang-tidy (fixed in D17335).

By making the FilePath an absolute path, it resolves the crashes.

https://reviews.llvm.org/D25006

Files:
  lib/Tooling/Core/Replacement.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -466,7 +466,7 @@
 void expectReplacementAt(const Replacement &Replace,
  StringRef File, unsigned Offset, unsigned Length) {
   ASSERT_TRUE(Replace.isApplicable());
-  EXPECT_EQ(File, Replace.getFilePath());
+  EXPECT_TRUE(Replace.getFilePath().endswith(File));
   EXPECT_EQ(Offset, Replace.getOffset());
   EXPECT_EQ(Length, Replace.getLength());
 }
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tooling {
@@ -103,8 +104,22 @@
 StringRef ReplacementText) {
   const std::pair DecomposedLocation =
   Sources.getDecomposedLoc(Start);
-  const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
-  this->FilePath = Entry ? Entry->getName() : InvalidLocation;
+  this->FilePath = InvalidLocation;
+  if (const FileEntry *Entry =
+  Sources.getFileEntryForID(DecomposedLocation.first)) {
+auto Dir = Sources.getFileManager()
+   .getVirtualFileSystem()
+   ->getCurrentWorkingDirectory();
+if (Dir) {
+  llvm::SmallString<128> AbsolutePath(Entry->getName());
+  std::error_code EC =
+  llvm::sys::fs::make_absolute((Dir.get()), AbsolutePath);
+  if (!EC) {
+llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+this->FilePath = AbsolutePath.str();
+  }
+}
+  }
   this->ReplacementRange = Range(DecomposedLocation.second, Length);
   this->ReplacementText = ReplacementText;
 }


Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -466,7 +466,7 @@
 void expectReplacementAt(const Replacement &Replace,
  StringRef File, unsigned Offset, unsigned Length) {
   ASSERT_TRUE(Replace.isApplicable());
-  EXPECT_EQ(File, Replace.getFilePath());
+  EXPECT_TRUE(Replace.getFilePath().endswith(File));
   EXPECT_EQ(Offset, Replace.getOffset());
   EXPECT_EQ(Length, Replace.getLength());
 }
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tooling {
@@ -103,8 +104,22 @@
 StringRef ReplacementText) {
   const std::pair DecomposedLocation =
   Sources.getDecomposedLoc(Start);
-  const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
-  this->FilePath = Entry ? Entry->getName() : InvalidLocation;
+  this->FilePath = InvalidLocation;
+  if (const FileEntry *Entry =
+  Sources.getFileEntryForID(DecomposedLocation.first)) {
+auto Dir = Sources.getFileManager()
+   .getVirtualFileSystem()
+   ->getCurrentWorkingDirectory();
+if (Dir) {
+  llvm::SmallString<128> AbsolutePath(Entry->getName());
+  std::error_code EC =
+  llvm::sys::fs::make_absolute((Dir.get()), AbsolutePath);
+  if (!EC) {
+llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+this->FilePath = AbsolutePath.str();
+  }
+}
+  }
   this->ReplacementRange = Range(DecomposedLocation.second, Length);
   this->ReplacementText = ReplacementText;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailma

Re: [PATCH] D25004: [x86][inline-asm][clang] accept 'v' constraint

2016-09-28 Thread Elena Demikhovsky via cfe-commits
delena added inline comments.


Comment at: test/CodeGen/x86-inline-asm-v-constraint.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes 
AVX512,AVX,SSE

add KNL tests here.


Repository:
  rL LLVM

https://reviews.llvm.org/D25004



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


Re: [PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki removed rL LLVM as the repository for this revision.
danielmarjamaki updated this revision to Diff 72775.
danielmarjamaki added a comment.

Use !isa. Suggestion by Gabor.


https://reviews.llvm.org/D24905

Files:
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  test/Analysis/unreachable-code-path.c

Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,18 @@
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
+
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (!isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;


Index: test/Analysis/unreachable-code-path.c
===
--- test/Analysis/unreachable-code-path.c
+++ test/Analysis/unreachable-code-path.c
@@ -158,3 +158,18 @@
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
+
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (!isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked an inline comment as done.


Comment at: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp:195
@@ +194,3 @@
+if (Optional S = I->getAs()) {
+  if (!isa(S->getStmt()))
+return S->getStmt();

yes I agree.


https://reviews.llvm.org/D24905



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


Re: [PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

https://reviews.llvm.org/D24905



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


[PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-09-28 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: EricWF.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Include an appropriate unwinder library (-lunwind or -lgcc_s) when constructing 
a linker script for libc++. This is necessary since otherwise clang++ set for 
pure LLVM stack (compiler-rt + libc++) does not link against -lgcc_s and 
linking any C++ program fails due to missing unwinder symbols.

In order to handle additional libraries, the linker script generator has been 
modified to accept any number of libraries as the second argument. The ABI 
library name check has been removed as it is redundant to the checks done in 
CMake, and additional check for empty SCRIPT_ABI_LIBNAME has been added in 
CMake (the empty value resulted in wrong usage error in the script before).

The change has been tested with all four C++ ABI library variants. In each 
case, clang++ failed to link a simple "Hello world" program without either of 
the unwinder libraries.


https://reviews.llvm.org/D25008

Files:
  lib/CMakeLists.txt
  utils/gen_link_script/gen_link_script.py

Index: utils/gen_link_script/gen_link_script.py
===
--- utils/gen_link_script/gen_link_script.py
+++ utils/gen_link_script/gen_link_script.py
@@ -16,23 +16,24 @@
 sys.exit(1)
 
 def usage_and_exit():
-print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] 
 ")
+print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] 
 ")
 
 def help_and_exit():
 help_msg = \
 """Usage
 
-  gen_link_script.py [--help] [--dryrun]  
+  gen_link_script.py [--help] [--dryrun]  
 
-  Generate a linker script that links libc++ to the proper ABI library.
+  Generate a linker script that links libc++ to the proper ABI library
+  (and other dependant libraries).
   The script replaces the specified libc++ symlink.
   An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
 
 Arguments
- The top level symlink to the versioned libc++ shared
 library. This file is replaced with a linker script.
- - The name of the ABI library to use in the linker 
script.
-The name must be one of [c++abi, stdc++, supc++, 
cxxrt].
+- The list of libraries (-l flags) to use in the linker
+script.
 
 Exit Status:
   0 if OK,
@@ -53,28 +54,22 @@
 if len(args) != 2:
 usage_and_exit()
 symlink_file = args[0]
-abi_libname = args[1]
-return dryrun, symlink_file, abi_libname
+abi_libs = args[1]
+return dryrun, symlink_file, abi_libs
 
 def main():
-dryrun, symlink_file, abi_libname = parse_args()
+dryrun, symlink_file, abi_libs = parse_args()
 
 # Check that the given libc++.so file is a valid symlink.
 if not os.path.islink(symlink_file):
 print_and_exit("symlink file %s is not a symlink" % symlink_file)
 
 # Read the symlink so we know what libc++ to link to in the linker script.
 linked_libcxx = os.readlink(symlink_file)
 
-# Check that the abi_libname is one of the supported values.
-supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-if abi_libname not in supported_abi_list:
-print_and_exit("abi name '%s' is not supported: Use one of %r" %
-(abi_libname, supported_abi_list))
-
 # Generate the linker script contents and print the script and destination
 # information.
-contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
+contents = "INPUT(%s %s)" % (linked_libcxx, abi_libs)
 print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
 
 # Remove the existing libc++ symlink and replace it with the script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -230,15 +230,26 @@
   set(SCRIPT_ABI_LIBNAME "${LIBCXX_CXX_ABI_LIBRARY}")
   if (SCRIPT_ABI_LIBNAME STREQUAL "cxxabi_shared")
 set(SCRIPT_ABI_LIBNAME "c++abi")
+  elseif(SCRIPT_ABI_LIBNAME STREQUAL "")
+message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT can not find an ABI 
library")
   endif()
+
+  # Prepare a complete list of dependant libraries for linking.
+  set(SCRIPT_LINKED_LIBS "-l${SCRIPT_ABI_LIBNAME}")
+  if (LIBCXXABI_USE_LLVM_UNWINDER)
+set(SCRIPT_LINKED_LIBS "${SCRIPT_LINKED_LIBS} -lunwind")
+  elseif (LIBCXX_HAS_GCC_S_LIB)
+set(SCRIPT_LINKED_LIBS "${SCRIPT_LINKED_LIBS} -lgcc_s")
+  endif()
+
   # Generate a linker script inplace of a libc++.so symlink. Rerun this command
   # after cxx builds.
   add_custom_command(TARGET cxx_shared POST_BUILD
 COMMAND
   ${PYTHON_EXECUTABLE} 
${LIBCXX_SOURCE_DIR}/utils/gen_link_script/gen_link_script.py
 ARGS
   "$"
-  "${SCRIPT_ABI_LIBNAME}"
+  "${SCRIPT_LINKED_LIBS}"
 WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
   )
 endif()


Index: utils/gen_link_script/gen_link_

Re: [PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-28 Thread Gábor Horváth via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D24905



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


Re: [PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-09-28 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.
rmaprath added a comment.

The patch generally makes sense to me.

I wonder if the test configuration can also benefit from this; 
`test/libcxx/test/target_info.py` manually updates the link line to use 
`-lgcc_s` or `-lunwind` depending on how the build is configured. Presumably, 
this workaround will no longer be needed if the linker script does that for us?

(Note:- `-lgcc_s` is linked twice there to satisfy some weird dependency, it's 
not a mistake)


https://reviews.llvm.org/D25008



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


Re: [PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-09-28 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25008#555041, @rmaprath wrote:

> The patch generally makes sense to me.
>
> I wonder if the test configuration can also benefit from this; 
> `test/libcxx/test/target_info.py` manually updates the link line to use 
> `-lgcc_s` or `-lunwind` depending on how the build is configured. Presumably, 
> this workaround will no longer be needed if the linker script does that for 
> us?


I was originally thinking about that but we don't use the linker script on 
APPLE and I have no clue how that system is handled or whether it suffers from 
the same issue at all.

> (Note:- `-lgcc_s` is linked twice there to satisfy some weird dependency, 
> it's not a mistake)


Thanks for letting me know. I almost prepared a patch for that ;-D.


https://reviews.llvm.org/D25008



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


Re: [PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins

2016-09-28 Thread Martin Storsjö via cfe-commits
mstorsjo retitled this revision from "Headers: Add iso_volatile load/store 
intrinsics" to "[MS] Implement __iso_volatile loads/stores as builtins".
mstorsjo updated the summary for this revision.
mstorsjo updated this revision to Diff 72782.
mstorsjo added a comment.

Changed to implement it as builtins, as requested. I had to put this at the 
bottom in EmitBuiltinExpr (which returns RValues) instead of in 
EmitARMBuiltinExpr (which returns Value*), since the returned Value* for stores 
is nullptr. A nullptr return value from EmitTargetBuiltinExpr indicates that it 
wasn't handled, this triggered errors about the store builtins being 
unsupported.


https://reviews.llvm.org/D24986

Files:
  include/clang/Basic/BuiltinsARM.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/ms-volatile-arm.c

Index: test/CodeGen/ms-volatile-arm.c
===
--- /dev/null
+++ test/CodeGen/ms-volatile-arm.c
@@ -0,0 +1,13 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s
+
+void test1(int volatile *p, int v) {
+  __iso_volatile_store32(p, v);
+  // CHECK-LABEL: @test1
+  // CHECK: store volatile {{.*}}, {{.*}}
+}
+int test2(const int volatile *p) {
+  return __iso_volatile_load32(p);
+  // CHECK-LABEL: @test2
+  // CHECK: load volatile {{.*}}
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -134,6 +134,36 @@
   return CGF.EmitLoadOfScalar(LV, E->getExprLoc());
 }
 
+static Value *EmitVolatileStore(CodeGenFunction &CGF, const CallExpr *E) {
+  Value *Address = CGF.EmitScalarExpr(E->getArg(0));
+  Value *Val = CGF.EmitScalarExpr(E->getArg(1));
+
+  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getArg(1)->getType());
+  // Call the full version of EmitStoreOfScalar directly, to override the volatile
+  // flag without actually setting volatile in the type. This avoids
+  // LValueIsSuitableForInlineAtomic picking it up and transforming it into an
+  // atomic store.
+  CGF.EmitStoreOfScalar(Val, LV.getAddress(), true, LV.getType(),
+LV.getAlignmentSource(), LV.getTBAAInfo(), false,
+LV.getTBAABaseType(), LV.getTBAAOffset(),
+LV.isNontemporal());
+  return nullptr;
+}
+
+static Value *EmitVolatileLoad(CodeGenFunction &CGF, const CallExpr *E) {
+  Value *Address = CGF.EmitScalarExpr(E->getArg(0));
+
+  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getType());
+  // Call the full version of EmitLoadOfScalar directly, to override the volatile
+  // flag without actually setting volatile in the type. This avoids
+  // LValueIsSuitableForInlineAtomic picking it up and transforming it into an
+  // atomic load.
+  return CGF.EmitLoadOfScalar(LV.getAddress(), true, LV.getType(),
+  E->getExprLoc(), LV.getAlignmentSource(),
+  LV.getTBAAInfo(), LV.getTBAABaseType(),
+  LV.getTBAAOffset(), LV.isNontemporal());
+}
+
 static RValue EmitBinaryAtomic(CodeGenFunction &CGF,
llvm::AtomicRMWInst::BinOp Kind,
const CallExpr *E) {
@@ -2558,6 +2588,33 @@
 return RValue::get(V);
   }
 
+  switch (getTarget().getTriple().getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+switch (BuiltinID) {
+case ARM::BI__iso_volatile_load8:
+case ARM::BI__iso_volatile_load16:
+case ARM::BI__iso_volatile_load32:
+case ARM::BI__iso_volatile_load64:
+  return RValue::get(EmitVolatileLoad(*this, E));
+case ARM::BI__iso_volatile_store8:
+case ARM::BI__iso_volatile_store16:
+case ARM::BI__iso_volatile_store32:
+case ARM::BI__iso_volatile_store64:
+  // EmitVolatileStore returns nullptr, but we want to
+  // return that RValue here. If handled via EmitTargetBuiltinExpr
+  // below, the returned Value *V will be nullptr, and we will
+  // continue on to declaring the builtin unsupported below, even
+  // though it was handled correctly.
+  return RValue::get(EmitVolatileStore(*this, E));
+}
+break;
+  default:
+break;
+  }
+
   // See if we have a target specific builtin that needs to be lowered.
   if (Value *V = EmitTargetBuiltinExpr(BuiltinID, E))
 return RValue::get(V);
Index: include/clang/Basic/BuiltinsARM.def
===
--- include/clang/Basic/BuiltinsARM.def
+++ include/clang/Basic/BuiltinsARM.def
@@ -115,6 +115,14 @@
 LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__iso_volatile_load8,   "ccCD*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__

r282569 - [Headers] Replace stray indentation with tabs with spaces. NFC.

2016-09-28 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Sep 28 04:34:51 2016
New Revision: 282569

URL: http://llvm.org/viewvc/llvm-project?rev=282569&view=rev
Log:
[Headers] Replace stray indentation with tabs with spaces. NFC.

This matches the rest of the surrounding file.

Modified:
cfe/trunk/lib/Headers/intrin.h

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=282569&r1=282568&r2=282569&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Wed Sep 28 04:34:51 2016
@@ -595,7 +595,7 @@ _InterlockedExchangeAdd_rel(long volatil
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) {
-   return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST);
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)
@@ -618,7 +618,7 @@ _InterlockedExchangeAdd64_rel(__int64 vo
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value) {
-   return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST);
 }
 #endif
 
/**\
@@ -653,7 +653,7 @@ _InterlockedIncrement_rel(long volatile
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedIncrement64(__int64 volatile *_Value) {
-   return __atomic_add_fetch(_Value, 1, __ATOMIC_SEQ_CST);
+  return __atomic_add_fetch(_Value, 1, __ATOMIC_SEQ_CST);
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)
@@ -702,7 +702,7 @@ _InterlockedDecrement_rel(long volatile
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedDecrement64(__int64 volatile *_Value) {
-   return __atomic_sub_fetch(_Value, 1, __ATOMIC_SEQ_CST);
+  return __atomic_sub_fetch(_Value, 1, __ATOMIC_SEQ_CST);
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)
@@ -763,7 +763,7 @@ _InterlockedAnd_rel(long volatile *_Valu
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask) {
-   return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)
@@ -824,7 +824,7 @@ _InterlockedOr_rel(long volatile *_Value
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask) {
-   return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)
@@ -885,7 +885,7 @@ _InterlockedXor_rel(long volatile *_Valu
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask) {
-   return __atomic_fetch_xor(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_xor(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)
@@ -955,8 +955,8 @@ _InterlockedExchange_rel(long volatile *
 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value) {
-   __atomic_exchange(_Target, &_Value, &_Value, __ATOMIC_SEQ_CST);
-   return _Value;
+  __atomic_exchange(_Target, &_Value, &_Value, __ATOMIC_SEQ_CST);
+  return _Value;
 }
 #endif
 #if defined(__arm__) || defined(__aarch64__)


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


Re: [PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

2016-09-28 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a subscriber: malcolm.parsons.
malcolm.parsons added a comment.

This check looks like it implements some of CppCoreGuidelines Bounds.4

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#bounds4-dont-use-standard-library-functions-and-types-that-are-not-bounds-checked


Repository:
  rL LLVM

https://reviews.llvm.org/D22725



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


Re: [PATCH] D25006: Make FilePath of Replacement an absolute file path when possible.

2016-09-28 Thread Haojian Wu via cfe-commits
hokein abandoned this revision.
hokein added a comment.

As discussed offline with klimek, we should change to the correct working 
directory before applying the replacements. So abandon this.


https://reviews.llvm.org/D25006



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


Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-09-28 Thread Andi via cfe-commits
Abpostelnicu updated this revision to Diff 72790.
Abpostelnicu marked 2 inline comments as done.
Abpostelnicu added a comment.

i will add the unit tests in the next patch.


https://reviews.llvm.org/D22910

Files:
  include/clang/AST/ExprCXX.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,23 @@
 // These never have a side-effect.
 return false;
 
+  case CXXOperatorCallExprClass: {
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increement and decrement are intended
+// to have a side-effect and other overloaded operators are not.
+// Otherwise fall through the logic of call expression.
+OverloadedOperatorKind Op = cast(this)->getOperator();
+if (CXXOperatorCallExpr::isAssignmentOp(Op)
+|| CXXOperatorCallExpr::isIncrementOp(Op)
+|| CXXOperatorCallExpr::isDecrementOp(Op)) {
+  const Decl *FD = cast(this)->getCalleeDecl();
+  bool IsPure = FD && (FD->hasAttr() || 
FD->hasAttr());
+  if (!IsPure)
+return true;
+}
+LLVM_FALLTHROUGH;
+  }
   case CallExprClass:
-  case CXXOperatorCallExprClass:
   case CXXMemberCallExprClass:
   case CUDAKernelCallExprClass:
   case UserDefinedLiteralClass: {
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -106,6 +106,26 @@
   // operations on floating point types.
   bool isFPContractable() const { return FPContractable; }
 
+  // Check to see if a given overloaded operator is of assignment kind
+  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+return Opc == OO_Equal || Opc == OO_StarEqual ||
+   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+   Opc == OO_PipeEqual;
+  }
+  
+  // Check to see if a given overloaded operator is of increment kind
+  static bool isIncrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_PlusPlus;
+  }
+
+  // Check to see if a given overloaded operator is of decrement kind
+  static bool isDecrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_MinusMinus;
+  }
+  
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 };


Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,23 @@
 // These never have a side-effect.
 return false;
 
+  case CXXOperatorCallExprClass: {
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increement and decrement are intended
+// to have a side-effect and other overloaded operators are not.
+// Otherwise fall through the logic of call expression.
+OverloadedOperatorKind Op = cast(this)->getOperator();
+if (CXXOperatorCallExpr::isAssignmentOp(Op)
+|| CXXOperatorCallExpr::isIncrementOp(Op)
+|| CXXOperatorCallExpr::isDecrementOp(Op)) {
+  const Decl *FD = cast(this)->getCalleeDecl();
+  bool IsPure = FD && (FD->hasAttr() || FD->hasAttr());
+  if (!IsPure)
+return true;
+}
+LLVM_FALLTHROUGH;
+  }
   case CallExprClass:
-  case CXXOperatorCallExprClass:
   case CXXMemberCallExprClass:
   case CUDAKernelCallExprClass:
   case UserDefinedLiteralClass: {
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -106,6 +106,26 @@
   // operations on floating point types.
   bool isFPContractable() const { return FPContractable; }
 
+  // Check to see if a given overloaded operator is of assignment kind
+  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+return Opc == OO_Equal || Opc == OO_StarEqual ||
+   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+   Opc == OO_PipeEqual;
+  }
+  
+  // Check to see if a given overloaded operator is of increment kind
+  static bool isIncrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_PlusPlus;
+  }
+
+  // Check to see if a given overloaded operator is of decrement kind
+  static bool isDecrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_MinusMinus;
+  }
+  
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r282572 - [ASTImporter] Implement some expression-related AST node import (part 2)

2016-09-28 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Wed Sep 28 05:16:56 2016
New Revision: 282572

URL: http://llvm.org/viewvc/llvm-project?rev=282572&view=rev
Log:
[ASTImporter] Implement some expression-related AST node import (part 2)

* Some code cleanup
* Add tests not present in http://reviews.llvm.org/D14286
* Integrate a test suite from Serge Pavlov (http://reviews.llvm.org/D14224)
* ArrayTypeTraitExpr: serialize sub-expression to avoid keeping it undefined
* Implement import of some nodes:
  - ArrayTypeTraitExpr
  - ExpressionTraitExpr
  - OpaqueValueExpr
  - ArraySubscriptExpr
  - ExplicitCastExpr
  - ImplicitValueInitExpr
  - OffsetOfExpr
  - CXXThisExpr
  - CXXThrowExpr
  - CXXNoexceptExpr
  - CXXDefaultArgExpr
  - CXXScalarValueInitExpr
  - CXXBindTemporaryExpr
  - CXXTemporaryObjectExpr
  - MaterializeTemporaryExpr
  - ExprWithCleanups

  - StaticAssertDecl
  - FriendDecl

  - DecayedType

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


Added:
cfe/trunk/test/ASTMerge/Inputs/class3.cpp
cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp
cfe/trunk/test/ASTMerge/class2.cpp
cfe/trunk/test/ASTMerge/exprs.cpp
Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/include/clang/AST/DeclFriend.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=282572&r1=282571&r2=282572&view=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Wed Sep 28 05:16:56 2016
@@ -24,6 +24,7 @@
 namespace clang {
   class ASTContext;
   class CXXCtorInitializer;
+  class CXXBaseSpecifier;
   class Decl;
   class DeclContext;
   class DiagnosticsEngine;
@@ -39,7 +40,9 @@ namespace clang {
   class ASTImporter {
   public:
 typedef llvm::DenseSet > NonEquivalentDeclSet;
-
+typedef llvm::DenseMap
+ImportedCXXBaseSpecifierMap;
+
   private:
 /// \brief The contexts we're importing to and from.
 ASTContext &ToContext, &FromContext;
@@ -68,7 +71,12 @@ namespace clang {
 /// \brief Mapping from the already-imported FileIDs in the "from" source
 /// manager to the corresponding FileIDs in the "to" source manager.
 llvm::DenseMap ImportedFileIDs;
-
+
+/// \brief Mapping from the already-imported CXXBasesSpecifier in
+///  the "from" source manager to the corresponding CXXBasesSpecifier
+///  in the "to" source manager.
+ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers;
+
 /// \brief Imported, anonymous tag declarations that are missing their 
 /// corresponding typedefs.
 SmallVector AnonTagsWithPendingTypedefs;
@@ -212,8 +220,13 @@ namespace clang {
 /// \returns the equivalent initializer in the "to" context.
 CXXCtorInitializer *Import(CXXCtorInitializer *FromInit);
 
+/// \brief Import the given CXXBaseSpecifier from the "from" context into
+/// the "to" context.
+///
+/// \returns the equivalent CXXBaseSpecifier in the source manager of the
+/// "to" context.
+CXXBaseSpecifier *Import(const CXXBaseSpecifier *FromSpec);
 
-
 /// \brief Import the definition of the given declaration, including all of
 /// the declarations it contains.
 ///

Modified: cfe/trunk/include/clang/AST/DeclFriend.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclFriend.h?rev=282572&r1=282571&r2=282572&view=diff
==
--- cfe/trunk/include/clang/AST/DeclFriend.h (original)
+++ cfe/trunk/include/clang/AST/DeclFriend.h Wed Sep 28 05:16:56 2016
@@ -166,6 +166,7 @@ public:
 
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
+  friend class ASTNodeImporter;
   friend TrailingObjects;
 };
 

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=282572&r1=282571&r2=282572&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Sep 28 05:16:56 2016
@@ -40,6 +40,7 @@ namespace clang {
 // Importing types
 QualType VisitType(const Type *T);
 QualType VisitBuiltinType(const BuiltinType *T);
+QualType VisitDecayedType(const DecayedType *T);
 QualType VisitComplexType(const ComplexType *T);
 QualType VisitPointerType(const PointerType *T);
 QualType VisitBlockPointerType(const BlockPointerType *T);
@@ -88,6 +89,8 @@ namespace clang {
   DeclarationNameInfo& To);
 void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
 
+bool ImportCastPath(CastExpr *E, CXXCastPath

Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-09-28 Thread Aleksei Sidorin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282572: [ASTImporter] Implement some expression-related AST 
node import (part 2) (authored by a.sidorin).

Changed prior to commit:
  https://reviews.llvm.org/D14326?vs=72625&id=72791#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D14326

Files:
  cfe/trunk/include/clang/AST/ASTImporter.h
  cfe/trunk/include/clang/AST/DeclFriend.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/test/ASTMerge/Inputs/class3.cpp
  cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp
  cfe/trunk/test/ASTMerge/class2.cpp
  cfe/trunk/test/ASTMerge/exprs.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/test/ASTMerge/class2.cpp
===
--- cfe/trunk/test/ASTMerge/class2.cpp
+++ cfe/trunk/test/ASTMerge/class2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class C3 {
+  int method_1(C2 *x) {
+return x->x;
+  }
+};
Index: cfe/trunk/test/ASTMerge/exprs.cpp
===
--- cfe/trunk/test/ASTMerge/exprs.cpp
+++ cfe/trunk/test/ASTMerge/exprs.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(Ch1 == 'a');
+static_assert(Ch2 == 'b');
+static_assert(Ch3 == 'c');
+
+static_assert(Ch4 == L'd');
+static_assert(Ch5 == L'e');
+static_assert(Ch6 == L'f');
+
+static_assert(C1 == 12);
+static_assert(C2 == 13);
+
+static_assert(C3 == 12);
+static_assert(C4 == 13);
+
+static_assert(C5 == 22L);
+static_assert(C6 == 23L);
+
+static_assert(C7 == 66LL);
+static_assert(C8 == 67ULL);
+
+static_assert(bval1 == true);
+static_assert(bval2 == false);
+
+static_assert(ExpressionTrait == false);
+
+static_assert(ArrayRank == 2);
+static_assert(ArrayExtent == 20);
+
+void testImport(int *x, const S1 &cs1, S1 &s1) {
+  testNewThrowDelete();
+  testArrayElement(nullptr, 12);
+  testTernaryOp(0, 1, 2);
+  testConstCast(cs1);
+  testStaticCast(s1);
+  testReinterpretCast(s1);
+  testDynamicCast(s1);
+  testScalarInit(42);
+  testOffsetOf();
+  testDefaultArg(12);
+  useTemplateType();
+}
Index: cfe/trunk/test/ASTMerge/Inputs/class3.cpp
===
--- cfe/trunk/test/ASTMerge/Inputs/class3.cpp
+++ cfe/trunk/test/ASTMerge/Inputs/class3.cpp
@@ -0,0 +1,26 @@
+class C1 {
+public:
+  C1();
+  ~C1();
+  C1 *method_1() {
+return this;
+  }
+  C1 method_2() {
+return C1();
+  }
+  void method_3() {
+const C1 &ref = C1();
+  }
+};
+
+class C11 : public C1 {
+};
+
+class C2 {
+private:
+  int x;
+  friend class C3;
+public:
+  static_assert(sizeof(x) == sizeof(int), "Error");
+  typedef class C2::C2 InjType;
+};
Index: cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp
===
--- cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp
+++ cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp
@@ -0,0 +1,131 @@
+// Integer literals
+const char Ch1 = 'a';
+const signed char Ch2 = 'b';
+const unsigned char Ch3 = 'c';
+
+const wchar_t Ch4 = L'd';
+const signed wchar_t Ch5 = L'e';
+const unsigned wchar_t Ch6 = L'f';
+
+const short C1 = 12;
+const unsigned short C2 = 13;
+
+const int C3 = 12;
+const unsigned int C4 = 13;
+
+const long C5 = 22;
+const unsigned long C6 = 23;
+
+const long long C7 = 66;
+const unsigned long long C8 = 67;
+
+
+// String literals
+const char str1[] = "ABCD";
+const char str2[] = "ABCD" "0123";
+
+const wchar_t wstr1[] = L"DEF";
+const wchar_t wstr2[] = L"DEF" L"123";
+
+
+// Boolean literals
+const bool bval1 = true;
+const bool bval2 = false;
+
+// Floating Literals
+const float F1 = 12.2F;
+const double F2 = 1E4;
+const long double F3 = 1.2E-3L;
+
+
+// nullptr literal
+const void *vptr = nullptr;
+
+
+int glb_1[4] = { 10, 20, 30, 40 };
+
+struct S1 {
+  int a;
+  int b[3];
+};
+
+struct S2 {
+  int c;
+  S1 d;
+};
+
+S2 glb_2 = { 22, .d.a = 44, .d.b[0] = 55, .d.b[1] = 66 };
+
+void testNewThrowDelete() {
+  throw;
+  char *p = new char[10];
+  delete[] p;
+}
+
+int testArrayElement(int *x, int n) {
+  return x[n];
+}
+
+int testTernaryOp(int c, int x, int y) {
+  return c ? x : y;
+}
+
+S1 &testConstCast(const S1 &x) {
+  return const_cast(x);
+}
+
+S1 &testStaticCast(S1 &x) {
+  return static_cast(x);
+}
+
+S1 &testReinterpretCast(S1 &x) {
+  return reinterpret_cast(x);
+}
+
+S1 &testDynamicCast(S1 &x) {
+  return dynamic_cast(x);
+}
+
+int testScalarInit(int x) {
+  return int(x);
+}

r282573 - Fix warnings in clang-completion-mode.el.

2016-09-28 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Wed Sep 28 05:20:10 2016
New Revision: 282573

URL: http://llvm.org/viewvc/llvm-project?rev=282573&view=rev
Log:
Fix warnings in clang-completion-mode.el.

- Use defvar to declare variables
- Don't use delete-backward-char, which is for interactive use only

Patch by Philipp Stephani

Modified:
cfe/trunk/utils/clang-completion-mode.el

Modified: cfe/trunk/utils/clang-completion-mode.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang-completion-mode.el?rev=282573&r1=282572&r2=282573&view=diff
==
--- cfe/trunk/utils/clang-completion-mode.el (original)
+++ cfe/trunk/utils/clang-completion-mode.el Wed Sep 28 05:20:10 2016
@@ -64,15 +64,15 @@ This variable will typically contain inc
   :group 'clang-completion-mode)
 
 ;;; The prefix header to use with Clang code completion. 
-(setq clang-completion-prefix-header "")
+(defvar clang-completion-prefix-header "")
 
 ;;; The substring we will use to filter completion results
-(setq clang-completion-substring "")
+(defvar clang-completion-substring "")
 
 ;;; The current completion buffer
-(setq clang-completion-buffer nil)
+(defvar clang-completion-buffer nil)
 
-(setq clang-result-string "")
+(defvar clang-result-string "")
 
 ;;; Compute the current line in the buffer 
 (defun current-line ()
@@ -199,14 +199,14 @@ This variable will typically contain inc
 ;; for the currently-active code completion.
 (defun clang-backspace ()
   (interactive)
-  (delete-backward-char 1)
+  (delete-char -1)
   (clang-update-filter))
 
 ;; Invoked when the user types the delete key to update the filter
 ;; for the currently-active code completion.
 (defun clang-delete ()
   (interactive)
-  (delete-backward-char 1)
+  (delete-char -1)
   (clang-update-filter))
 
 ;; Set up the keymap for the Clang minor mode.
@@ -246,4 +246,3 @@ This variable will typically contain inc
   nil
   " Clang"
   clang-completion-mode-map)
-


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


Re: [PATCH] D14326: ASTImporter: expressions, pt.2

2016-09-28 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Committed after Aaron's comment were addressed. Big thanks to all reviewers!


Repository:
  rL LLVM

https://reviews.llvm.org/D14326



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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

In https://reviews.llvm.org/D24397#555057, @bjope wrote:

> This test/CodeGen/builtins-ppc-p9vector.c test will fail together with this 
> upcoming LLVM patch https://reviews.llvm.org/D24955
>
> Problem is that lots of your
>
>   add i64 {{.*}}, 64
>
> checks will fails since the improved analysis will find out that the add has 
> the "nsw" "nuw" properties.
>
> I'm not so familiar with the regexps used by FileCheck, but somehow we need 
> to (also) allow
>
>   add nsw nuw i64 {{.*}}, 64
>
> in the checks to make it more future proof.


I can change the patterns that check for the add instructions to the following:
// CHECK: add {{[nsuw ]*}}i64 {{.*}}, 64

That will pass with:
add nsw i64
add nuw i64
add nsw nuw i64
...

Basically if all that is found between the "add" and "i64" is any combination 
of the letters "nsuw" and space, it will pass. As far as I'm concerned, 
ensuring that the strings there are well formed is irrelevant - all I'm testing 
is that an add instruction is emitted that adds the constant 64.

I can make the change and check it in if you're in agreement.


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


r282574 - [StaticAnalyzer] Fix false positives for vardecls that are technically unreachable but they are needed.

2016-09-28 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Wed Sep 28 05:39:53 2016
New Revision: 282574

URL: http://llvm.org/viewvc/llvm-project?rev=282574&view=rev
Log:
[StaticAnalyzer] Fix false positives for vardecls that are technically 
unreachable but they are needed.

Example:

switch (x) {
  int a;  // <- This is unreachable but needed
case 1:
  a = ...

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
cfe/trunk/test/Analysis/unreachable-code-path.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp?rev=282574&r1=282573&r2=282574&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp Wed Sep 28 
05:39:53 2016
@@ -191,8 +191,10 @@ void UnreachableCodeChecker::FindUnreach
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (!isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;

Modified: cfe/trunk/test/Analysis/unreachable-code-path.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unreachable-code-path.c?rev=282574&r1=282573&r2=282574&view=diff
==
--- cfe/trunk/test/Analysis/unreachable-code-path.c (original)
+++ cfe/trunk/test/Analysis/unreachable-code-path.c Wed Sep 28 05:39:53 2016
@@ -158,3 +158,18 @@ void testInlined() {
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
+


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


Re: [PATCH] D24905: Fix unreachable code false positive, vardecl in switch

2016-09-28 Thread Daniel Marjamäki via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282574: [StaticAnalyzer] Fix false positives for vardecls 
that are technically… (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D24905?vs=72775&id=72793#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24905

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  cfe/trunk/test/Analysis/unreachable-code-path.c

Index: cfe/trunk/test/Analysis/unreachable-code-path.c
===
--- cfe/trunk/test/Analysis/unreachable-code-path.c
+++ cfe/trunk/test/Analysis/unreachable-code-path.c
@@ -158,3 +158,18 @@
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (!isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;


Index: cfe/trunk/test/Analysis/unreachable-code-path.c
===
--- cfe/trunk/test/Analysis/unreachable-code-path.c
+++ cfe/trunk/test/Analysis/unreachable-code-path.c
@@ -158,3 +158,18 @@
 }
   }
 }
+
+// Don't warn about unreachable VarDecl.
+void dostuff(int*A);
+void varDecl(int X) {
+  switch (X) {
+int A; // No warning here.
+  case 1:
+dostuff(&A);
+break;
+  case 2:
+dostuff(&A);
+break;
+  }
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -191,8 +191,10 @@
 // Find the Stmt* in a CFGBlock for reporting a warning
 const Stmt *UnreachableCodeChecker::getUnreachableStmt(const CFGBlock *CB) {
   for (CFGBlock::const_iterator I = CB->begin(), E = CB->end(); I != E; ++I) {
-if (Optional S = I->getAs())
-  return S->getStmt();
+if (Optional S = I->getAs()) {
+  if (!isa(S->getStmt()))
+return S->getStmt();
+}
   }
   if (const Stmt *S = CB->getTerminator())
 return S;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r282575 - [libunwind] Add support for a single-threaded libunwind build

2016-09-28 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Wed Sep 28 05:57:15 2016
New Revision: 282575

URL: http://llvm.org/viewvc/llvm-project?rev=282575&view=rev
Log:
[libunwind] Add support for a single-threaded libunwind build

The EHABI unwinder is thread-agnostic, SJLJ unwinder and the DWARF unwinder have
a couple of pthread dependencies.

This patch makes it possible to build the whole of libunwind for a
single-threaded environment.

Reviewers: compnerd

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/CMakeLists.txt
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/Unwind_AppleExtras.cpp
libunwind/trunk/src/config.h

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=282575&r1=282574&r2=282575&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Sep 28 05:57:15 2016
@@ -107,6 +107,7 @@ option(LIBUNWIND_ENABLE_SHARED "Build li
 option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding 
support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX 
registers." OFF)
+option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
 
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
@@ -242,6 +243,11 @@ if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING
   list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_IS_NATIVE_ONLY)
 endif()
 
+# Threading-support
+if (NOT LIBUNWIND_ENABLE_THREADS)
+  list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS)
+endif()
+
 # ARM WMMX register support
 if (LIBUNWIND_ENABLE_ARM_WMMX)
   # __ARM_WMMX is a compiler pre-define (as per the ACLE 2.0). Clang does not

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=282575&r1=282574&r2=282575&view=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Wed Sep 28 05:57:15 2016
@@ -53,7 +53,9 @@ set(LIBUNWIND_SOURCES
 set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES})
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
-append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+if (LIBUNWIND_ENABLE_THREADS)
+  append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+endif()
 
 # Setup flags.
 append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC)

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=282575&r1=282574&r2=282575&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Wed Sep 28 05:57:15 2016
@@ -16,7 +16,9 @@
 #include 
 #include 
 #include 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#endif
 #include 
 
 #ifdef __APPLE__
@@ -60,7 +62,9 @@ private:
 
   // These fields are all static to avoid needing an initializer.
   // There is only one instance of this class per process.
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   static pthread_rwlock_t _lock;
+#endif
 #ifdef __APPLE__
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
@@ -87,8 +91,10 @@ DwarfFDECache::_bufferEnd = &_initial
 template 
 typename DwarfFDECache::entry DwarfFDECache::_initialBuffer[64];
 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
 template 
 pthread_rwlock_t DwarfFDECache::_lock = PTHREAD_RWLOCK_INITIALIZER;
+#endif
 
 #ifdef __APPLE__
 template 

Modified: libunwind/trunk/src/Unwind_AppleExtras.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind_AppleExtras.cpp?rev=282575&r1=282574&r2=282575&view=diff
==
--- libunwind/trunk/src/Unwind_AppleExtras.cpp (original)
+++ libunwind/trunk/src/Unwind_AppleExtras.cpp Wed Sep 28 05:57:15 2016
@@ -185,21 +185,29 @@ bool checkKeyMgrRegisteredFDEs(uintptr_t
 
 #if !defined(FOR_DYLD) && _LIBUNWIND_BUILD_SJLJ_APIS
 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#else
+  _Unwind_FunctionContext *fc_ = nullptr;
+#endif
 
 // Accessors to get get/set linked list of frames for sjlj based execeptions.
 _LIBUNWIND_HIDDEN
 struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   return (struct _Unwind_FunctionContext *)
 _pthread_getspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key);
+#else
+  return fc_;
+#endif
 }
 
 _LIBUNWIND_HIDDEN
 void __Unwind_SjLj_SetTopOfFunctionStack(

r282576 - ASTMerge: specify arch for GCCAsmStmt test explicitly to calm non-x86 buildbots

2016-09-28 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Wed Sep 28 05:57:36 2016
New Revision: 282576

URL: http://llvm.org/viewvc/llvm-project?rev=282576&view=rev
Log:
ASTMerge: specify arch for GCCAsmStmt test explicitly to calm non-x86 buildbots


Modified:
cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp

Modified: cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp?rev=282576&r1=282575&r2=282576&view=diff
==
--- cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp (original)
+++ cfe/trunk/test/ASTMerge/Inputs/exprs3.cpp Wed Sep 28 05:57:36 2016
@@ -104,17 +104,6 @@ void testOffsetOf() {
 }
 
 
-unsigned char asmFunc(unsigned char a, unsigned char b) {
-  unsigned int la = a;
-  unsigned int lb = b;
-  unsigned int bigres;
-  unsigned char res;
-  __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) :
-"edx", "cc");
-  res = bigres;
-  return res;
-}
-
 int testDefaultArg(int a = 2*2) {
   return a;
 }


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


Re: [PATCH] D24984: [libunwind] Add support for a single-threaded libunwind build

2016-09-28 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282575: [libunwind] Add support for a single-threaded 
libunwind build (authored by asiri).

Changed prior to commit:
  https://reviews.llvm.org/D24984?vs=72698&id=72798#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24984

Files:
  libunwind/trunk/CMakeLists.txt
  libunwind/trunk/src/CMakeLists.txt
  libunwind/trunk/src/UnwindCursor.hpp
  libunwind/trunk/src/Unwind_AppleExtras.cpp
  libunwind/trunk/src/config.h

Index: libunwind/trunk/CMakeLists.txt
===
--- libunwind/trunk/CMakeLists.txt
+++ libunwind/trunk/CMakeLists.txt
@@ -107,6 +107,7 @@
 option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX registers." OFF)
+option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
 
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
@@ -242,6 +243,11 @@
   list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_IS_NATIVE_ONLY)
 endif()
 
+# Threading-support
+if (NOT LIBUNWIND_ENABLE_THREADS)
+  list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS)
+endif()
+
 # ARM WMMX register support
 if (LIBUNWIND_ENABLE_ARM_WMMX)
   # __ARM_WMMX is a compiler pre-define (as per the ACLE 2.0). Clang does not
Index: libunwind/trunk/src/Unwind_AppleExtras.cpp
===
--- libunwind/trunk/src/Unwind_AppleExtras.cpp
+++ libunwind/trunk/src/Unwind_AppleExtras.cpp
@@ -185,21 +185,29 @@
 
 #if !defined(FOR_DYLD) && _LIBUNWIND_BUILD_SJLJ_APIS
 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#else
+  _Unwind_FunctionContext *fc_ = nullptr;
+#endif
 
 // Accessors to get get/set linked list of frames for sjlj based execeptions.
 _LIBUNWIND_HIDDEN
 struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   return (struct _Unwind_FunctionContext *)
 _pthread_getspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key);
+#else
+  return fc_;
+#endif
 }
 
 _LIBUNWIND_HIDDEN
 void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   _pthread_setspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key, fc);
+#else
+  fc_ = fc;
+#endif
 }
 #endif
-
-
-
-
Index: libunwind/trunk/src/config.h
===
--- libunwind/trunk/src/config.h
+++ libunwind/trunk/src/config.h
@@ -85,13 +85,20 @@
   } while (0)
 #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
 
+#if defined(_LIBUNWIND_HAS_NO_THREADS)
+  // only used with pthread calls, not needed for the single-threaded builds
+  #define _LIBUNWIND_LOG_NON_ZERO(x)
+#endif
+
 // Macros that define away in non-Debug builds
 #ifdef NDEBUG
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)
   #define _LIBUNWIND_TRACE_API(msg, ...)
   #define _LIBUNWIND_TRACING_UNWINDING 0
   #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+#define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #endif
 #else
   #ifdef __cplusplus
 extern "C" {
@@ -102,12 +109,14 @@
 }
   #endif
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)  _LIBUNWIND_LOG(msg, __VA_ARGS__)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) \
-do { \
-  int _err = x; \
-  if ( _err != 0 ) \
-_LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
- } while (0)
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+#define _LIBUNWIND_LOG_NON_ZERO(x) \
+  do { \
+int _err = x; \
+if ( _err != 0 ) \
+  _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
+   } while (0)
+  #endif
   #define _LIBUNWIND_TRACE_API(msg, ...) \
 do { \
   if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
Index: libunwind/trunk/src/UnwindCursor.hpp
===
--- libunwind/trunk/src/UnwindCursor.hpp
+++ libunwind/trunk/src/UnwindCursor.hpp
@@ -16,7 +16,9 @@
 #include 
 #include 
 #include 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#endif
 #include 
 
 #ifdef __APPLE__
@@ -60,7 +62,9 @@
 
   // These fields are all static to avoid needing an initializer.
   // There is only one instance of this class per process.
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   static pthread_rwlock_t _lock;
+#endif
 #ifdef __APPLE__
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
@@ -87,8 +91,10 @@
 template 
 typename DwarfFDECache::entry DwarfFDE

Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki removed rL LLVM as the repository for this revision.
danielmarjamaki updated this revision to Diff 72797.
danielmarjamaki added a comment.

Don't write warning for multiplication in LHS of <<. Often the execution order 
is not important.


https://reviews.llvm.org/D24861

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/parentheses.cpp

Index: test/Sema/parentheses.cpp
===
--- test/Sema/parentheses.cpp
+++ test/Sema/parentheses.cpp
@@ -95,6 +95,23 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
 
+  (void)(a >> b * c); // expected-warning {{operator '>>' has lower precedence 
than '*'; '*' will be evaluated first}} \
+ expected-note {{place parentheses around the '*' 
expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
+
+  (void)(a / b << c); // expected-warning {{operator '<<' has lower precedence 
than '/'; '/' will be evaluated first}} \
+ expected-note {{place parentheses around the '/' 
expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
+  (void)(a % b << c); // expected-warning {{operator '<<' has lower precedence 
than '%'; '%' will be evaluated first}} \
+ expected-note {{place parentheses around the '%' 
expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
+
+  (void)(a * b << c); // no warning, often the execution order does not matter.
+
   Stream() << b + c;
   Stream() >> b + c; // expected-warning {{operator '>>' has lower precedence 
than '+'; '+' will be evaluated first}} \
 expected-note {{place parentheses around the '+' 
expression to silence this warning}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11246,18 +11246,24 @@
   }
 }
 
-static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc,
-Expr *SubExpr, StringRef Shift) {
-  if (BinaryOperator *Bop = dyn_cast(SubExpr)) {
-if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
-  StringRef Op = Bop->getOpcodeStr();
-  S.Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
-  << Bop->getSourceRange() << OpLoc << Shift << Op;
-  SuggestParentheses(S, Bop->getOperatorLoc(),
-  S.PDiag(diag::note_precedence_silence) << Op,
-  Bop->getSourceRange());
-}
-  }
+static void DiagnoseAddOrMulInShift(Sema &S, SourceLocation OpLoc,
+Expr *SubExpr, StringRef Shift,
+bool ShiftLeftLHS) {
+  BinaryOperator *Bop = dyn_cast(SubExpr);
+  if (!Bop)
+return;
+  if (!Bop->isAdditiveOp() && !Bop->isMultiplicativeOp())
+return;
+  // In many cases, execution order does not matter for 'A*BgetOpcodeStr();
+  S.Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
+  << Bop->getSourceRange() << OpLoc << Shift << Op;
+  SuggestParentheses(S, Bop->getOperatorLoc(),
+ S.PDiag(diag::note_precedence_silence) << Op,
+ Bop->getSourceRange());
 }
 
 static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
@@ -11313,8 +11319,8 @@
   if ((Opc == BO_Shl && 
LHSExpr->getType()->isIntegralType(Self.getASTContext()))
   || Opc == BO_Shr) {
 StringRef Shift = BinaryOperator::getOpcodeStr(Opc);
-DiagnoseAdditionInShift(Self, OpLoc, LHSExpr, Shift);
-DiagnoseAdditionInShift(Self, OpLoc, RHSExpr, Shift);
+DiagnoseAddOrMulInShift(Self, OpLoc, LHSExpr, Shift, Opc == BO_Shl);
+DiagnoseAddOrMulInShift(Self, OpLoc, RHSExpr, Shift, false);
   }
 
   // Warn on overloaded shift operators and comparisons, such as:


Index: test/Sema/parentheses.cpp
===
--- test/Sema/parentheses.cpp
+++ test/Sema/parentheses.cpp
@@ -95,6 +95,23 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
 
+  (void)(a >> b * c); // expected-warning {{operator '>>' has lower precedence than '*'; '*' will be evaluated first}} \
+ expected-note {{place parentheses around the '*' expression to silence this warning}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
+
+  (void)(a / b << c); // expected-warning {{operator '<<' has lower precedence than '

Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

I updated the patch so it does not warn about 'A * B << C'. It's a simple fix. 
I have not made careful measurements but I guess that the performance penalty 
is acceptable.


https://reviews.llvm.org/D24861



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


r282577 - Merge conflicting replacements when they are order-independent.

2016-09-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Sep 28 06:02:16 2016
New Revision: 282577

URL: http://llvm.org/viewvc/llvm-project?rev=282577&view=rev
Log:
Merge conflicting replacements when they are order-independent.

Summary:
Now two replacements are considered order-independent if applying them in
either order produces the same result. These include (but not restricted
to) replacements that:
  - don't overlap (being directly adjacent is fine) and
  - are overlapping deletions.
  - are insertions at the same offset and applying them in either order
has the same effect, i.e. X + Y = Y + X if one inserts text X and the
other inserts text Y.

Discussion about this design can be found in D24717

Reviewers: djasper, klimek

Subscribers: omtcyfz, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=282577&r1=282576&r2=282577&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Wed Sep 28 06:02:16 2016
@@ -167,10 +167,25 @@ class Replacements {
   /// order-dependent replacements. To control the order in which
   /// order-dependent replacements are applied, use merge({R}) with R referring
   /// to the changed code after applying all existing replacements.
-  /// Two replacements are considered order-independent if they:
+  /// Two replacements A and B are considered order-independent if applying 
them
+  /// in either order produces the same result. Note that the range of the
+  /// replacement that is applied later still refers to the original code.
+  /// These include (but not restricted to) replacements that:
   ///   - don't overlap (being directly adjacent is fine) and
-  ///   - aren't both inserts at the same code location (would be
-  /// order-dependent).
+  ///   - are overlapping deletions.
+  ///   - are insertions at the same offset and applying them in either order
+  /// has the same effect, i.e. X + Y = Y + X when inserting X and Y
+  /// respectively.
+  /// Examples:
+  /// 1. Replacement A(0, 0, "a") and B(0, 0, "aa") are order-independent since
+  ///applying them in either order gives replacement (0, 0, "aaa").
+  ///However, A(0, 0, "a") and B(0, 0, "b") are order-dependent since
+  ///applying A first gives (0, 0, "ab") while applying B first gives (B, 
A,
+  ///"ba").
+  /// 2. Replacement A(0, 2, "123") and B(0, 2, "123") are order-independent
+  ///since applying them in either order gives (0, 2, "123").
+  /// 3. Replacement A(0, 3, "123") and B(2, 3, "321") are order-independent
+  ///since either order gives (0, 5, "12321").
   /// Replacements with offset UINT_MAX are special - we do not detect 
conflicts
   /// for such replacements since users may add them intentionally as a special
   /// category of replacements.
@@ -213,6 +228,22 @@ private:
 
   Replacements mergeReplacements(const ReplacementsImpl &Second) const;
 
+  // Returns `R` with new range that refers to code after `Replaces` being
+  // applied.
+  Replacement getReplacementInChangedCode(const Replacement &R) const;
+
+  // Returns a set of replacements that is equivalent to the current
+  // replacements by merging all adjacent replacements. Two sets of 
replacements
+  // are considered equivalent if they have the same effect when they are
+  // applied.
+  Replacements getCanonicalReplacements() const;
+
+  // If `R` and all existing replacements are order-indepedent, then merge it
+  // with `Replaces` and returns the merged replacements; otherwise, returns an
+  // error.
+  llvm::Expected
+  mergeIfOrderIndependent(const Replacement &R) const;
+
   ReplacementsImpl Replaces;
 };
 

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=282577&r1=282576&r2=282577&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 28 06:02:16 2016
@@ -134,14 +134,75 @@ void Replacement::setFromSourceRange(con
 ReplacementText);
 }
 
-llvm::Error makeConflictReplacementsError(const Replacement &New,
-  const Replacement &Existing) {
+Replacement
+Replacements::getReplacementInChangedCode(const Replacement &R) const {
+  unsigned NewStart = getShiftedCodePosition(R.getOffset());
+  unsigned NewEnd = getShiftedCodePosition(R.getOffset() + R.getLength());
+  return Replacement(R.getFilePath(), NewStart, NewEnd - NewStart,
+

Re: [PATCH] D24800: Merge conflicting replacements when they are order-independent.

2016-09-28 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282577: Merge conflicting replacements when they are 
order-independent. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D24800?vs=72666&id=72799#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24800

Files:
  cfe/trunk/include/clang/Tooling/Core/Replacement.h
  cfe/trunk/lib/Tooling/Core/Replacement.cpp
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/include/clang/Tooling/Core/Replacement.h
===
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h
@@ -167,10 +167,25 @@
   /// order-dependent replacements. To control the order in which
   /// order-dependent replacements are applied, use merge({R}) with R referring
   /// to the changed code after applying all existing replacements.
-  /// Two replacements are considered order-independent if they:
+  /// Two replacements A and B are considered order-independent if applying them
+  /// in either order produces the same result. Note that the range of the
+  /// replacement that is applied later still refers to the original code.
+  /// These include (but not restricted to) replacements that:
   ///   - don't overlap (being directly adjacent is fine) and
-  ///   - aren't both inserts at the same code location (would be
-  /// order-dependent).
+  ///   - are overlapping deletions.
+  ///   - are insertions at the same offset and applying them in either order
+  /// has the same effect, i.e. X + Y = Y + X when inserting X and Y
+  /// respectively.
+  /// Examples:
+  /// 1. Replacement A(0, 0, "a") and B(0, 0, "aa") are order-independent since
+  ///applying them in either order gives replacement (0, 0, "aaa").
+  ///However, A(0, 0, "a") and B(0, 0, "b") are order-dependent since
+  ///applying A first gives (0, 0, "ab") while applying B first gives (B, A,
+  ///"ba").
+  /// 2. Replacement A(0, 2, "123") and B(0, 2, "123") are order-independent
+  ///since applying them in either order gives (0, 2, "123").
+  /// 3. Replacement A(0, 3, "123") and B(2, 3, "321") are order-independent
+  ///since either order gives (0, 5, "12321").
   /// Replacements with offset UINT_MAX are special - we do not detect conflicts
   /// for such replacements since users may add them intentionally as a special
   /// category of replacements.
@@ -213,6 +228,22 @@
 
   Replacements mergeReplacements(const ReplacementsImpl &Second) const;
 
+  // Returns `R` with new range that refers to code after `Replaces` being
+  // applied.
+  Replacement getReplacementInChangedCode(const Replacement &R) const;
+
+  // Returns a set of replacements that is equivalent to the current
+  // replacements by merging all adjacent replacements. Two sets of replacements
+  // are considered equivalent if they have the same effect when they are
+  // applied.
+  Replacements getCanonicalReplacements() const;
+
+  // If `R` and all existing replacements are order-indepedent, then merge it
+  // with `Replaces` and returns the merged replacements; otherwise, returns an
+  // error.
+  llvm::Expected
+  mergeIfOrderIndependent(const Replacement &R) const;
+
   ReplacementsImpl Replaces;
 };
 
Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -134,14 +134,75 @@
 ReplacementText);
 }
 
-llvm::Error makeConflictReplacementsError(const Replacement &New,
-  const Replacement &Existing) {
+Replacement
+Replacements::getReplacementInChangedCode(const Replacement &R) const {
+  unsigned NewStart = getShiftedCodePosition(R.getOffset());
+  unsigned NewEnd = getShiftedCodePosition(R.getOffset() + R.getLength());
+  return Replacement(R.getFilePath(), NewStart, NewEnd - NewStart,
+ R.getReplacementText());
+}
+
+static llvm::Error makeConflictReplacementsError(const Replacement &New,
+ const Replacement &Existing) {
   return llvm::make_error(
   "New replacement:\n" + New.toString() +
   "\nconflicts with existing replacement:\n" + Existing.toString(),
   llvm::inconvertibleErrorCode());
 }
 
+Replacements Replacements::getCanonicalReplacements() const {
+  std::vector NewReplaces;
+  // Merge adjacent replacements.
+  for (const auto &R : Replaces) {
+if (NewReplaces.empty()) {
+  NewReplaces.push_back(R);
+  continue;
+}
+auto &Prev = NewReplaces.back();
+unsigned PrevEnd = Prev.getOffset() + Prev.getLength();
+if (PrevEnd < R.getOffset()) {
+  NewReplaces.push_back(R);
+} else {
+  assert(PrevEnd == R.getOffset() &&
+ "Existing replacements must not over

Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-09-28 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a subscriber: malcolm.parsons.


Comment at: lib/AST/Expr.cpp:2868
@@ +2867,3 @@
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increement and decrement are intended
+// to have a side-effect and other overloaded operators are not.

typo: increment


https://reviews.llvm.org/D22910



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


r282578 - ASTMerge: explicitly specify arch for GCCAsmStmt test to calm non-x86 buildbots

2016-09-28 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Wed Sep 28 06:04:42 2016
New Revision: 282578

URL: http://llvm.org/viewvc/llvm-project?rev=282578&view=rev
Log:
ASTMerge: explicitly specify arch for GCCAsmStmt test to calm non-x86 buildbots

This should fix r282572.

Added:
cfe/trunk/test/ASTMerge/Inputs/asm-function.cpp
cfe/trunk/test/ASTMerge/asm.cpp

Added: cfe/trunk/test/ASTMerge/Inputs/asm-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/asm-function.cpp?rev=282578&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/asm-function.cpp (added)
+++ cfe/trunk/test/ASTMerge/Inputs/asm-function.cpp Wed Sep 28 06:04:42 2016
@@ -0,0 +1,11 @@
+
+unsigned char asmFunc(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int lb = b;
+  unsigned int bigres;
+  unsigned char res;
+  __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) :
+"edx", "cc");
+  res = bigres;
+  return res;
+}

Added: cfe/trunk/test/ASTMerge/asm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/asm.cpp?rev=282578&view=auto
==
--- cfe/trunk/test/ASTMerge/asm.cpp (added)
+++ cfe/trunk/test/ASTMerge/asm.cpp Wed Sep 28 06:04:42 2016
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fcxx-exceptions -emit-pch -o 
%t.1.ast %S/Inputs/asm-function.cpp
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fcxx-exceptions -ast-merge 
%t.1.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+void testAsmImport() {
+  asmFunc(12, 42);
+}


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


Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 72802.
danielmarjamaki added a comment.

Fix review comments


https://reviews.llvm.org/D24656

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tidy/readability/RedundantDeclarationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-declaration.rst
  test/clang-tidy/readability-redundant-declaration.cpp

Index: test/clang-tidy/readability-redundant-declaration.cpp
===
--- test/clang-tidy/readability-redundant-declaration.cpp
+++ test/clang-tidy/readability-redundant-declaration.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s readability-redundant-declaration %t
+
+extern int Xyz;
+extern int Xyz;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Xyz' declaration [readability-redundant-declaration]
+// CHECK-FIXES: {{^}}{{$}}
+int Xyz = 123;
+
+extern int A;
+extern int A, B;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'A' declaration
+// CHECK-FIXES: {{^}}extern int A, B;{{$}}
+
+extern int Buf[10];
+extern int Buf[10];
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Buf' declaration
+// CHECK-FIXES: {{^}}{{$}}
+
+static int f();
+static int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'f' declaration
+// CHECK-FIXES: {{^}}{{$}}
+static int f() {}
Index: docs/clang-tidy/checks/readability-redundant-declaration.rst
===
--- docs/clang-tidy/checks/readability-redundant-declaration.rst
+++ docs/clang-tidy/checks/readability-redundant-declaration.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - readability-redundant-declaration
+
+readability-redundant-declaration
+=
+
+Finds redundant variable declarations.
+
+.. code-block:: c++
+
+  extern int X;
+  extern int X;
+
+becomes
+
+.. code-block:: c++
+
+  extern int X;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -133,6 +133,7 @@
readability-named-parameter
readability-non-const-parameter
readability-redundant-control-flow
+   readability-redundant-declaration
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -111,6 +111,11 @@
   Flags function parameters of a pointer type that could be changed to point to
   a constant type instead.
 
+- New `readability-redundant-declaration
+  `_ check
+
+  Warns about duplicate variable declarations.
+
 Fixed bugs:
 
 - `modernize-make-unique
Index: clang-tidy/readability/RedundantDeclarationCheck.h
===
--- clang-tidy/readability/RedundantDeclarationCheck.h
+++ clang-tidy/readability/RedundantDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantDeclarationCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Find redundant variable declarations.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-declaration.html
+class RedundantDeclarationCheck : public ClangTidyCheck {
+public:
+  RedundantDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_DECLARATION_H
Index: clang-tidy/readability/RedundantDeclarationCheck.cpp
===
--- clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -0,0 +1,70 @@
+//===--- RedundantDeclarationCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distribut

Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

2016-09-28 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki marked 3 inline comments as done.


Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:39
@@ +38,3 @@
+  bool MultiVar = false;
+  if (const auto *VD = dyn_cast(D)) {
+if (VD && VD->getPreviousDecl()->getStorageClass() == SC_Extern &&

I don't want to generate a fixit. because it could easily break the code. And 
it will probably depend on inclusion order.


Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:45
@@ +44,3 @@
+for (const auto Other : VD->getDeclContext()->decls()) {
+  if (Other != D && Other->getLocStart() == VD->getLocStart()) {
+MultiVar = true;

I think this is better. But not perfect. Maybe there is still a better way.


Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:59-65
@@ +58,9 @@
+  {
+auto Diag = diag(D->getLocation(), "redundant '%0' declaration")
+<< cast(D)->getName();
+if (!MultiVar && !DifferentHeaders)
+  Diag << FixItHint::CreateRemoval(
+   SourceRange(D->getSourceRange().getBegin(), EndLoc));
+  }
+  diag(Prev->getLocation(), "previously declared here", DiagnosticIDs::Note);
+}

Thanks! That works.


https://reviews.llvm.org/D24656



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


r282581 - [X86] Remove the mm_malloc.h include guard hack from the X86 builtins tests

2016-09-28 Thread Elad Cohen via cfe-commits
Author: eladcohen
Date: Wed Sep 28 06:59:09 2016
New Revision: 282581

URL: http://llvm.org/viewvc/llvm-project?rev=282581&view=rev
Log:
[X86] Remove the mm_malloc.h include guard hack from the X86 builtins tests

The X86 clang/test/CodeGen/*builtins.c tests define the mm_malloc.h include
guard as a hack for avoiding its inclusion (mm_malloc.h requires a hosted
environment since it expects stdlib.h to be available - which is not the case
in these internal clang codegen tests).
This patch removes this hack and instead passes -ffreestanding to clang cc1.

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


Modified:
cfe/trunk/test/CodeGen/3dnow-builtins.c
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx-cmp-builtins.c
cfe/trunk/test/CodeGen/avx-shuffle-builtins.c
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512cdintrin.c
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512er-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512ifma-builtins.c
cfe/trunk/test/CodeGen/avx512pf-builtins.c
cfe/trunk/test/CodeGen/avx512vbmi-builtins.c
cfe/trunk/test/CodeGen/avx512vbmivl-builtin.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
cfe/trunk/test/CodeGen/avx512vlcd-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c
cfe/trunk/test/CodeGen/bitscan-builtins.c
cfe/trunk/test/CodeGen/bmi-builtins.c
cfe/trunk/test/CodeGen/bmi2-builtins.c
cfe/trunk/test/CodeGen/f16c-builtins.c
cfe/trunk/test/CodeGen/fma-builtins.c
cfe/trunk/test/CodeGen/fma4-builtins.c
cfe/trunk/test/CodeGen/fsgsbase-builtins.c
cfe/trunk/test/CodeGen/lzcnt-builtins.c
cfe/trunk/test/CodeGen/mmx-builtins.c
cfe/trunk/test/CodeGen/pclmul-builtins.c
cfe/trunk/test/CodeGen/pku.c
cfe/trunk/test/CodeGen/popcnt-builtins.c
cfe/trunk/test/CodeGen/prefetchw-builtins.c
cfe/trunk/test/CodeGen/rd-builtins.c
cfe/trunk/test/CodeGen/rdrand-builtins.c
cfe/trunk/test/CodeGen/rtm-builtins.c
cfe/trunk/test/CodeGen/sha-builtins.c
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse.c
cfe/trunk/test/CodeGen/sse2-builtins.c
cfe/trunk/test/CodeGen/sse3-builtins.c
cfe/trunk/test/CodeGen/sse41-builtins.c
cfe/trunk/test/CodeGen/sse42-builtins.c
cfe/trunk/test/CodeGen/sse4a-builtins.c
cfe/trunk/test/CodeGen/ssse3-builtins.c
cfe/trunk/test/CodeGen/tbm-builtins.c
cfe/trunk/test/CodeGen/vector.c
cfe/trunk/test/CodeGen/xop-builtins.c

Modified: cfe/trunk/test/CodeGen/3dnow-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/3dnow-builtins.c?rev=282581&r1=282580&r2=282581&view=diff
==
--- cfe/trunk/test/CodeGen/3dnow-builtins.c (original)
+++ cfe/trunk/test/CodeGen/3dnow-builtins.c Wed Sep 28 06:59:09 2016
@@ -1,8 +1,6 @@
-// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature +3dnowa 
-emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=GCC 
-check-prefix=CHECK
-// RUN: %clang_cc1 %s -triple=x86_64-scei-ps4 -target-feature +3dnowa 
-emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=PS4 
-check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-unknown 
-target-feature +3dnowa -emit-llvm -o - -Wall -Werror | FileCheck %s 
-check-prefix=GCC -check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-scei-ps4 -target-feature 
+3dnowa -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=PS4 
-check-prefix=CHECK
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=282581&r1=282580&r2=282581&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Wed Sep 28 06:59:09 2016
@@ -1,8 +1,6 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx 
-emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx 
-fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck 
%s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 

Modified: cfe/trunk/test/CodeGen/avx-cmp-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-cmp-builtins.c?rev=282581&r1=282580&r2=282581&

Re: [PATCH] D24825: [X86] Remove the mm_malloc.h include guard hack from the X86 builtins tests

2016-09-28 Thread Elad Cohen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282581: [X86] Remove the mm_malloc.h include guard hack from 
the X86 builtins tests (authored by eladcohen).

Changed prior to commit:
  https://reviews.llvm.org/D24825?vs=72158&id=72805#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24825

Files:
  cfe/trunk/test/CodeGen/3dnow-builtins.c
  cfe/trunk/test/CodeGen/avx-builtins.c
  cfe/trunk/test/CodeGen/avx-cmp-builtins.c
  cfe/trunk/test/CodeGen/avx-shuffle-builtins.c
  cfe/trunk/test/CodeGen/avx2-builtins.c
  cfe/trunk/test/CodeGen/avx512bw-builtins.c
  cfe/trunk/test/CodeGen/avx512cdintrin.c
  cfe/trunk/test/CodeGen/avx512dq-builtins.c
  cfe/trunk/test/CodeGen/avx512er-builtins.c
  cfe/trunk/test/CodeGen/avx512f-builtins.c
  cfe/trunk/test/CodeGen/avx512ifma-builtins.c
  cfe/trunk/test/CodeGen/avx512pf-builtins.c
  cfe/trunk/test/CodeGen/avx512vbmi-builtins.c
  cfe/trunk/test/CodeGen/avx512vbmivl-builtin.c
  cfe/trunk/test/CodeGen/avx512vl-builtins.c
  cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
  cfe/trunk/test/CodeGen/avx512vlcd-builtins.c
  cfe/trunk/test/CodeGen/avx512vldq-builtins.c
  cfe/trunk/test/CodeGen/bitscan-builtins.c
  cfe/trunk/test/CodeGen/bmi-builtins.c
  cfe/trunk/test/CodeGen/bmi2-builtins.c
  cfe/trunk/test/CodeGen/f16c-builtins.c
  cfe/trunk/test/CodeGen/fma-builtins.c
  cfe/trunk/test/CodeGen/fma4-builtins.c
  cfe/trunk/test/CodeGen/fsgsbase-builtins.c
  cfe/trunk/test/CodeGen/lzcnt-builtins.c
  cfe/trunk/test/CodeGen/mmx-builtins.c
  cfe/trunk/test/CodeGen/pclmul-builtins.c
  cfe/trunk/test/CodeGen/pku.c
  cfe/trunk/test/CodeGen/popcnt-builtins.c
  cfe/trunk/test/CodeGen/prefetchw-builtins.c
  cfe/trunk/test/CodeGen/rd-builtins.c
  cfe/trunk/test/CodeGen/rdrand-builtins.c
  cfe/trunk/test/CodeGen/rtm-builtins.c
  cfe/trunk/test/CodeGen/sha-builtins.c
  cfe/trunk/test/CodeGen/sse-builtins.c
  cfe/trunk/test/CodeGen/sse.c
  cfe/trunk/test/CodeGen/sse2-builtins.c
  cfe/trunk/test/CodeGen/sse3-builtins.c
  cfe/trunk/test/CodeGen/sse41-builtins.c
  cfe/trunk/test/CodeGen/sse42-builtins.c
  cfe/trunk/test/CodeGen/sse4a-builtins.c
  cfe/trunk/test/CodeGen/ssse3-builtins.c
  cfe/trunk/test/CodeGen/tbm-builtins.c
  cfe/trunk/test/CodeGen/vector.c
  cfe/trunk/test/CodeGen/xop-builtins.c

Index: cfe/trunk/test/CodeGen/sha-builtins.c
===
--- cfe/trunk/test/CodeGen/sha-builtins.c
+++ cfe/trunk/test/CodeGen/sha-builtins.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature +sha -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +sha -emit-llvm -o - | FileCheck %s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: cfe/trunk/test/CodeGen/avx512cdintrin.c
===
--- cfe/trunk/test/CodeGen/avx512cdintrin.c
+++ cfe/trunk/test/CodeGen/avx512cdintrin.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx512cd -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512cd -emit-llvm -o - -Wall -Werror | FileCheck %s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: cfe/trunk/test/CodeGen/sse3-builtins.c
===
--- cfe/trunk/test/CodeGen/sse3-builtins.c
+++ cfe/trunk/test/CodeGen/sse3-builtins.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: cfe/trunk/test/CodeGen/avx512vbmi-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512vbmi-builtins.c
+++ cfe/trunk/test/CodeGen/avx512vbmi-builtins.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx512vbmi -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512vbmi -emit-llvm -o - -Wall -Werror | FileCheck %s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: cfe/trunk/test/CodeGen/sse.c
===
--- cfe/trunk/test/CodeGen/sse.c
+++ cfe/trunk/test/CodeGen/sse.c
@@ -1,8 +1,6 @@
-// RUN: %clang_cc1 -O3 -triple x86_64-apple-macosx10.8.0 -target-feature +sse4.1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding -O3 -triple x86_64-apple-macosx10.8.0 -target-feature +sse4.1 -emit-llvm %s -o - | FileCheck %s
 // FIXME: This tes

Re: [PATCH] D24825: [X86] Remove the mm_malloc.h include guard hack from the X86 builtins tests

2016-09-28 Thread Elad Cohen via cfe-commits
eladcohen added a comment.

Thanks for the review! committed r282581.


Repository:
  rL LLVM

https://reviews.llvm.org/D24825



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


Re: r282577 - Merge conflicting replacements when they are order-independent.

2016-09-28 Thread Eric Liu via cfe-commits
This is causing buildbot failure. I am working on a fix.

On Wed, Sep 28, 2016 at 1:11 PM Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Wed Sep 28 06:02:16 2016
> New Revision: 282577
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282577&view=rev
> Log:
> Merge conflicting replacements when they are order-independent.
>
> Summary:
> Now two replacements are considered order-independent if applying them in
> either order produces the same result. These include (but not restricted
> to) replacements that:
>   - don't overlap (being directly adjacent is fine) and
>   - are overlapping deletions.
>   - are insertions at the same offset and applying them in either order
> has the same effect, i.e. X + Y = Y + X if one inserts text X and the
> other inserts text Y.
>
> Discussion about this design can be found in D24717
>
> Reviewers: djasper, klimek
>
> Subscribers: omtcyfz, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D24800
>
> Modified:
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=282577&r1=282576&r2=282577&view=diff
>
> ==
> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Wed Sep 28 06:02:16
> 2016
> @@ -167,10 +167,25 @@ class Replacements {
>/// order-dependent replacements. To control the order in which
>/// order-dependent replacements are applied, use merge({R}) with R
> referring
>/// to the changed code after applying all existing replacements.
> -  /// Two replacements are considered order-independent if they:
> +  /// Two replacements A and B are considered order-independent if
> applying them
> +  /// in either order produces the same result. Note that the range of the
> +  /// replacement that is applied later still refers to the original code.
> +  /// These include (but not restricted to) replacements that:
>///   - don't overlap (being directly adjacent is fine) and
> -  ///   - aren't both inserts at the same code location (would be
> -  /// order-dependent).
> +  ///   - are overlapping deletions.
> +  ///   - are insertions at the same offset and applying them in either
> order
> +  /// has the same effect, i.e. X + Y = Y + X when inserting X and Y
> +  /// respectively.
> +  /// Examples:
> +  /// 1. Replacement A(0, 0, "a") and B(0, 0, "aa") are order-independent
> since
> +  ///applying them in either order gives replacement (0, 0, "aaa").
> +  ///However, A(0, 0, "a") and B(0, 0, "b") are order-dependent since
> +  ///applying A first gives (0, 0, "ab") while applying B first gives
> (B, A,
> +  ///"ba").
> +  /// 2. Replacement A(0, 2, "123") and B(0, 2, "123") are
> order-independent
> +  ///since applying them in either order gives (0, 2, "123").
> +  /// 3. Replacement A(0, 3, "123") and B(2, 3, "321") are
> order-independent
> +  ///since either order gives (0, 5, "12321").
>/// Replacements with offset UINT_MAX are special - we do not detect
> conflicts
>/// for such replacements since users may add them intentionally as a
> special
>/// category of replacements.
> @@ -213,6 +228,22 @@ private:
>
>Replacements mergeReplacements(const ReplacementsImpl &Second) const;
>
> +  // Returns `R` with new range that refers to code after `Replaces` being
> +  // applied.
> +  Replacement getReplacementInChangedCode(const Replacement &R) const;
> +
> +  // Returns a set of replacements that is equivalent to the current
> +  // replacements by merging all adjacent replacements. Two sets of
> replacements
> +  // are considered equivalent if they have the same effect when they are
> +  // applied.
> +  Replacements getCanonicalReplacements() const;
> +
> +  // If `R` and all existing replacements are order-indepedent, then
> merge it
> +  // with `Replaces` and returns the merged replacements; otherwise,
> returns an
> +  // error.
> +  llvm::Expected
> +  mergeIfOrderIndependent(const Replacement &R) const;
> +
>ReplacementsImpl Replaces;
>  };
>
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=282577&r1=282576&r2=282577&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 28 06:02:16 2016
> @@ -134,14 +134,75 @@ void Replacement::setFromSourceRange(con
>  ReplacementText);
>  }
>
> -llvm::Error makeConflictReplacementsError(const Replacement &New,
> -  

Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-09-28 Thread Andi via cfe-commits
Abpostelnicu updated this revision to Diff 72806.
Abpostelnicu marked an inline comment as done.
Abpostelnicu added a comment.

corrected typo


https://reviews.llvm.org/D22910

Files:
  include/clang/AST/ExprCXX.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,23 @@
 // These never have a side-effect.
 return false;
 
+  case CXXOperatorCallExprClass: {
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increment and decrement are intended
+// to have a side-effect and other overloaded operators are not.
+// Otherwise fall through the logic of call expression.
+OverloadedOperatorKind Op = cast(this)->getOperator();
+if (CXXOperatorCallExpr::isAssignmentOp(Op)
+|| CXXOperatorCallExpr::isIncrementOp(Op)
+|| CXXOperatorCallExpr::isDecrementOp(Op)) {
+  const Decl *FD = cast(this)->getCalleeDecl();
+  bool IsPure = FD && (FD->hasAttr() || 
FD->hasAttr());
+  if (!IsPure)
+return true;
+}
+LLVM_FALLTHROUGH;
+  }
   case CallExprClass:
-  case CXXOperatorCallExprClass:
   case CXXMemberCallExprClass:
   case CUDAKernelCallExprClass:
   case UserDefinedLiteralClass: {
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -106,6 +106,26 @@
   // operations on floating point types.
   bool isFPContractable() const { return FPContractable; }
 
+  // Check to see if a given overloaded operator is of assignment kind
+  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+return Opc == OO_Equal || Opc == OO_StarEqual ||
+   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+   Opc == OO_PipeEqual;
+  }
+  
+  // Check to see if a given overloaded operator is of increment kind
+  static bool isIncrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_PlusPlus;
+  }
+
+  // Check to see if a given overloaded operator is of decrement kind
+  static bool isDecrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_MinusMinus;
+  }
+  
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 };


Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2863,8 +2863,23 @@
 // These never have a side-effect.
 return false;
 
+  case CXXOperatorCallExprClass: {
+// When looking for potential side-effects, we assume that these
+// operators: assignment, increment and decrement are intended
+// to have a side-effect and other overloaded operators are not.
+// Otherwise fall through the logic of call expression.
+OverloadedOperatorKind Op = cast(this)->getOperator();
+if (CXXOperatorCallExpr::isAssignmentOp(Op)
+|| CXXOperatorCallExpr::isIncrementOp(Op)
+|| CXXOperatorCallExpr::isDecrementOp(Op)) {
+  const Decl *FD = cast(this)->getCalleeDecl();
+  bool IsPure = FD && (FD->hasAttr() || FD->hasAttr());
+  if (!IsPure)
+return true;
+}
+LLVM_FALLTHROUGH;
+  }
   case CallExprClass:
-  case CXXOperatorCallExprClass:
   case CXXMemberCallExprClass:
   case CUDAKernelCallExprClass:
   case UserDefinedLiteralClass: {
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -106,6 +106,26 @@
   // operations on floating point types.
   bool isFPContractable() const { return FPContractable; }
 
+  // Check to see if a given overloaded operator is of assignment kind
+  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+return Opc == OO_Equal || Opc == OO_StarEqual ||
+   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+   Opc == OO_PipeEqual;
+  }
+  
+  // Check to see if a given overloaded operator is of increment kind
+  static bool isIncrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_PlusPlus;
+  }
+
+  // Check to see if a given overloaded operator is of decrement kind
+  static bool isDecrementOp(OverloadedOperatorKind Opc) {
+return Opc == OO_MinusMinus;
+  }
+  
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24628: [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber

2016-09-28 Thread Dmitry Vyukov via cfe-commits
dvyukov accepted this revision.
dvyukov added a comment.
This revision is now accepted and ready to land.

Submitted in 282582.


https://reviews.llvm.org/D24628



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


[PATCH] D25017: [mips][msa] Range check MSA intrinsics with immediates

2016-09-28 Thread Simon Dardis via cfe-commits
sdardis created this revision.
sdardis added reviewers: vkalintiris, zoran.jovanovic.
sdardis added a subscriber: cfe-commits.
Herald added a subscriber: sdardis.

This patch teaches clang to range check immediates for MIPS MSA instrincs. This
checking is done strictly in comparison to some existing GCC implementations.
E.g. __msa_andvi_b(var, 257) does not result in andvi $wX, 1. Similarily
__msa_ldi_b takes a range of -128 to 127.

As part of this effort, correct the existing MSA test as it has both illegal 
types and
immediates.

https://reviews.llvm.org/D25017

Files:
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins-mips-msa-error.c
  test/CodeGen/builtins-mips-msa.c

Index: test/CodeGen/builtins-mips-msa.c
===
--- test/CodeGen/builtins-mips-msa.c
+++ test/CodeGen/builtins-mips-msa.c
@@ -138,28 +138,28 @@
   v4i32_r = __msa_bclr_w(v4i32_a, v4i32_b); // CHECK: call <4  x i32> @llvm.mips.bclr.w(
   v2i64_r = __msa_bclr_d(v2i64_a, v2i64_b); // CHECK: call <2  x i64> @llvm.mips.bclr.d(
 
-  v16i8_r = __msa_bclri_b(v16i8_a, 25); // CHECK: call <16 x i8>  @llvm.mips.bclri.b(
-  v8i16_r = __msa_bclri_h(v8i16_a, 25); // CHECK: call <8  x i16> @llvm.mips.bclri.h(
+  v16i8_r = __msa_bclri_b(v16i8_a, 3); // CHECK: call <16 x i8>  @llvm.mips.bclri.b(
+  v8i16_r = __msa_bclri_h(v8i16_a, 8); // CHECK: call <8  x i16> @llvm.mips.bclri.h(
   v4i32_r = __msa_bclri_w(v4i32_a, 25); // CHECK: call <4  x i32> @llvm.mips.bclri.w(
   v2i64_r = __msa_bclri_d(v2i64_a, 25); // CHECK: call <2  x i64> @llvm.mips.bclri.d(
 
   v16i8_r = __msa_binsl_b(v16i8_r, v16i8_a, v16i8_b); // CHECK: call <16 x i8>  @llvm.mips.binsl.b(
   v8i16_r = __msa_binsl_h(v8i16_r, v8i16_a, v8i16_b); // CHECK: call <8  x i16> @llvm.mips.binsl.h(
   v4i32_r = __msa_binsl_w(v4i32_r, v4i32_a, v4i32_b); // CHECK: call <4  x i32> @llvm.mips.binsl.w(
   v2i64_r = __msa_binsl_d(v2i64_r, v2i64_a, v2i64_b); // CHECK: call <2  x i64> @llvm.mips.binsl.d(
 
-  v16i8_r = __msa_binsli_b(v16i8_r, v16i8_a, 25); // CHECK: call <16 x i8>  @llvm.mips.binsli.b(
-  v8i16_r = __msa_binsli_h(v8i16_r, v8i16_a, 25); // CHECK: call <8  x i16> @llvm.mips.binsli.h(
+  v16i8_r = __msa_binsli_b(v16i8_r, v16i8_a, 3); // CHECK: call <16 x i8>  @llvm.mips.binsli.b(
+  v8i16_r = __msa_binsli_h(v8i16_r, v8i16_a, 8); // CHECK: call <8  x i16> @llvm.mips.binsli.h(
   v4i32_r = __msa_binsli_w(v4i32_r, v4i32_a, 25); // CHECK: call <4  x i32> @llvm.mips.binsli.w(
   v2i64_r = __msa_binsli_d(v2i64_r, v2i64_a, 25); // CHECK: call <2  x i64> @llvm.mips.binsli.d(
 
   v16i8_r = __msa_binsr_b(v16i8_r, v16i8_a, v16i8_b); // CHECK: call <16 x i8>  @llvm.mips.binsr.b(
   v8i16_r = __msa_binsr_h(v8i16_r, v8i16_a, v8i16_b); // CHECK: call <8  x i16> @llvm.mips.binsr.h(
   v4i32_r = __msa_binsr_w(v4i32_r, v4i32_a, v4i32_b); // CHECK: call <4  x i32> @llvm.mips.binsr.w(
   v2i64_r = __msa_binsr_d(v2i64_r, v2i64_a, v2i64_b); // CHECK: call <2  x i64> @llvm.mips.binsr.d(
 
-  v16i8_r = __msa_binsri_b(v16i8_r, v16i8_a, 25); // CHECK: call <16 x i8>  @llvm.mips.binsri.b(
-  v8i16_r = __msa_binsri_h(v8i16_r, v8i16_a, 25); // CHECK: call <8  x i16> @llvm.mips.binsri.h(
+  v16i8_r = __msa_binsri_b(v16i8_r, v16i8_a, 5); // CHECK: call <16 x i8>  @llvm.mips.binsri.b(
+  v8i16_r = __msa_binsri_h(v8i16_r, v8i16_a, 15); // CHECK: call <8  x i16> @llvm.mips.binsri.h(
   v4i32_r = __msa_binsri_w(v4i32_r, v4i32_a, 25); // CHECK: call <4  x i32> @llvm.mips.binsri.w(
   v2i64_r = __msa_binsri_d(v2i64_r, v2i64_a, 25); // CHECK: call <2  x i64> @llvm.mips.binsri.d(
 
@@ -182,8 +182,8 @@
   v4i32_r = __msa_bneg_w(v4i32_a, v4i32_b); // CHECK: call <4  x i32> @llvm.mips.bneg.w(
   v2i64_r = __msa_bneg_d(v2i64_a, v2i64_b); // CHECK: call <2  x i64> @llvm.mips.bneg.d(
 
-  v16i8_r = __msa_bnegi_b(v16i8_a, 25); // CHECK: call <16 x i8>  @llvm.mips.bnegi.b(
-  v8i16_r = __msa_bnegi_h(v8i16_a, 25); // CHECK: call <8  x i16> @llvm.mips.bnegi.h(
+  v16i8_r = __msa_bnegi_b(v16i8_a, 6); // CHECK: call <16 x i8>  @llvm.mips.bnegi.b(
+  v8i16_r = __msa_bnegi_h(v8i16_a, 14); // CHECK: call <8  x i16> @llvm.mips.bnegi.h(
   v4i32_r = __msa_bnegi_w(v4i32_a, 25); // CHECK: call <4  x i32> @llvm.mips.bnegi.w(
   v2i64_r = __msa_bnegi_d(v2i64_a, 25); // CHECK: call <2  x i64> @llvm.mips.bnegi.d(
 
@@ -206,8 +206,8 @@
   v4i32_r = __msa_bset_w(v4i32_a, v4i32_b); // CHECK: call <4  x i32> @llvm.mips.bset.w(
   v2i64_r = __msa_bset_d(v2i64_a, v2i64_b); // CHECK: call <2  x i64> @llvm.mips.bset.d(
 
-  v16i8_r = __msa_bseti_b(v16i8_a, 25); // CHECK: call <16 x i8>  @llvm.mips.bseti.b(
-  v8i16_r = __msa_bseti_h(v8i16_a, 25); // CHECK: call <8  x i16> @llvm.mips.bseti.h(
+  v16i8_r = __msa_bseti_b(v16i8_a, 5); // CHECK: call <16 x i8>  @llvm.mips.bseti.b(
+  v8i16_r = __msa_bseti_h(v8i16_a, 15); // CHECK: call <8  x i16> @llvm.mips.bseti.h(
   v4i32_r = __msa_bseti_w(v4i32_a, 25); // CHECK: call <4  x i32> @llvm.mips.bseti.w(
   v2i64_r = __msa_bseti_d(v2i64_a, 25); // CHECK: call <

r282583 - Trying to buildbot failures caused by r282577.

2016-09-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Wed Sep 28 07:49:14 2016
New Revision: 282583

URL: http://llvm.org/viewvc/llvm-project?rev=282583&view=rev
Log:
Trying to buildbot failures caused by r282577.

Modified:
cfe/trunk/lib/Tooling/Core/Replacement.cpp

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=282583&r1=282582&r2=282583&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 28 07:49:14 2016
@@ -287,8 +287,13 @@ llvm::Error Replacements::add(const Repl
 // with them and replace them with the merged replacements.
 auto MergeBegin = I;
 auto MergeEnd = std::next(I);
-while (I-- != Replaces.begin() && Overlap(R, *I))
+while (I != Replaces.begin()) {
+  --I;
+  // If `I` doesn't overlap with `R`, don't merge it.
+  if (!Overlap(R, *I))
+break;
   MergeBegin = I;
+}
 Replacements OverlapReplaces(MergeBegin, MergeEnd);
 llvm::Expected Merged =
 OverlapReplaces.mergeIfOrderIndependent(R);


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


Re: r282577 - Merge conflicting replacements when they are order-independent.

2016-09-28 Thread Eric Liu via cfe-commits
r282583 should fix this.

On Wed, Sep 28, 2016 at 2:14 PM Eric Liu  wrote:

> This is causing buildbot failure. I am working on a fix.
>
> On Wed, Sep 28, 2016 at 1:11 PM Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Wed Sep 28 06:02:16 2016
> New Revision: 282577
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282577&view=rev
> Log:
> Merge conflicting replacements when they are order-independent.
>
> Summary:
> Now two replacements are considered order-independent if applying them in
> either order produces the same result. These include (but not restricted
> to) replacements that:
>   - don't overlap (being directly adjacent is fine) and
>   - are overlapping deletions.
>   - are insertions at the same offset and applying them in either order
> has the same effect, i.e. X + Y = Y + X if one inserts text X and the
> other inserts text Y.
>
> Discussion about this design can be found in D24717
>
> Reviewers: djasper, klimek
>
> Subscribers: omtcyfz, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D24800
>
> Modified:
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=282577&r1=282576&r2=282577&view=diff
>
> ==
> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Wed Sep 28 06:02:16
> 2016
> @@ -167,10 +167,25 @@ class Replacements {
>/// order-dependent replacements. To control the order in which
>/// order-dependent replacements are applied, use merge({R}) with R
> referring
>/// to the changed code after applying all existing replacements.
> -  /// Two replacements are considered order-independent if they:
> +  /// Two replacements A and B are considered order-independent if
> applying them
> +  /// in either order produces the same result. Note that the range of the
> +  /// replacement that is applied later still refers to the original code.
> +  /// These include (but not restricted to) replacements that:
>///   - don't overlap (being directly adjacent is fine) and
> -  ///   - aren't both inserts at the same code location (would be
> -  /// order-dependent).
> +  ///   - are overlapping deletions.
> +  ///   - are insertions at the same offset and applying them in either
> order
> +  /// has the same effect, i.e. X + Y = Y + X when inserting X and Y
> +  /// respectively.
> +  /// Examples:
> +  /// 1. Replacement A(0, 0, "a") and B(0, 0, "aa") are order-independent
> since
> +  ///applying them in either order gives replacement (0, 0, "aaa").
> +  ///However, A(0, 0, "a") and B(0, 0, "b") are order-dependent since
> +  ///applying A first gives (0, 0, "ab") while applying B first gives
> (B, A,
> +  ///"ba").
> +  /// 2. Replacement A(0, 2, "123") and B(0, 2, "123") are
> order-independent
> +  ///since applying them in either order gives (0, 2, "123").
> +  /// 3. Replacement A(0, 3, "123") and B(2, 3, "321") are
> order-independent
> +  ///since either order gives (0, 5, "12321").
>/// Replacements with offset UINT_MAX are special - we do not detect
> conflicts
>/// for such replacements since users may add them intentionally as a
> special
>/// category of replacements.
> @@ -213,6 +228,22 @@ private:
>
>Replacements mergeReplacements(const ReplacementsImpl &Second) const;
>
> +  // Returns `R` with new range that refers to code after `Replaces` being
> +  // applied.
> +  Replacement getReplacementInChangedCode(const Replacement &R) const;
> +
> +  // Returns a set of replacements that is equivalent to the current
> +  // replacements by merging all adjacent replacements. Two sets of
> replacements
> +  // are considered equivalent if they have the same effect when they are
> +  // applied.
> +  Replacements getCanonicalReplacements() const;
> +
> +  // If `R` and all existing replacements are order-indepedent, then
> merge it
> +  // with `Replaces` and returns the merged replacements; otherwise,
> returns an
> +  // error.
> +  llvm::Expected
> +  mergeIfOrderIndependent(const Replacement &R) const;
> +
>ReplacementsImpl Replaces;
>  };
>
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=282577&r1=282576&r2=282577&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 28 06:02:16 2016
> @@ -134,14 +134,75 @@ void Replacement::setFromSourceRange(con
>  ReplacementText

Re: r282583 - Trying to buildbot failures caused by r282577.

2016-09-28 Thread Manuel Klimek via cfe-commits
On Wed, Sep 28, 2016 at 2:58 PM Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Wed Sep 28 07:49:14 2016
> New Revision: 282583
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282583&view=rev
> Log:
> Trying to buildbot failures caused by r282577.
>

A bit more explanation of what failed, and why this fixes it, would be nice
in the future :)


>
> Modified:
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=282583&r1=282582&r2=282583&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 28 07:49:14 2016
> @@ -287,8 +287,13 @@ llvm::Error Replacements::add(const Repl
>  // with them and replace them with the merged replacements.
>  auto MergeBegin = I;
>  auto MergeEnd = std::next(I);
> -while (I-- != Replaces.begin() && Overlap(R, *I))
> +while (I != Replaces.begin()) {
> +  --I;
> +  // If `I` doesn't overlap with `R`, don't merge it.
> +  if (!Overlap(R, *I))
> +break;
>MergeBegin = I;
> +}
>  Replacements OverlapReplaces(MergeBegin, MergeEnd);
>  llvm::Expected Merged =
>  OverlapReplaces.mergeIfOrderIndependent(R);
>
>
> ___
> 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] D24914: [clang-rename] Do not print out error message upon encountering multiple replacements in the same SourceLocation.

2016-09-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz abandoned this revision.
omtcyfz added a comment.

Abandoning this, because https://reviews.llvm.org/rL282577, which introduces 
replacement deduplication, eliminates this issue. Big thanks to Eric!


https://reviews.llvm.org/D24914



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


Re: r282583 - Trying to buildbot failures caused by r282577.

2016-09-28 Thread Eric Liu via cfe-commits
Decrementing "begin()" makes sanitizer sad. This fix makes sure "I" is
never decremented when it is the "begin".

On Wed, Sep 28, 2016 at 3:10 PM Manuel Klimek  wrote:

> On Wed, Sep 28, 2016 at 2:58 PM Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Wed Sep 28 07:49:14 2016
> New Revision: 282583
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282583&view=rev
> Log:
> Trying to buildbot failures caused by r282577.
>
>
> A bit more explanation of what failed, and why this fixes it, would be
> nice in the future :)
>
>
>
> Modified:
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=282583&r1=282582&r2=282583&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Wed Sep 28 07:49:14 2016
> @@ -287,8 +287,13 @@ llvm::Error Replacements::add(const Repl
>  // with them and replace them with the merged replacements.
>  auto MergeBegin = I;
>  auto MergeEnd = std::next(I);
> -while (I-- != Replaces.begin() && Overlap(R, *I))
> +while (I != Replaces.begin()) {
> +  --I;
> +  // If `I` doesn't overlap with `R`, don't merge it.
> +  if (!Overlap(R, *I))
> +break;
>MergeBegin = I;
> +}
>  Replacements OverlapReplaces(MergeBegin, MergeEnd);
>  llvm::Expected Merged =
>  OverlapReplaces.mergeIfOrderIndependent(R);
>
>
> ___
> 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] D24682: [PR30341] Alias must point to a definition

2016-09-28 Thread Sebastian Pop via cfe-commits
sebpop added inline comments.


Comment at: clang/lib/CodeGen/CGCXX.cpp:140-142
@@ +139,5 @@
+  // FIXME: An extern template instantiation will create functions with
+  // linkage "AvailableExternally". In libc++, some classes also define
+  // members with attribute "AlwaysInline" and expect no reference to
+  // be generated. It is desirable to reenable this optimisation after
+  // corresponding LLVM changes.

rsmith wrote:
> It's not clear what this comment about `AlwaysInline` is referring to, since 
> the code does not mention that.
I think we should just remove all the FIXME note: Aditya has just moved this 
comment from below... to here.


Comment at: clang/lib/CodeGen/CGCXX.cpp:162
@@ -161,3 @@
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define

... from here ...


Comment at: clang/lib/CodeGen/CGCXX.cpp:170
@@ -159,9 +169,3 @@
   if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  !TargetDecl.getDecl()->hasAttr()) {
 addReplacement(MangledName, Aliasee);

rsmith wrote:
> Did you mean to change the behavior here? For non-`available_externally` 
> functions, we never used to care whether they're `always_inline`. Why do we 
> care now?
I think this change does not modify the current behavior: the check has been 
moved up and we early return in that case.


https://reviews.llvm.org/D24682



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


Re: [PATCH] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-09-28 Thread Eric Liu via cfe-commits
ioeric added a comment.

Ping


https://reviews.llvm.org/D24380



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


Re: [PATCH] D23662: [libclang] Control whether crash recovery is enabled/disabled using function argument.

2016-09-28 Thread will via cfe-commits
wrmsr added a comment.

I just lost a few days diagnosing what wound up being this :(

In https://reviews.llvm.org/D23662#519445, @john.brawn wrote:

> Surely the fix then is to make sure CrashRecoveryContext::Disable //does// 
> reinstall the right signal handler?


The fix is to not do this by default as this breaks host environments. 
Libraries that don’t explicitly relate to signal handling have no business 
overriding signal handlers.

> Why not? Also I notice that using environment variables to control behaviour 
> is used in a bunch of places in libclang so you're introducing some 
> inconsistency here.


There are already API exports controlling crash recovery so the API is already 
inconsistent in addition to being broken by default. I understand env vars 
controlling environment related variability (dev vs prod) but not host-process 
and callsite related variability (cpython vs java).


Repository:
  rL LLVM

https://reviews.llvm.org/D23662



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


[PATCH] D25004: [x86][inline-asm][clang] accept 'v' constraint

2016-09-28 Thread coby via cfe-commits
coby created this revision.
coby added reviewers: echristo, delena.
coby added a subscriber: cfe-commits.
coby set the repository for this revision to rL LLVM.
Herald added a subscriber: mehdi_amini.

1. 'v' constraint for (x86) non-avx arch imitates the already implemented 'x' 
constraint, i.e. allows XMM{0-15} & YMM{0-15} depending on the apparent arch & 
mode (32/64).
2. for the avx512 arch it allows [X,Y,Z]MM{0-31} (mode dependent)

This patch applies the needed changes to clang
LLVM patch:

Repository:
  rL LLVM

https://reviews.llvm.org/D25004

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86-inline-asm-v-constraint.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3949,6 +3949,7 @@
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -3989,6 +3990,7 @@
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.
Index: test/CodeGen/x86-inline-asm-v-constraint.c
===
--- test/CodeGen/x86-inline-asm-v-constraint.c
+++ test/CodeGen/x86-inline-asm-v-constraint.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes 
AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", 
"=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
+__m256 testYMM(__m256 _ymm0) {
+#ifdef AVX
+  __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
+#endif
+  return _ymm0;
+}
+
+// AVX512: call <16 x float> asm "vpternlogd $$0, $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"(<16 x float> %0, <16 x float> %1)
+__m512 testZMM(__m512 _zmm0, __m512 _zmm1) {
+#ifdef AVX512
+  __asm__("vpternlogd $0, %1, %2, %0" :"=v"(_zmm0) : "v"(_zmm1), "v"(_zmm0));
+#endif
+  return _zmm0;
+}


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3949,6 +3949,7 @@
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -3989,6 +3990,7 @@
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.
Index: test/CodeGen/x86-inline-asm-v-constraint.c
===
--- test/CodeGen/x86-inline-asm-v-constraint.c
+++ test/CodeGen/x86-inline-asm-v-constraint.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", "=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", "=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
+__m256 testYMM(__m256 _ymm0) {
+#i

Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Bjorn Pettersson via cfe-commits
bjope added a subscriber: bjope.
bjope added a comment.

This test/CodeGen/builtins-ppc-p9vector.c test will fail together with this 
upcoming LLVM patch https://reviews.llvm.org/D24955

Problem is that lots of your

  add i64 {{.*}}, 64

checks will fails since the improved analysis will find out that the add has 
the "nsw" "nuw" properties.

I'm not so familiar with the regexps used by FileCheck, but somehow we need to 
(also) allow

  add nsw nuw i64 {{.*}}, 64

in the checks to make it more future proof.


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.

2016-09-28 Thread Matan via cfe-commits
mharoush created this revision.
mharoush added reviewers: rnk, myatsina.
mharoush added a subscriber: cfe-commits.
mharoush set the repository for this revision to rL LLVM.

This patch is a compatibility fix for clang, matching GCC support for charter 
escape when using extended in-line assembly (i.e, "%{" ,"%}" --> "{" ,"}" ).
It is meant to enable support for advanced features such as AVX512 
conditional\masked vector instructions/broadcast assembly syntax.

Note: This related test is dependent on the review on 
https://reviews.llvm.org/D25011

Repository:
  rL LLVM

https://reviews.llvm.org/D25012

Files:
  lib/AST/Stmt.cpp
  test/CodeGen/x86_inlineasm_curly_bracket_escape.c

Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -533,15 +533,17 @@
   DiagOffs = CurPtr-StrStart-1;
   return diag::err_asm_invalid_escape;
 }
-
+// Handle escaped char and continue looping over the asm string.
 char EscapedChar = *CurPtr++;
-if (EscapedChar == '%') {  // %% -> %
-  // Escaped percentage sign.
-  CurStringPiece += '%';
+switch (EscapedChar) {
+default:
+  break;
+case '%': // %% -> %
+case '{': // %{ -> {
+case '}': // %} -> }
+  CurStringPiece += EscapedChar;
   continue;
-}
-
-if (EscapedChar == '=') {  // %= -> Generate an unique ID.
+case '=': // %= -> Generate a unique ID.
   CurStringPiece += "${:uid}";
   continue;
 }
Index: test/CodeGen/x86_inlineasm_curly_bracket_escape.c
===
--- test/CodeGen/x86_inlineasm_curly_bracket_escape.c
+++ test/CodeGen/x86_inlineasm_curly_bracket_escape.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -o - -Wall -Werror | 
FileCheck %s
+// This test checks validity of inline assembly using curly brackets syntax
+// for extended inline asm.
+
+void test_curly_brackets(){
+//CHECK: #APP
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1} {z}
+//CHECK: #NO_APP
+  asm ("vpaddb\t %%xmm1,%%xmm0,%%xmm1 %{%%k1%}%{z%}\t":::);
+}


Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -533,15 +533,17 @@
   DiagOffs = CurPtr-StrStart-1;
   return diag::err_asm_invalid_escape;
 }
-
+// Handle escaped char and continue looping over the asm string.
 char EscapedChar = *CurPtr++;
-if (EscapedChar == '%') {  // %% -> %
-  // Escaped percentage sign.
-  CurStringPiece += '%';
+switch (EscapedChar) {
+default:
+  break;
+case '%': // %% -> %
+case '{': // %{ -> {
+case '}': // %} -> }
+  CurStringPiece += EscapedChar;
   continue;
-}
-
-if (EscapedChar == '=') {  // %= -> Generate an unique ID.
+case '=': // %= -> Generate a unique ID.
   CurStringPiece += "${:uid}";
   continue;
 }
Index: test/CodeGen/x86_inlineasm_curly_bracket_escape.c
===
--- test/CodeGen/x86_inlineasm_curly_bracket_escape.c
+++ test/CodeGen/x86_inlineasm_curly_bracket_escape.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -o - -Wall -Werror | FileCheck %s
+// This test checks validity of inline assembly using curly brackets syntax
+// for extended inline asm.
+
+void test_curly_brackets(){
+//CHECK: #APP
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1} {z}
+//CHECK: #NO_APP
+  asm ("vpaddb\t %%xmm1,%%xmm0,%%xmm1 %{%%k1%}%{z%}\t":::);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25011: [x86][inline-asm] Introducing (AVX512) k0-k7 registers for inline-asm usage

2016-09-28 Thread Matan via cfe-commits
mharoush created this revision.
mharoush added reviewers: delena, myatsina, rnk, echristo.
mharoush added a subscriber: cfe-commits.
mharoush set the repository for this revision to rL LLVM.
Herald added a subscriber: mehdi_amini.

This patch enables usage of k registers in inline assembly syntax.

Repository:
  rL LLVM

https://reviews.llvm.org/D25011

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avx512-inline-asm-kregisters-basics.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2346,6 +2346,7 @@
   "zmm8", "zmm9", "zmm10", "zmm11", "zmm12", "zmm13", "zmm14", "zmm15",
   "zmm16", "zmm17", "zmm18", "zmm19", "zmm20", "zmm21", "zmm22", "zmm23",
   "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31",
+  "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7",
 };
 
 const TargetInfo::AddlRegName AddlRegNames[] = {
Index: test/CodeGen/avx512-inline-asm-kregisters-basics.c
===
--- test/CodeGen/avx512-inline-asm-kregisters-basics.c
+++ test/CodeGen/avx512-inline-asm-kregisters-basics.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -o - -Wall -Werror | 
FileCheck %s
+// This test checks basic inline assembly recognition of k0-k7 registers for 
avx512.
+
+void test_basic_inline_asm_with_k_regs() {
+//CHECK: #APP
+//CHECK: kandw %k1, %k2, %k3
+//CHECK: #NO_APP
+asm("kandw %k1, %k2, %k3\t");
+//CHECK: #APP
+//CHECK: kandw %k4, %k5, %k6
+//CHECK: #NO_APP
+asm("kandw %k4, %k5, %k6\t");
+//CHECK: #APP
+//CHECK: kandw %k7, %k0, %k1
+//CHECK: #NO_APP
+asm("kandw %k7, %k0, %k1\t");
+}
\ No newline at end of file


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2346,6 +2346,7 @@
   "zmm8", "zmm9", "zmm10", "zmm11", "zmm12", "zmm13", "zmm14", "zmm15",
   "zmm16", "zmm17", "zmm18", "zmm19", "zmm20", "zmm21", "zmm22", "zmm23",
   "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31",
+  "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7",
 };
 
 const TargetInfo::AddlRegName AddlRegNames[] = {
Index: test/CodeGen/avx512-inline-asm-kregisters-basics.c
===
--- test/CodeGen/avx512-inline-asm-kregisters-basics.c
+++ test/CodeGen/avx512-inline-asm-kregisters-basics.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -S -o - -Wall -Werror | FileCheck %s
+// This test checks basic inline assembly recognition of k0-k7 registers for avx512.
+
+void test_basic_inline_asm_with_k_regs() {
+//CHECK: #APP
+//CHECK: kandw %k1, %k2, %k3
+//CHECK: #NO_APP
+asm("kandw %k1, %k2, %k3\t");
+//CHECK: #APP
+//CHECK: kandw %k4, %k5, %k6
+//CHECK: #NO_APP
+asm("kandw %k4, %k5, %k6\t");
+//CHECK: #APP
+//CHECK: kandw %k7, %k0, %k1
+//CHECK: #NO_APP
+asm("kandw %k7, %k0, %k1\t");
+}
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Bjorn Pettersson via cfe-commits
bjope added a comment.

In https://reviews.llvm.org/D24397#555121, @nemanjai wrote:

> In https://reviews.llvm.org/D24397#555057, @bjope wrote:
>
> > This test/CodeGen/builtins-ppc-p9vector.c test will fail together with this 
> > upcoming LLVM patch https://reviews.llvm.org/D24955
> >
> > Problem is that lots of your
> >
> >   add i64 {{.*}}, 64
> >
> > checks will fails since the improved analysis will find out that the add 
> > has the "nsw" "nuw" properties.
> >
> > I'm not so familiar with the regexps used by FileCheck, but somehow we need 
> > to (also) allow
> >
> >   add nsw nuw i64 {{.*}}, 64
> >
> > in the checks to make it more future proof.
>
>
> I can change the patterns that check for the add instructions to the 
> following:
>  // CHECK: add {{[nsuw ]*}}i64 {{.*}}, 64
>
> That will pass with:
>  add nsw i64
>  add nuw i64
>  add nsw nuw i64
>  ...
>
> Basically if all that is found between the "add" and "i64" is any combination 
> of the letters "nsuw" and space, it will pass. As far as I'm concerned, 
> ensuring that the strings there are well formed is irrelevant - all I'm 
> testing is that an add instruction is emitted that adds the constant 64.
>
> I can make the change and check it in if you're in agreement.


Solution sounds good to me!

And it would be very helpful if you do that. https://reviews.llvm.org/D24955 
will be my first patch contributing to llvm :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


[libunwind] r282589 - Also use the proper register numbers on CloudABI.

2016-09-28 Thread Ed Schouten via cfe-commits
Author: ed
Date: Wed Sep 28 08:51:23 2016
New Revision: 282589

URL: http://llvm.org/viewvc/llvm-project?rev=282589&view=rev
Log:
Also use the proper register numbers on CloudABI.

Without this change applied, unw_step() fails to obtain the next frame
properly.

Modified:
libunwind/trunk/include/libunwind.h

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=282589&r1=282588&r2=282589&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed Sep 28 08:51:23 2016
@@ -151,7 +151,7 @@ enum {
   UNW_X86_ECX = 1,
   UNW_X86_EDX = 2,
   UNW_X86_EBX = 3,
-#ifdef __FreeBSD__
+#if defined(__CloudABI__) || defined(__FreeBSD__)
   UNW_X86_ESP = 4,
   UNW_X86_EBP = 5,
 #else


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


[PATCH] D25019: [clang-tidy] Make add_new_check.py Python 3 compatible

2016-09-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: alexfh, ioeric, bkramer.
omtcyfz added subscribers: cfe-commits, aaron.ballman.

`add_new_check.py` didn't support Python 3.X for some reason, even though it 
used `print` in Python 3.X-compatible way. With just a few tweaks 
`add_new_check.py` supports both Python 2.7.X and Python 3.X.

Tested: Python 2.7.6, Python 2.7.12, Python 3.5.2.

https://reviews.llvm.org/D25019

Files:
  clang-tidy/add_new_check.py

Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -13,12 +13,14 @@
 import re
 import sys
 
+from six.moves import filter
+
 
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new entry
 # and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
-  with open(filename, 'r') as f:
+  with open(filename, 'rb') as f:
 lines = f.readlines()
 
   cpp_file = check_name_camel + '.cpp'
@@ -52,12 +54,12 @@
   with open(filename, 'wb') as f:
 header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() + '_'
 + check_name.upper().replace('-', '_') + '_H')
-f.write('//===--- ')
-f.write(os.path.basename(filename))
-f.write(' - clang-tidy')
-f.write('-' * max(0, 43 - len(os.path.basename(filename
-f.write('*- C++ -*-===//')
-f.write("""
+f.write(b'//===--- ')
+f.write((os.path.basename(filename)).encode())
+f.write(b' - clang-tidy')
+f.write(b'-' * max(0, 43 - len(os.path.basename(filename
+f.write(b'*- C++ -*-===//')
+f.write(b"""
 //
 // The LLVM Compiler Infrastructure
 //
@@ -92,23 +94,23 @@
 } // namespace clang
 
 #endif // %(header_guard)s
-""" % {'header_guard': header_guard,
-   'check_name': check_name_camel,
-   'check_name_dashes': check_name_dashes,
-   'module': module})
+""" % {b'header_guard': header_guard.encode(),
+   b'check_name': check_name_camel.encode(),
+   b'check_name_dashes': check_name_dashes.encode(),
+   b'module': module.encode()})
 
 
 # Adds the implementation of the new check.
 def write_implementation(module_path, module, check_name_camel):
   filename = os.path.join(module_path, check_name_camel) + '.cpp'
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
-f.write('//===--- ')
-f.write(os.path.basename(filename))
-f.write(' - clang-tidy')
-f.write('-' * max(0, 52 - len(os.path.basename(filename
-f.write('-===//')
-f.write("""
+f.write(b'//===--- ')
+f.write((os.path.basename(filename)).encode())
+f.write(b' - clang-tidy')
+f.write(b'-' * max(0, 52 - len(os.path.basename(filename
+f.write(b'-===//')
+f.write(b"""
 //
 // The LLVM Compiler Infrastructure
 //
@@ -145,16 +147,16 @@
 } // namespace %(module)s
 } // namespace tidy
 } // namespace clang
-""" % {'check_name': check_name_camel,
-   'module': module})
+""" % {b'check_name': check_name_camel.encode(),
+   b'module': module.encode()})
 
 
 # Modifies the module to include the new check.
 def adapt_module(module_path, module, check_name, check_name_camel):
   modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
- os.listdir(module_path))[0]
-  filename = os.path.join(module_path, modulecpp)
-  with open(filename, 'r') as f:
+ os.listdir(module_path))
+  filename = os.path.join(module_path, next(modulecpp))
+  with open(filename, 'rb') as f:
 lines = f.readlines()
 
   print('Updating %s...' % filename)
@@ -196,7 +198,7 @@
check_name_dashes + '.cpp'))
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
-f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
+f.write(b"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();
@@ -210,22 +212,22 @@
 
 // FIXME: Add something that doesn't trigger the check here.
 void awesome_f2();
-""" % {'check_name_dashes': check_name_dashes})
+""" % {b'check_name_dashes': check_name_dashes.encode()})
 
 
 # Recreates the list of checks in the docs/clang-tidy/checks directory.
 def update_checks_list(clang_tidy_path):
   docs_dir = os.path.join(clang_tidy_path, '../docs/clang-tidy/checks')
   filename = os.path.normpath(os.path.join(docs_dir, 'list.rst'))
-  with open(filename, 'r') as f:
+  with open(filename, 'rb') as f:
 lines = f.readlines()
   doc_files = filter(lambda s: s.endswith('.rst') and s != 'list.rst',
  os.listdir(docs_dir))
-  doc_files.sort()
+  doc_files = sorted(doc_files)
 
   def format_link(doc_file):
 check_name = doc_file.replace('.rst', '')
-with open(os.path.join(docs_dir, doc_file), 'r') as doc

Re: [PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-28 Thread Aditya Kumar via cfe-commits
hiraditya updated this revision to Diff 72827.
hiraditya added a comment.

Addressed Richard's comments.


https://reviews.llvm.org/D24682

Files:
  clang/lib/CodeGen/CGCXX.cpp
  clang/test/CodeGenCXX/alias-available-externally.cpp

Index: clang/test/CodeGenCXX/alias-available-externally.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/alias-available-externally.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+// Clang should not generate alias to available_externally definitions.
+// Check that the destructor of Foo is defined.
+// CHECK: define linkonce_odr void @_ZN3FooD2Ev
+template 
+struct String {
+  String() {}
+  ~String();
+};
+
+template 
+inline __attribute__((visibility("hidden"), always_inline))
+String::~String() {}
+
+extern template struct String;
+
+struct Foo : public String { Foo() { String s; } };
+
+Foo f;
Index: clang/lib/CodeGen/CGCXX.cpp
===
--- clang/lib/CodeGen/CGCXX.cpp
+++ clang/lib/CodeGen/CGCXX.cpp
@@ -134,6 +134,11 @@
   llvm::GlobalValue::LinkageTypes TargetLinkage =
   getFunctionLinkage(TargetDecl);
 
+  // available_externally definitions aren't real definitions, so we cannot
+  // create an alias to one.
+  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)
+return true;
+
   // Check if we have it already.
   StringRef MangledName = getMangledName(AliasDecl);
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
@@ -157,13 +162,7 @@
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
   if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  !TargetDecl.getDecl()->hasAttr()) {
 addReplacement(MangledName, Aliasee);
 return false;
   }


Index: clang/test/CodeGenCXX/alias-available-externally.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/alias-available-externally.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+// Clang should not generate alias to available_externally definitions.
+// Check that the destructor of Foo is defined.
+// CHECK: define linkonce_odr void @_ZN3FooD2Ev
+template 
+struct String {
+  String() {}
+  ~String();
+};
+
+template 
+inline __attribute__((visibility("hidden"), always_inline))
+String::~String() {}
+
+extern template struct String;
+
+struct Foo : public String { Foo() { String s; } };
+
+Foo f;
Index: clang/lib/CodeGen/CGCXX.cpp
===
--- clang/lib/CodeGen/CGCXX.cpp
+++ clang/lib/CodeGen/CGCXX.cpp
@@ -134,6 +134,11 @@
   llvm::GlobalValue::LinkageTypes TargetLinkage =
   getFunctionLinkage(TargetDecl);
 
+  // available_externally definitions aren't real definitions, so we cannot
+  // create an alias to one.
+  if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage)
+return true;
+
   // Check if we have it already.
   StringRef MangledName = getMangledName(AliasDecl);
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
@@ -157,13 +162,7 @@
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
   if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  !TargetDecl.getDecl()->hasAttr()) {
 addReplacement(MangledName, Aliasee);
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-28 Thread Aditya Kumar via cfe-commits
hiraditya marked 3 inline comments as done.
hiraditya added a comment.

https://reviews.llvm.org/D24682



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


[PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz created this revision.
omtcyfz added reviewers: alexfh, aaron.ballman, ioeric.
omtcyfz added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz, nemanjai.

C++ Core Guidelines Section "Expressions and statements" Suggestion 10 proposes 
to split declarations with multiple names into multiple single declarations. 
See the following example.

Example, bad.

```
std::vector velocities(10, 0), numbers(other_numbers),
  inputs(input.begin(), input.end());
```

Example, good.

```
std::vector velocities(10, 0);
std::vector numbers(other_numbers);
std::vector inputs(input.begin(), input.end());
```

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#a-nameres-name-oneaes10-declare-one-name-only-per-declaration

https://reviews.llvm.org/D25024

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp

Index: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-one-name-per-declaration %t
+
+int main() {
+  {
+int x = 42;
+  }
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names per declaration [cppcoreguidelines-one-name-per-declaration]
+  }
+  {
+int x = 42, y = 43, z = 44;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names per declaration
+  }
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -19,6 +19,7 @@
cert-flp30-c
cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-one-name-per-declaration
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - cppcoreguidelines-one-name-per-declaration
+
+cppcoreguidelines-one-name-per-declaration
+==
+
+Checks for declarations with multiple names. C++ Core Guidelines suggests to
+split such declarations into multiple declarations each containing one name.
+
+This would improve readability and prevents potential bugs caused by inattention
+and C/C++ syntax specifics.
+
+Example, bad.
+
+.. code-block:: c++
+
+  std::vector velocities(10, 0), numbers(other_numbers),
+   inputs(input.begin(), input.end());
+
+Example, good.
+
+.. code-block:: c++
+
+  std::vector velocities(10, 0);
+  std::vector numbers(other_numbers);
+  std::vector inputs(input.begin(), input.end());
+
+This rule is part of the "Expressions and statements" profile of the C++ Core
+Guidelines, see
+http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#a-nameres-name-oneaes10-declare-one-name-only-per-declaration
Index: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- OneNamePerDeclarationCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ONE_NAME_PER_DECLARATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ONE_NAME_PER_DECLARATION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// This check warns about multiple names in one declaration.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.html
+class OneNamePerDeclarationCheck : public ClangTidyCheck {
+public:
+  OneNamePerDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void c

[PATCH] D25027: Add getCommonRoot Interface in CompilationDatabase.

2016-09-28 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added reviewers: klimek, bkramer.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Provide a way allowing clang clients to get the common build directory
from the compilation database.

https://reviews.llvm.org/D25027

Files:
  include/clang/Tooling/CompilationDatabase.h
  include/clang/Tooling/JSONCompilationDatabase.h
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/JSONCompilationDatabase.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -95,6 +95,34 @@
   << ErrorMessage;
 }
 
+TEST(JSONCompilationDatabase, GetCommonRoot) {
+  std::string ErrorMessage;
+  std::string JSONDatabase = "[{\"directory\":\"//dir/build/\","
+ "\"command\":\"command\","
+ "\"file\":\"file1\"},"
+ " {\"directory\":\"//dir/build/\","
+ "\"command\":\"command\","
+ "\"file\":\"file2\"}]";
+
+  std::unique_ptr Database(
+  JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage,
+  JSONCommandLineSyntax::Gnu));
+  auto CommonRoot = Database->getCommonRoot();
+  ASSERT_TRUE(CommonRoot.hasValue());
+  EXPECT_EQ("//dir/build/", *CommonRoot);
+
+  JSONDatabase = "[{\"directory\":\"//dir/build/\","
+ "\"command\":\"command\","
+ "\"file\":\"file1\"},"
+ " {\"directory\":\"//dir/build2/\","
+ "\"command\":\"command\","
+ "\"file\":\"file2\"}]";
+  Database = JSONCompilationDatabase::loadFromBuffer(
+  JSONDatabase, ErrorMessage, JSONCommandLineSyntax::Gnu);
+  CommonRoot = Database->getCommonRoot();
+  EXPECT_FALSE(CommonRoot.hasValue());
+}
+
 TEST(JSONCompilationDatabase, GetAllCompileCommands) {
   std::string ErrorMessage;
   EXPECT_EQ(
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -366,6 +366,20 @@
 AllCommands.push_back(Cmd);
 MatchTrie.insert(NativeFilePath);
   }
+  if (!AllCommands.empty()) {
+SmallString<128> DirectoryStorage;
+SmallString<128> NextDirectoryStorage;
+llvm::StringRef Directory =
+std::get<0>(AllCommands[0])->getValue(DirectoryStorage);
+auto It = std::find_if(
+AllCommands.begin() + 1, AllCommands.end(),
+[&](JSONCompilationDatabase::CompileCommandRef &Command) {
+  return Directory !=
+ std::get<0>(Command)->getValue(NextDirectoryStorage);
+});
+if (It == AllCommands.end())
+  CommonRoot = Directory.str();
+  }
   return true;
 }
 
Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -322,6 +322,10 @@
   return std::vector();
 }
 
+llvm::Optional FixedCompilationDatabase::getCommonRoot() const {
+  return llvm::Optional("");
+}
+
 namespace clang {
 namespace tooling {
 
Index: lib/Tooling/CommonOptionsParser.cpp
===
--- lib/Tooling/CommonOptionsParser.cpp
+++ lib/Tooling/CommonOptionsParser.cpp
@@ -78,6 +78,10 @@
 return adjustCommands(Compilations->getAllCompileCommands());
   }
 
+  llvm::Optional getCommonRoot() const override {
+return Compilations->getCommonRoot();
+  }
+
 private:
   std::unique_ptr Compilations;
   std::vector Adjusters;
Index: include/clang/Tooling/JSONCompilationDatabase.h
===
--- include/clang/Tooling/JSONCompilationDatabase.h
+++ include/clang/Tooling/JSONCompilationDatabase.h
@@ -90,12 +90,18 @@
   /// database.
   std::vector getAllCompileCommands() const override;
 
+  /// \brief Returns the common build directory for all translation units in the
+  /// JSON compilation database.
+  llvm::Optional getCommonRoot() const override {
+return CommonRoot;
+  }
+
 private:
   /// \brief Constructs a JSON compilation database on a memory buffer.
   JSONCompilationDatabase(std::unique_ptr Database,
   JSONCommandLineSyntax Syntax)
   : Database(std::move(Database)), Syntax(Syntax),
-YAMLStream(this->Database->getBuffer(), SM) {}
+YAMLStream(this->Database->getBuffer(), SM), CommonRoot(llvm::None) {}
 
   /// \brief Parses the database file and creates the index.
   ///
@@ -130,6 +136,8 @@
   JSONCommandLineSyntax Syntax;
   llvm::SourceMgr SM;
   llvm::yaml::Stream YAMLStream;
+
+  llvm::Optional CommonRoot;
 };
 
 } /

Re: [PATCH] D18172: [CUDA][OpenMP] Add a generic offload action builder

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

A nice abstraction and cleanup. LGTM.



Comment at: lib/Driver/Driver.cpp:1625
@@ +1624,3 @@
+  // architecture. If we are in host-only mode we return 'success' so that
+  // the host use the CUDA offload kind.
+  if (auto *IA = dyn_cast(HostAction)) {

use -> uses


https://reviews.llvm.org/D18172



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


[libunwind] r282599 - libunwind: Add OpenBSD case for _Unwind_Ptr typedef

2016-09-28 Thread Ed Maste via cfe-commits
Author: emaste
Date: Wed Sep 28 10:37:21 2016
New Revision: 282599

URL: http://llvm.org/viewvc/llvm-project?rev=282599&view=rev
Log:
libunwind: Add OpenBSD case for _Unwind_Ptr typedef

Patch by Mark Kettenis

Modified:
libunwind/trunk/src/AddressSpace.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=282599&r1=282598&r2=282599&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed Sep 28 10:37:21 2016
@@ -35,7 +35,7 @@ namespace libunwind {
 #include "Registers.hpp"
 
 #if _LIBUNWIND_ARM_EHABI
-#if defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 
 typedef void *_Unwind_Ptr;
 


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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Sanjay Patel via cfe-commits
spatel added a subscriber: spatel.
spatel added a comment.

Having a clang regression/unit test that depends on optimizer behavior is 
generally viewed as wrong. Can the tests be split into front-end (clang) tests 
and separate tests for the IR optimizer? Both x86 and AArch64 have done 
something like that in the last few months for testing of builtins/intrinsics.


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


Re: [PATCH] D24601: XFAIL Driver/darwin-stdlib.cpp if CLANG_DEFAULT_CXX_STDLIB is set

2016-09-28 Thread Vedant Kumar via cfe-commits
vsk accepted this revision.
vsk added a reviewer: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D24601



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


Re: [PATCH] D23662: [libclang] Control whether crash recovery is enabled/disabled using function argument.

2016-09-28 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

> I could disable crash recovery by calling clang_toggleCrashRecovery(false) 
> after clang_createIndex has been called but this doesn't work because the 
> right JVM handler isn't reinstalled


Could you explain more why this doesn't work ? Is it a bug with the crash 
handling logic or something else ?

If we are going to have a 'clang_createIndex2' function to be able to introduce 
a new flag, it should be made to accept OR'ed enums for flags, so we can add 
more flags in the future and not get in a similar situation and have to add 
'clang_createIndex3'..


Repository:
  rL LLVM

https://reviews.llvm.org/D23662



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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

In https://reviews.llvm.org/D24397#555470, @spatel wrote:

> Having a clang regression/unit test that depends on optimizer behavior is 
> generally viewed as wrong. Can the tests be split into front-end (clang) 
> tests and separate tests for the IR optimizer? Both x86 and AArch64 have done 
> something like that in the last few months for testing of builtins/intrinsics.


Yeah, that sounds reasonable. I'll remove the -O2 from the test case and remove 
the checks for the select instructions. That's really the only major 
difference. So am I to understand the nsw/nuw flags will not be added without 
-O2 and the aforementioned changes will suffice?


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Sanjay Patel via cfe-commits
spatel added a comment.

In https://reviews.llvm.org/D24397#52, @nemanjai wrote:

> In https://reviews.llvm.org/D24397#555470, @spatel wrote:
>
> > Having a clang regression/unit test that depends on optimizer behavior is 
> > generally viewed as wrong. Can the tests be split into front-end (clang) 
> > tests and separate tests for the IR optimizer? Both x86 and AArch64 have 
> > done something like that in the last few months for testing of 
> > builtins/intrinsics.
>
>
> Yeah, that sounds reasonable. I'll remove the -O2 from the test case and 
> remove the checks for the select instructions. That's really the only major 
> difference. So am I to understand the nsw/nuw flags will not be added without 
> -O2 and the aforementioned changes will suffice?


Changing to -O0 or using -disable-llvm-optzns should keep the clang tests from 
breaking due to underlying changes in the IR optimizer. That may lead to a lot 
of bloat though. In 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160307/152324.html , 
it was viewed as ok, if not ideal, to pipe the clang IR output using "opt -S 
-mem2reg".

Note that clang itself uses APIs like IRBuilder::CreateNUWSub(), so I think 
it's possible to see no-wrap IR even without the IR optimizer kicking in (but 
probably isn't a concern in this case?).


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Sanjay Patel via cfe-commits
spatel added a comment.

Should also mention:
https://reviews.llvm.org/D17999
has scripts attached that could make this kind of test generation a lot easier. 
:)


Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-28 Thread Nemanja Ivanovic via cfe-commits
Well, I don't know much about what Clang will actually do here, but I'll
follow your advice and add -O0 and pipe to opt -S -mem2reg. I'll also add a
test case in LLVM (test/CodeGen/PowerPC) that will test that after opt and
llc, we generate the desired code for these builtins.

Thanks Sanjay and Bjorn.

On Wed, Sep 28, 2016 at 6:53 PM, Sanjay Patel 
wrote:

> spatel added a comment.
>
> In https://reviews.llvm.org/D24397#52, @nemanjai wrote:
>
> > In https://reviews.llvm.org/D24397#555470, @spatel wrote:
> >
> > > Having a clang regression/unit test that depends on optimizer behavior
> is generally viewed as wrong. Can the tests be split into front-end (clang)
> tests and separate tests for the IR optimizer? Both x86 and AArch64 have
> done something like that in the last few months for testing of
> builtins/intrinsics.
> >
> >
> > Yeah, that sounds reasonable. I'll remove the -O2 from the test case and
> remove the checks for the select instructions. That's really the only major
> difference. So am I to understand the nsw/nuw flags will not be added
> without -O2 and the aforementioned changes will suffice?
>
>
> Changing to -O0 or using -disable-llvm-optzns should keep the clang tests
> from breaking due to underlying changes in the IR optimizer. That may lead
> to a lot of bloat though. In http://lists.llvm.org/
> pipermail/cfe-commits/Week-of-Mon-20160307/152324.html , it was viewed as
> ok, if not ideal, to pipe the clang IR output using "opt -S -mem2reg".
>
> Note that clang itself uses APIs like IRBuilder::CreateNUWSub(), so I
> think it's possible to see no-wrap IR even without the IR optimizer kicking
> in (but probably isn't a concern in this case?).
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D24397
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-28 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


https://reviews.llvm.org/D25024



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


Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-28 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/copypaste/suspicious-clones.cpp:61
@@ -60,3 +60,3 @@
   b /= a + b;
-  c -= b * a; // expected-warning{{suspicious code clone detected; did you 
mean to use 'a'?}}
+  c -= b * a; // expected-warning{{Suspicious code clone detected; did you 
mean to use 'a'?}}
   return c;

zaks.anna wrote:
> The error message seems too verbose and focused on the implementation rather 
> than user (ex: "suspicious code clone" and "suggestion is based").
> 
> Maybe we could say something like this:
> 
> - Did you mean to use 'a'?
> - Similar code snippet here
> 
> 
Better:

Did you mean to use 'a'?
Similar code snippet here uses 'b'

Did you mean to use 'a' instead of 'b'?
Similar code snippet here


https://reviews.llvm.org/D24916



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


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-28 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

I would like to close that particular bug report, and thus I would like to have 
the reproducer of that bug as part of the test case.
The PositivePartiallyInClassInitialized is also a good test, but I fail to see 
how it is proves that that particular bug is solved.

Are you okay with me committing this as it currently is?


https://reviews.llvm.org/D24848



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


r282609 - [CUDA] added __nvvm_atom_{sys|cta}_* builtins.

2016-09-28 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Sep 28 12:47:35 2016
New Revision: 282609

URL: http://llvm.org/viewvc/llvm-project?rev=282609&view=rev
Log:
[CUDA] added __nvvm_atom_{sys|cta}_* builtins.

These builtins are available on sm_60+ GPU only.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=282609&r1=282608&r2=282609&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Sep 28 12:47:35 2016
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // Special Registers
 
 BUILTIN(__nvvm_read_ptx_sreg_tid_x, "i", "nc")
@@ -452,18 +456,28 @@ BUILTIN(__builtin_ptx_get_image_channel_
 BUILTIN(__nvvm_atom_add_g_i, "iiD*1i", "n")
 BUILTIN(__nvvm_atom_add_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_add_gen_i, "iiD*i", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_add_gen_i, "iiD*i", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_add_gen_i, "iiD*i", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_l, "LiLiD*1Li", "n")
 BUILTIN(__nvvm_atom_add_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_add_gen_l, "LiLiD*Li", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_add_gen_l, "LiLiD*Li", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_add_gen_l, "LiLiD*Li", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_ll, "LLiLLiD*1LLi", "n")
 BUILTIN(__nvvm_atom_add_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_add_gen_ll, "LLiLLiD*LLi", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_add_gen_ll, "LLiLLiD*LLi", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_add_gen_ll, "LLiLLiD*LLi", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_f, "ffD*1f", "n")
 BUILTIN(__nvvm_atom_add_s_f, "ffD*3f", "n")
 BUILTIN(__nvvm_atom_add_gen_f, "ffD*f", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_add_gen_f, "ffD*f", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_add_gen_f, "ffD*f", "n", "satom")
 BUILTIN(__nvvm_atom_add_g_d, "ddD*1d", "n")
 BUILTIN(__nvvm_atom_add_s_d, "ddD*3d", "n")
 BUILTIN(__nvvm_atom_add_gen_d, "ddD*d", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_add_gen_d, "ddD*d", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_add_gen_d, "ddD*d", "n", "satom")
 
 BUILTIN(__nvvm_atom_sub_g_i, "iiD*1i", "n")
 BUILTIN(__nvvm_atom_sub_s_i, "iiD*3i", "n")
@@ -478,97 +492,155 @@ BUILTIN(__nvvm_atom_sub_gen_ll, "LLiLLiD
 BUILTIN(__nvvm_atom_xchg_g_i, "iiD*1i", "n")
 BUILTIN(__nvvm_atom_xchg_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_xchg_gen_i, "iiD*i", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_i, "iiD*i", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_i, "iiD*i", "n", "satom")
 BUILTIN(__nvvm_atom_xchg_g_l, "LiLiD*1Li", "n")
 BUILTIN(__nvvm_atom_xchg_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_xchg_gen_l, "LiLiD*Li", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_l, "LiLiD*Li", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_l, "LiLiD*Li", "n", "satom")
 BUILTIN(__nvvm_atom_xchg_g_ll, "LLiLLiD*1LLi", "n")
 BUILTIN(__nvvm_atom_xchg_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_xchg_gen_ll, "LLiLLiD*LLi", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_xchg_gen_ll, "LLiLLiD*LLi", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_xchg_gen_ll, "LLiLLiD*LLi", "n", "satom")
 
 BUILTIN(__nvvm_atom_max_g_i, "iiD*1i", "n")
 BUILTIN(__nvvm_atom_max_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_max_gen_i, "iiD*i", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_max_gen_i, "iiD*i", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_max_gen_i, "iiD*i", "n", "satom")
 BUILTIN(__nvvm_atom_max_g_ui, "UiUiD*1Ui", "n")
 BUILTIN(__nvvm_atom_max_s_ui, "UiUiD*3Ui", "n")
 BUILTIN(__nvvm_atom_max_gen_ui, "UiUiD*Ui", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ui, "UiUiD*Ui", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ui, "UiUiD*Ui", "n", "satom")
 BUILTIN(__nvvm_atom_max_g_l, "LiLiD*1Li", "n")
 BUILTIN(__nvvm_atom_max_s_l, "LiLiD*3Li", "n")
 BUILTIN(__nvvm_atom_max_gen_l, "LiLiD*Li", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_max_gen_l, "LiLiD*Li", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_max_gen_l, "LiLiD*Li", "n", "satom")
 BUILTIN(__nvvm_atom_max_g_ul, "ULiULiD*1ULi", "n")
 BUILTIN(__nvvm_atom_max_s_ul, "ULiULiD*3ULi", "n")
 BUILTIN(__nvvm_atom_max_gen_ul, "ULiULiD*ULi", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ul, "ULiULiD*ULi", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_sys_max_gen_ul, "ULiULiD*ULi", "n", "satom")
 BUILTIN(__nvvm_atom_max_g_ll, "LLiLLiD*1LLi", "n")
 BUILTIN(__nvvm_atom_max_s_ll, "LLiLLiD*3LLi", "n")
 BUILTIN(__nvvm_atom_max_gen_ll, "LLiLLiD*LLi", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_max_gen_ll, "

Re: [PATCH] D24682: [PR30341] Alias must point to a definition

2016-09-28 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: clang/lib/CodeGen/CGCXX.cpp:170
@@ -170,3 +169,3 @@
 
   // If we have a weak, non-discardable alias (weak, weak_odr), like an extern
   // template instantiation or a dllexported class, avoid forming it on COFF.

We can now only reach this code for the case where `TargetLinkage != 
llvm::GlobalValue::AvailableExternallyLinkage`. Substituting `true` for that 
expression here gives

  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
  (true || !TargetDecl.getDecl()->hasAttr())) {

which simplifies to

  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {

not 

  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
  !TargetDecl.getDecl()->hasAttr()) {

We used to enter this case for a function that is discardable if unused, not 
available externally, and always inline (that is, a normal inline+always_inline 
function). With this change, we don't do so any more.


https://reviews.llvm.org/D24682



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


r282610 - [CUDA] Added support for CUDA-8

2016-09-28 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Sep 28 12:47:40 2016
New Revision: 282610

URL: http://llvm.org/viewvc/llvm-project?rev=282610&view=rev
Log:
[CUDA] Added support for CUDA-8

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

Added:

cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc
  - copied, changed from r282609, 
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc

cfe/trunk/test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_50.10.bc
  - copied, changed from r282609, 
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
Removed:

cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=282610&r1=282609&r2=282610&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Sep 28 12:47:40 2016
@@ -1774,8 +1774,7 @@ void Generic_GCC::CudaInstallationDetect
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
-// FIXME: Uncomment this once we can compile the cuda 8 headers.
-// CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
+CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
@@ -1795,6 +1794,16 @@ void Generic_GCC::CudaInstallationDetect
   FS.exists(LibDevicePath)))
   continue;
 
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(InstallPath + "/version.txt");
+if (!VersionFile) {
+  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
+  // version.txt isn't present.
+  Version = CudaVersion::CUDA_70;
+} else {
+  Version = ParseCudaVersionFile((*VersionFile)->getBuffer());
+}
+
 std::error_code EC;
 for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
@@ -1807,24 +1816,20 @@ void Generic_GCC::CudaInstallationDetect
   StringRef GpuArch = FileName.slice(
   LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
   LibDeviceMap[GpuArch] = FilePath.str();
-  // Insert map entries for specifc devices with this compute capability.
-  // NVCC's choice of libdevice library version is rather peculiar:
-  // 
http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection
-  // TODO: this will need to be updated once CUDA-8 is released.
+  // Insert map entries for specifc devices with this compute
+  // capability. NVCC's choice of the libdevice library version is
+  // rather peculiar and depends on the CUDA version.
   if (GpuArch == "compute_20") {
 LibDeviceMap["sm_20"] = FilePath;
 LibDeviceMap["sm_21"] = FilePath;
 LibDeviceMap["sm_32"] = FilePath;
   } else if (GpuArch == "compute_30") {
 LibDeviceMap["sm_30"] = FilePath;
-// compute_30 is the fallback libdevice variant for sm_30+,
-// unless CUDA specifies different version for specific GPU
-// arch.
-LibDeviceMap["sm_50"] = FilePath;
-LibDeviceMap["sm_52"] = FilePath;
-LibDeviceMap["sm_53"] = FilePath;
-// sm_6? are currently all aliases for sm_53 in LLVM and
-// should use compute_30.
+if (Version < CudaVersion::CUDA_80) {
+  LibDeviceMap["sm_50"] = FilePath;
+  LibDeviceMap["sm_52"] = FilePath;
+  LibDeviceMap["sm_53"] = FilePath;
+}
 LibDeviceMap["sm_60"] = FilePath;
 LibDeviceMap["sm_61"] = FilePath;
 LibDeviceMap["sm_62"] = FilePath;
@@ -1832,21 +1837,14 @@ void Generic_GCC::CudaInstallationDetect
 LibDeviceMap["sm_35"] = FilePath;
 LibDeviceMap["sm_37"] = FilePath;
   } else if (GpuArch == "compute_50") {
-// NVCC does not use compute_50 libdevice at all at the moment.
-// The version that's shipped with CUDA-7.5 is a copy of compute_30.
+if (Version >= CudaVersion::CUDA_80) {
+  LibDeviceMap["sm_50"] = FilePath;
+  LibDeviceMap["sm_52"] = FilePath;
+  LibDeviceMap["sm_53"] = FilePath;
+}
   }
 }
 
-llvm::ErrorOr> VersionFile =
-FS.getBufferForFile(InstallPath + "/version.txt");
-if (!VersionFile) {
-  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
-  // version.txt isn't present.
-  Vers

Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-28 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/copypaste/macros.cpp:8
@@ -7,3 +7,3 @@
 
-int foo(int a) { // expected-warning{{Detected code clone.}}
+int foo(int a) { // expected-warning{{Clones of this code were detected}}
   a = a + 1;

- Duplicate code detected
- Similar code here


Comment at: test/Analysis/copypaste/suspicious-clones.cpp:61
@@ -60,3 +60,3 @@
   b /= a + b;
-  c -= b * a; // expected-warning{{suspicious code clone detected; did you 
mean to use 'a'?}}
+  c -= b * a; // expected-warning{{Suspicious code clone detected; did you 
mean to use 'a'?}}
   return c;

zaks.anna wrote:
> zaks.anna wrote:
> > The error message seems too verbose and focused on the implementation 
> > rather than user (ex: "suspicious code clone" and "suggestion is based").
> > 
> > Maybe we could say something like this:
> > 
> > - Did you mean to use 'a'?
> > - Similar code snippet here
> > 
> > 
> Better:
> 
> Did you mean to use 'a'?
> Similar code snippet here uses 'b'
> 
> Did you mean to use 'a' instead of 'b'?
> Similar code snippet here
Another refinement

Potential copy-paste error: did you mean to use 'a' instead of 'b'?
Similar code here


https://reviews.llvm.org/D24916



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


Re: [PATCH] D24944: [CUDA] Added __nvvm_atom_{sys|cta}_* builtins for sm_60 GPUs.

2016-09-28 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282609: [CUDA] added __nvvm_atom_{sys|cta}_* builtins. 
(authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D24944?vs=72584&id=72862#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24944

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins-nvptx.c

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -8124,7 +8124,13 @@
Ptr->getType()}),
 {Ptr, ConstantInt::get(Builder.getInt32Ty(), Align.getQuantity())});
   };
-
+  auto MakeScopedAtomic = [&](unsigned IntrinsicID) {
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(
+CGM.getIntrinsic(IntrinsicID, {Ptr->getType()->getPointerElementType(),
+   Ptr->getType()}),
+{Ptr, EmitScalarExpr(E->getArg(1))});
+  };
   switch (BuiltinID) {
   case NVPTX::BI__nvvm_atom_add_gen_i:
   case NVPTX::BI__nvvm_atom_add_gen_l:
@@ -8243,6 +8249,109 @@
   case NVPTX::BI__nvvm_ldg_d:
   case NVPTX::BI__nvvm_ldg_d2:
 return MakeLdg(Intrinsic::nvvm_ldg_global_f);
+
+  case NVPTX::BI__nvvm_atom_cta_add_gen_i:
+  case NVPTX::BI__nvvm_atom_cta_add_gen_l:
+  case NVPTX::BI__nvvm_atom_cta_add_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_add_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_add_gen_i:
+  case NVPTX::BI__nvvm_atom_sys_add_gen_l:
+  case NVPTX::BI__nvvm_atom_sys_add_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_add_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_cta_add_gen_f:
+  case NVPTX::BI__nvvm_atom_cta_add_gen_d:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_add_gen_f_cta);
+  case NVPTX::BI__nvvm_atom_sys_add_gen_f:
+  case NVPTX::BI__nvvm_atom_sys_add_gen_d:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_add_gen_f_sys);
+  case NVPTX::BI__nvvm_atom_cta_xchg_gen_i:
+  case NVPTX::BI__nvvm_atom_cta_xchg_gen_l:
+  case NVPTX::BI__nvvm_atom_cta_xchg_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_exch_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_xchg_gen_i:
+  case NVPTX::BI__nvvm_atom_sys_xchg_gen_l:
+  case NVPTX::BI__nvvm_atom_sys_xchg_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_exch_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_cta_max_gen_i:
+  case NVPTX::BI__nvvm_atom_cta_max_gen_ui:
+  case NVPTX::BI__nvvm_atom_cta_max_gen_l:
+  case NVPTX::BI__nvvm_atom_cta_max_gen_ul:
+  case NVPTX::BI__nvvm_atom_cta_max_gen_ll:
+  case NVPTX::BI__nvvm_atom_cta_max_gen_ull:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_max_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_max_gen_i:
+  case NVPTX::BI__nvvm_atom_sys_max_gen_ui:
+  case NVPTX::BI__nvvm_atom_sys_max_gen_l:
+  case NVPTX::BI__nvvm_atom_sys_max_gen_ul:
+  case NVPTX::BI__nvvm_atom_sys_max_gen_ll:
+  case NVPTX::BI__nvvm_atom_sys_max_gen_ull:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_max_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_cta_min_gen_i:
+  case NVPTX::BI__nvvm_atom_cta_min_gen_ui:
+  case NVPTX::BI__nvvm_atom_cta_min_gen_l:
+  case NVPTX::BI__nvvm_atom_cta_min_gen_ul:
+  case NVPTX::BI__nvvm_atom_cta_min_gen_ll:
+  case NVPTX::BI__nvvm_atom_cta_min_gen_ull:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_min_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_min_gen_i:
+  case NVPTX::BI__nvvm_atom_sys_min_gen_ui:
+  case NVPTX::BI__nvvm_atom_sys_min_gen_l:
+  case NVPTX::BI__nvvm_atom_sys_min_gen_ul:
+  case NVPTX::BI__nvvm_atom_sys_min_gen_ll:
+  case NVPTX::BI__nvvm_atom_sys_min_gen_ull:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_min_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_cta_inc_gen_ui:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_inc_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_cta_dec_gen_ui:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_dec_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_inc_gen_ui:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_inc_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_sys_dec_gen_ui:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_dec_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_cta_and_gen_i:
+  case NVPTX::BI__nvvm_atom_cta_and_gen_l:
+  case NVPTX::BI__nvvm_atom_cta_and_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_and_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_and_gen_i:
+  case NVPTX::BI__nvvm_atom_sys_and_gen_l:
+  case NVPTX::BI__nvvm_atom_sys_and_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_and_gen_i_sys);
+  case NVPTX::BI__nvvm_atom_cta_or_gen_i:
+  case NVPTX::BI__nvvm_atom_cta_or_gen_l:
+  case NVPTX::BI__nvvm_atom_cta_or_gen_ll:
+return MakeScopedAtomic(Intrinsic::nvvm_atomic_or_gen_i_cta);
+  case NVPTX::BI__nvvm_atom_sys_or_gen_i:
+  case NVPTX::BI__nvvm_a

Re: [PATCH] D24946: [CUDA] Added support for CUDA-8

2016-09-28 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282610: [CUDA] Added support for CUDA-8 (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D24946?vs=72707&id=72863#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24946

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
  
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
  
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc
  
cfe/trunk/test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_50.10.bc
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/test/Driver/cuda-detect.cu
===
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -22,13 +22,14 @@
 // RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20
-// sm_30, sm_5x and sm_6x map to compute_30
+// sm_30, sm_6x map to compute_30.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
 // RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
+// sm_5x is a special case. Maps to compute_30 for cuda-7.x only.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
-// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
+// RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \
@@ -44,6 +45,12 @@
 // RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \
 // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35
+// sm_5x -> compute_50 for CUDA-8.0 and newer.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix COMMON \
+// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE50
+
 
 // Verify that -nocudainc prevents adding include path to CUDA headers.
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
@@ -56,8 +63,8 @@
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC
 
 // Verify that we get an error if there's no libdevice library to link with.
-// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_30  for this purpose.
-// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \
+// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_20  for this purpose.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_20 \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE
 
@@ -81,15 +88,16 @@
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
 // NOCUDA-NOT: Found CUDA installation:
 
-// MISSINGLIBDEVICE: error: cannot find libdevice for sm_30.
+// MISSINGLIBDEVICE: error: cannot find libdevice for sm_20.
 
 // COMMON: "-triple" "nvptx-nvidia-cuda"
 // COMMON-SAME: "-fcuda-is-device"
 // LIBDEVICE-SAME: "-mlink-cuda-bitcode"
 // NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"
 // LIBDEVICE20-SAME: libdevice.compute_20.10.bc
 // LIBDEVICE30-SAME: libdevice.compute_30.10.bc
 // LIBDEVICE35-SAME: libdevice.compute_35.10.bc
+// LIBDEVICE50-SAME: libdevice.compute_50.10.bc
 // NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc
 // LIBDEVICE-SAME: "-target-feature" "+ptx42"
 // NOLIBDEVICE-NOT: "-target-feature" "+ptx42"
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1774,8 +1774,7 @@
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
-// FIXME: Uncomment this once we can compile the cuda 8 headers.
-// CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
+CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
@@ -1795,6 +1794,16 @@
   FS.exists(LibDevicePath)))
   continue;
 
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(InstallPath + "/version.txt");
+if (!VersionFile) {
+  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
+  // version.txt isn't pre

Re: [PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-09-28 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/copypaste/suspicious-clones.cpp:61
@@ -60,3 +60,3 @@
   b /= a + b;
-  c -= b * a; // expected-warning{{suspicious code clone detected; did you 
mean to use 'a'?}}
+  c -= b * a; // expected-warning{{Suspicious code clone detected; did you 
mean to use 'a'?}}
   return c;

zaks.anna wrote:
> zaks.anna wrote:
> > zaks.anna wrote:
> > > The error message seems too verbose and focused on the implementation 
> > > rather than user (ex: "suspicious code clone" and "suggestion is based").
> > > 
> > > Maybe we could say something like this:
> > > 
> > > - Did you mean to use 'a'?
> > > - Similar code snippet here
> > > 
> > > 
> > Better:
> > 
> > Did you mean to use 'a'?
> > Similar code snippet here uses 'b'
> > 
> > Did you mean to use 'a' instead of 'b'?
> > Similar code snippet here
> Another refinement
> 
> Potential copy-paste error: did you mean to use 'a' instead of 'b'?
> Similar code here
Potential copy-paste error; did you really mean to use 'b' here?
Similar code using 'a' here
Similar code using 'c' here



https://reviews.llvm.org/D24916



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


Re: [PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-09-28 Thread Matthias Gehre via cfe-commits
mgehre added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
@@ -23,2 +24,3 @@
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

aaron.ballman wrote:
> Hmm, it seems like this is boilerplate we are going to want for every rule, 
> and that it's pretty easy to not get this right (for instance, if you change 
> the way the check is spelled, you have to remember to update this as well). 
> Could this actually be handled more transparently, by gathering this 
> information when the check is registered and exposing it to the check?
> 
> The checks would still need to use `unless(isSuppressed(Rules))` in some 
> form, but I am thinking that it would be more convenient if we could do: 
> `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
>  this);`
I see multiple ways on how to integrate that into clang-tidy:
1) Add something like you proposed to each matcher of each check
2) Change (or add overload of)
```
 DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
 DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
```
to add a AST node as parameter and make the SourceLocation optional. Most 
checks anyhow
call this like diag(E->getLoc(), ""), and then they would do diag(E, "...").
Diag then would check from the that AST node upwards to see if it finds a 
matching [[suppress]] attribute

3) Change the RecursiveASTVistor that drives the AST Matches to prune certain 
matchers from the list of to-be-evaluated matchers
for all AST subtrees that are below a certain [[suppress]] attribute. (This is 
based on how I image that the AST matchers work)


Comment at: clang-tidy/cppcoreguidelines/Suppression.h:59
@@ +58,3 @@
+ anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))),
+   hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules)
+  .matches(Node, Finder, Builder);

aaron.ballman wrote:
> Why is the check for `hasAttrs` required?
> 
> Also, this use of `hasAncestor()` makes this expensive to use, and that 
> expense may be hidden from the caller. Is there a way to structure this so 
> that we don't need to walk the entire ancestor tree?
hasAttr() is needed here, because inside of hasSuppressAttr(), we call 
getAttrs() which would assert if hasAttr() is false.
I cannot push hasAttr() into hasSuppressAttr(), because hasSuppressAttr() is a 
template getting either Decl or AttributedStmt,
and AttributedStmt does not have an hasAttr() method.


https://reviews.llvm.org/D24888



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


Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments

2016-09-28 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

@rnk, do you have any concerns about this patch?


https://reviews.llvm.org/D24472



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


Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-09-28 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

In the C++ Core Guidelines issue on namespaceing of the [[suppress]], it was 
state that Microsoft uses
[[gsl::suppress]] and it is the intent to update the C++ Core Guidelines to 
[[gsl::suppress]].


https://reviews.llvm.org/D24886



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


Re: [PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

The naming here is a bit hard to follow, we have 'dependent action', 
'dependency action', 'depending action', and I think they're all supposed to 
mean the same thing. Only 'dependent action' sounds right to me, can we use 
that universally (i.e. in all comments and names of functions and variables)?



Comment at: lib/Driver/Driver.cpp:2394
@@ +2393,3 @@
+Action *CurAction = *Inputs.begin();
+if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed)
+  return nullptr;

As a micro-optimization, check CanBeCollapsed first, then call the function:

  if (CanBeCollapsed && !CurAction->isCollapsingWithDependingActionLegal())



Comment at: lib/Driver/Driver.cpp:2408
@@ +2407,3 @@
+  if (!CurAction->isCollapsingWithDependingActionLegal() &&
+  CanBeCollapsed)
+return nullptr;

  if (CanBeCollapsed && !CurAction->isCollapsingWithDependingActionLegal())


Comment at: lib/Driver/Driver.cpp:2415
@@ +2414,3 @@
+CurAction = OA->getHostDependence();
+if (!CurAction->isCollapsingWithDependingActionLegal() &&
+CanBeCollapsed)

  if (CanBeCollapsed && !CurAction->isCollapsingWithDependingActionLegal())


Comment at: lib/Driver/Driver.cpp:2444
@@ +2443,3 @@
+  /// collapsed with it.
+  struct JobActionInfoTy final {
+/// The action this info refers to.

Putting "Ty" on the end of a type name seems unusual for our code base (we 
generally use that for typedefs or for variables that represent types of other 
entities). Just JobActionInfo should be fine.


Comment at: lib/Driver/Driver.cpp:2474
@@ +2473,3 @@
+  const Tool *
+  attemptCombineAssembleBackendCompile(ArrayRef ActionInfo,
+   const ActionList *&Inputs,

I don't think we need 'attempt' in the name here, just make this:

  combineAssembleBackendCompile


Comment at: lib/Driver/Driver.cpp:2507
@@ +2506,3 @@
+  const Tool *
+  attemptCombineAssembleBackend(ArrayRef ActionInfo,
+const ActionList *&Inputs,

We don't need 'attempt' in the name here either.


Comment at: lib/Driver/Driver.cpp:2540
@@ -2473,1 +2539,3 @@
   }
+  const Tool *attemptCombineBackendCompile(ArrayRef 
ActionInfo,
+   const ActionList *&Inputs,

  combineBackendCompile


Comment at: lib/Driver/Driver.cpp:2568
@@ +2567,3 @@
+  /// are appended to \a CollapsedOffloadAction.
+  void attemptCombineWithPreprocess(const Tool *T, const ActionList *&Inputs,
+ActionList &CollapsedOffloadAction) {

combineWithPreprocessor


Comment at: lib/Driver/Driver.cpp:2595
@@ +2594,3 @@
+
+  /// Check if a chain of action can be combined and return the tool that can
+  /// handle the combination of actions. The pointer to the current inputs \a

action -> actions


Comment at: lib/Driver/Driver.cpp:2632
@@ +2631,3 @@
+
+if (!T)
+  T = attemptCombineAssembleBackendCompile(ActionChain, Inputs,

I don't think the syntactic regularity here is helpful enough to justify this 
extra if. Just do:

  const Tool *T = combineAssembleBackendCompile(ActionChain, Inputs,
CollapsedOffloadAction);



https://reviews.llvm.org/D21840



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


Re: [PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: include/clang/Basic/DiagnosticDriverKinds.td:163
@@ +162,3 @@
+def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
+  "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading.">;
+def warn_drv_omp_offload_target_duplicate : Warning<

This message does not tell the user how they might make their -fopenmp option 
"compatible with offloading." Please make sure the message does, or is has an 
associated hint message which does.



https://reviews.llvm.org/D21843



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


[PATCH] D25036: [CUDA] Disallow exceptions in device code.

2016-09-28 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, cfe-commits.

https://reviews.llvm.org/D25036

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCUDA/exceptions-host-device.cu
  clang/test/SemaCUDA/exceptions.cu

Index: clang/test/SemaCUDA/exceptions.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/exceptions.cu
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+void host() {
+  throw NULL;
+  try {} catch(void*) {}
+}
+__device__ void device() {
+  throw NULL;
+  // expected-error@-1 {{cannot use 'throw' in __device__ function 'device'}}
+  try {} catch(void*) {}
+  // expected-error@-1 {{cannot use 'try' in __device__ function 'device'}}
+}
+__global__ void kernel() {
+  throw NULL;
+  // expected-error@-1 {{cannot use 'throw' in __global__ function 'kernel'}}
+  try {} catch(void*) {}
+  // expected-error@-1 {{cannot use 'try' in __global__ function 'kernel'}}
+}
Index: clang/test/SemaCUDA/exceptions-host-device.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/exceptions-host-device.cu
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -verify %s -S -o /dev/null
+// RUN: %clang_cc1 -fcxx-exceptions -verify -DHOST %s -S -o /dev/null
+
+#include "Inputs/cuda.h"
+
+// Check that it's an error to use 'try' and 'throw' from a __host__ __device__
+// function if and only if it's codegen'ed for device.
+
+#ifdef HOST
+// expected-no-diagnostics
+#endif
+
+__host__ __device__ void hd1() {
+  throw NULL;
+  try {} catch(void*) {}
+#ifndef HOST
+  // expected-error@-3 {{cannot use 'throw' in __host__ __device__ function 'hd1'}}
+  // expected-error@-3 {{cannot use 'try' in __host__ __device__ function 'hd1'}}
+#endif
+}
+
+// No error, never instantiated on device.
+inline __host__ __device__ void hd2() {
+  throw NULL;
+  try {} catch(void*) {}
+}
+void call_hd2() { hd2(); }
+
+// Error, instantiated on device.
+inline __host__ __device__ void hd3() {
+  throw NULL;
+  try {} catch(void*) {}
+#ifndef HOST
+  // expected-error@-3 {{cannot use 'throw' in __host__ __device__ function 'hd3'}}
+  // expected-error@-3 {{cannot use 'try' in __host__ __device__ function 'hd3'}}
+#endif
+}
+__device__ void call_hd3() { hd3(); }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3644,6 +3644,10 @@
   !getSourceManager().isInSystemHeader(TryLoc))
 Diag(TryLoc, diag::err_exceptions_disabled) << "try";
 
+  // Exceptions aren't allowed in CUDA device code.
+  if (getLangOpts().CUDA)
+CheckCUDAExceptionExpr(TryLoc, "try");
+
   if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
 Diag(TryLoc, diag::err_omp_simd_region_cannot_use_stmt) << "try";
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -683,6 +683,10 @@
   !getSourceManager().isInSystemHeader(OpLoc))
 Diag(OpLoc, diag::err_exceptions_disabled) << "throw";
 
+  // Exceptions aren't allowed in CUDA device code.
+  if (getLangOpts().CUDA)
+CheckCUDAExceptionExpr(OpLoc, "throw");
+
   if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
 Diag(OpLoc, diag::err_omp_simd_region_cannot_use_stmt) << "throw";
 
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -515,3 +515,27 @@
   }
   return true;
 }
+
+bool Sema::CheckCUDAExceptionExpr(SourceLocation Loc, StringRef ExprTy) {
+  assert(getLangOpts().CUDA && "Should only be called during CUDA compilation");
+  FunctionDecl *CurFn = dyn_cast(CurContext);
+  if (!CurFn)
+return true;
+  CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
+
+  // Raise an error immediately if this is a __global__ or __device__ function.
+  // If it's a __host__ __device__ function, enqueue a deferred error which will
+  // be emitted if the function is codegen'ed for device.
+  if (Target == CFT_Global || Target == CFT_Device) {
+Diag(Loc, diag::err_cuda_device_exceptions) << ExprTy << Target << CurFn;
+return false;
+  }
+  if (Target == CFT_HostDevice && getLangOpts().CUDAIsDevice) {
+PartialDiagnostic ErrPD{PartialDiagnostic::NullDiagnostic()};
+ErrPD.Reset(diag::err_cuda_device_exceptions);
+ErrPD << ExprTy << Target << CurFn;
+CurFn->addDeferredDiag({Loc, std::move(ErrPD)});
+return false;
+  }
+  return true;
+}
Index: c

Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-28 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@EricWF: Gentle ping.


https://reviews.llvm.org/D24864



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


Re: [PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: lib/Driver/Driver.cpp:1836
@@ +1835,3 @@
+ActionBuilderReturnCode
+getDeviceDepences(OffloadAction::DeviceDependences &DA, phases::ID 
CurPhase,
+  phases::ID FinalPhase, PhasesTy &Phases) override {

Depences - Spelling?


Comment at: lib/Driver/Driver.cpp:1854
@@ +1853,3 @@
+
+// We passed the device action to a host dependence, so we don't need 
to
+// do anything else with them.

to a -> as a


Comment at: lib/Driver/Driver.cpp:1879
@@ +1878,3 @@
+  // When generating code for OpenMP we use the host compile phase result 
as
+  // dependence to the device compile phase so that it can learn what
+  // declaration should be emitted. However, this is not the only use for

as dependence -> as a dependence (or as the dependence)


Comment at: lib/Driver/Driver.cpp:1880
@@ +1879,3 @@
+  // dependence to the device compile phase so that it can learn what
+  // declaration should be emitted. However, this is not the only use for
+  // the host action, so we have prevent it from being collapsed.

declaration -> declarations


Comment at: lib/Driver/Driver.cpp:1881
@@ +1880,3 @@
+  // declaration should be emitted. However, this is not the only use for
+  // the host action, so we have prevent it from being collapsed.
+  if (isa(HostAction)) {

have prevent -> prevent


Comment at: lib/Driver/Driver.cpp:1918
@@ +1917,3 @@
+  // Get the OpenMP toolchains. If we don't get any, the action builder 
will
+  // know there is nothing to do related with OpenMP offloading.
+  auto OpenMPTCRange = C.getOffloadToolChains();

related with -> related to


Comment at: lib/Driver/Driver.cpp:1949
@@ -1837,1 +1948,3 @@
+SpecializedBuilders.push_back(new OpenMPActionBuilder(C, Args, Inputs));
+
 //

Since we can have both OpenMP offloading and CUDA, please add a test that the 
phases work correctly for that case (or that we produce an error if that can't 
currently work correctly).


https://reviews.llvm.org/D21845



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


Re: [PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-28 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D24848#555636, @mgehre wrote:

> Are you okay with me committing this as it currently is?


Yes.


https://reviews.llvm.org/D24848



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


Re: [PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-28 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp:26
@@ +25,3 @@
+
+} // end anonymous namespace
+

Namespace is inconsistent with following ones. It I'm not mistaken, **// 
namespace** is prevailing form in CLang-tidy code.


https://reviews.llvm.org/D25024



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


Re: [PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: lib/Driver/Tools.cpp:243
@@ +242,3 @@
+// ignore inputs that refer to OpenMP offloading devices - they will be
+// embedded recurring to a proper linker script.
+if (auto *IA = II.getAction())

recurring -> according


Comment at: lib/Driver/Tools.cpp:334
@@ +333,3 @@
+  LksStream << "  OpenMP Offload Linker Script.\n";
+  LksStream << "*/\n";
+  LksStream << "TARGET(binary)\n";

We should also say 'autogenerated' somewhere in this comment.


Comment at: lib/Driver/Tools.cpp:386
@@ +385,3 @@
+  // Dump the contents of the linker script if the user requested that.
+  if (C.getArgs().hasArg(options::OPT_fopenmp_dump_offload_linker_script))
+llvm::errs() << LksBuffer;

I don't see why this is needed if we have -save-temps - I think we should 
remove this option entirely.


https://reviews.llvm.org/D21847



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


r282619 - Re-commit r282556, reverted in r282564, with a fix to CallArgList::addFrom to

2016-09-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Sep 28 14:09:10 2016
New Revision: 282619

URL: http://llvm.org/viewvc/llvm-project?rev=282619&view=rev
Log:
Re-commit r282556, reverted in r282564, with a fix to CallArgList::addFrom to
function correctly when targeting MS ABIs (this appears to have never mattered
prior to this change).

Update test case to always cover both 32-bit and 64-bit Windows ABIs, since
they behave somewhat differently from each other here.

Update test case to also cover operators , && and ||, which it appears are also
affected by P0145R3 (they're not explicitly called out by the design document,
but this is the emergent behavior of the existing wording).


Original commit message:

P0145R3 (C++17 evaluation order tweaks): evaluate the right-hand side of
assignment and compound-assignment operators before the left-hand side. (Even
if it's an overloaded operator.)

This completes the implementation of P0145R3 + P0400R0 for all targets except
Windows, where the evaluation order guarantees for <<, >>, and ->* are
unimplementable as the ABI requires the function arguments are evaluated from
right to left (because parameter destructors are run from left to right in the
callee).

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCall.h
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp
cfe/trunk/test/CodeGenObjCXX/property-object-reference-2.mm
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=282619&r1=282618&r2=282619&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Sep 28 14:09:10 2016
@@ -76,6 +76,16 @@ public:
   /// expression refers to.
   OverloadedOperatorKind getOperator() const { return Operator; }
 
+  static bool isAssignmentOp(OverloadedOperatorKind Opc) {
+return Opc == OO_Equal || Opc == OO_StarEqual ||
+   Opc == OO_SlashEqual || Opc == OO_PercentEqual ||
+   Opc == OO_PlusEqual || Opc == OO_MinusEqual ||
+   Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual ||
+   Opc == OO_AmpEqual || Opc == OO_CaretEqual ||
+   Opc == OO_PipeEqual;
+  }
+  bool isAssignmentOp() const { return isAssignmentOp(getOperator()); }
+
   /// \brief Returns the location of the operator symbol in the expression.
   ///
   /// When \c getOperator()==OO_Call, this is the location of the right

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=282619&r1=282618&r2=282619&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Sep 28 14:09:10 2016
@@ -3129,7 +3129,7 @@ static void emitWritebackArg(CodeGenFunc
 }
 
 void CallArgList::allocateArgumentMemory(CodeGenFunction &CGF) {
-  assert(!StackBase && !StackCleanup.isValid());
+  assert(!StackBase);
 
   // Save the stack.
   llvm::Function *F = CGF.CGM.getIntrinsic(llvm::Intrinsic::stacksave);
@@ -3172,7 +3172,8 @@ void CodeGenFunction::EmitNonNullArgChec
 void CodeGenFunction::EmitCallArgs(
 CallArgList &Args, ArrayRef ArgTypes,
 llvm::iterator_range ArgRange,
-const FunctionDecl *CalleeDecl, unsigned ParamsToSkip) {
+const FunctionDecl *CalleeDecl, unsigned ParamsToSkip,
+bool ForceRightToLeftEvaluation) {
   assert((int)ArgTypes.size() == (ArgRange.end() - ArgRange.begin()));
 
   auto MaybeEmitImplicitObjectSize = [&](unsigned I, const Expr *Arg) {
@@ -3191,7 +3192,8 @@ void CodeGenFunction::EmitCallArgs(
 
   // We *have* to evaluate arguments from right to left in the MS C++ ABI,
   // because arguments are destroyed left to right in the callee.
-  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
+  if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee() ||
+  ForceRightToLeftEvaluation) {
 // Insert a stack save if we're going to need any inalloca args.
 bool HasInAllocaArgs = false;
 for (ArrayRef::iterator I = ArgTypes.begin(), E = ArgTypes.end();

Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=282619&r1=282618&r2=282619&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Wed Sep 28 14:09:10 2016
@@ -81,10 +81,19 @@ namespace CodeGen {
   push_back(CallArg(rvalue, type, needscopy));
 }
 
+/// Add all the arguments from another CallArgList to this one. After doing
+

Re: [PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-28 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a subscriber: malcolm.parsons.


Comment at: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp:30
@@ +29,3 @@
+  Finder->addMatcher(
+  declStmt(declCountIsGreaterThan(1)).bind("multipleNameDeclaration"),
+  this);

Can declCountIsGreaterThan(1) be written as unless(declCountIs(1))?


https://reviews.llvm.org/D25024



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


Re: [PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: lib/Driver/ToolChains.cpp:2834
@@ +2833,3 @@
+  // If this tool chain is used for an OpenMP offloading device we have to make
+  // sure we always generate a shared library regardless the commands the user
+  // passed to the host. This is required because the runtime library requires

regardless the -> regardless of the


Comment at: lib/Driver/ToolChains.cpp:2836
@@ +2835,3 @@
+  // passed to the host. This is required because the runtime library requires
+  // to load the device image dynamically at run time.
+  if (DeviceOffloadKind == Action::OFK_OpenMP) {

requires to load -> is required to load


Comment at: lib/Driver/ToolChains.cpp:2854
@@ +2853,3 @@
+  case options::OPT_shared:
+  case options::OPT_static:
+  case options::OPT_fPIC:

And also?

  case options::OPT_dynamic:


https://reviews.llvm.org/D21848



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


Re: [PATCH] D21852: [Driver][OpenMP] Update actions builder to create bundling action when necessary.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D21852



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


r282621 - Long-overdue update to cxx_status: C++14 is no longer "upcoming".

2016-09-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Sep 28 14:22:36 2016
New Revision: 282621

URL: http://llvm.org/viewvc/llvm-project?rev=282621&view=rev
Log:
Long-overdue update to cxx_status: C++14 is no longer "upcoming".

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=282621&r1=282620&r2=282621&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Wed Sep 28 14:22:36 2016
@@ -28,11 +28,11 @@
 

 Last updated: $Date$
 
-Clang fully implements all published ISO C++ standards including C++11, as well as the upcoming C++14 standard, and some parts of the fledgling C++1z standard,
-and is considered a production-quality C++ compiler.
+Clang fully implements all published ISO C++ standards (C++98 / C++03, C++11, and C++14), and most of the upcoming C++1z standard.
 
 The Clang community is continually striving to improve C++ standards
 compliance between releases by submitting and tracking 
 C++11 implementation status
 
   Clang 3.3 and later implement all of the http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372";>ISO
+href="http://www.iso.org/iso/catalogue_detail.htm?csnumber=50372";>ISO
 C++ 2011 standard. The following table describes the Clang version
   in which each feature became available.
 
 By default, Clang builds C++ code according to the C++98 standard, with many
 C++11 features accepted as extensions. You can use Clang in C++11 mode with the
 -std=c++11 option. Clang's C++11 mode can be used
-with http://libcxx.llvm.org/";>libc++ or with gcc's libstdc++, but
-patches are needed to make libstdc++-4.4
-work with Clang in C++11 mode. Patches are also needed to make
-libstdc++-4.6
-and libstdc++-4.7 work with Clang
-releases prior to version 3.2 in C++11 mode.
+with http://libcxx.llvm.org/";>libc++ or with gcc's libstdc++.
 
 
  
@@ -428,10 +423,9 @@ change.
 
 C++14 implementation status
 
-Clang 3.4 and later implement all of the Draft International Standard (see 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf";>most
-recent publicly available draft)
-of the upcoming C++14 language standard. The following table describes the
+Clang 3.4 and later implement all of the http://www.iso.org/iso/catalogue_detail.htm?csnumber=64029";>ISO
+C++ 2014 standard. The following table describes the
 Clang version in which each feature became available.
 
 You can use Clang in C++14 mode with the -std=c++14 option


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


Re: [PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: include/clang/Driver/Action.h:504
@@ +503,3 @@
+  /// unbundling action.
+  struct DependingActionInfoTy final {
+/// \brief The tool chain of the depending action.

Don't need 'Ty' in the name of this struct.


Comment at: include/clang/Driver/Types.h:81
@@ +80,3 @@
+  /// isSrcFile - Is this a source file, i.e. something that still has to be
+  /// preprocessed. The logic behind this is the same that decides the first
+  /// compilation phase is a preprocessor one.

decided the first -> decides if the first


Comment at: include/clang/Driver/Types.h:82
@@ +81,3 @@
+  /// preprocessed. The logic behind this is the same that decides the first
+  /// compilation phase is a preprocessor one.
+  bool isSrcFile(ID Id);

preprocessor one -> preprocessing one


Comment at: lib/Driver/Driver.cpp:2091
@@ +2090,3 @@
+InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
+!types::isSrcFile(HostAction->getType())) {
+  auto UnbundlingHostAction =

This checks that the file needs to be preprocessed. What does preprocessing 
have to do with this? I don't imagine that providing a preprocessed source file 
as input should invoke the unbundler   .


Comment at: test/Driver/openmp-offload.c:274
@@ +273,3 @@
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target 
powerpc64le-linux 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \

Oh, are you using .i to indicate a bundle instead of a preprocessed file? Don't 
do that. Please use a different suffix -- the bundler has its own file format.


https://reviews.llvm.org/D21853



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


Re: [PATCH] D21856: [Driver][OpenMP] Add support to create jobs for bundling actions.

2016-09-28 Thread Hal Finkel via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D21856



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


Re: [PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 72881.
omtcyfz marked an inline comment as done.
omtcyfz added a comment.

Address couple comments.


https://reviews.llvm.org/D25024

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp
  clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp

Index: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-one-name-per-declaration %t
+
+int main() {
+  {
+int x = 42;
+  }
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names per declaration [cppcoreguidelines-one-name-per-declaration]
+  }
+  {
+int x = 42, y = 43, z = 44;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names per declaration
+  }
+  return 0;
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -19,6 +19,7 @@
cert-flp30-c
cert-oop11-cpp (redirects to misc-move-constructor-init) 
cppcoreguidelines-interfaces-global-init
+   cppcoreguidelines-one-name-per-declaration
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.rst
@@ -0,0 +1,29 @@
+.. title:: clang-tidy - cppcoreguidelines-one-name-per-declaration
+
+cppcoreguidelines-one-name-per-declaration
+==
+
+Checks for declarations with multiple names. C++ Core Guidelines suggests to
+split such declarations into multiple declarations each containing one name.
+
+This would improve readability and prevents potential bugs caused by inattention
+and C/C++ syntax specifics.
+
+Example, bad.
+
+.. code-block:: c++
+
+  std::vector velocities(10, 0), numbers(other_numbers),
+   inputs(input.begin(), input.end());
+
+Example, good.
+
+.. code-block:: c++
+
+  std::vector velocities(10, 0);
+  std::vector numbers(other_numbers);
+  std::vector inputs(input.begin(), input.end());
+
+This rule is part of the "Expressions and statements" profile of the C++ Core
+Guidelines, see
+http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#a-nameres-name-oneaes10-declare-one-name-only-per-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,9 @@
 Improvements to clang-tidy
 --
 
+- New `cppcoreguidelines-one-name-per-declaration
+  `_ check
+
 - New `cppcoreguidelines-slicing
   `_ check
 
Index: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.h
@@ -0,0 +1,35 @@
+//===--- OneNamePerDeclarationCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ONE_NAME_PER_DECLARATION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_ONE_NAME_PER_DECLARATION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// This check warns about multiple names in one declaration.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-one-name-per-declaration.html
+class OneNamePerDeclarationCheck : public ClangTidyCheck {
+public:
+  OneNamePerDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace cppco

Re: [PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-09-28 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp:26
@@ +25,3 @@
+
+} // end anonymous namespace
+

Eugene.Zelenko wrote:
> Namespace is inconsistent with following ones. It I'm not mistaken, **// 
> namespace** is prevailing form in CLang-tidy code.
You're right. That's interesting though, because LLVM Coding Guidelines suggest 
`end namespace mah_name`.


Comment at: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp:30
@@ +29,3 @@
+  Finder->addMatcher(
+  declStmt(declCountIsGreaterThan(1)).bind("multipleNameDeclaration"),
+  this);

malcolm.parsons wrote:
> Can declCountIsGreaterThan(1) be written as unless(declCountIs(1))?
Sure it can. I just thought `declCountIsGreaterThan` might be useful at some 
point.


https://reviews.llvm.org/D25024



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


  1   2   >