[PATCH] D25316: [clang-tidy] Enhance modernize-use-auto to casts

2016-10-13 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 74476.
malcolm.parsons added a comment.

Combine matchers


https://reviews.llvm.org/D25316

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-cast.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -15,6 +15,10 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
   // CHECK-FIXES: static auto *a_static = new MyType();
 
+  long long *ll = new long long();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
+  // CHECK-FIXES: auto *ll = new long long();
+
   MyType *derived = new MyDerivedType();
 
   void *vd = new MyType();
Index: test/clang-tidy/modernize-use-auto-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-auto-cast.cpp
@@ -0,0 +1,120 @@
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- -- \
+// RUN:   -std=c++11 -I %S/Inputs/modernize-use-auto
+
+struct A {
+  virtual ~A() {}
+};
+
+struct B : public A {};
+
+struct C {};
+
+void f_static_cast() {
+  long l = 1;
+  int i1 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto i1 = static_cast(l);
+
+  const int i2 = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto i2 = static_cast(l);
+
+  long long ll = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto ll = static_cast(l);
+  unsigned long long ull = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto ull = static_cast(l);
+  unsigned int ui = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto ui = static_cast(l);
+  long double ld = static_cast(l);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto ld = static_cast(l);
+
+  A *a = new B();
+  B *b1 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = static_cast(a);
+
+  B *const b2 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *const b2 = static_cast(a);
+
+  const B *b3 = static_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto *b3 = static_cast(a);
+
+  B &b4 = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto &b4 = static_cast(*a);
+
+  const B &b5 = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: const auto &b5 = static_cast(*a);
+
+  B &b6 = static_cast(*a), &b7 = static_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto &b6 = static_cast(*a), &b7 = static_cast(*a);
+
+  // Don't warn when non-cast involved
+  long double cast = static_cast(l), noncast = 5;
+
+  // Don't warn when auto is already being used.
+  auto i3 = static_cast(l);
+  auto *b8 = static_cast(a);
+  auto &b9 = static_cast(*a);
+}
+
+void f_dynamic_cast() {
+  A *a = new B();
+  B *b1 = dynamic_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *b1 = dynamic_cast(a);
+
+  B &b2 = dynamic_cast(*a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto &b2 = dynamic_cast(*a);
+}
+
+void f_reinterpret_cast() {
+  auto *a = new A();
+  C *c1 = reinterpret_cast(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto *c1 = reinterpret_cast(a);
+
+  C &c2 = reinterpret_cast(*a);
+  // CHECK-MESSAGES: :[[@

[PATCH] D25540: Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsics

2016-10-13 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm with a comment




Comment at: test/CodeGen/ms-intrinsics.c:3
 // RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
+// RUN: | FileCheck %s -check-prefixes CHECK,CHECK-I386,CHECK-X86
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \

Using CHECK-X86 for both 32- and 64-bit might be confusing to the reader. Maybe 
call it CHECK-INTEL? (Or maybe it's juts me that's confused.)


https://reviews.llvm.org/D25540



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


[PATCH] D25540: Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsics

2016-10-13 Thread David Majnemer via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:1151-1152
+  case Builtin::BI_ReturnAddress: {
+Value *Depth =
+Constant::getNullValue(ConvertType(getContext().UnsignedIntTy));
+Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);

I'd just use `Builder.getInt32(0)`, this will DTRT regardless of whatever 
UnsignedIntTy is.


https://reviews.llvm.org/D25540



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


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

2016-10-13 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki set the repository for this revision to rL LLVM.
danielmarjamaki updated this revision to Diff 74478.
danielmarjamaki added a comment.
Herald added a subscriber: modocache.

changed cast(D)->getName() to cast(D)


Repository:
  rL LLVM

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,71 @@
+//===--- RedundantDeclaratio

[clang-tools-extra] r284109 - Recommit r283538 "[clang-move] Support moving multiple classes in one run."

2016-10-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct 13 03:48:42 2016
New Revision: 284109

URL: http://llvm.org/viewvc/llvm-project?rev=284109&view=rev
Log:
Recommit r283538 "[clang-move] Support moving multiple classes in one run."

Added:
clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
clang-tools-extra/trunk/test/clang-move/move-class.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=284109&r1=284108&r2=284109&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu Oct 13 03:48:42 2016
@@ -297,31 +297,43 @@ ClangMoveTool::ClangMoveTool(
 : Spec(MoveSpec), FileToReplacements(FileToReplacements),
   OriginalRunningDirectory(OriginalRunningDirectory),
   FallbackStyle(FallbackStyle) {
-  Spec.Name = llvm::StringRef(Spec.Name).ltrim(':');
   if (!Spec.NewHeader.empty())
 CCIncludes.push_back("#include \"" + Spec.NewHeader + "\"\n");
 }
 
 void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
-  std::string FullyQualifiedName = "::" + Spec.Name;
+  SmallVector ClassNames;
+  llvm::StringRef(Spec.Names).split(ClassNames, ',');
+  Optional> InMovedClassNames;
+  for (StringRef ClassName : ClassNames) {
+llvm::StringRef GlobalClassName = ClassName.trim().ltrim(':');
+const auto HasName = hasName(("::" + GlobalClassName).str());
+InMovedClassNames =
+InMovedClassNames ? anyOf(*InMovedClassNames, HasName) : HasName;
+  }
+  if (!InMovedClassNames) {
+llvm::errs() << "No classes being moved.\n";
+return;
+  }
+
   auto InOldHeader = isExpansionInFile(
   MakeAbsolutePath(OriginalRunningDirectory, Spec.OldHeader));
   auto InOldCC = isExpansionInFile(
   MakeAbsolutePath(OriginalRunningDirectory, Spec.OldCC));
   auto InOldFiles = anyOf(InOldHeader, InOldCC);
   auto InMovedClass =
-  hasDeclContext(cxxRecordDecl(hasName(FullyQualifiedName)));
+  hasDeclContext(cxxRecordDecl(*InMovedClassNames));
 
   // Match moved class declarations.
   auto MovedClass = cxxRecordDecl(
-  InOldFiles, hasName(FullyQualifiedName), isDefinition(),
+  InOldFiles, *InMovedClassNames, isDefinition(),
   hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(;
   Finder->addMatcher(MovedClass.bind("moved_class"), this);
 
   // Match moved class methods (static methods included) which are defined
   // outside moved class declaration.
   Finder->addMatcher(cxxMethodDecl(InOldFiles,
-   ofClass(hasName(FullyQualifiedName)),
+   ofClass(*InMovedClassNames),
isDefinition())
  .bind("class_method"),
  this);

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=284109&r1=284108&r2=284109&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Thu Oct 13 03:48:42 2016
@@ -37,8 +37,9 @@ public:
   };
 
   struct MoveDefinitionSpec {
-// A fully qualified name, e.g. "X", "a::X".
-std::string Name;
+// A comma-separated list of fully qualified names, e.g. "Foo",
+// "a::Foo, b::Foo".
+std::string Names;
 // The file path of old header, can be relative path and absolute path.
 std::string OldHeader;
 // The file path of old cc, can be relative path and absolute path.

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=284109&r1=284108&r2=284109&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Thu Oct 13 
03:48:42 2016
@@ -37,8 +37,10 @@ std::error_code CreateNewFile(const llvm
 
 cl::OptionCategory ClangMoveCategory("clang-move options");
 
-cl::opt Name("name", cl::desc("The name of class being moved."),
-  cl::cat(ClangMoveCategory));
+cl::opt
+Names("names", cl::desc("A comma-separated list of the names of classes "
+"being moved, e.g. \"Foo\",

r284110 - Fix for PR30639: CGDebugInfo Null dereference with OpenMP array

2016-10-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 13 04:52:46 2016
New Revision: 284110

URL: http://llvm.org/viewvc/llvm-project?rev=284110&view=rev
Log:
Fix for PR30639: CGDebugInfo Null dereference with OpenMP array
access, by Erich Keane

OpenMP creates a variable array type with a a null size-expr. The Debug
generation failed to due to this. This patch corrects the openmp
implementation, updates the tests, and adds a new one for this
condition.

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

Added:
cfe/trunk/test/OpenMP/debug-info-openmp-array.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=284110&r1=284109&r2=284110&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Oct 13 04:52:46 2016
@@ -232,8 +232,15 @@ CodeGenFunction::GenerateOpenMPCapturedS
   assert(I->capturesVariableArrayType());
   II = &getContext().Idents.get("vla");
 }
-if (ArgType->isVariablyModifiedType())
-  ArgType = getContext().getVariableArrayDecayedType(ArgType);
+if (ArgType->isVariablyModifiedType()) {
+  bool IsReference = ArgType->isLValueReferenceType();
+  ArgType =
+  getContext().getCanonicalParamType(ArgType.getNonReferenceType());
+  if (IsReference && !ArgType->isPointerType()) {
+ArgType = getContext().getLValueReferenceType(
+ArgType, /*SpelledAsLValue=*/false);
+  }
+}
 Args.push_back(ImplicitParamDecl::Create(getContext(), nullptr,
  FD->getLocation(), II, ArgType));
 ++I;
@@ -297,8 +304,14 @@ CodeGenFunction::GenerateOpenMPCapturedS
   QualType VarTy = Var->getType();
   Address ArgAddr = ArgLVal.getAddress();
   if (!VarTy->isReferenceType()) {
-ArgAddr = EmitLoadOfReference(
-ArgAddr, ArgLVal.getType()->castAs());
+if (ArgLVal.getType()->isLValueReferenceType()) {
+  ArgAddr = EmitLoadOfReference(
+  ArgAddr, ArgLVal.getType()->castAs());
+} else {
+  assert(ArgLVal.getType()->isPointerType());
+  ArgAddr = EmitLoadOfPointer(
+  ArgAddr, ArgLVal.getType()->castAs());
+}
   }
   setAddrOfLocalVar(
   Var, Address(ArgAddr.getPointer(), getContext().getDeclAlign(Var)));

Added: cfe/trunk/test/OpenMP/debug-info-openmp-array.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/debug-info-openmp-array.cpp?rev=284110&view=auto
==
--- cfe/trunk/test/OpenMP/debug-info-openmp-array.cpp (added)
+++ cfe/trunk/test/OpenMP/debug-info-openmp-array.cpp Thu Oct 13 04:52:46 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fopenmp -x c++ %s -verify -debug-info-kind=limited 
-emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+
+void f(int m) {
+  int i;
+  int cen[m];
+#pragma omp parallel for
+  for (i = 0; i < m; ++i) {
+cen[i] = i;
+  }
+}
+
+// CHECK: !DILocalVariable(name: "cen", arg: 6

Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=284110&r1=284109&r2=284110&view=diff
==
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Thu Oct 13 04:52:46 2016
@@ -492,7 +492,7 @@ int main() {
 // CHECK: store float [[UP]], float* [[T_VAR1_LHS]],
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* 
nonnull %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x 
[[S_FLOAT_TY* dereferenceable(160) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* 
%{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* 
dereferenceable(160) %{{.+}})
 
 // Reduction list for runtime.
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
@@ -696,7 +696,7 @@ int main() {
 
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* 
nonnull %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(160) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.

[PATCH] D25503: [analyzer] Remove superquadratic behaviour from DataflowWorklist

2016-10-13 Thread Ted Kremenek via cfe-commits
krememek added a comment.

Looks great to me too.  Thanks for doing this!


Repository:
  rL LLVM

https://reviews.llvm.org/D25503



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


[PATCH] D25373: Fix for Bug 30639: CGDebugInfo Null dereference with OpenMP array access

2016-10-13 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284110: Fix for PR30639: CGDebugInfo Null dereference with 
OpenMP array (authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D25373?vs=74386&id=74485#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25373

Files:
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/test/OpenMP/debug-info-openmp-array.cpp
  cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
  cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
  cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
  cfe/trunk/test/OpenMP/target_map_codegen.cpp

Index: cfe/trunk/test/OpenMP/target_map_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp
@@ -675,7 +675,7 @@
   }
 }
 
-// CK13: define internal void [[KERNEL]](i[[sz]] [[VLA0:%.+]], i[[sz]] [[VLA1:%.+]], double* {{.+}}[[ARG:%.+]])
+// CK13: define internal void [[KERNEL]](i[[sz]] [[VLA0:%.+]], i[[sz]] [[VLA1:%.+]], double* {{.*}}[[ARG:%.+]])
 // CK13: [[ADDR0:%.+]] = alloca i[[sz]],
 // CK13: [[ADDR1:%.+]] = alloca i[[sz]],
 // CK13: [[ADDR2:%.+]] = alloca double*,
Index: cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
===
--- cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
+++ cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
@@ -301,7 +301,7 @@
 // CHECK: fadd float 5.55e+02, %
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
 
 // Reduction list for runtime.
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
@@ -500,7 +500,7 @@
 
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
 
 // CHECK: [[ARRS_PRIV:%.+]] = alloca [10 x [4 x [[S_FLOAT_TY,
 
Index: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
===
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
@@ -492,7 +492,7 @@
 // CHECK: store float [[UP]], float* [[T_VAR1_LHS]],
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(160) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(160) %{{.+}})
 
 // Reduction list for runtime.
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
@@ -696,7 +696,7 @@
 
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(160) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(160) %{{.+}})
 
 // CHECK: [[ARRS_PRIV:%.+]] = alloca [10 x [4 x [[S_FLOAT_TY,
 
Index: cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
@@ -222,7 +222,7 @@
   
   // make sure that firstprivate variables are generated in all cases and that we use those instances for operations inside the
   // target region
-  // TCHECK:  define void @__omp_offloading_{{.+}}(i{{[0-9]+}} [[A2_IN:%.+]], [10 x float]* {{.+}} [[B_IN:%.+]], i{{[0-9]+}} [[BN_SZ:%.+]], float* {{.+}} [[BN_IN:%.+]], [5 x [10 x double]]* {{.+}} [[C_IN:%.+]], i{{[0-9]+}} [[CN_SZ1:%.+]], i{{[0-9]+}} [[CN_SZ2:%.+]], double* {{.+}} [[CN_IN:%.+]], [[TT]]* {{.+}} [[D_IN:%.+]])
+  // TCHECK:  define {{.*

[PATCH] D25369: [clang-move] Better support enclosing class.

2016-10-13 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 74490.
hokein added a comment.

Rebase to master.


https://reviews.llvm.org/D25369

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/multiple_class_test.cpp
  test/clang-move/Inputs/multiple_class_test.h
  test/clang-move/move-multiple-classes.cpp

Index: test/clang-move/move-multiple-classes.cpp
===
--- test/clang-move/move-multiple-classes.cpp
+++ test/clang-move/move-multiple-classes.cpp
@@ -1,12 +1,15 @@
 // RUN: mkdir -p %T/move-multiple-classes
 // RUN: cp %S/Inputs/multiple_class_test*  %T/move-multiple-classes/
 // RUN: cd %T/move-multiple-classes
-// RUN: clang-move -names="a::Move1, b::Move2,c::Move3,c::Move4" -new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp -new_header=%T/move-multiple-classes/new_multiple_class_test.h -old_cc=%T/move-multiple-classes/multiple_class_test.cpp -old_header=../move-multiple-classes/multiple_class_test.h %T/move-multiple-classes/multiple_class_test.cpp --
+// RUN: clang-move -names="c::EnclosingMove5::Nested" -new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp -new_header=%T/move-multiple-classes/new_multiple_class_test.h -old_cc=%T/move-multiple-classes/multiple_class_test.cpp -old_header=../move-multiple-classes/multiple_class_test.h -dump_result %T/move-multiple-classes/multiple_class_test.cpp -- | FileCheck %s -check-prefix=CHECK-EMPTY
+// RUN: clang-move -names="a::Move1, b::Move2,c::Move3,c::Move4,c::EnclosingMove5" -new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp -new_header=%T/move-multiple-classes/new_multiple_class_test.h -old_cc=%T/move-multiple-classes/multiple_class_test.cpp -old_header=../move-multiple-classes/multiple_class_test.h %T/move-multiple-classes/multiple_class_test.cpp --
 // RUN: FileCheck -input-file=%T/move-multiple-classes/new_multiple_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
 // RUN: FileCheck -input-file=%T/move-multiple-classes/new_multiple_class_test.h -check-prefix=CHECK-NEW-TEST-H %s
 // RUN: FileCheck -input-file=%T/move-multiple-classes/multiple_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
 // RUN: FileCheck -input-file=%T/move-multiple-classes/multiple_class_test.h -check-prefix=CHECK-OLD-TEST-H %s
 //
+// CHECK-EMPTY: [{{[[:space:]]*}}]
+//
 // CHECK-OLD-TEST-H: namespace c {
 // CHECK-OLD-TEST-H: class NoMove {
 // CHECK-OLD-TEST-H: public:
@@ -42,6 +45,14 @@
 // CHECK-NEW-TEST-H: public:
 // CHECK-NEW-TEST-H:   int f();
 // CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: class EnclosingMove5 {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   class Nested {
+// CHECK-NEW-TEST-H: int f();
+// CHECK-NEW-TEST-H: static int b;
+// CHECK-NEW-TEST-H:   };
+// CHECK-NEW-TEST-H:   static int a;
+// CHECK-NEW-TEST-H: };
 // CHECK-NEW-TEST-H: } // namespace c
 
 // CHECK-NEW-TEST-CPP: #include "{{.*}}new_multiple_class_test.h"
@@ -54,4 +65,7 @@
 // CHECK-NEW-TEST-CPP: namespace c {
 // CHECK-NEW-TEST-CPP: int Move3::f() { return 0; }
 // CHECK-NEW-TEST-CPP: int Move4::f() { return 0; }
+// CHECK-NEW-TEST-CPP: int EnclosingMove5::a = 1;
+// CHECK-NEW-TEST-CPP: int EnclosingMove5::Nested::f() { return 0; }
+// CHECK-NEW-TEST-CPP: int EnclosingMove5::Nested::b = 1;
 // CHECK-NEW-TEST-CPP: } // namespace c
Index: test/clang-move/Inputs/multiple_class_test.h
===
--- test/clang-move/Inputs/multiple_class_test.h
+++ test/clang-move/Inputs/multiple_class_test.h
@@ -23,6 +23,15 @@
   int f();
 };
 
+class EnclosingMove5 {
+public:
+  class Nested {
+int f();
+static int b;
+  };
+  static int a;
+};
+
 class NoMove {
 public:
   int f();
Index: test/clang-move/Inputs/multiple_class_test.cpp
===
--- test/clang-move/Inputs/multiple_class_test.cpp
+++ test/clang-move/Inputs/multiple_class_test.cpp
@@ -21,6 +21,14 @@
   return 0;
 }
 
+int EnclosingMove5::a = 1;
+
+int EnclosingMove5::Nested::f() {
+  return 0;
+}
+
+int EnclosingMove5::Nested::b = 1;
+
 int NoMove::f() {
   return 0;
 }
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -24,6 +24,32 @@
 namespace move {
 namespace {
 
+AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const auto* Context = Node.getDeclContext();
+  if (!Context) return false;
+  while (const auto *NextContext = Context->getParent()) {
+if (isa(NextContext) ||
+isa(NextContext))
+  break;
+Context = NextContext;
+  }
+  return InnerMatcher.matches(*Decl::castFromDeclContext(Context), Finder,
+  Builder);
+}
+
+AST_MATCHER_P(CXXMethodDecl, ofOutermostEnclosingClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const CXXRecordDecl *Parent = Node.getParent();
+  if (!Parent) retur

[clang-tools-extra] r284111 - [clang-move] Better support enclosing class.

2016-10-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct 13 05:31:00 2016
New Revision: 284111

URL: http://llvm.org/viewvc/llvm-project?rev=284111&view=rev
Log:
[clang-move] Better support enclosing class.

Summary:
* When moving an outermost enclosing class, all its nested classes should also
  be moved together.
* Add a test for not moving nested class.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=284111&r1=284110&r2=284111&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu Oct 13 05:31:00 2016
@@ -24,6 +24,32 @@ namespace clang {
 namespace move {
 namespace {
 
+AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const auto* Context = Node.getDeclContext();
+  if (!Context) return false;
+  while (const auto *NextContext = Context->getParent()) {
+if (isa(NextContext) ||
+isa(NextContext))
+  break;
+Context = NextContext;
+  }
+  return InnerMatcher.matches(*Decl::castFromDeclContext(Context), Finder,
+  Builder);
+}
+
+AST_MATCHER_P(CXXMethodDecl, ofOutermostEnclosingClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const CXXRecordDecl *Parent = Node.getParent();
+  if (!Parent) return false;
+  while (const auto *NextParent =
+ dyn_cast(Parent->getParent())) {
+Parent = NextParent;
+  }
+
+  return InnerMatcher.matches(*Parent, Finder, Builder);
+}
+
 // Make the Path absolute using the CurrentDir if the Path is not an absolute
 // path. An empty Path will result in an empty string.
 std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
@@ -322,7 +348,7 @@ void ClangMoveTool::registerMatchers(ast
   MakeAbsolutePath(OriginalRunningDirectory, Spec.OldCC));
   auto InOldFiles = anyOf(InOldHeader, InOldCC);
   auto InMovedClass =
-  hasDeclContext(cxxRecordDecl(*InMovedClassNames));
+  hasOutermostEnclosingClass(cxxRecordDecl(*InMovedClassNames));
 
   // Match moved class declarations.
   auto MovedClass = cxxRecordDecl(
@@ -332,11 +358,11 @@ void ClangMoveTool::registerMatchers(ast
 
   // Match moved class methods (static methods included) which are defined
   // outside moved class declaration.
-  Finder->addMatcher(cxxMethodDecl(InOldFiles,
-   ofClass(*InMovedClassNames),
-   isDefinition())
- .bind("class_method"),
- this);
+  Finder->addMatcher(
+  cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*InMovedClassNames),
+isDefinition())
+  .bind("class_method"),
+  this);
 
   // Match static member variable definition of the moved class.
   Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())

Modified: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp?rev=284111&r1=284110&r2=284111&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp Thu 
Oct 13 05:31:00 2016
@@ -21,6 +21,14 @@ int Move4::f() {
   return 0;
 }
 
+int EnclosingMove5::a = 1;
+
+int EnclosingMove5::Nested::f() {
+  return 0;
+}
+
+int EnclosingMove5::Nested::b = 1;
+
 int NoMove::f() {
   return 0;
 }

Modified: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h?rev=284111&r1=284110&r2=284111&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h 
(original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h Thu 
Oct 13 05:31:00 2016
@@ -23,6 +23,15 @@ public:
   int f();
 };
 
+class EnclosingMove5 {
+public:
+  class Nested {
+int f();
+static int b;
+  };
+  static int a;
+};
+
 class NoMove {
 public:
   int f();

Modified: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp?re

[PATCH] D25369: [clang-move] Better support enclosing class.

2016-10-13 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284111: [clang-move] Better support enclosing class. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25369?vs=74490&id=74492#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25369

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
  clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp

Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -24,6 +24,32 @@
 namespace move {
 namespace {
 
+AST_MATCHER_P(Decl, hasOutermostEnclosingClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const auto* Context = Node.getDeclContext();
+  if (!Context) return false;
+  while (const auto *NextContext = Context->getParent()) {
+if (isa(NextContext) ||
+isa(NextContext))
+  break;
+Context = NextContext;
+  }
+  return InnerMatcher.matches(*Decl::castFromDeclContext(Context), Finder,
+  Builder);
+}
+
+AST_MATCHER_P(CXXMethodDecl, ofOutermostEnclosingClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const CXXRecordDecl *Parent = Node.getParent();
+  if (!Parent) return false;
+  while (const auto *NextParent =
+ dyn_cast(Parent->getParent())) {
+Parent = NextParent;
+  }
+
+  return InnerMatcher.matches(*Parent, Finder, Builder);
+}
+
 // Make the Path absolute using the CurrentDir if the Path is not an absolute
 // path. An empty Path will result in an empty string.
 std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
@@ -322,7 +348,7 @@
   MakeAbsolutePath(OriginalRunningDirectory, Spec.OldCC));
   auto InOldFiles = anyOf(InOldHeader, InOldCC);
   auto InMovedClass =
-  hasDeclContext(cxxRecordDecl(*InMovedClassNames));
+  hasOutermostEnclosingClass(cxxRecordDecl(*InMovedClassNames));
 
   // Match moved class declarations.
   auto MovedClass = cxxRecordDecl(
@@ -332,11 +358,11 @@
 
   // Match moved class methods (static methods included) which are defined
   // outside moved class declaration.
-  Finder->addMatcher(cxxMethodDecl(InOldFiles,
-   ofClass(*InMovedClassNames),
-   isDefinition())
- .bind("class_method"),
- this);
+  Finder->addMatcher(
+  cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*InMovedClassNames),
+isDefinition())
+  .bind("class_method"),
+  this);
 
   // Match static member variable definition of the moved class.
   Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition())
Index: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
+++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.h
@@ -23,6 +23,15 @@
   int f();
 };
 
+class EnclosingMove5 {
+public:
+  class Nested {
+int f();
+static int b;
+  };
+  static int a;
+};
+
 class NoMove {
 public:
   int f();
Index: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
+++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp
@@ -21,6 +21,14 @@
   return 0;
 }
 
+int EnclosingMove5::a = 1;
+
+int EnclosingMove5::Nested::f() {
+  return 0;
+}
+
+int EnclosingMove5::Nested::b = 1;
+
 int NoMove::f() {
   return 0;
 }
Index: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
===
--- clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
+++ clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp
@@ -1,12 +1,15 @@
 // RUN: mkdir -p %T/move-multiple-classes
 // RUN: cp %S/Inputs/multiple_class_test*  %T/move-multiple-classes/
 // RUN: cd %T/move-multiple-classes
-// RUN: clang-move -names="a::Move1, b::Move2,c::Move3,c::Move4" -new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp -new_header=%T/move-multiple-classes/new_multiple_class_test.h -old_cc=%T/move-multiple-classes/multiple_class_test.cpp -old_header=../move-multiple-classes/multiple_class_test.h %T/move-multiple-classes/multiple_class_test.cpp --
+// RUN: clang-move -names="c::EnclosingMove5::Nested" -new_cc=%T/move-multiple-classes/new_multiple_class_test.cpp -new_header=%T/move-multiple-classes/new_multiple_class_test.h -old_cc=%T/move-multiple-classes/multiple_class_test.cpp

[PATCH] D25503: [analyzer] Remove superquadratic behaviour from DataflowWorklist

2016-10-13 Thread Aleksei Sidorin via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.

This patch reduces both the analysis time and the line count. I like it! :)
Did you test Artem's approach?


Repository:
  rL LLVM

https://reviews.llvm.org/D25503



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


[PATCH] D25503: [analyzer] Remove superquadratic behaviour from DataflowWorklist

2016-10-13 Thread Artem Dergachev via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

In https://reviews.llvm.org/D25503#569046, @a.sidorin wrote:

> Did you test Artem's approach?


I don't think this is necessary, the priority queue looks like "the" data 
structure to use here.


Repository:
  rL LLVM

https://reviews.llvm.org/D25503



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


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

2016-10-13 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D24861



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


[PATCH] D25326: [StaticAnalyser] Don't merge different returns in ExplodedGraph

2016-10-13 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

I agree with the comments from you dcoughlin but I am not sure how to do it.

> Can you also add a test that tests this more directly (i.e., with 
> clang_analyzer_warnIfReached). I don't think it is good to have the only test 
> for this core coverage issue to be in tests for an alpha checker. Adding the 
> direct test would also make it easier to track down any regression if it 
> happens. The 'func.c' test file might be a good place for such a test.

I totally agree.

In func.c there such comments:
// expected-warning{{FALSE|TRUE|UNKNOWN}}

what does those FALSE|TRUE|UNKNOWN do?

I don't see what this will do:

  clang_analyzer_eval(!f);

I want that both returns are reached. and I want to ensure that result from 
function is both 1 and 0.

> You could also try to add a canary with clang analyzer eval after the if 
> statement to force the test to fail if we do add this symbolic reasoning.

sounds good. sorry but I don't see how to do it.


Repository:
  rL LLVM

https://reviews.llvm.org/D25326



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


r284112 - [analyzer] Link libStaticAnalyzerCheckers to libASTMatchers.

2016-10-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Oct 13 06:41:12 2016
New Revision: 284112

URL: http://llvm.org/viewvc/llvm-project?rev=284112&view=rev
Log:
[analyzer] Link libStaticAnalyzerCheckers to libASTMatchers.

AST matchers are useful for the analyzer's checkers.
More patches on particular checkers shall follow.

This is the first time clang binary gets linked to ASTMatchers.
The binary size increase for the clang executable would be
+0.5% in release mode, +2% in debug mode.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=284112&r1=284111&r2=284112&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Thu Oct 13 06:41:12 
2016
@@ -91,6 +91,7 @@ add_clang_library(clangStaticAnalyzerChe
 
   LINK_LIBS
   clangAST
+  clangASTMatchers
   clangAnalysis
   clangBasic
   clangLex


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


[PATCH] D25429: [analyzer] Link libStaticAnalyzerCheckers to libASTMatchers.

2016-10-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284112: [analyzer] Link libStaticAnalyzerCheckers to 
libASTMatchers. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D25429?vs=74109&id=74497#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25429

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -91,6 +91,7 @@
 
   LINK_LIBS
   clangAST
+  clangASTMatchers
   clangAnalysis
   clangBasic
   clangLex


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -91,6 +91,7 @@
 
   LINK_LIBS
   clangAST
+  clangASTMatchers
   clangAnalysis
   clangBasic
   clangLex
___
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-10-13 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 74499.
sdardis added a comment.

Update ld / st to respect their range and multiple of 16 constraint.


https://reviews.llvm.org/D25017

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  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 <2  x i64> @llvm.mips.bseti.d(
 
@@ -223,10 +223,10 @@
   v4i32_r = __msa_ceq_w(v4i32_a, v4i32_b); // CHECK: call <4  x i32> @llvm.mips.ceq.w(
   v2i64_r = __msa_ceq_d(v2i64_a, v2i64_b); // CHECK: call <2  x i64> @llvm.mips.ceq.d(
 
-  v16i8_r = __msa_ceqi_b(v16i8_a, 25); // CHECK: call <16 x i8>  @llvm.mips.ceqi.b(
-  v8i1

[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

2016-10-13 Thread Alexey Sotkin via cfe-commits
AlexeySotkin removed rL LLVM as the repository for this revision.
AlexeySotkin updated this revision to Diff 74482.
AlexeySotkin added a comment.

Adding test checking address space of array initializer


https://reviews.llvm.org/D25305

Files:
  test/CodeGenOpenCL/private-array-initialization.cl


Index: test/CodeGenOpenCL/private-array-initialization.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/private-array-initialization.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - | 
FileCheck %s
+
+// CHECK: @test.arr = private addrspace(2) constant [3 x i32] [i32 1, i32 2, 
i32 3], align 4
+
+void test() {
+ __private int arr[] = {1, 2, 3};
+// CHECK:  %[[arr_i8_ptr:[0-9]+]] = bitcast [3 x i32]* %arr to i8*
+// CHECK:  call void @llvm.memcpy.p0i8.p2i8.i32(i8* %[[arr_i8_ptr]], i8 
addrspace(2)* bitcast ([3 x i32] addrspace(2)* @test.arr to i8 addrspace(2)*), 
i32 12, i32 4, i1 false)
+}


Index: test/CodeGenOpenCL/private-array-initialization.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/private-array-initialization.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @test.arr = private addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3], align 4
+
+void test() {
+ __private int arr[] = {1, 2, 3};
+// CHECK:  %[[arr_i8_ptr:[0-9]+]] = bitcast [3 x i32]* %arr to i8*
+// CHECK:  call void @llvm.memcpy.p0i8.p2i8.i32(i8* %[[arr_i8_ptr]], i8 addrspace(2)* bitcast ([3 x i32] addrspace(2)* @test.arr to i8 addrspace(2)*), i32 12, i32 4, i1 false)
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-10-13 Thread Ziv Izhar via cfe-commits
zizhar updated this revision to Diff 74500.
zizhar added a comment.

changed :)
Thanks for the review :>


https://reviews.llvm.org/D15075

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/Headers/intrin.h
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/asm.c

Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -28,6 +28,16 @@
   asm ("nop" : : : "204"); // expected-error {{unknown register name '204' in asm}}
   asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
   asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
+  register void *clobber_conflict asm ("%rcx");
+  register void *no_clobber_conflict asm ("%rax");
+  int a,b,c;
+  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
 }
 
 // rdar://6094010
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -22,6 +22,7 @@
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 using namespace clang;
 using namespace sema;
@@ -137,6 +138,57 @@
   return false;
 }
 
+// Extracting the register name from the Expression value,
+// if there is no register name to extract, returns ""
+static StringRef extractRegisterName(const Expr *Expression,
+ const TargetInfo &Target) {
+  Expression = Expression->IgnoreImpCasts();
+  if (const DeclRefExpr *AsmDeclRef = dyn_cast(Expression)) {
+// Handle cases where the expression is a variable
+const VarDecl *Variable = dyn_cast(AsmDeclRef->getDecl());
+if (Variable && Variable->getStorageClass() == SC_Register) {
+  if (AsmLabelAttr *Attr = Variable->getAttr())
+if (Target.isValidGCCRegisterName(Attr->getLabel()))
+  return Target.getNormalizedGCCRegisterName(Attr->getLabel(), true);
+}
+  }
+  return "";
+}
+
+// Checks if there is a conflict between the input and output lists with the
+// clobbers list. If there's a conflict, returns the location of the
+// conflicted clobber, else returns nullptr
+static SourceLocation
+getClobberConflictLocation(MultiExprArg Exprs, StringLiteral **Constraints,
+   StringLiteral **Clobbers, int NumClobbers,
+   const TargetInfo &Target, ASTContext &Cont) {
+  llvm::StringSet<> InOutVars;
+  // Collect all the input and output registers from the extended asm
+  // statement
+  // in order to check for conflicts with the clobber list
+  for (int i = 0; i < Exprs.size(); ++i) {
+StringRef Constraint = Constraints[i]->getString();
+StringRef InOutReg = Target.getConstraintRegister(
+Constraint, extractRegisterName(Exprs[i], Target));
+if (InOutReg != "")
+  InOutVars.insert(InOutReg);
+  }
+  // Check for each item in the clobber list if it conflicts with the input
+  // or output
+  for (int i = 0; i < NumClobbers; ++i) {
+StringRef Clobber = Clobbers[i]->getString();
+// We only check registers, therefore we don't check cc and memory
+// clobbers
+if (Clobber == "cc" || Clobber == "memory")
+  continue;
+Clobber = Target.getNormalizedGCCRegisterName(Clobber, true);
+// Go over the output's registers we collected
+if (InOutVars.count(Clobber))
+  return Clobbers[i]->getLocStart();
+  }
+  return SourceLocation();
+}
+
 StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
  bool IsVolatile, unsigned NumOutputs,
  unsigned NumInputs, IdentifierInfo **Names,
@@ -543,6 +595,13 @@
 return StmtError();

[Clang-tools-extra][Clang-Tidy]: Fix modernize-avoid-bind erroneous scope resolution. [ping]

2016-10-13 Thread Idriss RIOUAK via cfe-commits
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.The check is modernize-avoid-bind.Consider the following:void bar(int x, int y);namespace N{  void bar(int x, int y);}void foo(){  auto Test = std::bind(N::bar,1,1);}clang-tidy’s modernize-avoid-bind check suggests writing:void foo(){  auto Test =[] {return bar(1,1);};}instead of:void foo(){  auto Test = [] {return N::bar(1,1);};}So clang-tidy has proposed an incorrect Fix.This is my proposal patch:

AvoidBindCheck.patch
Description: Binary data
And this is my proposal testcase:

modernize-avoid-bind.patch
Description: Binary data
Should I have to open a report on BugZilla?
Idriss Riouakidriss.rio...@studenti.unipr.itCorso di Laurea in scienze informatica.Dipartimento di Matematica e Informatica.





smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a subscriber: djasper.
v.g.vassilev added a comment.

I think @djasper could help with this review.


https://reviews.llvm.org/D7842



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


[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a reviewer: djasper.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D7842



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


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



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


[PATCH] D25479: Guard flag –fdenormal-fp-math with –fno-fast-math

2016-10-13 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


https://reviews.llvm.org/D25479



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


[PATCH] D25479: Guard flag –fdenormal-fp-math with –fno-fast-math

2016-10-13 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer added a comment.

thanks again for reviewing.


https://reviews.llvm.org/D25479



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


Re: [PATCH] D25539: [Coverage] Support for C++17 switch initializers

2016-10-13 Thread Alex L via cfe-commits
On 13 October 2016 at 03:42, Richard Smith  wrote:

> Do we need the same change for if-statements too?
>

Yes, a similar change should be made for them as well.


>
> On 12 Oct 2016 6:26 pm, "Vedant Kumar via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> vsk created this revision.
>> vsk added reviewers: arphaman, ikudrin.
>> vsk added a subscriber: cfe-commits.
>>
>> Generate coverage mappings for  in switch (; ).
>>
>> I'm unsure about whether or not the CodeGenPGO change in this patch
>> deserves more testing.
>>
>>
>> https://reviews.llvm.org/D25539
>>
>> Files:
>>   lib/CodeGen/CodeGenPGO.cpp
>>   lib/CodeGen/CoverageMappingGen.cpp
>>   test/CoverageMapping/switch.c
>>   test/CoverageMapping/switch.cpp
>>
>>
>> Index: test/CoverageMapping/switch.cpp
>> ===
>> --- test/CoverageMapping/switch.cpp
>> +++ test/CoverageMapping/switch.cpp
>> @@ -1,4 +1,5 @@
>> -// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping
>> -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s |
>> FileCheck %s
>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping
>> -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple
>> %itanium_abi_triple -main-file-name switch.cpp %s | FileCheck %s
>> +
>>  // CHECK: foo
>>  void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2
>> = #0
>>switch(i) {
>> @@ -10,7 +11,7 @@
>>int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2
>> = #1
>>  }
>>
>> -void nop() {}
>> +int nop() { return 0; }
>>
>>  // CHECK: bar
>>  void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 ->
>> [[@LINE+20]]:2 = #0
>> @@ -35,8 +36,16 @@
>>nop();// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2
>> = #6
>>  }
>>
>> +// CHECK: baz
>> +void baz() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+5]]:2
>> = #0
>> +  switch (int i = true ? nop()  // CHECK-NEXT: [[@LINE]]:26 ->
>> [[@LINE]]:31 = #2
>> +   : nop(); // CHECK-NEXT: [[@LINE]]:26 ->
>> [[@LINE]]:31 = (#0 - #2)
>> +  i) {}
>> +  nop();// CHECK-NEXT: [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
>> +}
>> +
>>  // CHECK-NEXT: main
>> -int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 ->
>> [[@LINE+34]]:2 = #0
>> +int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 ->
>> [[@LINE+35]]:2 = #0
>>int i = 0;
>>switch(i) {
>>case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10
>> = #2
>> @@ -48,7 +57,7 @@
>>default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10
>> = #4
>>  break;
>>}
>> -  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2
>> = #1
>> +  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2
>> = #1
>>case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10
>> = #6
>>  i = 1;
>>  break;
>> @@ -58,16 +67,17 @@
>>  break;
>>}
>>
>> -  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2
>> = #5
>> +  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2
>> = #5
>>case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11
>> = #10
>>case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11
>> = (#10 + #11)
>>  i = 11;
>>case 3:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11
>> = ((#10 + #11) + #12)
>>case 4:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11
>> = (((#10 + #11) + #12) + #13)
>>  i = 99;
>>}
>>
>> -  foo(1);   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11
>> = #9
>> +  foo(1);   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:11
>> = #9
>>bar(1);
>> +  baz();
>>return 0;
>>  }
>> Index: lib/CodeGen/CoverageMappingGen.cpp
>> ===
>> --- lib/CodeGen/CoverageMappingGen.cpp
>> +++ lib/CodeGen/CoverageMappingGen.cpp
>> @@ -813,6 +813,9 @@
>>
>>void VisitSwitchStmt(const SwitchStmt *S) {
>>  extendRegion(S);
>> +if (S->getInit())
>> +  Visit(S->getInit());
>> +
>>  Visit(S->getCond());
>>
>>  BreakContinueStack.push_back(BreakContinue());
>> Index: lib/CodeGen/CodeGenPGO.cpp
>> ===
>> --- lib/CodeGen/CodeGenPGO.cpp
>> +++ lib/CodeGen/CodeGenPGO.cpp
>> @@ -458,6 +458,8 @@
>>
>>void VisitSwitchStmt(const SwitchStmt *S) {
>>  RecordStmtCount(S);
>> +if (S->getInit())
>> +  Visit(S->getInit());
>>  Visit(S->getCond());
>>  CurrentCount = 0;
>>  BreakContinueStack.push_back(BreakContinue());
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
___

[libcxx] r284120 - Add missing include in test; NFC. Thanks to Jonathan Wakely for the report.

2016-10-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Oct 13 08:21:38 2016
New Revision: 284120

URL: http://llvm.org/viewvc/llvm-project?rev=284120&view=rev
Log:
Add missing include in test; NFC. Thanks to Jonathan Wakely for the report.

Modified:

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp?rev=284120&r1=284119&r2=284120&view=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
 Thu Oct 13 08:21:38 2016
@@ -14,6 +14,7 @@
 // is_partitioned(InputIterator first, InputIterator last, Predicate pred);
 
 #include 
+#include 
 #include 
 
 #include "test_iterators.h"


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


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

2016-10-13 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, rjmccall.
ahatanak added a subscriber: cfe-commits.

When compiling the following code, DoMarkVarDeclReferenced fails to capture 
variable "outerp":

  auto lambda =[&](auto p) {
return ^{
  return p + outerp;
}();
  };

This happens because Sema::getCurLambda() returns the lambda scope only when 
it's the last scope that has been pushed to Sema::FunctionScopes and therefore 
returns null if there is a block enclosed in the lambda. To fix this bug, this 
patch defines function Sema::getInnermostLambda() and uses it in 
DoMarkVarDeclReferenced to get the innermost lambda scope.

rdar://problem/28412462


https://reviews.llvm.org/D25556

Files:
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaObjCXX/blocks.mm


Index: test/SemaObjCXX/blocks.mm
===
--- test/SemaObjCXX/blocks.mm
+++ test/SemaObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
-std=c++14 %s
 @protocol NSObject;
 
 void bar(id(^)(void));
@@ -144,3 +144,14 @@
 
   template void f(X);
 }
+
+namespace GenericLambdaCapture {
+  int test(int outerp) {
+auto lambda =[&](auto p) {
+  return ^{
+return p + outerp;
+  }();
+};
+return lambda(1);
+  }
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14013,7 +14013,7 @@
 (SemaRef.CurContext != Var->getDeclContext() &&
  Var->getDeclContext()->isFunctionOrMethod() && 
Var->hasLocalStorage());
 if (RefersToEnclosingScope) {
-  if (LambdaScopeInfo *const LSI = SemaRef.getCurLambda()) {
+  if (LambdaScopeInfo *const LSI = SemaRef.getInnermostLambda()) {
 // If a variable could potentially be odr-used, defer marking it so
 // until we finish analyzing the full expression for any
 // lvalue-to-rvalue
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -1220,6 +1220,13 @@
   return nullptr;
 }
 
+LambdaScopeInfo *Sema::getInnermostLambda() {
+  for (auto I = FunctionScopes.rbegin(), E = FunctionScopes.rend(); I != E; 
++I)
+if (auto LSI = dyn_cast(*I))
+  return LSI;
+
+  return nullptr;
+}
 
 void Sema::ActOnComment(SourceRange Comment) {
   if (!LangOpts.RetainCommentsFromSystemHeaders &&
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -1247,6 +1247,9 @@
   /// \brief Retrieve the current generic lambda info, if any.
   sema::LambdaScopeInfo *getCurGenericLambda();
 
+  /// Retrieve the innermost lambda scope info, if any.
+  sema::LambdaScopeInfo *getInnermostLambda();
+
   /// \brief Retrieve the current captured region, if any.
   sema::CapturedRegionScopeInfo *getCurCapturedRegion();
 


Index: test/SemaObjCXX/blocks.mm
===
--- test/SemaObjCXX/blocks.mm
+++ test/SemaObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class -std=c++14 %s
 @protocol NSObject;
 
 void bar(id(^)(void));
@@ -144,3 +144,14 @@
 
   template void f(X);
 }
+
+namespace GenericLambdaCapture {
+  int test(int outerp) {
+auto lambda =[&](auto p) {
+  return ^{
+return p + outerp;
+  }();
+};
+return lambda(1);
+  }
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14013,7 +14013,7 @@
 (SemaRef.CurContext != Var->getDeclContext() &&
  Var->getDeclContext()->isFunctionOrMethod() && Var->hasLocalStorage());
 if (RefersToEnclosingScope) {
-  if (LambdaScopeInfo *const LSI = SemaRef.getCurLambda()) {
+  if (LambdaScopeInfo *const LSI = SemaRef.getInnermostLambda()) {
 // If a variable could potentially be odr-used, defer marking it so
 // until we finish analyzing the full expression for any
 // lvalue-to-rvalue
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -1220,6 +1220,13 @@
   return nullptr;
 }
 
+LambdaScopeInfo *Sema::getInnermostLambda() {
+  for (auto I = FunctionScopes.rbegin(), E = FunctionScopes.rend(); I != E; ++I)
+if (auto LSI = dyn_cast(*I))
+  return LSI;
+
+  return nullptr;
+}
 
 void Sema::ActOnComment(SourceRange Comment) {
   if (!LangOpts.RetainCommentsFromSystemHeaders &&
Index: include/clang/Sema/Sema.h
===

[PATCH] D25539: [Coverage] Support for C++17 switch initializers

2016-10-13 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

> I'm unsure about whether or not the CodeGenPGO change in this patch deserves 
> more testing.

It wouldn't harm to add a test for CodeGenPGO as well. A good test that you can 
as a starting point for the new one is `test/Profile/cxx-rangefor.cpp`. A 
single `PGOGEN` check for a PGO counter generated from a subexpression in a 
switch initializer should be sufficient.




Comment at: lib/CodeGen/CoverageMappingGen.cpp:818
+  Visit(S->getInit());
+
 Visit(S->getCond());

I noticed that you added a newline here, wouldn't it be better to have it after 
`extendRegion(S)` so that the `Visit` calls are grouped together?


https://reviews.llvm.org/D25539



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


[PATCH] D25479: Guard flag –fdenormal-fp-math with –fno-fast-math

2016-10-13 Thread Sjoerd Meijer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284121: Guard flag –fdenormal-fp-math with –fno-fast-math. 
(authored by SjoerdMeijer).

Changed prior to commit:
  https://reviews.llvm.org/D25479?vs=74363&id=74508#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25479

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/denormal-fp-math.c


Index: cfe/trunk/test/Driver/denormal-fp-math.c
===
--- cfe/trunk/test/Driver/denormal-fp-math.c
+++ cfe/trunk/test/Driver/denormal-fp-math.c
@@ -1,9 +1,12 @@
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck 
-check-prefix=CHECK-NO-UNSAFE %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -fno-unsafe-math-optimizations -v 2>&1 | FileCheck 
-check-prefix=CHECK-NO-UNSAFE %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo 
-v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
 
 // CHECK-IEEE: "-fdenormal-fp-math=ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
 // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4391,11 +4391,18 @@
   if (ReciprocalMath)
 CmdArgs.push_back("-freciprocal-math");
 
-  if (!TrappingMath) 
+  if (!TrappingMath)
 CmdArgs.push_back("-fno-trapping-math");
 
-  if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ))
-Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
+
+  if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
+   options::OPT_fno_fast_math,
+   options::OPT_funsafe_math_optimizations,
+   options::OPT_fno_unsafe_math_optimizations,
+   options::OPT_fdenormal_fp_math_EQ))
+if (A->getOption().getID() != options::OPT_fno_fast_math &&
+A->getOption().getID() != options::OPT_fno_unsafe_math_optimizations)
+  Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
 
   // Validate and pass through -fp-contract option.
   if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,


Index: cfe/trunk/test/Driver/denormal-fp-math.c
===
--- cfe/trunk/test/Driver/denormal-fp-math.c
+++ cfe/trunk/test/Driver/denormal-fp-math.c
@@ -1,9 +1,12 @@
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck -check-prefix=CHECK-NO-UNSAFE %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -fno-unsafe-math-optimizations -v 2>&1 | FileCheck -check-prefix=CHECK-NO-UNSAFE %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
 
 // CHECK-IEEE: "-fdenormal-fp-math=ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
 // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4391,11 +4391,18 @@
   if (ReciprocalMath)
 CmdArgs.push_back("-freciprocal-math");
 
-  if (!TrappingMath) 
+  if (!TrappingMath)
 CmdArgs.push_back("-fno-trapping-math");
 
-  if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ))
-Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
+
+  if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
+   options::OPT_fno_fast_math,
+   options::OPT_funsafe_math_optimizations,
+  

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

2016-10-13 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 74509.
omtcyfz marked 5 inline comments as done.
omtcyfz added a comment.
Herald added a subscriber: modocache.

Addressed bunch of comments.


https://reviews.llvm.org/D25024

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  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,33 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-one-name-per-declaration %t
+
+int main() {
+  {
+int x = 42;
+int y = 43;
+// No warning here.
+  }
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare more than one variable per declaration [cppcoreguidelines-one-name-per-declaration]
+  }
+  {
+int x = 42, y = 43, z = 44;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare more than one variable per declaration
+  }
+  for (int i = 0, j = 100; i < j; i++);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare more than one variable per declaration
+
+  char *p, c, a[7], *pp[7], **aa[10];
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare more than one variable per declaration
+  return 0;
+}
+
+void foo(int x, int y, int z) {} // Expect no warning.
+
+typedef int int_t, *intp_t, (&fp)(int, long), arr_t[10];
+
+template 
+void bar() {}
+
+template 
+bool any_of(InputIterator first, InputIterator last, Predicate pred);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
+   cert-dcl04-c (redirects to cppcoreguidelines-one-name-per-declaration) 
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl59-cpp (redirects to google-build-namespaces) 
@@ -19,6 +20,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 Univers

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

2016-10-13 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OneNamePerDeclarationCheck.cpp:38
+  diag(MultipleNameDeclaration->getStartLoc(),
+   "Do not declare multiple names per declaration");
+}

aaron.ballman wrote:
> Diagnostics do not start with a capital letter. Also, this diagnostic is not 
> really accurate. Consider `void f(int x, int y);` -- that's a single 
> declaration, but it declares multiple names. Perhaps: `do not declare more 
> than one variable per declaration` since this should really be focusing on 
> variable declarations rather than parameters, template parameter lists, etc
> Diagnostics do not start with a capital letter.

Clang SA diags do, actually. Though I can totally see the reason: consistency 
is important since it's clang-tidy check.

> Consider void f(int x, int y); -- that's a single declaration, but it 
> declares multiple names. Perhaps: do not declare more than one variable per 
> declaration since this should really be focusing on variable declarations 
> rather than parameters, template parameter lists, etc

Fixed, thank you for the note!



Comment at: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp:8
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names 
per declaration [cppcoreguidelines-one-name-per-declaration]

malcolm.parsons wrote:
> The guideline says "Flag non-function arguments with multiple declarators 
> involving declarator operators (e.g., int* p, q;)".
> 
> There are no declarator operators in this test, so there should be no warning.
The guideline says

> Reason: One-declaration-per line increases readability and avoids mistakes 
> related to the C/C++ grammar. It also leaves room for a more descriptive 
> end-of-line comment.

> Exception: a function declaration can contain several function argument 
> declarations.

I'm not sure why what you copied is written in "Enforcement" section, but I do 
not think that is how it should be handled. I am concerned not only about that 
specific case and I see no reason to cut off cases already presented in this 
test.


https://reviews.llvm.org/D25024



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


[libunwind] r284125 - [libunwind] Add missing include. NFC.

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct 13 09:32:24 2016
New Revision: 284125

URL: http://llvm.org/viewvc/llvm-project?rev=284125&view=rev
Log:
[libunwind] Add missing  include. NFC.

This missing include seems to cause compilation failures on older MacOS
versions (< 10.9). This is because r270692 has introduced uint64_t into
config.h without including this header.

Patch from: Jeremy Huddleston Sequoia (jerem...@apple.com)

Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=284125&r1=284124&r2=284125&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Thu Oct 13 09:32:24 2016
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 // Define static_assert() unless already defined by compiler.


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


Re: libunwind build regression fix

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Hi Jeremy,

Thanks for the patch, committed as r284125.

Cheers,

/ Asiri


From: jerem...@apple.com  on behalf of Jeremy Huddleston 
Sequoia 
Sent: 13 October 2016 06:57
To: Asiri Rathnayake
Subject: libunwind build regression fix

Hi Asiri,

Could you please push this build fix to libunwind.  Your 
LIBUNWIND_ENABLE_CROSS_UNWINDING change a few months ago introduced a build 
failure because uint64_t is used in config.h without an include of  
(failure noticed on macOS versions older than 10.9).

Thanks,
Jeremy


From 59508d1029580fe2f95eb4b8a002175c6f87710d Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia 
Date: Wed, 12 Oct 2016 22:52:51 -0700
Subject: [PATCH] config.h: Add missing include of stdint.h for uint64_t usage

Regressed-in: trunk r270692
Regressed-in: d2d1ea9d75dfc4f55540f7e3cf940c6a1d6674cc
Signed-off-by: Jeremy Huddleston Sequoia 
CC: Asiri Rathnayake 
---
 src/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/config.h b/src/config.h
index cfe7706..4e4dd99 100644
--- a/src/config.h
+++ b/src/config.h
@@ -16,6 +16,7 @@

 #include 
 #include 
+#include 
 #include 

 // Define static_assert() unless already defined by compiler.
--
2.9.3

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

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


[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-13 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 74514.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised by Aaron's comments. Added a sema test.


https://reviews.llvm.org/D25343

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Headers/opencl-c.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/convergent.cl
  test/SemaOpenCL/convergent.cl

Index: test/SemaOpenCL/convergent.cl
===
--- /dev/null
+++ test/SemaOpenCL/convergent.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify %s
+
+void f1(void) __attribute__((convergent));
+
+void f2(void) __attribute__((convergent(1))); // expected-error {{'convergent' attribute takes no arguments}}
+
+void f3(int a __attribute__((convergent))); // expected-warning {{'convergent' attribute only applies to functions}}
+
+void f4(void) {
+  int var1 __attribute__((convergent)); // expected-warning {{'convergent' attribute only applies to functions}}
+}
+
Index: test/CodeGenOpenCL/convergent.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/convergent.cl
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+void convfun(void) __attribute__((convergent));
+void non_convfun(void);
+void nodupfun(void) __attribute__((noduplicate));
+
+void f(void);
+void g(void);
+
+// Test two if's are merged and non_convfun duplicated.
+// The LLVM IR is equivalent to:
+//if (a) {
+//  f();
+//  non_convfun();
+//  g();
+//} else {
+//  non_conffun();
+//}
+//
+// CHECK: define spir_func void @test_merge_if(i32 %[[a:.+]])
+// CHECK: %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK: br i1 %[[tobool]], label %[[if_end3_critedge:.+]], label %[[if_then:.+]]
+// CHECK: [[if_then]]:
+// CHECK: tail call spir_func void @f()
+// CHECK: tail call spir_func void @non_convfun()
+// CHECK: tail call spir_func void @g()
+// CHECK: br label %[[if_end3:.+]]
+// CHECK: [[if_end3_critedge]]:
+// CHECK: tail call spir_func void @non_convfun()
+// CHECK: br label %[[if_end3]]
+// CHECK: [[if_end3]]:
+// CHECK-LABEL: ret void
+
+void test_merge_if(int a) {
+  if (a) {
+f();
+  }
+  non_convfun();
+  if (a) {
+g();
+  }
+}
+
+// CHECK-DAG: declare spir_func void @f()
+// CHECK-DAG: declare spir_func void @non_convfun()
+// CHECK-DAG: declare spir_func void @g()
+
+// Test two if's are not merged.
+// CHECK: define spir_func void @test_no_merge_if(i32 %[[a:.+]])
+// CHECK:  %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK: br i1 %[[tobool]], label %[[if_end:.+]], label %[[if_then:.+]]
+// CHECK: [[if_then]]:
+// CHECK: tail call spir_func void @f()
+// CHECK-NOT: call spir_func void @non_convfun()
+// CHECK-NOT: call spir_func void @g()
+// CHECK: br label %[[if_end]]
+// CHECK: [[if_end]]:
+// CHECK:  %[[tobool_pr:.+]] = phi i1 [ true, %[[if_then]] ], [ false, %{{.+}} ]
+// CHECK:  tail call spir_func void @convfun() #[[attr5:.+]]
+// CHECK:  br i1 %[[tobool_pr]], label %[[if_then2:.+]], label %[[if_end3:.+]]
+// CHECK: [[if_then2]]:
+// CHECK: tail call spir_func void @g()
+// CHECK:  br label %[[if_end3:.+]]
+// CHECK: [[if_end3]]:
+// CHECK-LABEL:  ret void
+
+void test_no_merge_if(int a) {
+  if (a) {
+f();
+  }
+  convfun();
+  if(a) {
+g();
+  }
+}
+
+// CHECK: declare spir_func void @convfun(){{[^#]*}} #[[attr2:[0-9]+]]
+
+// Test loop is unrolled for convergent function.
+// CHECK-LABEL: define spir_func void @test_unroll()
+// CHECK:  tail call spir_func void @convfun() #[[attr5:[0-9]+]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK-LABEL:  ret void
+
+void test_unroll() {
+  for (int i = 0; i < 10; i++)
+convfun();
+}
+
+// Test loop is not unrolled for noduplicate function.
+// CHECK-LABEL: define spir_func void @test_not_unroll()
+// CHECK:  br label %[[for_body:.+]]
+// CHECK: [[for_cond_cleanup:.+]]:
+// CHECK:  ret void
+// CHECK: [[for_body]]:
+// CHECK:  tail call spir_func void @nodupfun() #[[attr6:[0-9]+]]
+// CHECK-NOT: call spir_func void @nodupfun()
+// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+
+void test_not_unroll() {
+  for (int i = 0; i < 10; i++)
+nodupfun();
+}
+
+// CHECK: declare spir_func void @nodupfun(){{[^#]*}} #[[attr3:[0-9]+]]
+
+// CHECK-DAG: attributes #[[attr2]] = { {{[^}]*}}convergent{{[^}]*}} }
+// CHECK-DAG: attributes #[[attr3]] = { {{[^}]*}}n

Re: libunwind build regression fix

2016-10-13 Thread Asiri Rathnayake via cfe-commits
And... apologies for that disclaimer notice.

Cheers,

/ Asiri


From: cfe-commits  on behalf of Asiri 
Rathnayake via cfe-commits 
Sent: 13 October 2016 15:42
To: Jeremy Huddleston Sequoia
Cc: cfe-commits@lists.llvm.org
Subject: Re: libunwind build regression fix

Hi Jeremy,

Thanks for the patch, committed as r284125.

Cheers,

/ Asiri


From: jerem...@apple.com  on behalf of Jeremy Huddleston 
Sequoia 
Sent: 13 October 2016 06:57
To: Asiri Rathnayake
Subject: libunwind build regression fix

Hi Asiri,

Could you please push this build fix to libunwind.  Your 
LIBUNWIND_ENABLE_CROSS_UNWINDING change a few months ago introduced a build 
failure because uint64_t is used in config.h without an include of  
(failure noticed on macOS versions older than 10.9).

Thanks,
Jeremy


From 59508d1029580fe2f95eb4b8a002175c6f87710d Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia 
Date: Wed, 12 Oct 2016 22:52:51 -0700
Subject: [PATCH] config.h: Add missing include of stdint.h for uint64_t usage

Regressed-in: trunk r270692
Regressed-in: d2d1ea9d75dfc4f55540f7e3cf940c6a1d6674cc
Signed-off-by: Jeremy Huddleston Sequoia 
CC: Asiri Rathnayake 
---
 src/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/config.h b/src/config.h
index cfe7706..4e4dd99 100644
--- a/src/config.h
+++ b/src/config.h
@@ -16,6 +16,7 @@

 #include 
 #include 
+#include 
 #include 

 // Define static_assert() unless already defined by compiler.
--
2.9.3

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

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

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


[PATCH] D25520: [CodeCompletion] Add block placeholders when completing member access for Objective-C block property setters

2016-10-13 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D25520#568448, @akyrtzi wrote:

> What if the user just wants to invoke the block, this is as common or more, 
> like:
>
> `self.onEventHandler(10)`
>
> The assign literal completion is useful but it should be an additional entry 
> (with maybe lower priority) not replace the property completion.
>  BTW, it would be great if we had completion as if it was a function call, so 
> 2 entries, 1 for block invocation and 1 for assigning literal. Absence the 
> block invocation call it should be 1 for normal property completion and 1 for 
> assigning literal.


You're right, I forgot about the most common use of block properties. I will 
update the patch today.

It makes sense to complete block invocation as well, but that has to be done in 
a separate patch. I suppose that completion for block invocations should be 
provided for normal sub expressions as well then.


Repository:
  rL LLVM

https://reviews.llvm.org/D25520



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


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

2016-10-13 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 74519.
rmaprath added a comment.
Herald added a subscriber: modocache.

Patch re-based on the latest trunk.

I've resolved my downstream issues, will be committing soon.

/ Asiri


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/cxa_thread_atexit.cpp
  src/fallback_malloc.cpp
  src/threading_support.h
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,9 +12,7 @@
 #include 
 #include 
 #include 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
+#include "../src/threading_support.h"
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -40,19 +38,19 @@
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
-size_t  thread_globals [ NUMTHREADS ] = { 0 };
-pthread_t   threads[ NUMTHREADS ];
+size_t thread_globals [ NUMTHREADS ] = { 0 };
+__libcxxabi_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
+__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_join ( threads [ i ], NULL );
+__libcxxabi_thread_join ( &threads [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,107 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+mach_port_t __libcxxabi_thread_get_port()
+{
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
+// Thread
+typedef pthread_t __libcxxabi_thread_t;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_create(__libcxxabi_thread_t* __t,
+   void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_join(__libcxxabi_thread_t* __t)
+{
+return pthread_join(*__t, 0);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_create(__libcxxabi_tls_key *key,
+   void (*destructor)

[PATCH] D25519: [CodeCompletion] Refactor: Extract two Objective-C block formatting related functions from FormatFunctionParameter

2016-10-13 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 74520.
arphaman marked 2 inline comments as done.
arphaman added a comment.

The updated patch has comments for the two extracted functions.


Repository:
  rL LLVM

https://reviews.llvm.org/D25519

Files:
  lib/Sema/SemaCodeComplete.cpp

Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -2162,6 +2162,59 @@
   return Result;
 }
 
+/// \brief Tries to find the most appropriate type location for an Objective-C
+/// block placeholder.
+///
+/// This function ignores things like typedefs and qualifiers in order to
+/// present the most relevant and accurate block placeholders in code completion
+/// results.
+static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo,
+ FunctionTypeLoc &Block,
+ FunctionProtoTypeLoc &BlockProto,
+ bool SuppressBlock = false) {
+  if (!TSInfo)
+return;
+  TypeLoc TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
+  while (true) {
+// Look through typedefs.
+if (!SuppressBlock) {
+  if (TypedefTypeLoc TypedefTL = TL.getAs()) {
+if (TypeSourceInfo *InnerTSInfo =
+TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
+  TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc();
+  continue;
+}
+  }
+
+  // Look through qualified types
+  if (QualifiedTypeLoc QualifiedTL = TL.getAs()) {
+TL = QualifiedTL.getUnqualifiedLoc();
+continue;
+  }
+
+  if (AttributedTypeLoc AttrTL = TL.getAs()) {
+TL = AttrTL.getModifiedLoc();
+continue;
+  }
+}
+
+// Try to get the function prototype behind the block pointer type,
+// then we're done.
+if (BlockPointerTypeLoc BlockPtr = TL.getAs()) {
+  TL = BlockPtr.getPointeeLoc().IgnoreParens();
+  Block = TL.getAs();
+  BlockProto = TL.getAs();
+}
+break;
+  }
+}
+
+static std::string
+formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
+   FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto,
+   bool SuppressBlock = false,
+   Optional> ObjCSubsts = None);
+
 static std::string FormatFunctionParameter(const PrintingPolicy &Policy,
const ParmVarDecl *Param,
bool SuppressName = false,
@@ -2192,47 +2245,13 @@
 }
 return Result;
   }
-  
+
   // The argument for a block pointer parameter is a block literal with
   // the appropriate type.
   FunctionTypeLoc Block;
   FunctionProtoTypeLoc BlockProto;
-  TypeLoc TL;
-  if (TypeSourceInfo *TSInfo = Param->getTypeSourceInfo()) {
-TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
-while (true) {
-  // Look through typedefs.
-  if (!SuppressBlock) {
-if (TypedefTypeLoc TypedefTL = TL.getAs()) {
-  if (TypeSourceInfo *InnerTSInfo =
-  TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
-TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc();
-continue;
-  }
-}
-
-// Look through qualified types
-if (QualifiedTypeLoc QualifiedTL = TL.getAs()) {
-  TL = QualifiedTL.getUnqualifiedLoc();
-  continue;
-}
-
-if (AttributedTypeLoc AttrTL = TL.getAs()) {
-  TL = AttrTL.getModifiedLoc();
-  continue;
-}
-  }
-  
-  // Try to get the function prototype behind the block pointer type,
-  // then we're done.
-  if (BlockPointerTypeLoc BlockPtr = TL.getAs()) {
-TL = BlockPtr.getPointeeLoc().IgnoreParens();
-Block = TL.getAs();
-BlockProto = TL.getAs();
-  }
-  break;
-}
-  }
+  findTypeLocationForBlockDecl(Param->getTypeSourceInfo(), Block, BlockProto,
+   SuppressBlock);
 
   if (!Block) {
 // We were unable to find a FunctionProtoTypeLoc with parameter names
@@ -2258,12 +2277,30 @@
 
   // We have the function prototype behind the block pointer type, as it was
   // written in the source.
+  return formatBlockPlaceholder(Policy, Param, Block, BlockProto, SuppressBlock,
+ObjCSubsts);
+}
+
+/// \brief Returns a placeholder string that corresponds to an Objective-C block
+/// declaration.
+///
+/// \param BlockDecl A declaration with an Objective-C block type.
+///
+/// \param Block The most relevant type location for that block type.
+///
+/// \param SuppressBlockName Determines wether or not the name of the block
+/// declaration is included in the resulting string.
+static std::string
+formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
+   FunctionTypeLoc &Block, Functi

[libcxxabi] r284128 - [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct 13 10:05:19 2016
New Revision: 284128

URL: http://llvm.org/viewvc/llvm-project?rev=284128&view=rev
Log:
[libcxxabi] Refactor pthread usage into a separate API

This patch refactors all pthread uses of libc++abi into a separate API. This
is the first step towards supporting an externlly-threaded libc++abi library.

I've followed the conventions already used in the libc++ library for the same
purpose.

Patch from: Saleem Abdulrasool and Asiri Rathnayake

Reviewed by: compnerd, EricWF

Differential revisions:
  https://reviews.llvm.org/D18482 (original)
  https://reviews.llvm.org/D24864 (final)

Added:
libcxxabi/trunk/src/threading_support.h
Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/src/config.h
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception_storage.cpp
libcxxabi/trunk/src/cxa_guard.cpp
libcxxabi/trunk/src/cxa_thread_atexit.cpp
libcxxabi/trunk/src/fallback_malloc.cpp
libcxxabi/trunk/test/test_exception_storage.pass.cpp
libcxxabi/trunk/test/test_fallback_malloc.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=284128&r1=284127&r2=284128&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Thu Oct 13 10:05:19 2016
@@ -340,6 +340,7 @@ endif()
 
 if (LIBCXXABI_HAS_PTHREAD_API)
   add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+  add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
 endif()
 
 if (MSVC)

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=284128&r1=284127&r2=284128&view=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Thu Oct 13 10:05:19 2016
@@ -16,6 +16,36 @@
 
 #include 
 
+// Configure inline visibility attributes
+#if defined(_WIN32)
+ #if defined(_MSC_VER) && !defined(__clang__)
+  // Using Microsoft Visual C++ compiler
+  #define _LIBCXXABI_INLINE_VISIBILITY __forceinline
+ #else
+  #if __has_attribute(__internal_linkage__)
+   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__internal_linkage__, 
__always_inline__))
+  #else
+   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+  #endif
+ #endif
+#else
+ #if __has_attribute(__internal_linkage__)
+  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__internal_linkage__, 
__always_inline__))
+ #else
+  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ 
((__visibility__("hidden"), __always_inline__))
+ #endif
+#endif
+
+// Try and deduce a threading api if one has not been explicitly set.
+#if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
+!defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+  #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
+#define _LIBCXXABI_USE_THREAD_API_PTHREAD
+  #else
+#error "No thread API"
+  #endif
+#endif
+
 // Set this in the CXXFLAGS when you need it, because otherwise we'd have to
 // #if !defined(__linux__) && !defined(__APPLE__) && ...
 // and so-on for *every* platform.

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=284128&r1=284127&r2=284128&view=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Thu Oct 13 10:05:19 2016
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "config.h"
+#include "threading_support.h"
 #include "cxxabi.h"
 
 #include // for std::terminate

Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception_storage.cpp?rev=284128&r1=284127&r2=284128&view=diff
==
--- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp Thu Oct 13 10:05:19 2016
@@ -14,6 +14,7 @@
 #include "cxa_exception.hpp"
 
 #include "config.h"
+#include "threading_support.h"
 
 #if defined(_LIBCXXABI_HAS_NO_THREADS)
 
@@ -44,28 +45,27 @@ extern "C" {
 
 #else
 
-#include 
 #include "abort_message.h"
 #include "fallback_malloc.h"
 
-//  In general, we treat all pthread errors as fatal.
+//  In general, we treat all threading errors as fatal.
 //  We cannot call std::terminate() because that will in turn
 //  call __cxa_get_globals() and cause infinite recursion.
 
 namespace __cxxabiv1 {
 namespace {
-pthread_key_t  key_;
-pthread_once_t flag_ = PTHREAD_ONCE_INIT;
+__libcxxabi_tls_key key_;
+__libcxxabi_exec_once_flag flag_ = _LIBCXXABI_EXEC_ONCE_INITIALIZER;
 
 void destruct_ (void *p) {
 __free_with_fallback 

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

2016-10-13 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp:8
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names 
per declaration [cppcoreguidelines-one-name-per-declaration]

omtcyfz wrote:
> malcolm.parsons wrote:
> > The guideline says "Flag non-function arguments with multiple declarators 
> > involving declarator operators (e.g., int* p, q;)".
> > 
> > There are no declarator operators in this test, so there should be no 
> > warning.
> The guideline says
> 
> > Reason: One-declaration-per line increases readability and avoids mistakes 
> > related to the C/C++ grammar. It also leaves room for a more descriptive 
> > end-of-line comment.
> 
> > Exception: a function declaration can contain several function argument 
> > declarations.
> 
> I'm not sure why what you copied is written in "Enforcement" section, but I 
> do not think that is how it should be handled. I am concerned not only about 
> that specific case and I see no reason to cut off cases already presented in 
> this test.
"mistakes related to the C/C++ grammar" only occur when declarator operators 
are involved. e.g. in `int* p, q` a reader might incorrectly think that q was a 
pointer.

I see reasons not to warn about cases like
`for (auto i = c.begin(), e = someExpensiveFn(); i != e; i++)`
`for (int i = 0, j = someExpensiveFn(); i < j; i++);`
because the alternatives increase variable scope, or for
`int x = 42, y = 43;`
because it's not difficult to read.

As we disagree on this, can it be made configurable?


https://reviews.llvm.org/D25024



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


[PATCH] D25565: Deduplicate sets of replacements by file names.

2016-10-13 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added subscribers: cfe-commits, bkramer, hokein.
Herald added a subscriber: klimek.

If there are multiple  pairs with the same file
path after removing dots, we only keep one pair (with path after dots being
removed) and discard the rest.


https://reviews.llvm.org/D25565

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

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -972,5 +972,23 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
+TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+  std::map FileToReplaces;
+  FileToReplaces["../../a/b/.././c.h"] = Replacements();
+  FileToReplaces["../../a/c.h"] = Replacements();
+  FileToReplaces = deduplicateReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, RemoveDotSlash) {
+  std::map FileToReplaces;
+  FileToReplaces["./a/b/.././c.h"] = Replacements();
+  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces = deduplicateReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,7 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
   bool Result = true;
-  for (const auto &Entry : FileToReplaces)
+  for (const auto &Entry : deduplicateReplacementsByFile(FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +73,8 @@
   FileManager &Files = SM.getFileManager();
 
   bool Result = true;
-  for (const auto &FileAndReplaces : FileToReplaces) {
+  for (const auto &FileAndReplaces :
+   deduplicateReplacementsByFile(FileToReplaces)) {
 const std::string &FilePath = FileAndReplaces.first;
 auto &CurReplaces = FileAndReplaces.second;
 
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
@@ -564,13 +565,15 @@
   return Result;
 }
 
-std::map
-groupReplacementsByFile(const Replacements &Replaces) {
-  std::map FileToReplaces;
-  for (const auto &Replace : Replaces)
-// We can ignore the Error here since \p Replaces is already conflict-free.
-FileToReplaces[Replace.getFilePath()].add(Replace);
-  return FileToReplaces;
+std::map deduplicateReplacementsByFile(
+const std::map &FileToReplaces) {
+  std::map Result;
+  for (const auto &Entry : FileToReplaces) {
+llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
+Result[CleanPath.str()] = std::move(Entry.second);
+  }
+  return Result;
 }
 
 } // end namespace tooling
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -230,8 +230,6 @@
   Replacements(const_iterator Begin, const_iterator End)
   : Replaces(Begin, End) {}
 
-  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;
@@ -294,10 +292,11 @@
 calculateRangesAfterReplacements(const Replacements &Replaces,
  const std::vector &Ranges);
 
-/// \brief Groups a random set of replacements by file path. Replacements
-/// related to the same file entry are put into the same vector.
-std::map
-groupReplacementsByFile(const Replacements &Replaces);
+/// \brief If there are multiple  pairs with the same file
+/// path after removing dots, we only keep one pair (with path after dots being
+/// removed) and discard the rest.
+std::map deduplicateReplacementsByFile(
+const std::map &FileToReplaces);
 
 template 
 Replacement::Replacement(const SourceManager &Sources,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25565: Deduplicate sets of replacements by file names.

2016-10-13 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 74531.
ioeric added a comment.

- Updated comments for RefactoringTool.


https://reviews.llvm.org/D25565

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

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -972,5 +972,23 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
+TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+  std::map FileToReplaces;
+  FileToReplaces["../../a/b/.././c.h"] = Replacements();
+  FileToReplaces["../../a/c.h"] = Replacements();
+  FileToReplaces = deduplicateReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, RemoveDotSlash) {
+  std::map FileToReplaces;
+  FileToReplaces["./a/b/.././c.h"] = Replacements();
+  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces = deduplicateReplacementsByFile(FileToReplaces);
+  EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,7 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
   bool Result = true;
-  for (const auto &Entry : FileToReplaces)
+  for (const auto &Entry : deduplicateReplacementsByFile(FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +73,8 @@
   FileManager &Files = SM.getFileManager();
 
   bool Result = true;
-  for (const auto &FileAndReplaces : FileToReplaces) {
+  for (const auto &FileAndReplaces :
+   deduplicateReplacementsByFile(FileToReplaces)) {
 const std::string &FilePath = FileAndReplaces.first;
 auto &CurReplaces = FileAndReplaces.second;
 
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
@@ -564,13 +565,15 @@
   return Result;
 }
 
-std::map
-groupReplacementsByFile(const Replacements &Replaces) {
-  std::map FileToReplaces;
-  for (const auto &Replace : Replaces)
-// We can ignore the Error here since \p Replaces is already conflict-free.
-FileToReplaces[Replace.getFilePath()].add(Replace);
-  return FileToReplaces;
+std::map deduplicateReplacementsByFile(
+const std::map &FileToReplaces) {
+  std::map Result;
+  for (const auto &Entry : FileToReplaces) {
+llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
+Result[CleanPath.str()] = std::move(Entry.second);
+  }
+  return Result;
 }
 
 } // end namespace tooling
Index: include/clang/Tooling/Refactoring.h
===
--- include/clang/Tooling/Refactoring.h
+++ include/clang/Tooling/Refactoring.h
@@ -55,6 +55,9 @@
 
   /// \brief Apply all stored replacements to the given Rewriter.
   ///
+  /// FileToReplaces will be deduplicated with `deduplicateReplacementsByFile`
+  /// before application.
+  ///
   /// Replacement applications happen independently of the success of other
   /// applications.
   ///
@@ -75,6 +78,9 @@
 ///
 /// \pre Replacements must be conflict-free.
 ///
+/// FileToReplaces will be deduplicated with `deduplicateReplacementsByFile`
+/// before application.
+///
 /// Replacement applications happen independently of the success of other
 /// applications.
 ///
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -230,8 +230,6 @@
   Replacements(const_iterator Begin, const_iterator End)
   : Replaces(Begin, End) {}
 
-  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;
@@ -294,10 +292,11 @@
 calculateRangesAfterReplacements(const Replacements &Replaces,
  const std::vector &Ranges);
 
-/// \brief Groups a random set of replacements by file path. Replacements
-/// related to the same file entry are put into the same vector.
-std::map

[PATCH] D25520: [CodeCompletion] Add block placeholders when completing member access for Objective-C block property setters

2016-10-13 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 74528.
arphaman added a comment.

The updated patch now treats the block property setter completion as a 
completion result that's additional to the default property completion result.


Repository:
  rL LLVM

https://reviews.llvm.org/D25520

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-block-property-assignment.m

Index: test/Index/complete-block-property-assignment.m
===
--- /dev/null
+++ test/Index/complete-block-property-assignment.m
@@ -0,0 +1,68 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+// rdar://28481726
+
+void func(int x);
+typedef int Foo;
+typedef void (^FooBlock)(Foo *someParameter);
+
+@interface Obj
+@property (readwrite, nonatomic, copy) void (^onAction)(Obj *object);
+@property (readwrite, nonatomic) int foo;
+@end
+
+@interface Test : Obj
+@property (readwrite, nonatomic, copy) FooBlock onEventHandler;
+@property (readonly, nonatomic, copy) void (^onReadonly)(int *someParameter);
+@property (readonly, nonatomic, strong) Obj *obj;
+@end
+
+@implementation Test
+
+#define SELFY self
+
+- (void)test {
+  self.foo = 2;
+  [self takeInt: 2]; self.foo = 2;
+  /* Comment */ self.foo = 2;
+  SELFY.foo = 2
+}
+
+// RUN: c-index-test -code-completion-at=%s:26:8 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:27:27 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:28:22 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:29:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction}{Equal  = }{Placeholder ^(Obj *object)} (38)
+// CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler}{Equal  = }{Placeholder ^(Foo *someParameter)} (38)
+// CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+
+- (void) takeInt:(int)x { }
+
+- (int) testFailures {
+  (self.foo);
+  int x = self.foo;
+  [self takeInt: self.foo];
+  if (self.foo) {
+func(self.foo);
+  }
+  return self.foo;
+}
+
+// RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-NO %s
+// RUN: c-index-test -code-completion-at=%s:48:16 %s | FileCheck -check-prefix=CHECK-NO %s
+// RUN: c-index-test -code-completion-at=%s:49:23 %s | FileCheck -check-prefix=CHECK-NO %s
+// RUN: c-index-test -code-completion-at=%s:50:12 %s | FileCheck -check-prefix=CHECK-NO %s
+// RUN: c-index-test -code-completion-at=%s:51:15 %s | FileCheck -check-prefix=CHECK-NO %s
+// RUN: c-index-test -code-completion-at=%s:53:15 %s | FileCheck -check-prefix=CHECK-NO %s
+// CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)
+// CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35)
+// CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35)
+// CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35)
+// CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35)
+
+@end
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -2212,6 +2212,7 @@
 static std::string
 formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto,
+   bool SuppressBlockName = false,
bool SuppressBlock = false,
Optional> ObjCSubsts = None);
 
@@ -2277,7 +2278,8 @@
 
   // We have the function prototype behind the block pointer type, as it was
   // written in the source.
-  return formatBlockPlaceholder(Policy, Param, Block, BlockProto, SuppressBlock,
+  return formatBlockPlaceholder(Policy, Param, Block, BlockProto,
+/*SuppressBlockName=*/false, SuppressBlock,
 ObjCSubsts);
 }
 
@@ -2293,7 +2295,7 @@
 static std::string
 formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto,
-   bool SuppressBlock,
+   bool SuppressBlockName, bool SuppressBlock,
Optional>

[PATCH] D25520: [CodeCompletion] Add block placeholders when completing member access for Objective-C block property setters

2016-10-13 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

Right now I gave the setter completion a flat priority bump of 3. Should 
something different be used? What do you think of the following possible 
priority heuristic: when completing blocks properties that return `void` the 
default property completion result should show up before the setter, otherwise 
the setter should show up before the property (we normally don't want to ignore 
the result of the call, right)?


Repository:
  rL LLVM

https://reviews.llvm.org/D25520



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


[PATCH] D25540: Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsics

2016-10-13 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 74533.
agutowski added a comment.

change checking prefix for x86 tests; use Int32 instead of UnsignedIntTy


https://reviews.llvm.org/D25540

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -1112,14 +1112,6 @@
 /**\
 |* Misc
 \**/
-static __inline__ void * __DEFAULT_FN_ATTRS
-_AddressOfReturnAddress(void) {
-  return (void*)((char*)__builtin_frame_address(0) + sizeof(void*));
-}
-static __inline__ void * __DEFAULT_FN_ATTRS
-_ReturnAddress(void) {
-  return __builtin_return_address(0);
-}
 #if defined(__i386__) || defined(__x86_64__)
 static __inline__ void __DEFAULT_FN_ATTRS
 __cpuid(int __info[4], int __level) {
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1147,6 +1147,10 @@
 Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);
 return RValue::get(Builder.CreateCall(F, Depth));
   }
+  case Builtin::BI_ReturnAddress: {
+Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);
+return RValue::get(Builder.CreateCall(F, Builder.getInt32(0)));
+  }
   case Builtin::BI__builtin_frame_address: {
 Value *Depth =
 CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy, this);
@@ -7697,7 +7701,11 @@
   case X86::BI_BitScanReverse:
   case X86::BI_BitScanReverse64:
 return EmitMSVCBuiltinExpr(MSVCIntrin::_BitScanReverse, E);
+  case X86::BI_AddressOfReturnAddress: {
+Value *F = CGM.getIntrinsic(Intrinsic::addressofreturnaddress);
+return Builder.CreateCall(F);
   }
+  }
 }
 
 
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -2039,6 +2039,8 @@
 TARGET_HEADER_BUILTIN(__emul,  "LLiii","nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -753,6 +753,7 @@
 LANGBUILTIN(__popcnt,   "UiUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt64, "ULLiULLi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__readfsdword,"ULiULi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_ReturnAddress, "v*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl8,  "UcUcUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl16, "UsUsUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl,   "UiUii", "n", ALL_MS_LANGUAGES)
Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
+// RUN: | FileCheck %s -check-prefixes CHECK,CHECK-I386,CHECK-INTEL
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN: -triple thumbv7--windows -Oz -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ARM-X64
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-ARM-X64
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -Oz -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64 --check-prefix=CHECK-ARM-X64
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-X64,CHECK-ARM-X64,CHECK-INTEL
 
 // intrin.h needs size_t, but -ffreestanding prevents us from getting it from
 // stddef.h.  Work around it with this typedef.
@@ -14,6 +14,22 @@
 
 #include 
 
+void *test_ReturnAddress() {
+  return _ReturnAddress();
+}
+// CHECK-LABEL: define{{.*}}i8* @test_ReturnAddress()
+// CHECK: = tail call i8* @llvm.returnaddress(i32 0)
+// CHECK: ret i8*
+
+#if defined(__i386__) || defined(__x86_64__)
+void *test_AddressOfReturnAddress() {
+  return _AddressOfReturnAddress();
+}
+// CHECK-INTEL-LABEL: define i8* @test_AddressOfReturnAddress()
+// CHECK-INTEL: = tail call i8* @llvm.addressofreturnaddress()
+// 

r284131 - Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsics

2016-10-13 Thread Albert Gutowski via cfe-commits
Author: agutowski
Date: Thu Oct 13 11:03:42 2016
New Revision: 284131

URL: http://llvm.org/viewvc/llvm-project?rev=284131&view=rev
Log:
Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsics

Reviewers: rnk, thakis, majnemer, hans

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=284131&r1=284130&r2=284131&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Thu Oct 13 11:03:42 2016
@@ -753,6 +753,7 @@ LANGBUILTIN(__popcnt16, "UsUs", "nc"
 LANGBUILTIN(__popcnt,   "UiUi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt64, "ULLiULLi", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__readfsdword,"ULiULi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_ReturnAddress, "v*", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl8,  "UcUcUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl16, "UsUsUc","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_rotl,   "UiUii", "n", ALL_MS_LANGUAGES)

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=284131&r1=284130&r2=284131&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Oct 13 11:03:42 2016
@@ -2039,6 +2039,8 @@ TARGET_HEADER_BUILTIN(_WriteBarrier,
 TARGET_HEADER_BUILTIN(__emul,  "LLiii","nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
 TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi", "nh", "intrin.h", ALL_MS_LANGUAGES, 
"")
 
+TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=284131&r1=284130&r2=284131&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Oct 13 11:03:42 2016
@@ -1147,6 +1147,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);
 return RValue::get(Builder.CreateCall(F, Depth));
   }
+  case Builtin::BI_ReturnAddress: {
+Value *F = CGM.getIntrinsic(Intrinsic::returnaddress);
+return RValue::get(Builder.CreateCall(F, Builder.getInt32(0)));
+  }
   case Builtin::BI__builtin_frame_address: {
 Value *Depth =
 CGM.EmitConstantExpr(E->getArg(0), getContext().UnsignedIntTy, this);
@@ -7697,6 +7701,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI_BitScanReverse:
   case X86::BI_BitScanReverse64:
 return EmitMSVCBuiltinExpr(MSVCIntrin::_BitScanReverse, E);
+  case X86::BI_AddressOfReturnAddress: {
+Value *F = CGM.getIntrinsic(Intrinsic::addressofreturnaddress);
+return Builder.CreateCall(F);
+  }
   }
 }
 

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=284131&r1=284130&r2=284131&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Oct 13 11:03:42 2016
@@ -1112,14 +1112,6 @@ __stosq(unsigned __int64 *__dst, unsigne
 
/**\
 |* Misc
 
\**/
-static __inline__ void * __DEFAULT_FN_ATTRS
-_AddressOfReturnAddress(void) {
-  return (void*)((char*)__builtin_frame_address(0) + sizeof(void*));
-}
-static __inline__ void * __DEFAULT_FN_ATTRS
-_ReturnAddress(void) {
-  return __builtin_return_address(0);
-}
 #if defined(__i386__) || defined(__x86_64__)
 static __inline__ void __DEFAULT_FN_ATTRS
 __cpuid(int __info[4], int __level) {

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=284131&r1=284130&r2=284131&view=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Thu Oct 13 11:03:42 2016
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
-// RUN: | FileCheck %s -

[PATCH] D7842: Make clang-format-diff compatible with Python 3.4

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

This patch needs rebasing.


https://reviews.llvm.org/D7842



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


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

The print related changes were added in in r280240 
(https://reviews.llvm.org/D23319). Could you rebase the patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



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


[PATCH] D25565: Deduplicate sets of replacements by file names.

2016-10-13 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: include/clang/Tooling/Core/Replacement.h:233
 
-  Replacements mergeReplacements(const ReplacementsImpl &Second) const;
-

This is dead code.


https://reviews.llvm.org/D25565



___
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-10-13 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp:8
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names 
per declaration [cppcoreguidelines-one-name-per-declaration]

malcolm.parsons wrote:
> omtcyfz wrote:
> > malcolm.parsons wrote:
> > > The guideline says "Flag non-function arguments with multiple declarators 
> > > involving declarator operators (e.g., int* p, q;)".
> > > 
> > > There are no declarator operators in this test, so there should be no 
> > > warning.
> > The guideline says
> > 
> > > Reason: One-declaration-per line increases readability and avoids 
> > > mistakes related to the C/C++ grammar. It also leaves room for a more 
> > > descriptive end-of-line comment.
> > 
> > > Exception: a function declaration can contain several function argument 
> > > declarations.
> > 
> > I'm not sure why what you copied is written in "Enforcement" section, but I 
> > do not think that is how it should be handled. I am concerned not only 
> > about that specific case and I see no reason to cut off cases already 
> > presented in this test.
> "mistakes related to the C/C++ grammar" only occur when declarator operators 
> are involved. e.g. in `int* p, q` a reader might incorrectly think that q was 
> a pointer.
> 
> I see reasons not to warn about cases like
> `for (auto i = c.begin(), e = someExpensiveFn(); i != e; i++)`
> `for (int i = 0, j = someExpensiveFn(); i < j; i++);`
> because the alternatives increase variable scope, or for
> `int x = 42, y = 43;`
> because it's not difficult to read.
> 
> As we disagree on this, can it be made configurable?
We usually try to ensure that the check matches the behavior required by the 
normative wording of coding rules we follow. Based on that, the C++ core 
guideline rule only cares about declarator operators while the CERT 
recommendation kind of does not care about them. If you think the C++ core 
guideline enforcement is wrong, you can file a bug against that project to see 
if the editors agree, but I think the check should match the documented 
behavior from the guidelines. FWIW, I'm happy to work on the CERT semantics if 
you don't want to deal with those beyond what you've already done (or you can 
tackle the semantic differences if you want).


https://reviews.llvm.org/D25024



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


[PATCH] D25541: [CUDA] Emit deferred diagnostics during Sema rather than during codegen.

2016-10-13 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Nice! Looks like this wasn't too bad.




Comment at: clang/lib/Sema/SemaCUDA.cpp:546
+  // Externally-visible and similar functions are always emitted.
+  if (S.getASTContext().GetGVALinkageForFunction(FD) > GVA_DiscardableODR)
+return true;

There are two other instances of conditions equivalent to this in 
`ASTContext::DeclMustBeEmitted`. You should add a predicate like 
`isDiscardableGVALinkage(GVALinkage)` to Linkage.h and call it in 
`DeclMustBeEmitted`.



Comment at: clang/lib/Sema/SemaCUDA.cpp:654
+
+for (FunctionDecl *Callee : CGIt->second) {
+  if (Seen.count(Callee) || IsKnownEmitted(S, Callee))

This is iterating a DenseSet of pointers, so it'll be non-determinstic. Use 
SetVector to get a determinstically ordered set.


https://reviews.llvm.org/D25541



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


[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-13 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from some minor nits, the attribute functionality looks fine to me. As to 
whether we think this is a worthy attribute to add or not, I leave that to 
people who know CUDA and OpenCL better than I do, so please wait for 
@tstellarAMD or @Anastasia to sign off before committing.




Comment at: include/clang/Basic/AttrDocs.td:612
+  let Content = [{
+The ``convergent`` attribute can be placed on function declarations. It is
+translated to LLVM ``convergent`` attribute, which indicates the call

aaron.ballman wrote:
> on a function declaration
"declarations" should be singular (declaration).



Comment at: test/SemaOpenCL/convergent.cl:1
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify %s
+

Should add `-fsyntax-only` to the test.


https://reviews.llvm.org/D25343



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


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-13 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: modocache, beanz.

Use the -print-libgcc-file-name compiler option to obtain the path to
libgcc or an equivalent compiler runtime library, rather than hardcoding
-lgcc_s. This aims to make it possible to avoid linking with -lgcc_s
when -rtlib=compiler-rt is used along with libunwind.


https://reviews.llvm.org/D25568

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_C_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_C_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-13 Thread Michał Górny via cfe-commits
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74536.

https://reviews.llvm.org/D25568

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-13 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 74538.
mgorny added a comment.

Fixed indentation.


https://reviews.llvm.org/D25568

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if (${libgcc_check_ret} EQUAL 0)
+add_library_flags("${libgcc_path}")
+  else()
+add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+  endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if (${libgcc_check_ret} EQUAL 0)
+add_library_flags("${libgcc_path}")
+  else()
+add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+  endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25520: [CodeCompletion] Add block placeholders when completing member access for Objective-C block property setters

2016-10-13 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

>   What do you think of the following possible priority heuristic

SGTM.

Changes LGTM. I'd also recommend that as a follow-up patch it would be great to 
extend the setter completion to variables as well (global variables, fields, 
ivars, etc.)


Repository:
  rL LLVM

https://reviews.llvm.org/D25520



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


Re: libunwind build regression fix

2016-10-13 Thread Jeremy Huddleston Sequoia via cfe-commits
Thanks.

> On Oct 13, 2016, at 07:42, Asiri Rathnayake  wrote:
> 
> Hi Jeremy,
> 
> Thanks for the patch, committed as r284125.
> 
> Cheers,
> 
> / Asiri
> 
> 
> From: jerem...@apple.com  on behalf of Jeremy Huddleston 
> Sequoia 
> Sent: 13 October 2016 06:57
> To: Asiri Rathnayake
> Subject: libunwind build regression fix
> 
> Hi Asiri,
> 
> Could you please push this build fix to libunwind.  Your 
> LIBUNWIND_ENABLE_CROSS_UNWINDING change a few months ago introduced a build 
> failure because uint64_t is used in config.h without an include of  
> (failure noticed on macOS versions older than 10.9).
> 
> Thanks,
> Jeremy
> 
> 
> From 59508d1029580fe2f95eb4b8a002175c6f87710d Mon Sep 17 00:00:00 2001
> From: Jeremy Huddleston Sequoia 
> Date: Wed, 12 Oct 2016 22:52:51 -0700
> Subject: [PATCH] config.h: Add missing include of stdint.h for uint64_t usage
> 
> Regressed-in: trunk r270692
> Regressed-in: d2d1ea9d75dfc4f55540f7e3cf940c6a1d6674cc
> Signed-off-by: Jeremy Huddleston Sequoia 
> CC: Asiri Rathnayake 
> ---
> src/config.h | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/src/config.h b/src/config.h
> index cfe7706..4e4dd99 100644
> --- a/src/config.h
> +++ b/src/config.h
> @@ -16,6 +16,7 @@
> 
> #include 
> #include 
> +#include 
> #include 
> 
> // Define static_assert() unless already defined by compiler.
> --
> 2.9.3
> 
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.
> 



smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284133 - Add more 64bit swiftcall convention tests

2016-10-13 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Thu Oct 13 12:17:36 2016
New Revision: 284133

URL: http://llvm.org/viewvc/llvm-project?rev=284133&view=rev
Log:
Add more 64bit swiftcall convention tests

Added:
cfe/trunk/test/CodeGen/64bit-swiftcall.c

Added: cfe/trunk/test/CodeGen/64bit-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284133&view=auto
==
--- cfe/trunk/test/CodeGen/64bit-swiftcall.c (added)
+++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 12:17:36 2016
@@ -0,0 +1,696 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o 
- %s | FileCheck %s
+
+#define SWIFTCALL __attribute__((swiftcall))
+#define OUT __attribute__((swift_indirect_result))
+#define ERROR __attribute__((swift_error_result))
+#define CONTEXT __attribute__((swift_context))
+
+// CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant 
[[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, float 0.00e+00, float 
0.00e+00 }
+
+/*/
+/** PARAMETER ABIS ***/
+/*/
+
+SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {}
+// CHECK-LABEL: define {{.*}} void @indirect_result_1(i32* noalias sret align 
4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}})
+
+// TODO: maybe this shouldn't suppress sret.
+SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) {  
__builtin_unreachable(); }
+// CHECK-LABEL: define {{.*}} i32 @indirect_result_2(i32* noalias align 4 
dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}})
+
+typedef struct { char array[1024]; } struct_reallybig;
+SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { 
__builtin_unreachable(); }
+// CHECK-LABEL: define {{.*}} void @indirect_result_3({{.*}}* noalias sret 
{{.*}}, i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 
dereferenceable(4){{.*}})
+
+SWIFTCALL void context_1(CONTEXT void *self) {}
+// CHECK-LABEL: define {{.*}} void @context_1(i8* swiftself
+
+SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {}
+// CHECK-LABEL: define {{.*}} void @context_2(i8*{{.*}}, i8* swiftself
+
+SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {}
+// CHECK-LABEL: define {{.*}} void @context_error_1(i32* swiftself{{.*}}, 
float** swifterror)
+// CHECK:   [[TEMP:%.*]] = alloca float*, align 8
+// CHECK:   [[T0:%.*]] = load float*, float** [[ERRORARG:%.*]], align 8
+// CHECK:   store float* [[T0]], float** [[TEMP]], align 8
+// CHECK:   [[T0:%.*]] = load float*, float** [[TEMP]], align 8
+// CHECK:   store float* [[T0]], float** [[ERRORARG]], align 8
+void test_context_error_1() {
+  int x;
+  float *error;
+  context_error_1(&x, &error);
+}
+// CHECK-LABEL: define void @test_context_error_1()
+// CHECK:   [[X:%.*]] = alloca i32, align 4
+// CHECK:   [[ERROR:%.*]] = alloca float*, align 8
+// CHECK:   [[TEMP:%.*]] = alloca swifterror float*, align 8
+// CHECK:   [[T0:%.*]] = load float*, float** [[ERROR]], align 8
+// CHECK:   store float* [[T0]], float** [[TEMP]], align 8
+// CHECK:   call [[SWIFTCC:swiftcc]] void @context_error_1(i32* swiftself 
[[X]], float** swifterror [[TEMP]])
+// CHECK:   [[T0:%.*]] = load float*, float** [[TEMP]], align 8
+// CHECK:   store float* [[T0]], float** [[ERROR]], align 8
+
+SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float 
**error) {}
+// CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, i32* 
swiftself{{.*}}, float** swifterror)
+
+/*/
+/** LOWERING */
+/*/
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef float float8 __attribute__((ext_vector_type(8)));
+typedef double double2 __attribute__((ext_vector_type(2)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+typedef int int5 __attribute__((ext_vector_type(5)));
+typedef int int8 __attribute__((ext_vector_type(8)));
+
+#define TEST(TYPE)   \
+  SWIFTCALL TYPE return_##TYPE(void) {   \
+TYPE result = {};\
+return result;   \
+  }  \
+  SWIFTCALL void take_##TYPE(TYPE v) {   \
+  }  \
+  void test_##TYPE() {   \
+take_##

[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-13 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 74541.
yaxunl added a comment.

Minor revision by Aaron's comments.


https://reviews.llvm.org/D25343

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Headers/opencl-c.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/convergent.cl
  test/SemaOpenCL/convergent.cl

Index: test/SemaOpenCL/convergent.cl
===
--- /dev/null
+++ test/SemaOpenCL/convergent.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -fsyntax-only -verify %s
+
+void f1(void) __attribute__((convergent));
+
+void f2(void) __attribute__((convergent(1))); // expected-error {{'convergent' attribute takes no arguments}}
+
+void f3(int a __attribute__((convergent))); // expected-warning {{'convergent' attribute only applies to functions}}
+
+void f4(void) {
+  int var1 __attribute__((convergent)); // expected-warning {{'convergent' attribute only applies to functions}}
+}
+
Index: test/CodeGenOpenCL/convergent.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/convergent.cl
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+void convfun(void) __attribute__((convergent));
+void non_convfun(void);
+void nodupfun(void) __attribute__((noduplicate));
+
+void f(void);
+void g(void);
+
+// Test two if's are merged and non_convfun duplicated.
+// The LLVM IR is equivalent to:
+//if (a) {
+//  f();
+//  non_convfun();
+//  g();
+//} else {
+//  non_conffun();
+//}
+//
+// CHECK: define spir_func void @test_merge_if(i32 %[[a:.+]])
+// CHECK: %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK: br i1 %[[tobool]], label %[[if_end3_critedge:.+]], label %[[if_then:.+]]
+// CHECK: [[if_then]]:
+// CHECK: tail call spir_func void @f()
+// CHECK: tail call spir_func void @non_convfun()
+// CHECK: tail call spir_func void @g()
+// CHECK: br label %[[if_end3:.+]]
+// CHECK: [[if_end3_critedge]]:
+// CHECK: tail call spir_func void @non_convfun()
+// CHECK: br label %[[if_end3]]
+// CHECK: [[if_end3]]:
+// CHECK-LABEL: ret void
+
+void test_merge_if(int a) {
+  if (a) {
+f();
+  }
+  non_convfun();
+  if (a) {
+g();
+  }
+}
+
+// CHECK-DAG: declare spir_func void @f()
+// CHECK-DAG: declare spir_func void @non_convfun()
+// CHECK-DAG: declare spir_func void @g()
+
+// Test two if's are not merged.
+// CHECK: define spir_func void @test_no_merge_if(i32 %[[a:.+]])
+// CHECK:  %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK: br i1 %[[tobool]], label %[[if_end:.+]], label %[[if_then:.+]]
+// CHECK: [[if_then]]:
+// CHECK: tail call spir_func void @f()
+// CHECK-NOT: call spir_func void @non_convfun()
+// CHECK-NOT: call spir_func void @g()
+// CHECK: br label %[[if_end]]
+// CHECK: [[if_end]]:
+// CHECK:  %[[tobool_pr:.+]] = phi i1 [ true, %[[if_then]] ], [ false, %{{.+}} ]
+// CHECK:  tail call spir_func void @convfun() #[[attr5:.+]]
+// CHECK:  br i1 %[[tobool_pr]], label %[[if_then2:.+]], label %[[if_end3:.+]]
+// CHECK: [[if_then2]]:
+// CHECK: tail call spir_func void @g()
+// CHECK:  br label %[[if_end3:.+]]
+// CHECK: [[if_end3]]:
+// CHECK-LABEL:  ret void
+
+void test_no_merge_if(int a) {
+  if (a) {
+f();
+  }
+  convfun();
+  if(a) {
+g();
+  }
+}
+
+// CHECK: declare spir_func void @convfun(){{[^#]*}} #[[attr2:[0-9]+]]
+
+// Test loop is unrolled for convergent function.
+// CHECK-LABEL: define spir_func void @test_unroll()
+// CHECK:  tail call spir_func void @convfun() #[[attr5:[0-9]+]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK-LABEL:  ret void
+
+void test_unroll() {
+  for (int i = 0; i < 10; i++)
+convfun();
+}
+
+// Test loop is not unrolled for noduplicate function.
+// CHECK-LABEL: define spir_func void @test_not_unroll()
+// CHECK:  br label %[[for_body:.+]]
+// CHECK: [[for_cond_cleanup:.+]]:
+// CHECK:  ret void
+// CHECK: [[for_body]]:
+// CHECK:  tail call spir_func void @nodupfun() #[[attr6:[0-9]+]]
+// CHECK-NOT: call spir_func void @nodupfun()
+// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
+
+void test_not_unroll() {
+  for (int i = 0; i < 10; i++)
+nodupfun();
+}
+
+// CHECK: declare spir_func void @nodupfun(){{[^#]*}} #[[attr3:[0-9]+]]
+
+// CHECK-DAG: attributes #[[attr2]] = { {{[^}]*}}convergent{{[^}]*}} }
+// CHECK-DAG: attributes #[[attr3]] = { {{[^}]*}}noduplicate{{[^}]*}} }
+// CHECK-DAG: at

[PATCH] D25537: [ThinLTO] Update doc to include lld

2016-10-13 Thread Davide Italiano via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284137: [ThinLTO] Update doc to include lld (now supported). 
(authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D25537?vs=74459&id=74545#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25537

Files:
  cfe/trunk/docs/ThinLTO.rst


Index: cfe/trunk/docs/ThinLTO.rst
===
--- cfe/trunk/docs/ThinLTO.rst
+++ cfe/trunk/docs/ThinLTO.rst
@@ -62,8 +62,8 @@
   `_.
 - **ld64**:
   Starting with `Xcode 8 `_.
-
-Additionally, support is being added to the *lld* linker.
+- **lld**:
+  Starting with r284050 (ELF only).
 
 Usage
 =
@@ -109,6 +109,8 @@
   ``-Wl,-plugin-opt,jobs=N``
 - ld64:
   ``-Wl,-mllvm,-threads=N``
+- lld:
+  ``-Wl,--thinlto-jobs=N``
 
 Incremental
 ---


Index: cfe/trunk/docs/ThinLTO.rst
===
--- cfe/trunk/docs/ThinLTO.rst
+++ cfe/trunk/docs/ThinLTO.rst
@@ -62,8 +62,8 @@
   `_.
 - **ld64**:
   Starting with `Xcode 8 `_.
-
-Additionally, support is being added to the *lld* linker.
+- **lld**:
+  Starting with r284050 (ELF only).
 
 Usage
 =
@@ -109,6 +109,8 @@
   ``-Wl,-plugin-opt,jobs=N``
 - ld64:
   ``-Wl,-mllvm,-threads=N``
+- lld:
+  ``-Wl,--thinlto-jobs=N``
 
 Incremental
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284137 - [ThinLTO] Update doc to include lld (now supported).

2016-10-13 Thread Davide Italiano via cfe-commits
Author: davide
Date: Thu Oct 13 12:42:38 2016
New Revision: 284137

URL: http://llvm.org/viewvc/llvm-project?rev=284137&view=rev
Log:
[ThinLTO] Update doc to include lld (now supported).

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

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=284137&r1=284136&r2=284137&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Thu Oct 13 12:42:38 2016
@@ -62,8 +62,8 @@ ThinLTO is currently supported for the f
   `_.
 - **ld64**:
   Starting with `Xcode 8 `_.
-
-Additionally, support is being added to the *lld* linker.
+- **lld**:
+  Starting with r284050 (ELF only).
 
 Usage
 =
@@ -109,6 +109,8 @@ be reduced to ``N`` via:
   ``-Wl,-plugin-opt,jobs=N``
 - ld64:
   ``-Wl,-mllvm,-threads=N``
+- lld:
+  ``-Wl,--thinlto-jobs=N``
 
 Incremental
 ---


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


[PATCH] D25448: [ubsan] Disable -fsanitize=vptr checks for devirtualized calls

2016-10-13 Thread John McCall via cfe-commits
rjmccall requested changes to this revision.
rjmccall added inline comments.
This revision now requires changes to proceed.



Comment at: lib/CodeGen/CodeGenFunction.h:379
+  /// Set of object pointers which are blacklisted from the UB sanitizer.
+  llvm::SmallPtrSet SanitizerBasePointerBlacklist;
+

Please find some way to do this that doesn't require adding new tracking state 
like this.  It should be quite easy to pass down that a call was devirtualized.


https://reviews.llvm.org/D25448



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


[PATCH] D25539: [Coverage] Support for C++17 switch initializers

2016-10-13 Thread Vedant Kumar via cfe-commits
vsk updated the summary for this revision.
vsk updated this revision to Diff 74552.
vsk added a comment.

Per @arphaman's comments:

- Add a CodeGenPGO test which checks whether counters can be created for 
statements inside of switch initializers.
- Group calls to 'Visit' together.


https://reviews.llvm.org/D25539

Files:
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/switch.c
  test/CoverageMapping/switch.cpp
  test/Profile/cxx-stmt-initializers.cpp

Index: test/Profile/cxx-stmt-initializers.cpp
===
--- /dev/null
+++ test/Profile/cxx-stmt-initializers.cpp
@@ -0,0 +1,17 @@
+// Tests for instrumentation of C++17 statement initializers
+
+// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-stmt-initializers.cpp -std=c++1z -o - -emit-llvm -fprofile-instrument=clang > %tgen
+// RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
+
+// PGOGEN: @[[SIC:__profc__Z11switch_initv]] = private global [3 x i64] zeroinitializer
+
+// Note: We expect counters for the function entry block, the condition in the
+// switch initializer, and the switch successor block.
+//
+// CHECK-LABEL: define {{.*}}void @_Z11switch_initv()
+// PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 0
+void switch_init() {
+  switch (int i = true ? 0 : 1; i) {}
+  // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 2
+  // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 1
+}
Index: test/CoverageMapping/switch.cpp
===
--- test/CoverageMapping/switch.cpp
+++ test/CoverageMapping/switch.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple -main-file-name switch.cpp %s | FileCheck %s
+
 // CHECK: foo
 void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
   switch(i) {
@@ -10,7 +11,7 @@
   int x = 0;// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
 }
 
-void nop() {}
+int nop() { return 0; }
 
 // CHECK: bar
 void bar(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+20]]:2 = #0
@@ -35,8 +36,16 @@
   nop();// CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #6
 }
 
+// CHECK: baz
+void baz() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+5]]:2 = #0
+  switch (int i = true ? nop()  // CHECK-NEXT: [[@LINE]]:26 -> [[@LINE]]:31 = #2
+   : nop(); // CHECK-NEXT: [[@LINE]]:26 -> [[@LINE]]:31 = (#0 - #2)
+  i) {}
+  nop();// CHECK-NEXT: [[@LINE]]:3 -> [[@LINE+1]]:2 = #1
+}
+
 // CHECK-NEXT: main
-int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0
+int main() {// CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+35]]:2 = #0
   int i = 0;
   switch(i) {
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+7]]:10 = #2
@@ -48,7 +57,7 @@
   default:  // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4
 break;
   }
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+22]]:2 = #1
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+23]]:2 = #1
   case 0:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+6]]:10 = #6
 i = 1;
 break;
@@ -58,16 +67,17 @@
 break;
   }
 
-  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+12]]:2 = #5
+  switch(i) {   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+13]]:2 = #5
   case 1:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+5]]:11 = #10
   case 2:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+4]]:11 = (#10 + #11)
 i = 11;
   case 3:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = ((#10 + #11) + #12)
   case 4:   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = (((#10 + #11) + #12) + #13)
 i = 99;
   }
 
-  foo(1);   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = #9
+  foo(1);   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:11 = #9
   bar(1);
+  baz();
   return 0;
 }
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -813,6 +813,8 @@
 
   void VisitSwitchStmt(const SwitchStmt *S) {
 extendRegion(S);
+if (S->getInit())
+  Visit(S->getInit());
 Visit(S->getCond());
 
 BreakContinueStack.push_back(BreakContinue());
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -458,6 +458,8 @@
 
   void VisitSwitchStmt(const 

r284140 - Pass -ffunction-sections/-fdata-sections along to gold-plugin

2016-10-13 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Oct 13 13:05:53 2016
New Revision: 284140

URL: http://llvm.org/viewvc/llvm-project?rev=284140&view=rev
Log:
Pass -ffunction-sections/-fdata-sections along to gold-plugin

Summary:
These options need to be passed to the plugin in order to have
an effect on LTO/ThinLTO compiles.

Reviewers: mehdi_amini, pcc

Subscribers: jfb, dschuff, mehdi_amini, cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284140&r1=284139&r2=284140&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 13 13:05:53 2016
@@ -2002,6 +2002,14 @@ static unsigned getLTOParallelism(const
   return Parallelism;
 }
 
+// CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
+// default.
+static bool isUseSeparateSections(const llvm::Triple &Triple) {
+  return Triple.getOS() == llvm::Triple::CloudABI ||
+ Triple.getArch() == llvm::Triple::wasm32 ||
+ Triple.getArch() == llvm::Triple::wasm64;
+}
+
 static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
   ArgStringList &CmdArgs, bool IsThinLTO,
   const Driver &D) {
@@ -2051,6 +2059,19 @@ static void AddGoldPlugin(const ToolChai
 else
   CmdArgs.push_back("-plugin-opt=-debugger-tune=gdb");
   }
+
+  bool UseSeparateSections =
+  isUseSeparateSections(ToolChain.getEffectiveTriple());
+
+  if (Args.hasFlag(options::OPT_ffunction_sections,
+   options::OPT_fno_function_sections, UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-function-sections");
+  }
+
+  if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
+   UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-data-sections");
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
@@ -4763,11 +4784,7 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back("-generate-type-units");
   }
 
-  // CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
-  // default.
-  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI ||
- Triple.getArch() == llvm::Triple::wasm32 ||
- Triple.getArch() == llvm::Triple::wasm64;
+  bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
options::OPT_fno_function_sections, UseSeparateSections)) {

Added: cfe/trunk/test/Driver/gold-lto-sections.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto-sections.c?rev=284140&view=auto
==
--- cfe/trunk/test/Driver/gold-lto-sections.c (added)
+++ cfe/trunk/test/Driver/gold-lto-sections.c Thu Oct 13 13:05:53 2016
@@ -0,0 +1,8 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -ffunction-sections -fdata-sections \
+// RUN: | FileCheck %s
+// CHECK: "-plugin-opt=-function-sections"
+// CHECK: "-plugin-opt=-data-sections"


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


[PATCH] D24644: Pass -ffunction-sections/-fdata-sections along to gold-plugin

2016-10-13 Thread Teresa Johnson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284140: Pass -ffunction-sections/-fdata-sections along to 
gold-plugin (authored by tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D24644?vs=71591&id=74555#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24644

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/gold-lto-sections.c


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2002,6 +2002,14 @@
   return Parallelism;
 }
 
+// CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
+// default.
+static bool isUseSeparateSections(const llvm::Triple &Triple) {
+  return Triple.getOS() == llvm::Triple::CloudABI ||
+ Triple.getArch() == llvm::Triple::wasm32 ||
+ Triple.getArch() == llvm::Triple::wasm64;
+}
+
 static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
   ArgStringList &CmdArgs, bool IsThinLTO,
   const Driver &D) {
@@ -2051,6 +2059,19 @@
 else
   CmdArgs.push_back("-plugin-opt=-debugger-tune=gdb");
   }
+
+  bool UseSeparateSections =
+  isUseSeparateSections(ToolChain.getEffectiveTriple());
+
+  if (Args.hasFlag(options::OPT_ffunction_sections,
+   options::OPT_fno_function_sections, UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-function-sections");
+  }
+
+  if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
+   UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-data-sections");
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
@@ -4763,11 +4784,7 @@
 CmdArgs.push_back("-generate-type-units");
   }
 
-  // CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
-  // default.
-  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI ||
- Triple.getArch() == llvm::Triple::wasm32 ||
- Triple.getArch() == llvm::Triple::wasm64;
+  bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
options::OPT_fno_function_sections, UseSeparateSections)) {
Index: cfe/trunk/test/Driver/gold-lto-sections.c
===
--- cfe/trunk/test/Driver/gold-lto-sections.c
+++ cfe/trunk/test/Driver/gold-lto-sections.c
@@ -0,0 +1,8 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -ffunction-sections -fdata-sections \
+// RUN: | FileCheck %s
+// CHECK: "-plugin-opt=-function-sections"
+// CHECK: "-plugin-opt=-data-sections"


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -2002,6 +2002,14 @@
   return Parallelism;
 }
 
+// CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
+// default.
+static bool isUseSeparateSections(const llvm::Triple &Triple) {
+  return Triple.getOS() == llvm::Triple::CloudABI ||
+ Triple.getArch() == llvm::Triple::wasm32 ||
+ Triple.getArch() == llvm::Triple::wasm64;
+}
+
 static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
   ArgStringList &CmdArgs, bool IsThinLTO,
   const Driver &D) {
@@ -2051,6 +2059,19 @@
 else
   CmdArgs.push_back("-plugin-opt=-debugger-tune=gdb");
   }
+
+  bool UseSeparateSections =
+  isUseSeparateSections(ToolChain.getEffectiveTriple());
+
+  if (Args.hasFlag(options::OPT_ffunction_sections,
+   options::OPT_fno_function_sections, UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-function-sections");
+  }
+
+  if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
+   UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-data-sections");
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
@@ -4763,11 +4784,7 @@
 CmdArgs.push_back("-generate-type-units");
   }
 
-  // CloudABI and WebAssembly use -ffunction-sections and -fdata-sections by
-  // default.
-  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI ||
- Triple.getArch() == llvm::Triple::wasm32 ||
- Triple.getArch() == llvm::Triple::wasm64;
+  bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
options::OPT_fno_function_sections, UseSeparateSections)) {
Index: cfe/trunk/test/Driver/gold-lto-sections.c
===

[PATCH] D25283: AvailabilityAttrs: Refactor context checking when diagnosing an availability violation

2016-10-13 Thread Erik Pilkington via cfe-commits
erik.pilkington updated this revision to Diff 74547.
erik.pilkington added a comment.

This new patch fixes the style issues @aaron.ballman and @manmanren brought up.
Thanks,
Erik


https://reviews.llvm.org/D25283

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  test/SemaObjC/class-unavail-warning.m

Index: test/SemaObjC/class-unavail-warning.m
===
--- test/SemaObjC/class-unavail-warning.m
+++ test/SemaObjC/class-unavail-warning.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only  -triple x86_64-apple-darwin10 -verify %s
+// RUN: %clang_cc1  -fsyntax-only -fblocks -triple x86_64-apple-darwin10 -verify %s
 // rdar://9092208
 
 __attribute__((unavailable("not available")))
@@ -98,3 +98,19 @@
 @end
 @interface UnavailSub(cat) // no error
 @end
+
+int unavail_global UNAVAILABLE;
+
+UNAVAILABLE __attribute__((objc_root_class))
+@interface TestAttrContext
+-meth;
+@end
+
+@implementation TestAttrContext
+-meth {
+  unavail_global = 2; // no warn
+  (void) ^{
+unavail_global = 4; // no warn
+  };
+}
+@end
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -103,17 +103,17 @@
   return false;
 }
 
-AvailabilityResult Sema::ShouldDiagnoseAvailabilityOfDecl(
-NamedDecl *&D, VersionTuple ContextVersion, std::string *Message) {
-  AvailabilityResult Result = D->getAvailability(Message, ContextVersion);
+AvailabilityResult
+Sema::ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D, std::string *Message) {
+  AvailabilityResult Result = D->getAvailability(Message);
 
   // For typedefs, if the typedef declaration appears available look
   // to the underlying type to see if it is more restrictive.
   while (const TypedefNameDecl *TD = dyn_cast(D)) {
 if (Result == AR_Available) {
   if (const TagType *TT = TD->getUnderlyingType()->getAs()) {
 D = TT->getDecl();
-Result = D->getAvailability(Message, ContextVersion);
+Result = D->getAvailability(Message);
 continue;
   }
 }
@@ -124,26 +124,18 @@
   if (ObjCInterfaceDecl *IDecl = dyn_cast(D)) {
 if (IDecl->getDefinition()) {
   D = IDecl->getDefinition();
-  Result = D->getAvailability(Message, ContextVersion);
+  Result = D->getAvailability(Message);
 }
   }
 
   if (const EnumConstantDecl *ECD = dyn_cast(D))
 if (Result == AR_Available) {
   const DeclContext *DC = ECD->getDeclContext();
   if (const EnumDecl *TheEnumDecl = dyn_cast(DC))
-Result = TheEnumDecl->getAvailability(Message, ContextVersion);
+Result = TheEnumDecl->getAvailability(Message);
 }
 
-  switch (Result) {
-  case AR_Available:
-return Result;
-
-  case AR_Unavailable:
-  case AR_Deprecated:
-return getCurContextAvailability() != Result ? Result : AR_Available;
-
-  case AR_NotYetIntroduced: {
+  if (Result == AR_NotYetIntroduced) {
 // Don't do this for enums, they can't be redeclared.
 if (isa(D) || isa(D))
   return AR_Available;
@@ -166,23 +158,18 @@
 
 return Warn ? AR_NotYetIntroduced : AR_Available;
   }
-  }
-  llvm_unreachable("Unknown availability result!");
+
+  return Result;
 }
 
 static void
 DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
const ObjCInterfaceDecl *UnknownObjCClass,
bool ObjCPropertyAccess) {
-  VersionTuple ContextVersion;
-  if (const DeclContext *DC = S.getCurObjCLexicalContext())
-ContextVersion = S.getVersionForDecl(cast(DC));
-
   std::string Message;
-  // See if this declaration is unavailable, deprecated, or partial in the
-  // current context.
+  // See if this declaration is unavailable, deprecated, or partial.
   if (AvailabilityResult Result =
-  S.ShouldDiagnoseAvailabilityOfDecl(D, ContextVersion, &Message)) {
+  S.ShouldDiagnoseAvailabilityOfDecl(D, &Message)) {
 
 if (Result == AR_NotYetIntroduced && S.getCurFunctionOrMethodDecl()) {
   S.getEnclosingFunction()->HasPotentialAvailabilityViolations = true;
@@ -192,8 +179,7 @@
 const ObjCPropertyDecl *ObjCPDecl = nullptr;
 if (const ObjCMethodDecl *MD = dyn_cast(D)) {
   if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) {
-AvailabilityResult PDeclResult =
-PD->getAvailability(nullptr, ContextVersion);
+AvailabilityResult PDeclResult = PD->getAvailability(nullptr);
 if (PDeclResult == Result)
   ObjCPDecl = PD;
   }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6313,30 +6313,6 @@
   diag.Triggered = true;
 }
 
-static bool isDeclDeprecated(Decl *D) {
-  do {
-if (D->isDeprecated())
-  return true;
-// A category implicitly has the availability of the interface.

[PATCH] D25283: AvailabilityAttrs: Refactor context checking when diagnosing an availability violation

2016-10-13 Thread Erik Pilkington via cfe-commits
erik.pilkington added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:179
-  if (const DeclContext *DC = S.getCurObjCLexicalContext())
-ContextVersion = S.getVersionForDecl(cast(DC));
-

manmanren wrote:
> I don't quite get why we can remove the above logic (i.e why we can avoid 
> passing ContextVersion when diagnosing the availability). Is it because we 
> move the logic to DoEmitAvailabilityWarning?
Yep. It doesn't make sense to check context here because we may delay the 
diagnostic, in which case we have to check again in the new context (this what 
isDecl(Deprecated|Unavailable) does). I think it makes more sense to do all the 
checking in `DoEmitAvailabilityWarning`, because at that point the paths for 
delayed and normal diagnostics meet again, and we always have the correct 
context.


https://reviews.llvm.org/D25283



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


Re: [libcxxabi] r284128 - [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Looks like this broke the gcc builder:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/builds/573/steps/build.libcxxabi/logs/stdio

I'll have a look soon, might not be able to do so before tomorrow. Please
feel free to revert if this is blocking.

Sorry for the trouble.

/ Asiri

On Thu, Oct 13, 2016 at 4:05 PM, Asiri Rathnayake via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: asiri
> Date: Thu Oct 13 10:05:19 2016
> New Revision: 284128
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284128&view=rev
> Log:
> [libcxxabi] Refactor pthread usage into a separate API
>
> This patch refactors all pthread uses of libc++abi into a separate API.
> This
> is the first step towards supporting an externlly-threaded libc++abi
> library.
>
> I've followed the conventions already used in the libc++ library for the
> same
> purpose.
>
> Patch from: Saleem Abdulrasool and Asiri Rathnayake
>
> Reviewed by: compnerd, EricWF
>
> Differential revisions:
>   https://reviews.llvm.org/D18482 (original)
>   https://reviews.llvm.org/D24864 (final)
>
> Added:
> libcxxabi/trunk/src/threading_support.h
> Modified:
> libcxxabi/trunk/CMakeLists.txt
> libcxxabi/trunk/src/config.h
> libcxxabi/trunk/src/cxa_exception.cpp
> libcxxabi/trunk/src/cxa_exception_storage.cpp
> libcxxabi/trunk/src/cxa_guard.cpp
> libcxxabi/trunk/src/cxa_thread_atexit.cpp
> libcxxabi/trunk/src/fallback_malloc.cpp
> libcxxabi/trunk/test/test_exception_storage.pass.cpp
> libcxxabi/trunk/test/test_fallback_malloc.pass.cpp
>
> Modified: libcxxabi/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/
> CMakeLists.txt?rev=284128&r1=284127&r2=284128&view=diff
> 
> ==
> --- libcxxabi/trunk/CMakeLists.txt (original)
> +++ libcxxabi/trunk/CMakeLists.txt Thu Oct 13 10:05:19 2016
> @@ -340,6 +340,7 @@ endif()
>
>  if (LIBCXXABI_HAS_PTHREAD_API)
>add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
> +  add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
>  endif()
>
>  if (MSVC)
>
> Modified: libcxxabi/trunk/src/config.h
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> config.h?rev=284128&r1=284127&r2=284128&view=diff
> 
> ==
> --- libcxxabi/trunk/src/config.h (original)
> +++ libcxxabi/trunk/src/config.h Thu Oct 13 10:05:19 2016
> @@ -16,6 +16,36 @@
>
>  #include 
>
> +// Configure inline visibility attributes
> +#if defined(_WIN32)
> + #if defined(_MSC_VER) && !defined(__clang__)
> +  // Using Microsoft Visual C++ compiler
> +  #define _LIBCXXABI_INLINE_VISIBILITY __forceinline
> + #else
> +  #if __has_attribute(__internal_linkage__)
> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__internal_linkage__, __always_inline__))
> +  #else
> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__always_inline__))
> +  #endif
> + #endif
> +#else
> + #if __has_attribute(__internal_linkage__)
> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__internal_linkage__, __always_inline__))
> + #else
> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__visibility__("hidden"), __always_inline__))
> + #endif
> +#endif
> +
> +// Try and deduce a threading api if one has not been explicitly set.
> +#if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
> +!defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
> +  #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
> +#define _LIBCXXABI_USE_THREAD_API_PTHREAD
> +  #else
> +#error "No thread API"
> +  #endif
> +#endif
> +
>  // Set this in the CXXFLAGS when you need it, because otherwise we'd have
> to
>  // #if !defined(__linux__) && !defined(__APPLE__) && ...
>  // and so-on for *every* platform.
>
> Modified: libcxxabi/trunk/src/cxa_exception.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> cxa_exception.cpp?rev=284128&r1=284127&r2=284128&view=diff
> 
> ==
> --- libcxxabi/trunk/src/cxa_exception.cpp (original)
> +++ libcxxabi/trunk/src/cxa_exception.cpp Thu Oct 13 10:05:19 2016
> @@ -12,6 +12,7 @@
>  //===---
> ---===//
>
>  #include "config.h"
> +#include "threading_support.h"
>  #include "cxxabi.h"
>
>  #include // for std::terminate
>
> Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> cxa_exception_storage.cpp?rev=284128&r1=284127&r2=284128&view=diff
> 
> ==
> --- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
> +++ libcxxabi/trunk/src/cxa_exception_storage.cpp Thu Oct 13 10:05:19 2016
> @@ -14,6 +14,7 @@
>  #include "cxa_exception.hpp"
>
>  #include "config.h"
> +#include "threading_support.h"
>
>  #if defi

[PATCH] D25571: Add and use isDiscardableGVALinkage function.

2016-10-13 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25571

Files:
  clang/include/clang/Basic/Linkage.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaCUDA.cpp


Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -543,7 +543,7 @@
 return false;
 
   // Externally-visible and similar functions are always emitted.
-  if (S.getASTContext().GetGVALinkageForFunction(FD) > GVA_DiscardableODR)
+  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8802,15 +8802,10 @@
   }
 }
 
-GVALinkage Linkage = GetGVALinkageForFunction(FD);
-
 // static, static inline, always_inline, and extern inline functions can
 // always be deferred.  Normal inline functions can be deferred in C99/C++.
 // Implicit template instantiations can also be deferred in C++.
-if (Linkage == GVA_Internal || Linkage == GVA_AvailableExternally ||
-Linkage == GVA_DiscardableODR)
-  return false;
-return true;
+return !isDiscardableGVALinkage(GetGVALinkageForFunction(FD));
   }
   
   const VarDecl *VD = cast(D);
@@ -8821,9 +8816,7 @@
 return false;
 
   // Variables that can be needed in other TUs are required.
-  GVALinkage L = GetGVALinkageForVariable(VD);
-  if (L != GVA_Internal && L != GVA_AvailableExternally &&
-  L != GVA_DiscardableODR)
+  if (!isDiscardableGVALinkage(GetGVALinkageForVariable(VD)))
 return true;
 
   // Variables that have destruction with side-effects are required.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9241,7 +9241,7 @@
   /// discover that a function is known-emitted, we remove it and everything it
   /// transitively calls from this set and add those functions to
   /// CUDAKnownEmittedFns.
-  llvm::DenseMap> CUDACallGraph;
+  llvm::DenseMap> 
CUDACallGraph;
 
   /// Diagnostic builder for CUDA errors which may or may not be deferred.
   ///
Index: clang/include/clang/Basic/Linkage.h
===
--- clang/include/clang/Basic/Linkage.h
+++ clang/include/clang/Basic/Linkage.h
@@ -69,6 +69,10 @@
   GVA_StrongODR
 };
 
+inline bool isDiscardableGVALinkage(GVALinkage L) {
+  return L <= GVA_DiscardableODR;
+}
+
 inline bool isExternallyVisible(Linkage L) {
   return L == ExternalLinkage || L == VisibleNoLinkage;
 }


Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -543,7 +543,7 @@
 return false;
 
   // Externally-visible and similar functions are always emitted.
-  if (S.getASTContext().GetGVALinkageForFunction(FD) > GVA_DiscardableODR)
+  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8802,15 +8802,10 @@
   }
 }
 
-GVALinkage Linkage = GetGVALinkageForFunction(FD);
-
 // static, static inline, always_inline, and extern inline functions can
 // always be deferred.  Normal inline functions can be deferred in C99/C++.
 // Implicit template instantiations can also be deferred in C++.
-if (Linkage == GVA_Internal || Linkage == GVA_AvailableExternally ||
-Linkage == GVA_DiscardableODR)
-  return false;
-return true;
+return !isDiscardableGVALinkage(GetGVALinkageForFunction(FD));
   }
   
   const VarDecl *VD = cast(D);
@@ -8821,9 +8816,7 @@
 return false;
 
   // Variables that can be needed in other TUs are required.
-  GVALinkage L = GetGVALinkageForVariable(VD);
-  if (L != GVA_Internal && L != GVA_AvailableExternally &&
-  L != GVA_DiscardableODR)
+  if (!isDiscardableGVALinkage(GetGVALinkageForVariable(VD)))
 return true;
 
   // Variables that have destruction with side-effects are required.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9241,7 +9241,7 @@
   /// discover that a function is known-emitted, we remove it and everything it
   /// transitively calls from this set and add those functions to
   /// CUDAKnownEmittedFns.
-  llvm::DenseMap> CU

Re: [libunwind] r284125 - [libunwind] Add missing include. NFC.

2016-10-13 Thread Joerg Sonnenberger via cfe-commits
On Thu, Oct 13, 2016 at 02:32:24PM -, Asiri Rathnayake via cfe-commits 
wrote:
> This missing include seems to cause compilation failures on older MacOS
> versions (< 10.9). This is because r270692 has introduced uint64_t into
> config.h without including this header.

But that would be inttypes.h, wouldn't it be?

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


[PATCH] D25572: [Coverage] Support for C++17 if initializers

2016-10-13 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added reviewers: arphaman, ikudrin.
vsk added a subscriber: cfe-commits.

Generate coverage mappings for  in if (; ).

Here's some sample output (let's hope phab gets the spaces right :) --

  12|   |// CHECK-LABEL: define {{.*}}void @_Z11switch_initv()
  13|   |// PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 0
  14|  1|void switch_init() {
  15|  1|  switch (int i = true ? 0 : 1; i) {}
  ^1  ^0
  16|  1|  // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 2
  17|  1|  // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 1
  18|  1|}
  19|   |
  20|   |// Note: We expect counters for the function entry block, the 
condition in the
  21|   |// if initializer, and the if successor block.
  22|   |//
  23|   |// CHECK-LABEL: define {{.*}}void @_Z7if_initv()
  24|   |// PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 0
  25|  1|void if_init() {
  26|  1|  if (int i = true ? 0 : 1; i) {}
  ^1  ^0 ^1 ^0
  27|  1|  // PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 2
  28|  1|  // PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 1
  29|  1|}

I did some local testing of this patch (as well as 
https://reviews.llvm.org/D25539) using a maze of macros to generate parts of 
the IfStmt / SwitchStmt. The goal of that exercise was to break popRegions(). 
Ultimately I decided against checking those tests in because they seem a bit 
paranoid. We're not actually pushing new regions for the initializer 
statements..


https://reviews.llvm.org/D25572

Files:
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/if.c
  test/CoverageMapping/if.cpp
  test/Profile/cxx-stmt-initializers.cpp


Index: test/Profile/cxx-stmt-initializers.cpp
===
--- test/Profile/cxx-stmt-initializers.cpp
+++ test/Profile/cxx-stmt-initializers.cpp
@@ -4,6 +4,7 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN 
%s
 
 // PGOGEN: @[[SIC:__profc__Z11switch_initv]] = private global [3 x i64] 
zeroinitializer
+// PGOGEN: @[[IIC:__profc__Z7if_initv]] = private global [3 x i64] 
zeroinitializer
 
 // Note: We expect counters for the function entry block, the condition in the
 // switch initializer, and the switch successor block.
@@ -15,3 +16,14 @@
   // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 2
   // PGOGEN: store {{.*}} @[[SIC]], i64 0, i64 1
 }
+
+// Note: We expect counters for the function entry block, the condition in the
+// if initializer, and the if successor block.
+//
+// CHECK-LABEL: define {{.*}}void @_Z7if_initv()
+// PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 0
+void if_init() {
+  if (int i = true ? 0 : 1; i) {}
+  // PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 2
+  // PGOGEN: store {{.*}} @[[IIC]], i64 0, i64 1
+}
Index: test/CoverageMapping/if.cpp
===
--- test/CoverageMapping/if.cpp
+++ test/CoverageMapping/if.cpp
@@ -1,5 +1,16 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name if.c %s | FileCheck %s
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -std=c++1z -triple %itanium_abi_triple 
-main-file-name if.cpp %s | FileCheck %s
 
+int nop() { return 0; }
+
+// CHECK-LABEL: _Z3foov:
+void foo() {// CHECK-NEXT: [[@LINE]]:12 -> [[@LINE+5]]:2 = 
#0
+  if (int j = true ? nop()  // CHECK-NEXT: [[@LINE]]:22 -> [[@LINE]]:27 = 
#2
+   : nop(); // CHECK-NEXT: [[@LINE]]:22 -> [[@LINE]]:27 = 
(#0 - #2)
+  j)// CHECK-NEXT: [[@LINE]]:7 -> [[@LINE]]:8 = #0
+++j;// CHECK-NEXT: [[@LINE]]:5 -> [[@LINE]]:8 = #1
+}
+
+// CHECK-LABEL: main:
 int main() {// CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 
= #0
   int i = 0;
 // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> 
[[@LINE+1]]:12 = #0
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -875,6 +875,9 @@
 
   void VisitIfStmt(const IfStmt *S) {
 extendRegion(S);
+if (S->getInit())
+  Visit(S->getInit());
+
 // Extend into the condition before we propagate through it below - this is
 // needed to handle macros that generate the "if" but not the condition.
 extendRegion(S->getCond());
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -490,6 +490,8 @@
   void VisitIfStmt(const IfStmt *S) {
 RecordStmtCount(S);
 uint64_t ParentCount = CurrentCount;
+if (S->getInit())
+  Visit(S->getInit());
 Visit(S->getCond());
 
 // Counte

[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Jackie Kay via cfe-commits
jacquelinekay added a comment.

I tested clang-format in vim with the recent state of trunk and it seems to 
work without my patch. The bug I ran into initially was fixed in 
https://reviews.llvm.org/D23319 with added encoding. So I think this can be 
closed without merging.


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



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


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

2016-10-13 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

In https://reviews.llvm.org/D24991#565861, @EricWF wrote:

> In https://reviews.llvm.org/D24991#565715, @mclow.lists wrote:
>
> > How does this play with existing binaries?  Applications that expect these 
> > functions to exist in the dylib?
>
>
> This patch is majorly ABI breaking, although we could probably find a 
> formulation that wasn't.


Eric, Marshall,
any suggestions on how to fix the backwards compatibility issue?

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D24991



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


[PATCH] D25547: [CodeGen][ObjC] Do not emit objc_storeStrong to initialize a constexpr variable

2016-10-13 Thread John McCall via cfe-commits
rjmccall added a comment.

The correct fix is to honor isInit by folding the logic for EmitScalarInit into 
this function.  That should allow you to eliminate EmitScalarInit completely, 
although it would be fine to leave it as just a call to EmitStoreThroughLValue. 
 I did a quick audit of all the calls to EmitStoreThroughLValue that might pass 
isInit=true, and it does look like none of them are relying on the current 
behavior for ARC ownership; the most suspicious are the calls from 
EmitObjCCollectionLiteral, but the l-value there is non lifetime-qualified, so 
it's fine.


https://reviews.llvm.org/D25547



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


[PATCH] D25541: [CUDA] Emit deferred diagnostics during Sema rather than during codegen.

2016-10-13 Thread Justin Lebar via cfe-commits
jlebar marked 2 inline comments as done.
jlebar added a comment.

In https://reviews.llvm.org/D25541#569360, @rnk wrote:

> Nice! Looks like this wasn't too bad.


Like many things in my life lately, it wasn't after Richard explained to me how 
to do it.   :)

Thank you for the review.




Comment at: clang/lib/Sema/SemaCUDA.cpp:546
+  // Externally-visible and similar functions are always emitted.
+  if (S.getASTContext().GetGVALinkageForFunction(FD) > GVA_DiscardableODR)
+return true;

rnk wrote:
> There are two other instances of conditions equivalent to this in 
> `ASTContext::DeclMustBeEmitted`. You should add a predicate like 
> `isDiscardableGVALinkage(GVALinkage)` to Linkage.h and call it in 
> `DeclMustBeEmitted`.
Sure, let me do that in a separate patch, https://reviews.llvm.org/D25571.


https://reviews.llvm.org/D25541



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


[libcxxabi] r284141 - [libcxxabi] Fix gcc build after r284128

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct 13 13:40:57 2016
New Revision: 284141

URL: http://llvm.org/viewvc/llvm-project?rev=284141&view=rev
Log:
[libcxxabi] Fix gcc build after r284128

NFC.

Modified:
libcxxabi/trunk/src/config.h

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=284141&r1=284140&r2=284141&view=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Thu Oct 13 13:40:57 2016
@@ -16,6 +16,10 @@
 
 #include 
 
+#ifndef __has_attribute
+  #define __has_attribute(x) 0
+#endif
+
 // Configure inline visibility attributes
 #if defined(_WIN32)
  #if defined(_MSC_VER) && !defined(__clang__)


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


r284142 - Module: emit initializers for C/ObjC after r276159.

2016-10-13 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Oct 13 13:42:14 2016
New Revision: 284142

URL: http://llvm.org/viewvc/llvm-project?rev=284142&view=rev
Log:
Module: emit initializers for C/ObjC after r276159.

In r276159, we started to defer emitting initializers for VarDecls, but
forgot to add the initializers for non-C++ language.

rdar://28740482

Added:
cfe/trunk/test/Modules/Inputs/objc-initializer/
cfe/trunk/test/Modules/Inputs/objc-initializer/X.h
cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
cfe/trunk/test/Modules/objc-initializer.m
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284142&r1=284141&r2=284142&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 13 13:42:14 2016
@@ -10511,7 +10511,13 @@ void Sema::CheckCompleteVariableDeclarat
   }
 
   // All the following checks are C++ only.
-  if (!getLangOpts().CPlusPlus) return;
+  if (!getLangOpts().CPlusPlus) {
+  // If this variable must be emitted, add it as an initializer for the
+  // current module.
+ if (Context.DeclMustBeEmitted(var) && !ModuleScopes.empty())
+   Context.addModuleInitializer(ModuleScopes.back().Module, var);
+ return;
+  }
 
   if (auto *DD = dyn_cast(var))
 CheckCompleteDecompositionDeclaration(DD);

Added: cfe/trunk/test/Modules/Inputs/objc-initializer/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-initializer/X.h?rev=284142&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-initializer/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-initializer/X.h Thu Oct 13 13:42:14 2016
@@ -0,0 +1,3 @@
+@interface NSString
+@end
+static const NSString * const kSimDeviceIOGetInterface = 
@"simdeviceio_get_interface";

Added: cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap?rev=284142&view=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/objc-initializer/module.modulemap Thu Oct 13 
13:42:14 2016
@@ -0,0 +1,4 @@
+module X {
+  header "X.h"
+  export *
+}

Added: cfe/trunk/test/Modules/objc-initializer.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-initializer.m?rev=284142&view=auto
==
--- cfe/trunk/test/Modules/objc-initializer.m (added)
+++ cfe/trunk/test/Modules/objc-initializer.m Thu Oct 13 13:42:14 2016
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-initializer %s -emit-llvm -o - -fobjc-arc | FileCheck %s
+// CHECK: kSimDeviceIOGetInterface = internal constant {{.*}} bitcast
+
+#import 
+void test2(const NSString*);
+void test() {
+  test2(kSimDeviceIOGetInterface);
+}


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


Re: r276159 - [modules] Don't emit initializers for VarDecls within a module eagerly whenever

2016-10-13 Thread Manman via cfe-commits
Hi Richard,

I committed a follow-up patch in r284142 to fix issues with C/ObjC.

Let me know if you see any problem.

Manman

> On Jul 20, 2016, at 12:10 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Wed Jul 20 14:10:16 2016
> New Revision: 276159
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=276159&view=rev
> Log:
> [modules] Don't emit initializers for VarDecls within a module eagerly 
> whenever
> we first touch any part of that module. Instead, defer them until the first
> time that module is (transitively) imported. The initializer step for a module
> then recursively initializes modules that its own headers imported.
> 
> For example, this avoids running the  global initializer in programs
> that don't actually use iostreams, but do use other parts of the standard
> library.
> 
> Added:
>cfe/trunk/test/Modules/Inputs/unused-global-init/
>  - copied from r275623, cfe/trunk/test/Modules/Inputs/unused-global-init/
>cfe/trunk/test/Modules/unused-global-init.cpp
>  - copied, changed from r275623, 
> cfe/trunk/test/Modules/unused-global-init.cpp
> Modified:
>cfe/trunk/include/clang/AST/ASTContext.h
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>cfe/trunk/lib/AST/ASTContext.cpp
>cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>cfe/trunk/lib/Sema/SemaDecl.cpp
>cfe/trunk/lib/Sema/SemaLookup.cpp
>cfe/trunk/lib/Serialization/ASTReader.cpp
>cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>cfe/trunk/lib/Serialization/ASTWriter.cpp
>cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>cfe/trunk/test/Modules/Inputs/unused-global-init/used.h
>cfe/trunk/test/Modules/odr.cpp
>cfe/trunk/test/Modules/templates.mm
> 
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=276159&r1=276158&r2=276159&view=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jul 20 14:10:16 2016
> @@ -312,6 +312,18 @@ class ASTContext : public RefCountedBase
>   /// definitions of that entity.
>   llvm::DenseMap> MergedDefModules;
> 
> +  /// \brief Initializers for a module, in order. Each Decl will be either
> +  /// something that has a semantic effect on startup (such as a variable 
> with
> +  /// a non-constant initializer), or an ImportDecl (which recursively 
> triggers
> +  /// initialization of another module).
> +  struct PerModuleInitializers {
> +llvm::SmallVector Initializers;
> +llvm::SmallVector LazyInitializers;
> +
> +void resolve(ASTContext &Ctx);
> +  };
> +  llvm::DenseMap ModuleInitializers;
> +
> public:
>   /// \brief A type synonym for the TemplateOrInstantiation mapping.
>   typedef llvm::PointerUnion
> @@ -883,6 +895,17 @@ public:
> return MergedIt->second;
>   }
> 
> +  /// Add a declaration to the list of declarations that are initialized
> +  /// for a module. This will typically be a global variable (with internal
> +  /// linkage) that runs module initializers, such as the iostream 
> initializer,
> +  /// or an ImportDecl nominating another module that has initializers.
> +  void addModuleInitializer(Module *M, Decl *Init);
> +
> +  void addLazyModuleInitializers(Module *M, ArrayRef IDs);
> +
> +  /// Get the initializations to perform when importing a module, if any.
> +  ArrayRef getModuleInitializers(Module *M);
> +
>   TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
> 
>   ExternCContextDecl *getExternCContextDecl() const;
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=276159&r1=276158&r2=276159&view=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jul 20 14:10:16 2016
> @@ -1390,8 +1390,14 @@ private:
>   bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
>TypeDiagnoser *Diagnoser);
> 
> +  struct ModuleScope {
> +clang::Module *Module;
> +VisibleModuleSet OuterVisibleModules;
> +  };
> +  /// The modules we're currently parsing.
> +  llvm::SmallVector ModuleScopes;
> +
>   VisibleModuleSet VisibleModules;
> -  llvm::SmallVector VisibleModulesStack;
> 
>   Module *CachedFakeTopLevelModule;
> 
> 
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=276159&r1=276158&r2=276159&view=diff
> ==
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Jul 20 14:10:16 
> 2016
> @@ -684,6 +

Re: [libcxxabi] r284128 - [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Should be fixed in r284141.

/ Asiri

On Thu, Oct 13, 2016 at 7:20 PM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> Looks like this broke the gcc builder: http://lab.llvm.org:
> 8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-
> gcc49-cxx11/builds/573/steps/build.libcxxabi/logs/stdio
>
> I'll have a look soon, might not be able to do so before tomorrow. Please
> feel free to revert if this is blocking.
>
> Sorry for the trouble.
>
> / Asiri
>
> On Thu, Oct 13, 2016 at 4:05 PM, Asiri Rathnayake via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: asiri
>> Date: Thu Oct 13 10:05:19 2016
>> New Revision: 284128
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=284128&view=rev
>> Log:
>> [libcxxabi] Refactor pthread usage into a separate API
>>
>> This patch refactors all pthread uses of libc++abi into a separate API.
>> This
>> is the first step towards supporting an externlly-threaded libc++abi
>> library.
>>
>> I've followed the conventions already used in the libc++ library for the
>> same
>> purpose.
>>
>> Patch from: Saleem Abdulrasool and Asiri Rathnayake
>>
>> Reviewed by: compnerd, EricWF
>>
>> Differential revisions:
>>   https://reviews.llvm.org/D18482 (original)
>>   https://reviews.llvm.org/D24864 (final)
>>
>> Added:
>> libcxxabi/trunk/src/threading_support.h
>> Modified:
>> libcxxabi/trunk/CMakeLists.txt
>> libcxxabi/trunk/src/config.h
>> libcxxabi/trunk/src/cxa_exception.cpp
>> libcxxabi/trunk/src/cxa_exception_storage.cpp
>> libcxxabi/trunk/src/cxa_guard.cpp
>> libcxxabi/trunk/src/cxa_thread_atexit.cpp
>> libcxxabi/trunk/src/fallback_malloc.cpp
>> libcxxabi/trunk/test/test_exception_storage.pass.cpp
>> libcxxabi/trunk/test/test_fallback_malloc.pass.cpp
>>
>> Modified: libcxxabi/trunk/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLis
>> ts.txt?rev=284128&r1=284127&r2=284128&view=diff
>> 
>> ==
>> --- libcxxabi/trunk/CMakeLists.txt (original)
>> +++ libcxxabi/trunk/CMakeLists.txt Thu Oct 13 10:05:19 2016
>> @@ -340,6 +340,7 @@ endif()
>>
>>  if (LIBCXXABI_HAS_PTHREAD_API)
>>add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
>> +  add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
>>  endif()
>>
>>  if (MSVC)
>>
>> Modified: libcxxabi/trunk/src/config.h
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/conf
>> ig.h?rev=284128&r1=284127&r2=284128&view=diff
>> 
>> ==
>> --- libcxxabi/trunk/src/config.h (original)
>> +++ libcxxabi/trunk/src/config.h Thu Oct 13 10:05:19 2016
>> @@ -16,6 +16,36 @@
>>
>>  #include 
>>
>> +// Configure inline visibility attributes
>> +#if defined(_WIN32)
>> + #if defined(_MSC_VER) && !defined(__clang__)
>> +  // Using Microsoft Visual C++ compiler
>> +  #define _LIBCXXABI_INLINE_VISIBILITY __forceinline
>> + #else
>> +  #if __has_attribute(__internal_linkage__)
>> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__internal_linkage__, __always_inline__))
>> +  #else
>> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__always_inline__))
>> +  #endif
>> + #endif
>> +#else
>> + #if __has_attribute(__internal_linkage__)
>> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__internal_linkage__, __always_inline__))
>> + #else
>> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__visibility__("hidden"), __always_inline__))
>> + #endif
>> +#endif
>> +
>> +// Try and deduce a threading api if one has not been explicitly set.
>> +#if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
>> +!defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
>> +  #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
>> +#define _LIBCXXABI_USE_THREAD_API_PTHREAD
>> +  #else
>> +#error "No thread API"
>> +  #endif
>> +#endif
>> +
>>  // Set this in the CXXFLAGS when you need it, because otherwise we'd
>> have to
>>  // #if !defined(__linux__) && !defined(__APPLE__) && ...
>>  // and so-on for *every* platform.
>>
>> Modified: libcxxabi/trunk/src/cxa_exception.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_
>> exception.cpp?rev=284128&r1=284127&r2=284128&view=diff
>> 
>> ==
>> --- libcxxabi/trunk/src/cxa_exception.cpp (original)
>> +++ libcxxabi/trunk/src/cxa_exception.cpp Thu Oct 13 10:05:19 2016
>> @@ -12,6 +12,7 @@
>>  //===--
>> ===//
>>
>>  #include "config.h"
>> +#include "threading_support.h"
>>  #include "cxxabi.h"
>>
>>  #include // for std::terminate
>>
>> Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_
>> exception_storage.cpp?rev=284128&r1=284127&r2=284128&view=diff
>> 
>> ==

r284144 - [CUDA] Disallow __shared__ variables in host functions.

2016-10-13 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Oct 13 13:45:13 2016
New Revision: 284144

URL: http://llvm.org/viewvc/llvm-project?rev=284144&view=rev
Log:
[CUDA] Disallow __shared__ variables in host functions.

Reviewers: tra, rnk

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCUDA/bad-attributes.cu

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284144&r1=284143&r2=284144&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 13 13:45:13 
2016
@@ -6747,6 +6747,9 @@ def err_cuda_vla : Error<
 "cannot use variable-length arrays in "
 "%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
 def err_cuda_extern_shared : Error<"__shared__ variable %0 cannot be 
'extern'">;
+def err_cuda_host_shared : Error<
+"__shared__ local variables not allowed in "
+"%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
 def err_cuda_nonglobal_constant : Error<"__constant__ variables must be 
global">;
 
 def warn_non_pod_vararg_with_format_string : Warning<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=284144&r1=284143&r2=284144&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct 13 13:45:13 2016
@@ -3724,6 +3724,10 @@ static void handleSharedAttr(Sema &S, De
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }
+  if (S.getLangOpts().CUDA && VD->hasLocalStorage() &&
+  S.CUDADiagIfHostCode(Attr.getLoc(), diag::err_cuda_host_shared)
+  << S.CurrentCUDATarget())
+return;
   D->addAttr(::new (S.Context) CUDASharedAttr(
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }

Modified: cfe/trunk/test/SemaCUDA/bad-attributes.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/bad-attributes.cu?rev=284144&r1=284143&r2=284144&view=diff
==
--- cfe/trunk/test/SemaCUDA/bad-attributes.cu (original)
+++ cfe/trunk/test/SemaCUDA/bad-attributes.cu Thu Oct 13 13:45:13 2016
@@ -65,6 +65,7 @@ __global__ static inline void foobar() {
 __constant__ int global_constant;
 void host_fn() {
   __constant__ int c; // expected-error {{__constant__ variables must be 
global}}
+  __shared__ int s; // expected-error {{__shared__ local variables not allowed 
in __host__ functions}}
 }
 __device__ void device_fn() {
   __constant__ int c; // expected-error {{__constant__ variables must be 
global}}


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


r284143 - [CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIf{Device, Host}Code().

2016-10-13 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Oct 13 13:45:08 2016
New Revision: 284143

URL: http://llvm.org/viewvc/llvm-project?rev=284143&view=rev
Log:
[CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIf{Device,Host}Code().

Summary:
Together these let you easily create diagnostics that

 - are never emitted for host code
 - are always emitted for __device__ and __global__ functions, and
 - are emitted for __host__ __device__ functions iff these functions are
   codegen'ed.

At the moment there are only three diagnostics that need this treatment,
but I have more to add, and it's not sustainable to write code for emitting
every such diagnostic twice, and from a special wrapper in SemaCUDA.cpp.

While we're at it, don't emit the function name in
err_cuda_device_exceptions: It's not necessary to print it, and making
this work in the new framework in the face of a null value for
dyn_cast(CurContext) isn't worth the effort.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284143&r1=284142&r2=284143&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 13 13:45:08 
2016
@@ -6734,7 +6734,7 @@ def note_cuda_conflicting_device_functio
   "conflicting __device__ function declared here">;
 def err_cuda_device_exceptions : Error<
   "cannot use '%0' in "
-  "%select{__device__|__global__|__host__|__host__ __device__}1 function %2">;
+  "%select{__device__|__global__|__host__|__host__ __device__}1 function">;
 def err_dynamic_var_init : Error<
 "dynamic initialization is not supported for "
 "__device__, __constant__, and __shared__ variables.">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284143&r1=284142&r2=284143&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 13 13:45:08 2016
@@ -9245,6 +9245,100 @@ public:
   /// before incrementing, so you can emit an error.
   bool PopForceCUDAHostDevice();
 
+  /// Diagnostic builder for CUDA errors which may or may not be deferred.
+  ///
+  /// In CUDA, there exist constructs (e.g. variable-length arrays, try/catch)
+  /// which are not allowed to appear inside __device__ functions and are
+  /// allowed to appear in __host__ __device__ functions only if the 
host+device
+  /// function is never codegen'ed.
+  ///
+  /// To handle this, we use the notion of "deferred diagnostics", where we
+  /// attach a diagnostic to a FunctionDecl that's emitted iff it's codegen'ed.
+  ///
+  /// This class lets you emit either a regular diagnostic, a deferred
+  /// diagnostic, or no diagnostic at all, according to an argument you pass to
+  /// its constructor, thus simplifying the process of creating these "maybe
+  /// deferred" diagnostics.
+  class CUDADiagBuilder {
+  public:
+enum Kind {
+  /// Emit no diagnostics.
+  K_Nop,
+  /// Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
+  K_Immediate,
+  /// Create a deferred diagnostic, which is emitted only if the function
+  /// it's attached to is codegen'ed.
+  K_Deferred
+};
+
+CUDADiagBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
+FunctionDecl *Fn, Sema &S);
+
+/// Convertible to bool: True if we immediately emitted an error, false if
+/// we didn't emit an error or we created a deferred error.
+///
+/// Example usage:
+///
+///   if (CUDADiagBuilder(...) << foo << bar)
+/// return ExprError();
+///
+/// But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() -- you probably
+/// want to use these instead of creating a CUDADiagBuilder yourself.
+operator bool() const { return ImmediateDiagBuilder.hasValue(); }
+
+template 
+friend const CUDADiagBuilder &operator<<(const CUDADiagBuilder &Diag,
+ const T &Value) {
+  if (Diag.ImmediateDiagBuilder.hasValue())
+*Diag.ImmediateDiagBuilder << Value;
+  else if (Diag.PartialDiagInfo.hasValue())
+Diag.PartialDiagInfo->PD << Value;
+  return Diag;
+}
+
+  private:
+struct PartialDiagnosticInfo {
+  PartialDiagnosticInfo(SourceLocation 

r284145 - [CUDA] Allow static variables in __host__ __device__ functions, so long as they're never codegen'ed for device.

2016-10-13 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Oct 13 13:45:17 2016
New Revision: 284145

URL: http://llvm.org/viewvc/llvm-project?rev=284145&view=rev
Log:
[CUDA] Allow static variables in __host__ __device__ functions, so long as 
they're never codegen'ed for device.

Reviewers: tra, rnk

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/static-vars-hd.cu
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCUDA/device-var-init.cu

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284145&r1=284144&r2=284145&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 13 13:45:17 
2016
@@ -6741,8 +6741,8 @@ def err_dynamic_var_init : Error<
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
 def err_device_static_local_var : Error<
-"Within a __device__/__global__ function, "
-"only __shared__ variables may be marked \"static\"">;
+"within a %select{__device__|__global__|__host__|__host__ __device__}0 "
+"function, only __shared__ variables may be marked 'static'">;
 def err_cuda_vla : Error<
 "cannot use variable-length arrays in "
 "%select{__device__|__global__|__host__|__host__ __device__}0 functions">;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284145&r1=284144&r2=284145&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 13 13:45:17 2016
@@ -10677,12 +10677,11 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
   // CUDA E.2.9.4: Within the body of a __device__ or __global__
   // function, only __shared__ variables may be declared with
   // static storage class.
-  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
-  (FD->hasAttr() || FD->hasAttr()) &&
-  !VD->hasAttr()) {
-Diag(VD->getLocation(), diag::err_device_static_local_var);
+  if (getLangOpts().CUDA && !VD->hasAttr() &&
+  CUDADiagIfDeviceCode(VD->getLocation(),
+   diag::err_device_static_local_var)
+  << CurrentCUDATarget())
 VD->setInvalidDecl();
-  }
 }
   }
 
@@ -10696,7 +10695,7 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
 if (Init && VD->hasGlobalStorage()) {
   if (VD->hasAttr() || VD->hasAttr() ||
   VD->hasAttr()) {
-assert((!VD->isStaticLocal() || VD->hasAttr()));
+assert(!VD->isStaticLocal() || VD->hasAttr());
 bool AllowedInit = false;
 if (const CXXConstructExpr *CE = dyn_cast(Init))
   AllowedInit =

Modified: cfe/trunk/test/SemaCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/device-var-init.cu?rev=284145&r1=284144&r2=284145&view=diff
==
--- cfe/trunk/test/SemaCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/SemaCUDA/device-var-init.cu Thu Oct 13 13:45:17 2016
@@ -207,9 +207,9 @@ __device__ void df_sema() {
   // expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
 
   static __device__ int ds;
-  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
   static __constant__ int dc;
-  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
   static int v;
-  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
 }

Added: cfe/trunk/test/SemaCUDA/static-vars-hd.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/static-vars-hd.cu?rev=284145&view=auto
==
--- cfe/trunk/test/SemaCUDA/static-vars-hd.cu (added)
+++ cfe/trunk/test/SemaCUDA/static-vars-hd.cu Thu Oct 13 13:45:17 2016
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -S -o /dev/null -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -S -o /dev/null -D HOST -verify %s
+
+#include "Inputs/cuda.h"
+
+#ifdef HOST
+// expected-no-diagnostics
+#endif
+
+__host__ __device__ void f() {
+  static int x 

[PATCH] D25143: [CUDA] Disallow __shared__ variables in host functions.

2016-10-13 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284144: [CUDA] Disallow __shared__ variables in host 
functions. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25143?vs=73172&id=74565#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25143

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/SemaCUDA/bad-attributes.cu


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3724,6 +3724,10 @@
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }
+  if (S.getLangOpts().CUDA && VD->hasLocalStorage() &&
+  S.CUDADiagIfHostCode(Attr.getLoc(), diag::err_cuda_host_shared)
+  << S.CurrentCUDATarget())
+return;
   D->addAttr(::new (S.Context) CUDASharedAttr(
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6747,6 +6747,9 @@
 "cannot use variable-length arrays in "
 "%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
 def err_cuda_extern_shared : Error<"__shared__ variable %0 cannot be 
'extern'">;
+def err_cuda_host_shared : Error<
+"__shared__ local variables not allowed in "
+"%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
 def err_cuda_nonglobal_constant : Error<"__constant__ variables must be 
global">;
 
 def warn_non_pod_vararg_with_format_string : Warning<
Index: cfe/trunk/test/SemaCUDA/bad-attributes.cu
===
--- cfe/trunk/test/SemaCUDA/bad-attributes.cu
+++ cfe/trunk/test/SemaCUDA/bad-attributes.cu
@@ -65,6 +65,7 @@
 __constant__ int global_constant;
 void host_fn() {
   __constant__ int c; // expected-error {{__constant__ variables must be 
global}}
+  __shared__ int s; // expected-error {{__shared__ local variables not allowed 
in __host__ functions}}
 }
 __device__ void device_fn() {
   __constant__ int c; // expected-error {{__constant__ variables must be 
global}}


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3724,6 +3724,10 @@
 S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
 return;
   }
+  if (S.getLangOpts().CUDA && VD->hasLocalStorage() &&
+  S.CUDADiagIfHostCode(Attr.getLoc(), diag::err_cuda_host_shared)
+  << S.CurrentCUDATarget())
+return;
   D->addAttr(::new (S.Context) CUDASharedAttr(
   Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
 }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6747,6 +6747,9 @@
 "cannot use variable-length arrays in "
 "%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
 def err_cuda_extern_shared : Error<"__shared__ variable %0 cannot be 'extern'">;
+def err_cuda_host_shared : Error<
+"__shared__ local variables not allowed in "
+"%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
 def err_cuda_nonglobal_constant : Error<"__constant__ variables must be global">;
 
 def warn_non_pod_vararg_with_format_string : Warning<
Index: cfe/trunk/test/SemaCUDA/bad-attributes.cu
===
--- cfe/trunk/test/SemaCUDA/bad-attributes.cu
+++ cfe/trunk/test/SemaCUDA/bad-attributes.cu
@@ -65,6 +65,7 @@
 __constant__ int global_constant;
 void host_fn() {
   __constant__ int c; // expected-error {{__constant__ variables must be global}}
+  __shared__ int s; // expected-error {{__shared__ local variables not allowed in __host__ functions}}
 }
 __device__ void device_fn() {
   __constant__ int c; // expected-error {{__constant__ variables must be global}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25150: [CUDA] Allow static variables in __host__ __device__ functions, so long as they're never codegen'ed for device.

2016-10-13 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284145: [CUDA] Allow static variables in __host__ __device__ 
functions, so long as… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25150?vs=73182&id=74566#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25150

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCUDA/device-var-init.cu
  cfe/trunk/test/SemaCUDA/static-vars-hd.cu


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6741,8 +6741,8 @@
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
 def err_device_static_local_var : Error<
-"Within a __device__/__global__ function, "
-"only __shared__ variables may be marked \"static\"">;
+"within a %select{__device__|__global__|__host__|__host__ __device__}0 "
+"function, only __shared__ variables may be marked 'static'">;
 def err_cuda_vla : Error<
 "cannot use variable-length arrays in "
 "%select{__device__|__global__|__host__|__host__ __device__}0 functions">;
Index: cfe/trunk/test/SemaCUDA/static-vars-hd.cu
===
--- cfe/trunk/test/SemaCUDA/static-vars-hd.cu
+++ cfe/trunk/test/SemaCUDA/static-vars-hd.cu
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -S -o /dev/null -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -S -o /dev/null -D HOST -verify %s
+
+#include "Inputs/cuda.h"
+
+#ifdef HOST
+// expected-no-diagnostics
+#endif
+
+__host__ __device__ void f() {
+  static int x = 42;
+#ifndef HOST
+  // expected-error@-2 {{within a __host__ __device__ function, only 
__shared__ variables may be marked 'static'}}
+#endif
+}
+
+inline __host__ __device__ void g() {
+  static int x = 42; // no error on device because this is never codegen'ed 
there.
+}
+void call_g() { g(); }
Index: cfe/trunk/test/SemaCUDA/device-var-init.cu
===
--- cfe/trunk/test/SemaCUDA/device-var-init.cu
+++ cfe/trunk/test/SemaCUDA/device-var-init.cu
@@ -207,9 +207,9 @@
   // expected-error@-1 {{initialization is not supported for __shared__ 
variables.}}
 
   static __device__ int ds;
-  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
   static __constant__ int dc;
-  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
   static int v;
-  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
 }
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -10677,12 +10677,11 @@
   // CUDA E.2.9.4: Within the body of a __device__ or __global__
   // function, only __shared__ variables may be declared with
   // static storage class.
-  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
-  (FD->hasAttr() || FD->hasAttr()) &&
-  !VD->hasAttr()) {
-Diag(VD->getLocation(), diag::err_device_static_local_var);
+  if (getLangOpts().CUDA && !VD->hasAttr() &&
+  CUDADiagIfDeviceCode(VD->getLocation(),
+   diag::err_device_static_local_var)
+  << CurrentCUDATarget())
 VD->setInvalidDecl();
-  }
 }
   }
 
@@ -10696,7 +10695,7 @@
 if (Init && VD->hasGlobalStorage()) {
   if (VD->hasAttr() || VD->hasAttr() ||
   VD->hasAttr()) {
-assert((!VD->isStaticLocal() || VD->hasAttr()));
+assert(!VD->isStaticLocal() || VD->hasAttr());
 bool AllowedInit = false;
 if (const CXXConstructExpr *CE = dyn_cast(Init))
   AllowedInit =


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6741,8 +6741,8 @@
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
 def err_device_static_local_var : Error<
-"Within a __device__/__global__ function, "
-"only __shared__ variables may be marked \"static\"">;
+"within a %select{__device__|

[PATCH] D25139: [CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIfDeviceCode().

2016-10-13 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284143: [CUDA] Add Sema::CUDADiagBuilder and 
Sema::CUDADiagIf{Device,Host}Code(). (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25139?vs=73576&id=74564#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25139

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

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9245,16 +9245,120 @@
   /// before incrementing, so you can emit an error.
   bool PopForceCUDAHostDevice();
 
+  /// Diagnostic builder for CUDA errors which may or may not be deferred.
+  ///
+  /// In CUDA, there exist constructs (e.g. variable-length arrays, try/catch)
+  /// which are not allowed to appear inside __device__ functions and are
+  /// allowed to appear in __host__ __device__ functions only if the host+device
+  /// function is never codegen'ed.
+  ///
+  /// To handle this, we use the notion of "deferred diagnostics", where we
+  /// attach a diagnostic to a FunctionDecl that's emitted iff it's codegen'ed.
+  ///
+  /// This class lets you emit either a regular diagnostic, a deferred
+  /// diagnostic, or no diagnostic at all, according to an argument you pass to
+  /// its constructor, thus simplifying the process of creating these "maybe
+  /// deferred" diagnostics.
+  class CUDADiagBuilder {
+  public:
+enum Kind {
+  /// Emit no diagnostics.
+  K_Nop,
+  /// Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
+  K_Immediate,
+  /// Create a deferred diagnostic, which is emitted only if the function
+  /// it's attached to is codegen'ed.
+  K_Deferred
+};
+
+CUDADiagBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
+FunctionDecl *Fn, Sema &S);
+
+/// Convertible to bool: True if we immediately emitted an error, false if
+/// we didn't emit an error or we created a deferred error.
+///
+/// Example usage:
+///
+///   if (CUDADiagBuilder(...) << foo << bar)
+/// return ExprError();
+///
+/// But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() -- you probably
+/// want to use these instead of creating a CUDADiagBuilder yourself.
+operator bool() const { return ImmediateDiagBuilder.hasValue(); }
+
+template 
+friend const CUDADiagBuilder &operator<<(const CUDADiagBuilder &Diag,
+ const T &Value) {
+  if (Diag.ImmediateDiagBuilder.hasValue())
+*Diag.ImmediateDiagBuilder << Value;
+  else if (Diag.PartialDiagInfo.hasValue())
+Diag.PartialDiagInfo->PD << Value;
+  return Diag;
+}
+
+  private:
+struct PartialDiagnosticInfo {
+  PartialDiagnosticInfo(SourceLocation Loc, PartialDiagnostic PD,
+FunctionDecl *Fn)
+  : Loc(Loc), PD(std::move(PD)), Fn(Fn) {}
+
+  ~PartialDiagnosticInfo() { Fn->addDeferredDiag({Loc, std::move(PD)}); }
+
+  SourceLocation Loc;
+  PartialDiagnostic PD;
+  FunctionDecl *Fn;
+};
+
+// Invariant: At most one of these Optionals has a value.
+// FIXME: Switch these to a Variant once that exists.
+llvm::Optional ImmediateDiagBuilder;
+llvm::Optional PartialDiagInfo;
+  };
+
+  /// Creates a CUDADiagBuilder that emits the diagnostic if the current context
+  /// is "used as device code".
+  ///
+  /// - If CurContext is a __host__ function, does not emit any diagnostics.
+  /// - If CurContext is a __device__ or __global__ function, emits the
+  ///   diagnostics immediately.
+  /// - If CurContext is a __host__ __device__ function and we are compiling for
+  ///   the device, creates a deferred diagnostic which is emitted if and when
+  ///   the function is codegen'ed.
+  ///
+  /// Example usage:
+  ///
+  ///  // Variable-length arrays are not allowed in CUDA device code.
+  ///  if (CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget())
+  ///return ExprError();
+  ///  // Otherwise, continue parsing as normal.
+  CUDADiagBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID);
+
+  /// Creates a CUDADiagBuilder that emits the diagnostic if the current context
+  /// is "used as host code".
+  ///
+  /// Same as CUDADiagIfDeviceCode, with "host" and "device" switched.
+  CUDADiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID);
+
   enum CUDAFunctionTarget {
 CFT_Device,
 CFT_Global,
 CFT_Host,
 CFT_HostDevice,
 CFT_InvalidTarget
   };
 
+  /// Determines whether the giv

[clang-tools-extra] r284147 - Print stack trace for clang-change-namespace tool.

2016-10-13 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Oct 13 13:56:14 2016
New Revision: 284147

URL: http://llvm.org/viewvc/llvm-project?rev=284147&view=rev
Log:
Print stack trace for clang-change-namespace tool.

Modified:
clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp

Modified: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=284147&r1=284146&r2=284147&view=diff
==
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp 
(original)
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp Thu 
Oct 13 13:56:14 2016
@@ -38,6 +38,7 @@
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Signals.h"
 
 using namespace clang;
 using namespace llvm;
@@ -69,6 +70,7 @@ cl::opt Style("style",
 } // anonymous namespace
 
 int main(int argc, const char **argv) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   tooling::CommonOptionsParser OptionsParser(argc, argv,
  ChangeNamespaceCategory);
   const auto &Files = OptionsParser.getSourcePathList();


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


Re: [libunwind] r284125 - [libunwind] Add missing include. NFC.

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Had a look at the C99 spec, according to section 7.18.1.1 ("Exact-width
integer types"), the types uint_t should be available in stdint.h
itself, inttypes.h on the other hand builds on stdint.h and provides more
functionality.

I don't see a particular need to include inttypes.h here?

Cheers,

/ Asiri

On Thu, Oct 13, 2016 at 7:46 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Thu, Oct 13, 2016 at 02:32:24PM -, Asiri Rathnayake via cfe-commits
> wrote:
> > This missing include seems to cause compilation failures on older MacOS
> > versions (< 10.9). This is because r270692 has introduced uint64_t into
> > config.h without including this header.
>
> But that would be inttypes.h, wouldn't it be?
>
> Joerg
> ___
> 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


[clang-tools-extra] r284148 - Print stack trace for clang-move tool.

2016-10-13 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Oct 13 14:04:19 2016
New Revision: 284148

URL: http://llvm.org/viewvc/llvm-project?rev=284148&view=rev
Log:
Print stack trace for clang-move tool.

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=284148&r1=284147&r2=284148&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Thu Oct 13 
14:04:19 2016
@@ -15,9 +15,10 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/Signals.h"
 #include "llvm/Support/YAMLTraits.h"
-#include "llvm/Support/Path.h"
 #include 
 #include 
 
@@ -72,6 +73,7 @@ cl::opt Dump("dump_result",
 } // namespace
 
 int main(int argc, const char **argv) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   // Add "-fparse-all-comments" compile option to make clang parse all 
comments,
   // otherwise, ordinary comments like "//" and "/*" won't get parsed (This is
   // a bit of hacky).


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


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-13 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@EricWF: Gentle ping.


https://reviews.llvm.org/D25468



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


[PATCH] D25292: [coroutines] Add diagnostics for copy/move assignment operators and functions with deduced return types.

2016-10-13 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Ping.


https://reviews.llvm.org/D25292



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


r284150 - Swift Calling Convention: Fix out of bounds access

2016-10-13 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Thu Oct 13 14:19:37 2016
New Revision: 284150

URL: http://llvm.org/viewvc/llvm-project?rev=284150&view=rev
Log:
Swift Calling Convention: Fix out of bounds access

Use iterator instead of address of element in vector

It is not valid to access one after the last element.

rdar://28759508

Modified:
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
cfe/trunk/test/CodeGen/64bit-swiftcall.c

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=284150&r1=284149&r2=284150&view=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Thu Oct 13 14:19:37 2016
@@ -384,7 +384,7 @@ void SwiftAggLowering::splitVectorEntry(
   auto eltTy = split.first;
   CharUnits eltSize = getTypeStoreSize(CGM, eltTy);
   auto numElts = split.second;
-  Entries.insert(&Entries[index + 1], numElts - 1, StorageEntry());
+  Entries.insert(Entries.begin() + index + 1, numElts - 1, StorageEntry());
 
   CharUnits begin = Entries[index].Begin;
   for (unsigned i = 0; i != numElts; ++i) {

Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284150&r1=284149&r2=284150&view=diff
==
--- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original)
+++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 14:19:37 2016
@@ -694,3 +694,22 @@ typedef struct {
 TEST(struct_l5)
 // CHECK: define swiftcc void @return_struct_l5([[STRUCT5:%.*]]* noalias sret
 // CHECK: define swiftcc void @take_struct_l5([[STRUCT5]]*
+
+
+// Don't crash.
+typedef union {
+int4 v[2];
+struct {
+  int LSW;
+  int d7;
+  int d6;
+  int d5;
+  int d4;
+  int d3;
+  int d2;
+  int MSW;
+} s;
+} union_het_vecint;
+TEST(union_het_vecint)
+// CHECK: define swiftcc void @return_union_het_vecint([[UNION:%.*]]* noalias 
sret
+// CHECK: define swiftcc void @take_union_het_vecint([[UNION]]*


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


[PATCH] D20785: Python 3.5 compatibility for clang-format.py

2016-10-13 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Thanks I am closing it!


Repository:
  rL LLVM

https://reviews.llvm.org/D20785



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


r284154 - CodeGen: ensure that the runtime calling convention matches

2016-10-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Oct 13 14:45:08 2016
New Revision: 284154

URL: http://llvm.org/viewvc/llvm-project?rev=284154&view=rev
Log:
CodeGen: ensure that the runtime calling convention matches

Incorrect specification of the calling convention results in UB which can cause
the code path to be eliminated.  Simplify the existing code by using the
RuntimeCall constructor in `CodeGenFunction`.

Added:
cfe/trunk/test/CodeGenObjC/runtime-abi-match.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=284154&r1=284153&r2=284154&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Thu Oct 13 14:45:08 2016
@@ -150,18 +150,16 @@ namespace {
   };
 
   struct CallObjCEndCatch final : EHScopeStack::Cleanup {
-CallObjCEndCatch(bool MightThrow, llvm::Value *Fn) :
-  MightThrow(MightThrow), Fn(Fn) {}
+CallObjCEndCatch(bool MightThrow, llvm::Value *Fn)
+: MightThrow(MightThrow), Fn(Fn) {}
 bool MightThrow;
 llvm::Value *Fn;
 
 void Emit(CodeGenFunction &CGF, Flags flags) override {
-  if (!MightThrow) {
-CGF.Builder.CreateCall(Fn)->setDoesNotThrow();
-return;
-  }
-
-  CGF.EmitRuntimeCallOrInvoke(Fn);
+  if (MightThrow)
+CGF.EmitRuntimeCallOrInvoke(Fn);
+  else
+CGF.EmitNounwindRuntimeCall(Fn);
 }
   };
 }
@@ -230,10 +228,8 @@ void CGObjCRuntime::EmitTryCatchStmt(Cod
 
 // Enter the catch.
 llvm::Value *Exn = RawExn;
-if (beginCatchFn) {
-  Exn = CGF.Builder.CreateCall(beginCatchFn, RawExn, "exn.adjusted");
-  cast(Exn)->setDoesNotThrow();
-}
+if (beginCatchFn)
+  Exn = CGF.EmitNounwindRuntimeCall(beginCatchFn, RawExn, "exn.adjusted");
 
 CodeGenFunction::LexicalScope cleanups(CGF, 
Handler.Body->getSourceRange());
 

Added: cfe/trunk/test/CodeGenObjC/runtime-abi-match.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/runtime-abi-match.m?rev=284154&view=auto
==
--- cfe/trunk/test/CodeGenObjC/runtime-abi-match.m (added)
+++ cfe/trunk/test/CodeGenObjC/runtime-abi-match.m Thu Oct 13 14:45:08 2016
@@ -0,0 +1,24 @@
+// RUN: %clang -target armv7-windows -fobjc-runtime=ios -O1 -fexceptions -S 
-emit-llvm %s -o - | FileCheck %s
+
+void (*f)(id);
+void (*g)(void);
+void h(void);
+
+@interface NSNumber
++ (NSNumber *)numberWithInt:(int)i;
+@end
+
+void i(void) {
+  @try {
+@throw(@1);
+  } @catch (id i) {
+(*f)(i);
+(*g)();
+  }
+}
+
+// CHECK: call arm_aapcs_vfpcc i8* @objc_begin_catch
+// CHECK: call arm_aapcs_vfpcc void @objc_end_catch
+// CHECK-NOT: call i8* @objc_begin_catch
+// CHECK-NOT: call void @objc_end_catch
+


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


[clang-tools-extra] r284155 - [clang-move] error out when fail to create new files.

2016-10-13 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Oct 13 14:49:19 2016
New Revision: 284155

URL: http://llvm.org/viewvc/llvm-project?rev=284155&view=rev
Log:
[clang-move] error out when fail to create new files.

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=284155&r1=284154&r2=284155&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Thu Oct 13 
14:49:19 2016
@@ -108,10 +108,22 @@ int main(int argc, const char **argv) {
   if (CodeStatus)
 return CodeStatus;
 
-  if (!NewCC.empty())
-CreateNewFile(NewCC);
-  if (!NewHeader.empty())
-CreateNewFile(NewHeader);
+  if (!NewCC.empty()) {
+std::error_code EC = CreateNewFile(NewCC);
+if (EC) {
+  llvm::errs() << "Failed to create " << NewCC << ": " << EC.message()
+   << "\n";
+  return EC.value();
+}
+  }
+  if (!NewHeader.empty()) {
+std::error_code EC = CreateNewFile(NewHeader);
+if (EC) {
+  llvm::errs() << "Failed to create " << NewHeader << ": " << EC.message()
+   << "\n";
+  return EC.value();
+}
+  }
 
   IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions());
   clang::TextDiagnosticPrinter DiagnosticPrinter(errs(), &*DiagOpts);


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


r284156 - test: attempt to repair SCEI buildbots

2016-10-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Oct 13 15:10:22 2016
New Revision: 284156

URL: http://llvm.org/viewvc/llvm-project?rev=284156&view=rev
Log:
test: attempt to repair SCEI buildbots

The tests target ARM, ensure that the ARM target is registered.

Modified:
cfe/trunk/test/CodeGenObjC/runtime-abi-match.m

Modified: cfe/trunk/test/CodeGenObjC/runtime-abi-match.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/runtime-abi-match.m?rev=284156&r1=284155&r2=284156&view=diff
==
--- cfe/trunk/test/CodeGenObjC/runtime-abi-match.m (original)
+++ cfe/trunk/test/CodeGenObjC/runtime-abi-match.m Thu Oct 13 15:10:22 2016
@@ -1,4 +1,5 @@
 // RUN: %clang -target armv7-windows -fobjc-runtime=ios -O1 -fexceptions -S 
-emit-llvm %s -o - | FileCheck %s
+// REQUIRES: arm-registered-target
 
 void (*f)(id);
 void (*g)(void);


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


[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again

2016-10-13 Thread Albert Gutowski via cfe-commits
agutowski created this revision.
agutowski added reviewers: rnk, hans, majnemer, mstorsjo.
agutowski added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

Previously global 64-bit versions of _Interlocked functions broke buildbots on 
i386, so now I'm adding them as builtins for x86-64 and ARM only (should they 
be also on AArch64? I had problems with testing it for AArch64, so I left it)


https://reviews.llvm.org/D25576

Files:
  include/clang/Basic/BuiltinsARM.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  test/CodeGen/ms-intrinsics.c

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -387,25 +387,13 @@
  void *_Exchange, void *_Comparand);
 void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination,
 void *_Exchange, void *_Comparand);
-static __inline__
-__int64 _InterlockedDecrement64(__int64 volatile *_Addend);
-static __inline__
-__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);
-static __inline__
-__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value);
 void *_InterlockedExchangePointer(void *volatile *_Target, void *_Value);
-static __inline__
-__int64 _InterlockedIncrement64(__int64 volatile *_Addend);
 long _InterlockedOr_np(long volatile *_Value, long _Mask);
 short _InterlockedOr16_np(short volatile *_Value, short _Mask);
-static __inline__
-__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask);
 __int64 _InterlockedOr64_np(__int64 volatile *_Value, __int64 _Mask);
 char _InterlockedOr8_np(char volatile *_Value, char _Mask);
 long _InterlockedXor_np(long volatile *_Value, long _Mask);
 short _InterlockedXor16_np(short volatile *_Value, short _Mask);
-static __inline__
-__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask);
 __int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask);
 char _InterlockedXor8_np(char volatile *_Value, char _Mask);
 unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int);
@@ -428,6 +416,27 @@
 
 #endif /* __x86_64__ */
 
+#if defined(__x86_64__) || defined(__arm__)
+
+static __inline__
+__int64 _InterlockedDecrement64(__int64 volatile *_Addend);
+static __inline__
+__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);
+static __inline__
+__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value);
+static __inline__
+__int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value);
+static __inline__
+__int64 _InterlockedIncrement64(__int64 volatile *_Addend);
+static __inline__
+__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask);
+static __inline__
+__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask);
+static __inline__
+__int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask);
+
+#endif
+
 /**\
 |* Bit Counting and Testing
 \**/
@@ -545,15 +554,7 @@
 _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value) {
   return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE);
 }
-#endif
-#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);
-}
-#endif
-#if defined(__arm__) || defined(__aarch64__)
-static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value) {
   return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE);
 }
@@ -567,15 +568,6 @@
 }
 #endif
 /**\
-|* Interlocked Exchange Sub
-\**/
-#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);
-}
-#endif
-/**\
 |* Interlocked Increment
 \**/
 #if defined(__arm__) || defined(__aarch64__)
@@ -603,15 +595,7 @@
 _InterlockedIncrement_rel(long volatile *_Value) {
   return __atomic_add_fetch(_Value, 1, __ATOMIC_RELEASE);
 }
-#endif
-#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);
-}
-#endif
-#if define

[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again

2016-10-13 Thread Reid Kleckner via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:2730
+llvm::AtomicOrdering::SequentiallyConsistent);
+return Builder.CreateSub(RMWI, ConstantInt::get(IntTy, 1));
   }

Can you make a helper similar to MakeBinaryAtomicValue for inc/dec and share 
this code with the 16 and 32-bit atomic increment implementations? You can do 
something like `Builder.CreateBinOp(Inc ? Instruction::Add : Instruction::Sub, 
...)`


https://reviews.llvm.org/D25576



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


[PATCH] D25571: Add and use isDiscardableGVALinkage function.

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

lgtm




Comment at: clang/include/clang/Sema/Sema.h:9244
   /// CUDAKnownEmittedFns.
-  llvm::DenseMap> CUDACallGraph;
+  llvm::DenseMap> 
CUDACallGraph;
 

I think you meant to make this change as part of the original patch.


https://reviews.llvm.org/D25571



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


  1   2   >