Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-05 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 43964.
pxli168 added a comment.

Fix some unused diagnostic and wrong diagnostic. Add test for these diagnostics.


http://reviews.llvm.org/D15603

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/AST/TypeNodes.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenOpenCL/pipe_types.cl
  test/PCH/ocl_types.cl
  test/PCH/ocl_types.h
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/pipes-1.2-negative.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1686,6 +1686,10 @@
   return Visit(TL.getValueLoc());
 }
 
+bool CursorVisitor::VisitPipeTypeLoc(PipeTypeLoc TL) {
+  return Visit(TL.getValueLoc());
+}
+
 #define DEFAULT_TYPELOC_IMPL(CLASS, PARENT) \
 bool CursorVisitor::Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
   return Visit##PARENT##Loc(TL); \
Index: test/SemaOpenCL/pipes-1.2-negative.cl
===
--- /dev/null
+++ test/SemaOpenCL/pipes-1.2-negative.cl
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+
+void foo(read_only pipe int p); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+
+void test1(pipe int *p){// expected-error {{pipes packet types cannot be of reference type}}
+}
+void test2(pipe p){// expected-error {{missing actual type specifier for pipe}}
+}
+void test3(int pipe p){// expected-error {{cannot combine with previous 'int' declaration specifier}}
+}
Index: test/PCH/ocl_types.h
===
--- test/PCH/ocl_types.h
+++ test/PCH/ocl_types.h
@@ -44,6 +44,7 @@
 // image2d_array_depth_t
 typedef image2d_array_depth_t img2darr_dep_t;
 
+#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
 // image2d_msaa_t
 typedef image2d_msaa_t img2dmsaa_t;
 
@@ -56,4 +57,14 @@
 // image2d_array_msaa_depth_t
 typedef image2d_array_msaa_depth_t img2darrmsaadep_t;
 
+// pipe specifier
+
+typedef struct _person {
+  int id;
+  const char *name;
+} Person;
+
+void int_pipe_function(pipe int);
+
+void person_pipe_function(pipe Person);
 #endif
Index: test/PCH/ocl_types.cl
===
--- test/PCH/ocl_types.cl
+++ test/PCH/ocl_types.cl
@@ -1,9 +1,9 @@
 // Test this without pch.
-// RUN: %clang_cc1 -include %S/ocl_types.h -fsyntax-only %s
+// RUN: %clang_cc1 -include %S/ocl_types.h -fsyntax-only %s -cl-std=CL2.0 -D__OPENCL_VERSION__=200
 
 // Test with pch.
-// RUN: %clang_cc1 -x cl -emit-pch -o %t %S/ocl_types.h
-// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s -ast-print
+// RUN: %clang_cc1 -x cl -emit-pch -o %t %S/ocl_types.h -cl-std=CL2.0 -D__OPENCL_VERSION__=200
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s -ast-print -cl-std=CL2.0 -D__OPENCL_VERSION__=200
 
 void foo1(img1d_t img);
 
@@ -24,3 +24,15 @@
 void foo8(evt_t evt) {
   evt_t loc_evt;
 }
+
+#if __OPENCL_VERSION__ >= 200
+
+void foo9(pipe int P) {
+  int_pipe_function(P);
+}
+
+void foo10(pipe Person P) {
+  person_pipe_function(P);
+}
+
+#endif
Index: test/CodeGenOpenCL/pipe_types.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/pipe_types.cl
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %opencl.pipe_t = type opaque
+typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
+typedef int __attribute__((ext_vector_type(4))) int4;
+
+void test1(read_only pipe int p) {
+// CHECK: define voi

Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-05 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 43965.
LegalizeAdulthood added a comment.

Add more unit tests from comments


http://reviews.llvm.org/D8149

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1622,6 +1622,7 @@
   EXPECT_TRUE(matches("class X { void f(int i) {} };", Function1Arg));
   EXPECT_TRUE(notMatches("void f() {}", Function1Arg));
   EXPECT_TRUE(notMatches("void f(int i, int j, int k) {}", Function1Arg));
+  EXPECT_TRUE(matches("void f(int i, ...) {};", Function1Arg));
 }
 
 TEST(Matcher, References) {
@@ -4276,6 +4277,15 @@
   EXPECT_TRUE(matches("void f(int i) {}", functionType()));
 }
 
+TEST(TypeMatching, MatchesFunctionProtoTypes) {
+  EXPECT_TRUE(matches("int (*f)(int);", functionProtoType()));
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(notMatchesC("void f();", functionProtoType()));
+  EXPECT_TRUE(
+  matchesC("void f(void);", functionProtoType(parameterCountIs(0;
+}
+
 TEST(TypeMatching, MatchesParenType) {
   EXPECT_TRUE(
   matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType());
@@ -4977,7 +4987,20 @@
   namespaceDecl(isInline(), hasName("m";
 }
 
-// FIXME: Figure out how to specify paths so the following tests pass on Windows.
+TEST(HasUnderlyingTypeMatcher, Match) {
+  EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;",
+  typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(matches("typedef const int T;",
+  typedefDecl(hasUnderlyingType(asString("const int");
+  EXPECT_TRUE(notMatches("typedef const int T;",
+ typedefDecl(hasUnderlyingType(asString("int");
+  EXPECT_TRUE(
+  matches("typedef int foo; typedef foo bar;",
+  typedefDecl(hasUnderlyingType(asString("foo")), hasName("bar";
+}
+
+// FIXME: Figure out how to specify paths so the following tests pass on
+// Windows.
 #ifndef LLVM_ON_WIN32
 
 TEST(Matcher, IsExpansionInMainFileMatcher) {
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -181,6 +181,7 @@
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);
+  REGISTER_MATCHER(functionProtoType);
   REGISTER_MATCHER(functionTemplateDecl);
   REGISTER_MATCHER(functionType);
   REGISTER_MATCHER(gotoStmt);
@@ -248,6 +249,7 @@
   REGISTER_MATCHER(hasTrueExpression);
   REGISTER_MATCHER(hasTypeLoc);
   REGISTER_MATCHER(hasUnaryOperand);
+  REGISTER_MATCHER(hasUnderlyingType);
   REGISTER_MATCHER(hasUnarySelector);
   REGISTER_MATCHER(hasValueType);
   REGISTER_MATCHER(ifStmt);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -168,6 +168,21 @@
 ///   matches "typedef int X"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches the underlying type of a typedef declaration
+///
+/// Given
+/// \code
+///   typedef int X;
+///   typedef float Y;
+/// \endcode
+/// typedefDecl(hasUnderlyingType(asString("int")))
+///   matches "typedef int X"
+AST_MATCHER_P(TypedefDecl, hasUnderlyingType, internal::Matcher,
+  InnerMatcher) {
+  QualType UnderlyingType = Node.getUnderlyingType();
+  return InnerMatcher.matches(UnderlyingType, Finder, Builder);
+}
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2889,16 +2904,24 @@
 Node.param_end(), Finder, Builder);
 }
 
-/// \brief Matches \c FunctionDecls that have a specific parameter count.
+/// \brief Matches \c FunctionDecls and FunctionProtoTypes that have a specific
+/// parameter count.
 ///
 /// Given
 /// \code
 ///   void f(int i) {}
 ///   void g(int i, int j) {}
+///   void h(int i, int j);
+///   void j(int i);
 /// \endcode
 /// functionDecl(parameterCountIs(2))
-///   matches g(int i, int j) {}
-AST_MATCHER_P(FunctionDecl, parameterCountIs, unsigned, N) {
+///   matches void g(int i, int j) {}
+/// functionProtoType(parameterCountIs(2))
+///   matches void h(int i, int j)
+AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+  FunctionProtoType),
+  unsigned, N) {
   return Node.getNumParams() == N;
 }
 
@

r256822 - [ARM] [AARCH64] Add CodeGen IR tests for {VS}QRDML{AS}H v8.1a intrinsics.

2016-01-05 Thread Alexandros Lamprineas via cfe-commits
Author: alelab01
Date: Tue Jan  5 03:58:29 2016
New Revision: 256822

URL: http://llvm.org/viewvc/llvm-project?rev=256822&view=rev
Log:
[ARM] [AARCH64] Add CodeGen IR tests for {VS}QRDML{AS}H v8.1a intrinsics.

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

Modified:
cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c
cfe/trunk/test/CodeGen/arm-v8.1a-neon-intrinsics.c

Modified: cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c?rev=256822&r1=256821&r2=256822&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c Tue Jan  5 03:58:29 
2016
@@ -1,128 +1,198 @@
 // REQUIRES: aarch64-registered-target
 
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon \
-// RUN:  -target-feature +v8.1a -O3 -S -o - %s \
-// RUN:  | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64
+// RUN:  -target-feature +v8.1a -S -emit-llvm -o - %s | FileCheck %s
 
  #include 
 
-// CHECK-AARCH64-LABEL: test_vqrdmlah_laneq_s16
+// CHECK-LABEL: test_vqrdmlah_laneq_s16
 int16x4_t test_vqrdmlah_laneq_s16(int16x4_t a, int16x4_t b, int16x8_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.4h, {{v[0-9]+}}.4h, {{v[0-9]+}}.h[7]
+// CHECK: shufflevector <8 x i16> {{%.*}}, <8 x i16> {{%.*}}, <4 x i32> 
+// CHECK: call <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x i16> {{%.*}}, 
<4 x i16> {{%.*}})
+// CHECK: call <4 x i16> @llvm.aarch64.neon.sqadd.v4i16(<4 x i16> {{%.*}}, <4 
x i16> {{%.*}})
   return vqrdmlah_laneq_s16(a, b, v, 7);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlah_laneq_s32
+// CHECK-LABEL: test_vqrdmlah_laneq_s32
 int32x2_t test_vqrdmlah_laneq_s32(int32x2_t a, int32x2_t b, int32x4_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.s[3]
+// CHECK: shufflevector <4 x i32> {{%.*}}, <4 x i32> {{%.*}}, <2 x i32> 
+// CHECK: call <2 x i32> @llvm.aarch64.neon.sqrdmulh.v2i32(<2 x i32> {{%.*}}, 
<2 x i32> {{%.*}})
+// CHECK: call <2 x i32> @llvm.aarch64.neon.sqadd.v2i32(<2 x i32> {{%.*}}, <2 
x i32> {{%.*}})
   return vqrdmlah_laneq_s32(a, b, v, 3);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahq_laneq_s16
+// CHECK-LABEL: test_vqrdmlahq_laneq_s16
 int16x8_t test_vqrdmlahq_laneq_s16(int16x8_t a, int16x8_t b, int16x8_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.8h, {{v[0-9]+}}.8h, {{v[0-9]+}}.h[7]
+// CHECK: shufflevector <8 x i16> {{%.*}}, <8 x i16> {{%.*}}, <8 x i32> 
+// CHECK: call <8 x i16> @llvm.aarch64.neon.sqrdmulh.v8i16(<8 x i16> {{%.*}}, 
<8 x i16> {{%.*}})
+// CHECK: call <8 x i16> @llvm.aarch64.neon.sqadd.v8i16(<8 x i16> {{%.*}}, <8 
x i16> {{%.*}})
   return vqrdmlahq_laneq_s16(a, b, v, 7);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahq_laneq_s32
+// CHECK-LABEL: test_vqrdmlahq_laneq_s32
 int32x4_t test_vqrdmlahq_laneq_s32(int32x4_t a, int32x4_t b, int32x4_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.s[3]
+// CHECK: shufflevector <4 x i32> {{%.*}}, <4 x i32> {{%.*}}, <4 x i32> 
+// CHECK: call <4 x i32> @llvm.aarch64.neon.sqrdmulh.v4i32(<4 x i32> {{%.*}}, 
<4 x i32> {{%.*}})
+// CHECK: call <4 x i32> @llvm.aarch64.neon.sqadd.v4i32(<4 x i32> {{%.*}}, <4 
x i32> {{%.*}})
   return vqrdmlahq_laneq_s32(a, b, v, 3);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahh_s16
+// CHECK-LABEL: test_vqrdmlahh_s16
 int16_t test_vqrdmlahh_s16(int16_t a, int16_t b, int16_t c) {
-// CHECK-AARCH64: sqrdmlah {{h[0-9]+|v[0-9]+.4h}}, {{h[0-9]+|v[0-9]+.4h}}, 
{{h[0-9]+|v[0-9]+.4h}}
+// CHECK: [[insb:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[insc:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[mul:%.*]] = call <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x 
i16> [[insb]], <4 x i16> [[insc]])
+// CHECK: extractelement <4 x i16> [[mul]], i64 0
+// CHECK: [[insa:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[insmul:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[add:%.*]] = call <4 x i16> @llvm.aarch64.neon.sqadd.v4i16(<4 x 
i16> [[insa]], <4 x i16> [[insmul]])
+// CHECK: extractelement <4 x i16> [[add]], i64 0
   return vqrdmlahh_s16(a, b, c);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahs_s32
+// CHECK-LABEL: test_vqrdmlahs_s32
 int32_t test_vqrdmlahs_s32(int32_t a, int32_t b, int32_t c) {
-// CHECK-AARCH64: sqrdmlah {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
+// CHECK: call i32 @llvm.aarch64.neon.sqrdmulh.i32(i32 {{%.*}}, i32 {{%.*}})
+// CHECK: call i32 @llvm.aarch64.neon.sqadd.i32(i32 {{%.*}}, i32 {{%.*}})
   return vqrdmlahs_s32(a, b, c);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahh_lane_s16
+// CHECK-LABEL: test_vqrdmlahh_lane_s16
 int16_t test_vqrdmlahh_lane_s16(int16_t a, int16_t b, int16x4_t c) {
-// CHECK-AARCH64: sqrdmlah {{h[0-9]+|v[0-9]+.4h}}, {{h[0-9]+|v[0-9]+.4h}}, 
{{v[0-9]+}}.h[3]
+// CHECK:

Re: [PATCH] D15223: [ARM] [AARCH64] Add CodeGen IR tests for {VS}QRDML{AS}H v8.1a intrinsics.

2016-01-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256822: [ARM] [AARCH64] Add CodeGen IR tests for 
{VS}QRDML{AS}H v8.1a intrinsics. (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D15223?vs=43885&id=43969#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15223

Files:
  cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c
  cfe/trunk/test/CodeGen/arm-v8.1a-neon-intrinsics.c

Index: cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c
===
--- cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c
+++ cfe/trunk/test/CodeGen/aarch64-v8.1a-neon-intrinsics.c
@@ -1,128 +1,198 @@
 // REQUIRES: aarch64-registered-target
 
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon \
-// RUN:  -target-feature +v8.1a -O3 -S -o - %s \
-// RUN:  | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64
+// RUN:  -target-feature +v8.1a -S -emit-llvm -o - %s | FileCheck %s
 
  #include 
 
-// CHECK-AARCH64-LABEL: test_vqrdmlah_laneq_s16
+// CHECK-LABEL: test_vqrdmlah_laneq_s16
 int16x4_t test_vqrdmlah_laneq_s16(int16x4_t a, int16x4_t b, int16x8_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.4h, {{v[0-9]+}}.4h, {{v[0-9]+}}.h[7]
+// CHECK: shufflevector <8 x i16> {{%.*}}, <8 x i16> {{%.*}}, <4 x i32> 
+// CHECK: call <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x i16> {{%.*}}, <4 x i16> {{%.*}})
+// CHECK: call <4 x i16> @llvm.aarch64.neon.sqadd.v4i16(<4 x i16> {{%.*}}, <4 x i16> {{%.*}})
   return vqrdmlah_laneq_s16(a, b, v, 7);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlah_laneq_s32
+// CHECK-LABEL: test_vqrdmlah_laneq_s32
 int32x2_t test_vqrdmlah_laneq_s32(int32x2_t a, int32x2_t b, int32x4_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.s[3]
+// CHECK: shufflevector <4 x i32> {{%.*}}, <4 x i32> {{%.*}}, <2 x i32> 
+// CHECK: call <2 x i32> @llvm.aarch64.neon.sqrdmulh.v2i32(<2 x i32> {{%.*}}, <2 x i32> {{%.*}})
+// CHECK: call <2 x i32> @llvm.aarch64.neon.sqadd.v2i32(<2 x i32> {{%.*}}, <2 x i32> {{%.*}})
   return vqrdmlah_laneq_s32(a, b, v, 3);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahq_laneq_s16
+// CHECK-LABEL: test_vqrdmlahq_laneq_s16
 int16x8_t test_vqrdmlahq_laneq_s16(int16x8_t a, int16x8_t b, int16x8_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.8h, {{v[0-9]+}}.8h, {{v[0-9]+}}.h[7]
+// CHECK: shufflevector <8 x i16> {{%.*}}, <8 x i16> {{%.*}}, <8 x i32> 
+// CHECK: call <8 x i16> @llvm.aarch64.neon.sqrdmulh.v8i16(<8 x i16> {{%.*}}, <8 x i16> {{%.*}})
+// CHECK: call <8 x i16> @llvm.aarch64.neon.sqadd.v8i16(<8 x i16> {{%.*}}, <8 x i16> {{%.*}})
   return vqrdmlahq_laneq_s16(a, b, v, 7);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahq_laneq_s32
+// CHECK-LABEL: test_vqrdmlahq_laneq_s32
 int32x4_t test_vqrdmlahq_laneq_s32(int32x4_t a, int32x4_t b, int32x4_t v) {
-// CHECK-AARCH64: sqrdmlah {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.s[3]
+// CHECK: shufflevector <4 x i32> {{%.*}}, <4 x i32> {{%.*}}, <4 x i32> 
+// CHECK: call <4 x i32> @llvm.aarch64.neon.sqrdmulh.v4i32(<4 x i32> {{%.*}}, <4 x i32> {{%.*}})
+// CHECK: call <4 x i32> @llvm.aarch64.neon.sqadd.v4i32(<4 x i32> {{%.*}}, <4 x i32> {{%.*}})
   return vqrdmlahq_laneq_s32(a, b, v, 3);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahh_s16
+// CHECK-LABEL: test_vqrdmlahh_s16
 int16_t test_vqrdmlahh_s16(int16_t a, int16_t b, int16_t c) {
-// CHECK-AARCH64: sqrdmlah {{h[0-9]+|v[0-9]+.4h}}, {{h[0-9]+|v[0-9]+.4h}}, {{h[0-9]+|v[0-9]+.4h}}
+// CHECK: [[insb:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[insc:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[mul:%.*]] = call <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x i16> [[insb]], <4 x i16> [[insc]])
+// CHECK: extractelement <4 x i16> [[mul]], i64 0
+// CHECK: [[insa:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[insmul:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[add:%.*]] = call <4 x i16> @llvm.aarch64.neon.sqadd.v4i16(<4 x i16> [[insa]], <4 x i16> [[insmul]])
+// CHECK: extractelement <4 x i16> [[add]], i64 0
   return vqrdmlahh_s16(a, b, c);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahs_s32
+// CHECK-LABEL: test_vqrdmlahs_s32
 int32_t test_vqrdmlahs_s32(int32_t a, int32_t b, int32_t c) {
-// CHECK-AARCH64: sqrdmlah {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
+// CHECK: call i32 @llvm.aarch64.neon.sqrdmulh.i32(i32 {{%.*}}, i32 {{%.*}})
+// CHECK: call i32 @llvm.aarch64.neon.sqadd.i32(i32 {{%.*}}, i32 {{%.*}})
   return vqrdmlahs_s32(a, b, c);
 }
 
-// CHECK-AARCH64-LABEL: test_vqrdmlahh_lane_s16
+// CHECK-LABEL: test_vqrdmlahh_lane_s16
 int16_t test_vqrdmlahh_lane_s16(int16_t a, int16_t b, int16x4_t c) {
-// CHECK-AARCH64: sqrdmlah {{h[0-9]+|v[0-9]+.4h}}, {{h[0-9]+|v[0-9]+.4h}}, {{v[0-9]+}}.h[3]
+// CHECK: extractelement <4 x i16> {{%.*}}, i32 3
+// CHECK: [[insb:%.*]] = insertelement <4 x i16> undef, i16 {{%.*}}, i64 0
+// CHECK: [[insc:%.

Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-05 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a reviewer: Anastasia.
Anastasia added a comment.

LGTM!



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:108
@@ +107,3 @@
+PipeTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc);
+  }

Yes, I think we might, otherwise I don't see how we are going to allows any 
element type (including user defined types) for pipe without adding a template 
like functionality to C parsing.


http://reviews.llvm.org/D15603



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


Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-05 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:108
@@ +107,3 @@
+PipeTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc);
+  }

Anastasia wrote:
> Yes, I think we might, otherwise I don't see how we are going to allows any 
> element type (including user defined types) for pipe without adding a 
> template like functionality to C parsing.
OK, I will send a patch only for these two builtin function (I don't think 
other pipe functions need to be built-in), and I think we can discuss about the 
function mangle for them, now I have a version without mangle and a hard code 
version.


http://reviews.llvm.org/D15603



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


[PATCH] D15888: [Analyzer] Change the default SA checkers for PS4

2016-01-05 Thread Sean Eveson via cfe-commits
seaneveson created this revision.
seaneveson added reviewers: zaks.anna, dcoughlin.
seaneveson added a subscriber: cfe-commits.

This patch removes security.*, unix.API and unix.Vfork from the default 
checkers for PS4.

http://reviews.llvm.org/D15888

Files:
  lib/Driver/Tools.cpp
  test/Driver/ps4-analyzer-defaults.cpp

Index: test/Driver/ps4-analyzer-defaults.cpp
===
--- /dev/null
+++ test/Driver/ps4-analyzer-defaults.cpp
@@ -0,0 +1,33 @@
+// Check that the default analyzer checkers for PS4 are:
+//   core
+//   cplusplus
+//   deadcode
+//   nullability
+//   unix
+// Excluding:
+//   unix.API
+//   unix.Vfork
+
+// Check for expected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-POS-CHECKERS
+//
+// Negative check for unexpected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-NEG-CHECKERS
+//
+// Check for all unix checkers except API and Vfork
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-UNIX-CHECKERS
+
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=core
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=cplusplus
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=deadcode
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=nullability
+//
+// CHECK-PS4-NEG-CHECKERS-NOT: analyzer-checker={{osx|security}}
+//
+// CHECK-PS4-UNIX-CHECKERS: analyzer-checker=unix
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.API
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.Vfork
+// CHECK-PS4-UNIX-CHECKERS-NOT: analyzer-checker=unix.{{API|Vfork}}
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3592,6 +3592,12 @@
   if (!IsWindowsMSVC)
 CmdArgs.push_back("-analyzer-checker=unix");
 
+  // Disable some unix checkers for PS4.
+  if (IsPS4CPU) {
+CmdArgs.push_back("-analyzer-disable-checker=unix.API");
+CmdArgs.push_back("-analyzer-disable-checker=unix.Vfork");
+  }
+
   if (getToolChain().getTriple().getVendor() == llvm::Triple::Apple)
 CmdArgs.push_back("-analyzer-checker=osx");
 
@@ -3601,13 +3607,15 @@
 CmdArgs.push_back("-analyzer-checker=cplusplus");
 
   // Enable the following experimental checkers for testing.
-  CmdArgs.push_back(
-  "-analyzer-checker=security.insecureAPI.UncheckedReturn");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
-  CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+  if (!IsPS4CPU) {
+CmdArgs.push_back(
+"-analyzer-checker=security.insecureAPI.UncheckedReturn");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.getpw");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.gets");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
+CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+  }
 
   // Default nullability checks.
   CmdArgs.push_back("-analyzer-checker=nullability.NullPassedToNonnull");


Index: test/Driver/ps4-analyzer-defaults.cpp
===
--- /dev/null
+++ test/Driver/ps4-analyzer-defaults.cpp
@@ -0,0 +1,33 @@
+// Check that the default analyzer checkers for PS4 are:
+//   core
+//   cplusplus
+//   deadcode
+//   nullability
+//   unix
+// Excluding:
+//   unix.API
+//   unix.Vfork
+
+// Check for expected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-POS-CHECKERS
+//
+// Negative check for unexpected checkers
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-NEG-CHECKERS
+//
+// Check for all unix checkers except API and Vfork
+// RUN: %clang -target x86_64-scei-ps4 --analyze %s -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PS4-UNIX-CHECKERS
+
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=core
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=cplusplus
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=deadcode
+// CHECK-PS4-POS-CHECKERS-DAG: analyzer-checker=nullability
+//
+// CHECK-PS4-NEG-CHECKERS-NOT: analyzer-checker={{osx|security}}
+//
+// CHECK-PS4-UNIX-CHECKERS: analyzer-checker=unix
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=unix.API
+// CHECK-PS4-UNIX-CHECKERS-DAG: analyzer-disable-checker=u

Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-01-05 Thread Renato Golin via cfe-commits
rengolin added a comment.

Tests?


http://reviews.llvm.org/D15883



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:1235-1243
@@ -1235,9 +1234,11 @@
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::Constant *GVC = GetAddrOfGlobal(D, /*IsForDefinition=*/true);
+llvm::GlobalValue *GV = dyn_cast(GVC);
+
+// In case of different address spaces, we may still get a cast, even with
+// IsForDefinition equal to true. Query mangled names table to get
+// GlobalValue.
+if (!GV)
+  GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary

You are right -- I missed this case. Fixed.

Patch updated.


http://reviews.llvm.org/D15686



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


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-05 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 43982.
andreybokhanko marked an inline comment as done.
andreybokhanko added a comment.

Fixed tra's note.


http://reviews.llvm.org/D15686

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/duplicate-mangled-name.cpp

Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1226,27 +1226,28 @@
 
   for (DeferredGlobal &G : CurDeclsToEmit) {
 GlobalDecl D = G.GD;
-llvm::GlobalValue *GV = G.GV;
 G.GV = nullptr;
 
 // We should call GetAddrOfGlobal with IsForDefinition set to true in order
 // to get GlobalValue with exactly the type we need, not something that
 // might had been created for another decl with the same mangled name but
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, /*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::Constant *GVC = GetAddrOfGlobal(D, /*IsForDefinition=*/true);
+llvm::GlobalValue *GV = dyn_cast(GVC);
+
+// In case of different address spaces, we may still get a cast, even with
+// IsForDefinition equal to true. Query mangled names table to get
+// GlobalValue.
+if (!GV)
+  GV = GetGlobalValue(getMangledName(D));
 
 // Check to see if we've already emitted this.  This is necessary
 // for a couple of reasons: first, decls can end up in the
 // deferred-decls queue multiple times, and second, decls can end
 // up with definitions in unusual ways (e.g. by an extern inline
 // function acquiring a strong function redefinition).  Just
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;
 
 // Otherwise, emit the definition and move on to the next one.
@@ -1707,7 +1708,7 @@
   }
 
   if (const auto *VD = dyn_cast(D))
-return EmitGlobalVarDefinition(VD);
+return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
   
   llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
@@ -1748,8 +1749,8 @@
 // error.
 if (IsForDefinition && !Entry->isDeclaration()) {
   GlobalDecl OtherGD;
-  // Check that GD is not yet in ExplicitDefinitions is required to make
-  // sure that we issue an error only once.
+  // Check that GD is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
   if (lookupRepresentativeDecl(MangledName, OtherGD) &&
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
@@ -1962,7 +1963,8 @@
 llvm::Constant *
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
- const VarDecl *D) {
+ const VarDecl *D,
+ bool IsForDefinition) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -1978,19 +1980,56 @@
 if (Entry->getType() == Ty)
   return Entry;
 
+// If there are two attempts to define the same mangled name, issue an
+// error.
+if (IsForDefinition && !Entry->isDeclaration()) {
+  GlobalDecl OtherGD;
+  const VarDecl *OtherD;
+
+  // Check that D is not yet in DiagnosedConflictingDefinitions is required
+  // to make sure that we issue an error only once.
+  if (lookupRepresentativeDecl(MangledName, OtherGD) &&
+  (D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
+  (OtherD = dyn_cast(OtherGD.getDecl())) &&
+  OtherD->hasInit() &&
+  DiagnosedConflictingDefinitions.insert(D).second) {
+getDiags().Report(D->getLocation(),
+  diag::err_duplicate_mangled_name);
+getDiags().Report(OtherGD.getDecl()->getLocation(),
+  diag::note_previous_definition);
+  }
+}
+
 // Make sure the result is of the correct type.
 if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
   return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
 
-return llvm::ConstantExpr::getBitCast(Entry, Ty);
+// (If global is requested for a definition, we always need to create a new
+// global, not just return a bitcast.)
+if (!IsForDefinition)
+  return llvm::ConstantExpr::getBitCast(Entry, Ty);
   }
 
   unsigned AddrSpace = GetGlobalVarAddressSpace(D, Ty->getAddressSpace());
   auto *GV = new llvm::GlobalVariable(
   getModule(), Ty->getElementType(), false,
   llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
   llvm::GlobalVariable::NotThreadLocal, AddrSpace);
 
+  // If we already created

r256830 - clang-format: Improve line wrapping behavior in call sequences.

2016-01-05 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Jan  5 07:03:50 2016
New Revision: 256830

URL: http://llvm.org/viewvc/llvm-project?rev=256830&view=rev
Log:
clang-format: Improve line wrapping behavior in call sequences.

r256750 has been leading to an undesired behavior:

  aa
  ..aa();

This change increases penalty for wrapping before member accesses that aren't
calls. Thus, this is again formatted as (as it has been before r256750):

  aa..aa(
  );

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=256830&r1=256829&r2=256830&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Jan  5 07:03:50 2016
@@ -378,7 +378,7 @@ void ContinuationIndenter::addTokenOnCur
TT_CtorInitializerColon)) &&
  ((Previous.getPrecedence() != prec::Assignment &&
(Previous.isNot(tok::lessless) || Previous.OperatorIndex != 0 ||
-!Previous.LastOperator)) ||
+Previous.NextOperator)) ||
   Current.StartsBinaryExpression)) {
 // Always indent relative to the RHS of the expression unless this is a
 // simple assignment without binary expression on the RHS. Also indent
@@ -693,7 +693,7 @@ unsigned ContinuationIndenter::moveState
 std::min(State.LowestLevelOnLine, Current.NestingLevel);
   if (Current.isMemberAccess())
 State.Stack.back().StartOfFunctionCall =
-Current.LastOperator ? 0 : State.Column;
+!Current.NextOperator ? 0 : State.Column;
   if (Current.is(TT_SelectorName)) {
 State.Stack.back().ObjCSelectorNameFound = true;
 if (Style.IndentWrappedFunctionNames) {

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=256830&r1=256829&r2=256830&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Jan  5 07:03:50 2016
@@ -248,9 +248,9 @@ struct FormatToken {
   /// with the same precedence, contains the 0-based operator index.
   unsigned OperatorIndex = 0;
 
-  /// \brief Is this the last operator (or "."/"->") in a sequence of operators
-  /// with the same precedence?
-  bool LastOperator = false;
+  /// \brief If this is an operator (or "."/"->") in a sequence of operators
+  /// with the same precedence, points to the next operator.
+  FormatToken *NextOperator = nullptr;
 
   /// \brief Is this token part of a \c DeclStmt defining multiple variables?
   ///

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256830&r1=256829&r2=256830&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jan  5 07:03:50 2016
@@ -1330,6 +1330,8 @@ public:
   } else {
 // Operator found.
 if (CurrentPrecedence == Precedence) {
+  if (LatestOperator)
+LatestOperator->NextOperator = Current;
   LatestOperator = Current;
   Current->OperatorIndex = OperatorIndex;
   ++OperatorIndex;
@@ -1339,7 +1341,7 @@ public:
 }
 
 if (LatestOperator && (Current || Precedence > 0)) {
-  LatestOperator->LastOperator = true;
+  // LatestOperator->LastOperator = true;
   if (Precedence == PrecedenceArrowAndPeriod) {
 // Call expressions don't have a binary operator precedence.
 addFakeParenthesis(Start, prec::Unknown);
@@ -1771,7 +1773,15 @@ unsigned TokenAnnotator::splitPenalty(co
 // which might otherwise be blown up onto many lines. Here, clang-format
 // won't produce "hanging" indents anyway as there is no other trailing
 // call.
-return Right.LastOperator ? 150 : 35;
+//
+// Also apply higher penalty is not a call as that might lead to a wrapping
+// like:
+//
+//   aaa
+//   .a.();
+return !Right.NextOperator || !Right.NextOperator->Previous->closesScope()
+   ? 150
+   : 35;
   }
 
   if (Right.is(TT_TrailingAnnotation) &&
@@ -1823,7 +1833,7 @@ unsigned TokenAnnotator::splitPenalty(co
 
   if (Right.is(tok::lessless)) {
 if (Left.is(tok::string_literal) &&
-(!Right.LastOperator || Right.OperatorIndex != 1)) {
+(Right.Nex

r256831 - clang-format: Avoid creating hanging indents in call sequences.

2016-01-05 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Jan  5 07:03:59 2016
New Revision: 256831

URL: http://llvm.org/viewvc/llvm-project?rev=256831&view=rev
Log:
clang-format: Avoid creating hanging indents in call sequences.

Before:
  .aaa(
  )
.aaa(a);

After:
  
.aaa()
.aaa(a);

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=256831&r1=256830&r2=256831&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Jan  5 07:03:59 2016
@@ -38,6 +38,12 @@ static unsigned getLengthToMatchingParen
   return End->TotalLength - Tok.TotalLength + 1;
 }
 
+static unsigned getLengthToNextOperator(const FormatToken &Tok) {
+  if (!Tok.NextOperator)
+return 0;
+  return Tok.NextOperator->TotalLength - Tok.TotalLength;
+}
+
 // Returns \c true if \c Tok is the "." or "->" of a call and starts the next
 // segment of a builder type call.
 static bool startsSegmentOfBuilderTypeCall(const FormatToken &Tok) {
@@ -174,6 +180,10 @@ bool ContinuationIndenter::mustBreak(con
   if (State.Column < NewLineColumn)
 return false;
 
+  if (Current.isMemberAccess() &&
+  State.Column + getLengthToNextOperator(Current) > Style.ColumnLimit)
+return true;
+
   if (Style.AlwaysBreakBeforeMultilineStrings &&
   (NewLineColumn == State.FirstIndent + Style.ContinuationIndentWidth ||
Previous.is(tok::comma) || Current.NestingLevel < 2) &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256831&r1=256830&r2=256831&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan  5 07:03:59 2016
@@ -4157,8 +4157,9 @@ TEST_F(FormatTest, FormatsBuilderPattern
   verifyFormat("return a->a().a().aa() <\n"
"   aaa->a().a().aa();");
   verifyFormat(
-  "aaa->aaa->aaa(\n"
-  "aa)\n"
+  "aaa->aaa\n"
+  "->aaa(\n"
+  "aa)\n"
   "->(aaa);");
   verifyFormat(
   "aaa->aaa\n"
@@ -4243,6 +4244,13 @@ TEST_F(FormatTest, FormatsBuilderPattern
"aa);");
   verifyFormat(".aa().aaa(\n"
"aa);");
+  verifyFormat("aa.aaa()\n"
+   ".aaa(a);",
+   getLLVMStyleWithColumns(60));
+  verifyFormat("aa\n"
+   ".aaa()\n"
+   ".aaa(a);",
+   getLLVMStyleWithColumns(59));
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {


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


r256832 - clang-format: Handle \n the same way as std::endl with stream operator.

2016-01-05 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Jan  5 07:06:27 2016
New Revision: 256832

URL: http://llvm.org/viewvc/llvm-project?rev=256832&view=rev
Log:
clang-format: Handle \n the same way as std::endl with stream operator.

clang-format breaks multi-line streams after std::endl.
It now also break for '\n', the suggested replacement for std::endl:

  http://llvm.org/docs/CodingStandards.html#avoid-std-endl

Before:
  llvm::errs() << aa << '\n' << bb
   << '\n';
  llvm::errs() <<  << "aa\n" << 
   << "bb\n";

After:
  llvm::errs() << aa << '\n'
   << bb << '\n';
  llvm::errs() <<  << "aa\n"
   <<  << "bb\n";

This changeset ensure that multiline streams have a line break after:
  - std::endl
  - '\n'
  - "\n"
  - "Some Text\n"

Patch by Jean-Philippe Dufraigne, thank you.

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=256832&r1=256831&r2=256832&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Jan  5 07:06:27 2016
@@ -257,8 +257,10 @@ bool ContinuationIndenter::mustBreak(con
   Previous.is(tok::l_brace) && !Current.isOneOf(tok::r_brace, 
tok::comment))
 return true;
 
-  if (Current.is(tok::lessless) && Previous.is(tok::identifier) &&
-  Previous.TokenText == "endl")
+  if (Current.is(tok::lessless) &&
+  ((Previous.is(tok::identifier) && Previous.TokenText == "endl") ||
+   (Previous.Tok.isLiteral() && (Previous.TokenText.endswith("\\n\"") ||
+ Previous.TokenText == "\'\\n\'"
 return true;
 
   return false;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256832&r1=256831&r2=256832&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan  5 07:06:27 2016
@@ -5065,6 +5065,15 @@ TEST_F(FormatTest, AlignsPipes) {
   verifyFormat("llvm::errs() << aa << endl\n"
" << bb << endl;");
   verifyFormat("llvm::errs() << endl << bb << endl;");
+
+  // Handle '\n'.
+  verifyFormat("llvm::errs() << aa << \"\\n\"\n"
+   " << bb << \"\\n\";");
+  verifyFormat("llvm::errs() << aa << \'\\n\'\n"
+   " << bb << \'\\n\';");
+  verifyFormat("llvm::errs() <<  << \"aa\\n\"\n"
+   " <<  << \"bb\\n\";");
+  verifyFormat("llvm::errs() << \"\\n\" << bb << 
\"\\n\";");
 }
 
 TEST_F(FormatTest, UnderstandsEquals) {


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


Re: [PATCH] D15266: [clang-format] Handle \n the same way as std::endl with stream operator.

2016-01-05 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r256832.


http://reviews.llvm.org/D15266



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


[PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-01-05 Thread Timon Van Overveldt via cfe-commits
timonvo created this revision.
timonvo added a reviewer: logan.
timonvo added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Adds a number of constants, defined in the ARM EHABI spec, to the Clang
lib/Headers/unwind.h header. This is prerequisite for landing
http://reviews.llvm.org/D15781, as previously discussed there.

http://reviews.llvm.org/D15883

Files:
  lib/Headers/unwind.h

Index: lib/Headers/unwind.h
===
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -79,6 +79,7 @@
 struct _Unwind_Exception;
 typedef enum {
   _URC_NO_REASON = 0,
+  _URC_OK = 0, /* used by ARM EHABI */
   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
 
   _URC_FATAL_PHASE2_ERROR = 2,
@@ -88,7 +89,8 @@
   _URC_END_OF_STACK = 5,
   _URC_HANDLER_FOUND = 6,
   _URC_INSTALL_CONTEXT = 7,
-  _URC_CONTINUE_UNWIND = 8
+  _URC_CONTINUE_UNWIND = 8,
+  _URC_FAILURE = 9 /* used by ARM EHABI */
 } _Unwind_Reason_Code;
 
 typedef enum {
@@ -150,6 +152,13 @@
   _UVRSR_FAILED = 2
 } _Unwind_VRS_Result;
 
+typedef uint32_t _Unwind_State;
+#define _US_VIRTUAL_UNWIND_FRAME  ((_Unwind_State)0)
+#define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1)
+#define _US_UNWIND_FRAME_RESUME   ((_Unwind_State)2)
+#define _US_ACTION_MASK   ((_Unwind_State)3)
+#define _US_FORCE_UNWIND  ((_Unwind_State)8)
+
 _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context,
   _Unwind_VRS_RegClass __regclass,
   uint32_t __regno,


Index: lib/Headers/unwind.h
===
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -79,6 +79,7 @@
 struct _Unwind_Exception;
 typedef enum {
   _URC_NO_REASON = 0,
+  _URC_OK = 0, /* used by ARM EHABI */
   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
 
   _URC_FATAL_PHASE2_ERROR = 2,
@@ -88,7 +89,8 @@
   _URC_END_OF_STACK = 5,
   _URC_HANDLER_FOUND = 6,
   _URC_INSTALL_CONTEXT = 7,
-  _URC_CONTINUE_UNWIND = 8
+  _URC_CONTINUE_UNWIND = 8,
+  _URC_FAILURE = 9 /* used by ARM EHABI */
 } _Unwind_Reason_Code;
 
 typedef enum {
@@ -150,6 +152,13 @@
   _UVRSR_FAILED = 2
 } _Unwind_VRS_Result;
 
+typedef uint32_t _Unwind_State;
+#define _US_VIRTUAL_UNWIND_FRAME  ((_Unwind_State)0)
+#define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1)
+#define _US_UNWIND_FRAME_RESUME   ((_Unwind_State)2)
+#define _US_ACTION_MASK   ((_Unwind_State)3)
+#define _US_FORCE_UNWIND  ((_Unwind_State)8)
+
 _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context,
   _Unwind_VRS_RegClass __regclass,
   uint32_t __regno,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r256829 - [AArch64] Teaches clang about Samsung Exynos-M1

2016-01-05 Thread MinSeong Kim via cfe-commits
Author: minseongkim
Date: Tue Jan  5 06:53:24 2016
New Revision: 256829

URL: http://llvm.org/viewvc/llvm-project?rev=256829&view=rev
Log:
[AArch64] Teaches clang about Samsung Exynos-M1

Adds core tuning support for new Samsung Exynos-M1 core (ARMv8-A).

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/Driver/aarch64-cpus.c
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=256829&r1=256828&r2=256829&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jan  5 06:53:24 2016
@@ -5316,7 +5316,8 @@ public:
   bool setCPU(const std::string &Name) override {
 bool CPUKnown = llvm::StringSwitch(Name)
 .Case("generic", true)
-.Cases("cortex-a53", "cortex-a57", "cortex-a72", 
"cortex-a35", true)
+.Cases("cortex-a53", "cortex-a57", "cortex-a72",
+   "cortex-a35", "exynos-m1", true)
 .Case("cyclone", true)
 .Default(false);
 return CPUKnown;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256829&r1=256828&r2=256829&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan  5 06:53:24 2016
@@ -2107,7 +2107,7 @@ static bool DecodeAArch64Mcpu(const Driv
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
   if (CPU == "cyclone" || CPU == "cortex-a53" || CPU == "cortex-a57" ||
-  CPU == "cortex-a72" || CPU == "cortex-a35") {
+  CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1") {
 Features.push_back("+neon");
 Features.push_back("+crc");
 Features.push_back("+crypto");

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=256829&r1=256828&r2=256829&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Tue Jan  5 06:53:24 2016
@@ -26,6 +26,7 @@
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m1 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // CHECK-BASIC-V8: 
"target-features"="+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon"
 
 

Modified: cfe/trunk/test/Driver/aarch64-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=256829&r1=256828&r2=256829&view=diff
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (original)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Tue Jan  5 06:53:24 2016
@@ -74,6 +74,20 @@
 // RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a72 -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-CA72 %s
 // ARM64-CA72: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a72"
 
+// RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=M1 %s
+// RUN: %clang -target aarch64 -mlittle-endian -mcpu=exynos-m1 -### -c %s 2>&1 
| FileCheck -check-prefix=M1 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=exynos-m1 -### -c %s 
2>&1 | FileCheck -check-prefix=M1 %s
+// RUN: %clang -target aarch64 -mtune=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=M1 %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=exynos-m1 -### -c %s 
2>&1 | FileCheck -check-prefix=M1 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=exynos-m1 -### -c %s 
2>&1 | FileCheck -check-prefix=M1 %s
+// M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "exynos-m1"
+
+// RUN: %clang -target arm64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-M1 %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=exynos-m1 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-M1 %s
+// RUN: %clang -target arm64 -mtune=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-M1 %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=exynos-m1 -### -c %s 2>&

Re: [PATCH] D15664: Teaches clang about Exynos-M1

2016-01-05 Thread MinSeong KIM via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256829: [AArch64] Teaches clang about Samsung Exynos-M1 
(authored by MinSeongKIM).

Changed prior to commit:
  http://reviews.llvm.org/D15664?vs=43354&id=43984#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15664

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/CodeGen/arm-target-features.c
  cfe/trunk/test/Driver/aarch64-cpus.c
  cfe/trunk/test/Driver/arm-cortex-cpus.c
  cfe/trunk/test/Preprocessor/aarch64-target-features.c

Index: cfe/trunk/test/CodeGen/arm-target-features.c
===
--- cfe/trunk/test/CodeGen/arm-target-features.c
+++ cfe/trunk/test/CodeGen/arm-target-features.c
@@ -26,6 +26,7 @@
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu exynos-m1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // CHECK-BASIC-V8: "target-features"="+crc,+crypto,+dsp,+fp-armv8,+hwdiv,+hwdiv-arm,+neon"
 
 
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -92,11 +92,13 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A53 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A57 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A72 %s
+// RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M1 %s
 // CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+// CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
 // CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -398,40 +398,48 @@
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=exynos-m1 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
 // RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a72 -### -c %

Re: [PATCH] D15195: PR4941: Add support for -fno-builtin-foo options.

2016-01-05 Thread Chad Rosier via cfe-commits
mcrosier added a comment.

Ping.


http://reviews.llvm.org/D15195



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


r256838 - [OpenCL] Disallow taking an address of a function.

2016-01-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Tue Jan  5 08:39:27 2016
New Revision: 256838

URL: http://llvm.org/viewvc/llvm-project?rev=256838&view=rev
Log:
[OpenCL] Disallow taking an address of a function.

An undecorated function designator implies taking the address of a function,
which is illegal in OpenCL. Implementing a check for this earlier to allow
the error to be reported even in the presence of other more obvious errors.

Patch by Neil Hickey!

http://reviews.llvm.org/D15691


Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaOpenCL/cond.cl
cfe/trunk/test/SemaOpenCL/func_ptr.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=256838&r1=256837&r2=256838&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Jan  5 08:39:27 
2016
@@ -910,6 +910,10 @@ def warn_pragma_expected_enable_disable
 def warn_pragma_unknown_extension : Warning<
   "unknown OpenCL extension %0 - ignoring">, InGroup;
 
+// OpenCL error
+def err_opencl_taking_function_address_parser : Error<
+  "taking address of function is not allowed">;
+
 // OpenMP support.
 def warn_pragma_omp_ignored : Warning<
   "unexpected '#pragma omp ...' in program">, InGroup, 
DefaultIgnore;

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=256838&r1=256837&r2=256838&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Jan  5 08:39:27 2016
@@ -1334,8 +1334,23 @@ ExprResult Parser::ParseCastExpression(b
 return ExprError();
   }
 
+  // Check to see whether Res is a function designator only. If it is and we
+  // are compiling for OpenCL, we need to return an error as this implies
+  // that the address of the function is being taken, which is illegal in CL.
+
   // These can be followed by postfix-expr pieces.
-  return ParsePostfixExpressionSuffix(Res);
+  Res = ParsePostfixExpressionSuffix(Res);
+  if (getLangOpts().OpenCL)
+if (Expr *PostfixExpr = Res.get()) {
+  QualType Ty = PostfixExpr->getType();
+  if (!Ty.isNull() && Ty->isFunctionType()) {
+Diag(PostfixExpr->getExprLoc(),
+ diag::err_opencl_taking_function_address_parser);
+return ExprError();
+  }
+}
+
+  return Res;
 }
 
 /// \brief Once the leading part of a postfix-expression is parsed, this

Modified: cfe/trunk/test/SemaOpenCL/cond.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/cond.cl?rev=256838&r1=256837&r2=256838&view=diff
==
--- cfe/trunk/test/SemaOpenCL/cond.cl (original)
+++ cfe/trunk/test/SemaOpenCL/cond.cl Tue Jan  5 08:39:27 2016
@@ -128,5 +128,5 @@ int foo2(int);
 
 unsigned int ntest12(int2 C)
 {
-  return (unsigned int)(C ? foo1 : foo2); // expected-error {{taking address 
of function is not allowed}}
+  return (unsigned int)(C ? foo1 : foo2); // expected-error {{taking address 
of function is not allowed}} expected-error {{taking address of function is not 
allowed}}
 }

Modified: cfe/trunk/test/SemaOpenCL/func_ptr.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/func_ptr.cl?rev=256838&r1=256837&r2=256838&view=diff
==
--- cfe/trunk/test/SemaOpenCL/func_ptr.cl (original)
+++ cfe/trunk/test/SemaOpenCL/func_ptr.cl Tue Jan  5 08:39:27 2016
@@ -11,6 +11,9 @@ void bar()
   foo((void*)foo); // expected-error{{taking address of function is not 
allowed}}
   foo(&foo); // expected-error{{taking address of function is not allowed}}
 
+  // initializing an array with the address of functions is an error
+  void* vptrarr[2] = {foo, &foo}; // expected-error{{taking address of 
function is not allowed}} expected-error{{taking address of function is not 
allowed}}
+
   // just calling a function is correct
   foo(0);
 }


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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-01-05 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki updated this revision to Diff 43997.
danielmarjamaki marked an inline comment as done.
danielmarjamaki added a comment.

Refactorings thanks to review comments


http://reviews.llvm.org/D13126

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  test/Analysis/conversion.c

Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.Conversion -verify %s
+
+unsigned char U8;
+signed char S8;
+
+void assign1() {
+  unsigned X = 1000;
+  U8 = X; // expected-warning {{Loss of precision}}
+}
+
+// don't warn for macros
+#define DOSTUFF   ({ unsigned X = 1000; U8 = X; })
+void dontwarn1() {
+  DOSTUFF;
+}
+
+// don't warn for calculations
+// seen some fp. For instance:  c2 = (c2 >= 'A' && c2 <= 'Z') ? c2 - 'A' + 'a' : c2;
+// there is a todo in the checker to handle calculations
+void dontwarn2() {
+  signed S = -32;
+  U8 = S+10;
+}
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -0,0 +1,149 @@
+//=== ConversionChecker.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines ConversionChecker that warns about dangerous conversions where
+// there is possible loss of precision.
+//
+//===--===//
+#include "ClangSACheckers.h"
+#include "clang/AST/ParentMap.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ConversionChecker : public Checker> {
+  mutable std::unique_ptr BT;
+
+public:
+  void checkPreStmt(const ImplicitCastExpr *Cast, CheckerContext &C) const {
+// TODO: For now we only warn about DeclRefExpr, to avoid noise. Warn for
+// calculations also.
+if (!isa(Cast->IgnoreParenImpCasts()))
+  return;
+// Don't warn for loss of precision in macros
+if (Cast->getExprLoc().isMacroID())
+  return;
+const ParentMap &PM = C.getLocationContext()->getParentMap();
+const Stmt *Parent = PM.getParent(Cast);
+if (!Parent)
+  return;
+const BinaryOperator *B = dyn_cast(Parent);
+if (!B)
+  return;
+
+BinaryOperator::Opcode Opc = B->getOpcode();
+if (Opc == BO_Assign || BO_AddAssign || BO_SubAssign || Opc == BO_MulAssign)
+  diagnoseLossOfPrecision(Cast, C);
+  }
+
+private:
+  void diagnoseLossOfPrecision(const ImplicitCastExpr *Cast,
+   CheckerContext &C) const;
+
+  void reportBug(CheckerContext &C, const char Msg[]) const {
+// Generate an error node.
+ExplodedNode *N = C.generateErrorNode(C.getState());
+if (!N)
+  return;
+
+if (!BT)
+  BT.reset(new BuiltinBug(this, "Conversion", "Loss of sign/precision."));
+
+// Generate a report for this bug.
+auto R = llvm::make_unique(*BT, Msg, N);
+C.emitReport(std::move(R));
+  }
+};
+}
+
+static bool isSigned(const Expr *E) {
+  return E->getType()->isSignedIntegerType();
+}
+
+// Can E value be greater or equal than Val?
+static bool canBeGreaterEqual(CheckerContext &C, const Expr *E,
+  unsigned long long Val) {
+  ProgramStateRef State = C.getState();
+  llvm::Optional EVal = C.getSVal(E).getAs();
+  if (!EVal)
+return false;
+
+  SValBuilder &Bldr = C.getSValBuilder();
+  DefinedSVal V = Bldr.makeIntVal(Val, C.getASTContext().LongLongTy);
+
+  // Is DefinedEVal less than V?
+  SVal GE = Bldr.evalBinOp(State, BO_GE, *EVal, V, Bldr.getConditionType());
+  if (GE.isUnknownOrUndef())
+return false;
+  ConstraintManager &CM = C.getConstraintManager();
+  ProgramStateRef StGE, StLT;
+  std::tie(StGE, StLT) = CM.assumeDual(State, GE.castAs());
+  return (StGE && !StLT);
+}
+
+// Can E have negative value?
+static bool canBeNegative(CheckerContext &C, const Expr *E) {
+  ProgramStateRef State = C.getState();
+  SVal EVal = State->getSVal(E, C.getLocationContext());
+  if (EVal.isUnknownOrUndef() || !EVal.getAs())
+return false;
+  DefinedSVal DefinedEVal = EVal.castAs();
+
+  SValBuilder &Bldr = C.getSValBuilder();
+  DefinedSVal V = Bldr.makeIntVal(0, false);
+
+  SVal LT =
+  Bldr.evalBinOp(State, BO_LT, DefinedEVal, V, Bldr.g

Re: r244070 - [CMake] First pass at adding support for clang bootstrap builds to CMake

2016-01-05 Thread Chris Bieneman via cfe-commits
I think you may be misaligning the if statements. I've only used it when doing 
full LLVM+clang builds. In fact, some of the more advanced knobs depend on LLVM 
being built in-tree (which is a bug that I should fix). If you’re having 
problems making it work, let me know. It is still largely untested outside 
darwin and a handful of users, so I expect there will be bugs.

-Chris

> On Jan 3, 2016, at 4:33 PM, Chandler Carruth  wrote:
> 
> Hey Chris, I just noticed that this option is only available when you build 
> Clang as a standalone project, as opposed to building all of LLVM. Was that 
> intentional? Is there any plan to support this in more normal whole-LLVM 
> builds? It seems substantially more useful for stuff like picking up 
> miscompiles...
> 
> -Chandler
> 
> On Wed, Aug 5, 2015 at 10:39 AM Chris Bieneman  > wrote:
> Author: cbieneman
> Date: Wed Aug  5 12:38:12 2015
> New Revision: 244070
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=244070&view=rev 
> 
> Log:
> [CMake] First pass at adding support for clang bootstrap builds to CMake
> 
> Summary:
> This patch adds a new CLANG_ENABLE_BOOTSTRAP option to CMake which adds 
> targets for building a stage2 bootstrap compiler. The targets are:
> 
> bootstrap-configure
> bootstrap-build
> bootstrap (same as bootstrap-configure and bootstrap-build)
> bootstrap-install
> bootstrap-check-llvm
> bootstrap-check-clang
> bootstrap-check-all
> 
> If you are using 3.3.20150708 or greater it utilizes the ninja 
> USES_TERMINAL_* settings on the external project so that the output is 
> properly buffered.
> 
> Reviewers: bogner, chandlerc
> 
> Subscribers: filcab, cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D11743 
> 
> 
> Modified:
> cfe/trunk/CMakeLists.txt
> 
> Modified: cfe/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=244070&r1=244069&r2=244070&view=diff
>  
> 
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Wed Aug  5 12:38:12 2015
> @@ -96,6 +96,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> 
>option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
>  "Set to ON to force using an old, unsupported host toolchain." OFF)
> +  option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
> 
>include(AddLLVM)
>include(TableGen)
> @@ -551,3 +552,76 @@ if (CLANG_BUILT_STANDALONE)
>  ${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake
>  COPYONLY)
>  endif ()
> +
> +if (CLANG_ENABLE_BOOTSTRAP)
> +  include(ExternalProject)
> +
> +  if(CMAKE_VERSION VERSION_LESS 3.3.20150708)
> +set(cmake_3_4_USES_TERMINAL_OPTIONS)
> +  else()
> +set(cmake_3_4_USES_TERMINAL_OPTIONS
> +  USES_TERMINAL_CONFIGURE 1
> +  USES_TERMINAL_BUILD 1
> +  USES_TERMINAL_INSTALL 1
> +  )
> +  endif()
> +
> +  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/)
> +  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/)
> +
> +  add_custom_target(bootstrap-clear
> +DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
> +)
> +  add_custom_command(
> +OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
> +DEPENDS clang
> +COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
> +COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
> +COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
> +COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}
> +COMMAND ${CMAKE_COMMAND} -E touch 
> ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
> +COMMENT "Clobberring bootstrap build and stamp directories"
> +)
> +
> +  ExternalProject_Add(bootstrap
> +DEPENDS clang
> +PREFIX bootstrap
> +SOURCE_DIR ${CMAKE_SOURCE_DIR}
> +STAMP_DIR ${STAMP_DIR}
> +BINARY_DIR ${BINARY_DIR}
> +CMAKE_ARGS
> +# We shouldn't need to set this here, but INSTALL_DIR doesn't
> +# seem to work, so instead I'm passing this through
> +-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
> +${CLANG_BOOTSTRAP_CMAKE_ARGS}
> +-DCMAKE_CXX_COMPILER=${CMAKE_BINARY_DIR}/bin/clang++
> +-DCMAKE_C_COMPILER=${CMAKE_BINARY_DIR}/bin/clang
> +INSTALL_COMMAND ""
> +STEP_TARGETS configure build
> +${cmake_3_4_USES_TERMINAL_OPTIONS}
> +)
> +
> +  # exclude really-install from main target
> +  set_target_properties(bootstrap PROPERTIES 
> _EP_really-install_EXCLUDE_FROM_MAIN On)
> +  ExternalProject_Add_Step(bootstrap really-install
> +COMMAND ${CMAKE_COMMAND} --build  --target install
> +COMMENT "Performing install step for 'bootstrap'"
> +DEPENDEES build
> +  )
> +  ExternalProject_Add_StepTargets(boots

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-05 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44003.
hokein added a comment.

Add UseHeaderFileExtension option.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker', '.hpp']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,131 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // ok
+  void f2();
+  template
+  T f3() {  // ok
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4(); // ok
+};
+  };
+  static void f4(); // ok
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() { // ok
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // ok
+  static int a; // ok
+};
+
+template 
+void CB::f1() { // ok
+}
+
+template 
+void CB::CCA::f2(T a) { // ok
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() { // ok
+}
+
+template 
+int CB::a = 2; // ok;
+
+template 
+T tf() { // ok
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // ok
+inline int f6() { return 1; } // ok
+namespace {
+  int f7() { return 1; } // ok
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+  const int c = 1; // ok;
+}
+
+class CC {
+  static int d;
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+
+namespace {
+  int e = 2; // ok
+}
+
+const char* const g = "foo"; // ok
+static int h = 1; // ok
+const int i = 1; // ok
+extern int j; // ok
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -0,0 +1,36 @@
+misc-definitions-in-headers
+===
+
+Finds non-extern non-inline function and variable definitions in header files, which can lead to potential ODR violations.
+
+..

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-05 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44006.
hokein added a comment.

Update doc.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker', '.hpp']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,131 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // ok
+  void f2();
+  template
+  T f3() {  // ok
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4(); // ok
+};
+  };
+  static void f4(); // ok
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() { // ok
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // ok
+  static int a; // ok
+};
+
+template 
+void CB::f1() { // ok
+}
+
+template 
+void CB::CCA::f2(T a) { // ok
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() { // ok
+}
+
+template 
+int CB::a = 2; // ok;
+
+template 
+T tf() { // ok
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function definition is not allowed in header file [misc-definitions-in-headers]
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // ok
+inline int f6() { return 1; } // ok
+namespace {
+  int f7() { return 1; } // ok
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+  const int c = 1; // ok;
+}
+
+class CC {
+  static int d;
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable definition is not allowed in header file [misc-definitions-in-headers]
+
+namespace {
+  int e = 2; // ok
+}
+
+const char* const g = "foo"; // ok
+static int h = 1; // ok
+const int i = 1; // ok
+extern int j; // ok
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -0,0 +1,41 @@
+misc-definitions-in-headers
+===
+
+Finds non-extern non-inline function and variable definitions in header files, which can lead to potential ODR violations.
+
+.. code:: c++
+   // Foo.

r256841 - clang-format: Fix corner case in "if it saves columns"-calculation.

2016-01-05 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Jan  5 10:10:39 2016
New Revision: 256841

URL: http://llvm.org/viewvc/llvm-project?rev=256841&view=rev
Log:
clang-format: Fix corner case in "if it saves columns"-calculation.

Before:
  
  .(
  aa)
  .aa();

After:
  .(
  aa)
  .aa();

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=256841&r1=256840&r2=256841&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Jan  5 10:10:39 2016
@@ -177,7 +177,7 @@ bool ContinuationIndenter::mustBreak(con
 return true;
 
   unsigned NewLineColumn = getNewLineColumn(State);
-  if (State.Column < NewLineColumn)
+  if (State.Column <= NewLineColumn)
 return false;
 
   if (Current.isMemberAccess() &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256841&r1=256840&r2=256841&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan  5 10:10:39 2016
@@ -4251,6 +4251,9 @@ TEST_F(FormatTest, FormatsBuilderPattern
".aaa()\n"
".aaa(a);",
getLLVMStyleWithColumns(59));
+  verifyFormat(".(\n"
+   "aa)\n"
+   ".aa();");
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
@@ -8305,7 +8308,7 @@ TEST_F(FormatTest, ConfigurableUseOfTab)
"\t();\n"
"};",
Tab);
-  verifyFormat("enum A {\n"
+  verifyFormat("enum AA {\n"
"\ta1, // Force multiple lines\n"
"\ta2,\n"
"\ta3\n"


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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-05 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44008.
hokein added a comment.

Update doc and address comments on test file.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,133 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // ok: inline class member function definition
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4(); // ok
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function definition is not allowed
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function definition is not allowed
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// ok: member function definition of a nested template class in a class
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // ok: forward declaration
+  static int a; // ok: class static data member declaration
+};
+
+template 
+void CB::f1() { // ok: Member function definition of a class template
+}
+
+template 
+void CB::CCA::f2(T a) {
+// ok: member function definition of a nested class in a class template
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// ok: member function definition of a nested class in a class template
+}
+
+template 
+int CB::a = 2; // ok: static data member definition of a class template
+
+template 
+T tf() { // ok: template function definition
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function definition is not allowed
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // ok: function declaration
+inline int f6() { return 1; } // ok: inline function definition
+namespace {
+  int f7() { return 1; } // ok: internal linkage function definition
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable definition is not allowed
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable definition is not allowed
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed
+  const int c = 1; // ok: internal linkage variable definition
+}
+
+class CC {
+  static int d; // ok: class static data member declaration
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable definition is not allowed
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable definition is not allowed
+
+namespace {
+  int e = 2; // ok: internal linkage variable definition
+}
+
+const char* const g = "foo"; // ok: internal linkage variable definition
+static int h = 1; // ok: internal linkage variable definition
+const int i = 1; // ok: internal linkage variable definition
+extern int j; // ok: internal linkage variable definition
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-05 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44010.
hokein marked 4 inline comments as done.
hokein added a comment.

Update.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,133 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // OK: inline class member function definition
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4();
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function definition is not allowed
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function definition is not allowed
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// OK: member function definition of a nested template class in a class
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // OK: forward declaration
+  static int a; // OK: class static data member declaration
+};
+
+template 
+void CB::f1() { // OK: Member function definition of a class template
+}
+
+template 
+void CB::CCA::f2(T a) {
+// OK: member function definition of a nested class in a class template
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// OK: member function definition of a nested class in a class template
+}
+
+template 
+int CB::a = 2; // OK: static data member definition of a class template
+
+template 
+T tf() { // OK: template function definition
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function definition is not allowed
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // OK: function declaration
+inline int f6() { return 1; } // OK: inline function definition
+namespace {
+  int f7() { return 1; } // OK: internal linkage function definition
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable definition is not allowed
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable definition is not allowed
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed
+  const int c = 1; // OK: internal linkage variable definition
+}
+
+class CC {
+  static int d; // OK: class static data member declaration
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable definition is not allowed
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable definition is not allowed
+
+namespace {
+  int e = 2; // OK: internal linkage variable definition
+}
+
+const char* const g = "foo"; // OK: internal linkage variable definition
+static int h = 1; // OK: internal linkage variable definition
+const int i = 1; // OK: internal linkage variable definition
+extern int j; // OK: internal linkage variable definition
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===

Re: [PATCH] D9600: Add scan-build python implementation

2016-01-05 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist added a comment.

sorry for the delay, hard to get free time these days. ;)



Comment at: tools/scan-build-py/libscanbuild/intercept.py:146
@@ +145,3 @@
+})
+elif sys.platform == 'darwin':
+logging.debug('intercept gonna preload libear on OSX')

dcoughlin wrote:
> Can you change this to default to compiler-wrapper interposition on Darwin 
> with a command-line flag to force library-based interposition?
> 
> Library-based interposition will fail silently if SIP is enabled, so this 
> should be detected when that flag is passed so the user is informed. You can 
> detect whether SIP is enabled on Darwin by checking whether (1) there is a 
> binary called 'csrutil' in the path and, if so, (2) whether the output of 
> executing 'csrutil status' contains 'System Integrity Protection status: 
> enabled'.
> 
> 
ok, implemented the SIP check. (also added SELinux check, which behaves the 
same as SIP.)

about the default behavior: `scan-build` command has the other compiler-wrapper 
(run compiler & analyzer) and flags can turn this module on. `intercept-build` 
default is the library-based and flag can turn the compiler-wrapper 
interposition on... i would keep it this way. (and also not make platform 
dependent switches into the code.)


http://reviews.llvm.org/D9600



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


Re: [PATCH] D15220: [OPENMP] dist_schedule clause for distribute directive

2016-01-05 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 44012.
carlo.bertolli marked an inline comment as done.
carlo.bertolli added a comment.

Update to dist_schedule patch, as requested: show whole context and add ast 
print regression test.


Repository:
  rL LLVM

http://reviews.llvm.org/D15220

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/distribute_dist_schedule_ast_print.cpp
  test/OpenMP/distribute_dist_schedule_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2218,6 +2218,11 @@
 void OMPClauseEnqueue::VisitOMPMapClause(const OMPMapClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPDistScheduleClause(
+const OMPDistScheduleClause *C) {
+  Visitor->AddStmt(C->getChunkSize());
+  Visitor->AddStmt(C->getHelperChunkSize());
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/distribute_dist_schedule_messages.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_dist_schedule_messages.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note {{declared here}}
+
+template 
+T tmain(T argc) {
+  T b = argc, c, d, e, f, g;
+  char ** argv;
+  static T a;
+// CHECK: static T a;
+  #pragma omp distribute dist_schedule // expected-error {{expected '(' after 'dist_schedule'}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (argc)) // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-warning {{extra tokens at the end of '#pragma omp distribute' are ignored}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static, argc > 0 ? argv[1] : argv[2]) // expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static), dist_schedule (static, 1) // expected-error {{directive '#pragma omp distribute' cannot contain more than one 'dist_schedule' clause}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static, S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  for (int i = 0; i < 10; ++i) foo();
+  return T();
+}
+
+int main(int argc, char **argv) {
+  #pragma omp distribute dist_schedule // expected-error {{expected '(' after 'dist_schedule'}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule ( // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule () // expected-error {{expected 'static' in OpenMP clause 'dist_schedule'}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i) foo();
+  #pragma omp distribute dist_schedule (static, // expected-erro

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-05 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44013.
hokein marked 2 inline comments as done.
hokein added a comment.

Correct punctuation usage.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,133 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // OK: inline class member function definition.
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4();
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function definition is not allowed
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function definition is not allowed
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// OK: member function definition of a nested template class in a class.
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // OK: forward declaration.
+  static int a; // OK: class static data member declaration.
+};
+
+template 
+void CB::f1() { // OK: Member function definition of a class template.
+}
+
+template 
+void CB::CCA::f2(T a) {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+int CB::a = 2; // OK: static data member definition of a class template.
+
+template 
+T tf() { // OK: template function definition.
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function definition is not allowed
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function definition is not allowed
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // OK: function declaration.
+inline int f6() { return 1; } // OK: inline function definition.
+namespace {
+  int f7() { return 1; } // OK: internal linkage function definition.
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable definition is not allowed
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable definition is not allowed
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable definition is not allowed
+  const int c = 1; // OK: internal linkage variable definition.
+}
+
+class CC {
+  static int d; // OK: class static data member declaration.
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable definition is not allowed
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable definition is not allowed
+
+namespace {
+  int e = 2; // OK: internal linkage variable definition.
+}
+
+const char* const g = "foo"; // OK: internal linkage variable definition.
+static int h = 1; // OK: internal linkage variable definition.
+const int i = 1; // OK: internal linkage variable definition.
+extern int j; // OK: internal linkage variable definition.
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
Index: docs/clang-tidy/checks/misc-definitions-in-headers.r

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-05 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:20
@@ +19,3 @@
+   const int c = 1;
+   namespace {
+ int f = 2;

Done. I have also updated my comments here for these cases. Right now it should 
be ready for review again. Thanks.


http://reviews.llvm.org/D15710



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


Re: [clang-tools-extra] r256562 - [clang-tidy] Fix a use-after-free bug found by asan

2016-01-05 Thread Alexander Kornienko via cfe-commits
On Mon, Jan 4, 2016 at 7:39 PM, Kostya Serebryany  wrote:

> Nice!
> is a fuzzer for clang-tidy possible/
>

Should be no more difficult than clang-fuzzer.


> desirable?
>

It might be useful to find crashes in clang-tidy earlier than we feed a ton
of sources to it. Not sure how effective it would be, since most checks
only do something interesting when a rather complicated pattern is found in
the code. You can take a look at the tests

to get an idea.


> similar to what we have for clang and clang-format
> (tools/clang-format/fuzzer, ./tools/clang-fuzzer)
>
>
> On Tue, Dec 29, 2015 at 8:14 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Tue Dec 29 10:14:38 2015
>> New Revision: 256562
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256562&view=rev
>> Log:
>> [clang-tidy] Fix a use-after-free bug found by asan
>>
>> Modified:
>>
>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=256562&r1=256561&r2=256562&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>> Tue Dec 29 10:14:38 2015
>> @@ -491,9 +491,10 @@ void SimplifyBooleanExprCheck::check(con
>>  bool containsDiscardedTokens(
>>  const ast_matchers::MatchFinder::MatchResult &Result,
>>  CharSourceRange CharRange) {
>> -  StringRef ReplacementText =
>> +  std::string ReplacementText =
>>Lexer::getSourceText(CharRange, *Result.SourceManager,
>> -   Result.Context->getLangOpts()).str();
>> +   Result.Context->getLangOpts())
>> +  .str();
>>Lexer Lex(CharRange.getBegin(), Result.Context->getLangOpts(),
>>  ReplacementText.data(), ReplacementText.data(),
>>  ReplacementText.data() + ReplacementText.size());
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15195: PR4941: Add support for -fno-builtin-foo options.

2016-01-05 Thread Bob Wilson via cfe-commits
bob.wilson accepted this revision.
bob.wilson added a comment.
This revision is now accepted and ready to land.

This looks good to me. Thanks for working on this!


http://reviews.llvm.org/D15195



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


Re: [clang-tools-extra] r256562 - [clang-tidy] Fix a use-after-free bug found by asan

2016-01-05 Thread Kostya Serebryany via cfe-commits
On Tue, Jan 5, 2016 at 9:01 AM, Alexander Kornienko 
wrote:

> On Mon, Jan 4, 2016 at 7:39 PM, Kostya Serebryany  wrote:
>
>> Nice!
>> is a fuzzer for clang-tidy possible/
>>
>
> Should be no more difficult than clang-fuzzer.
>

Let's do it then?


>
>
>> desirable?
>>
>
> It might be useful to find crashes in clang-tidy earlier than we feed a
> ton of sources to it. Not sure how effective it would be, since most checks
> only do something interesting when a rather complicated pattern is found in
> the code. You can take a look at the tests
> 
> to get an idea.
>
>
>> similar to what we have for clang and clang-format
>> (tools/clang-format/fuzzer, ./tools/clang-fuzzer)
>>
>>
>> On Tue, Dec 29, 2015 at 8:14 AM, Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Tue Dec 29 10:14:38 2015
>>> New Revision: 256562
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=256562&view=rev
>>> Log:
>>> [clang-tidy] Fix a use-after-free bug found by asan
>>>
>>> Modified:
>>>
>>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=256562&r1=256561&r2=256562&view=diff
>>>
>>> ==
>>> ---
>>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>>> (original)
>>> +++
>>> clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
>>> Tue Dec 29 10:14:38 2015
>>> @@ -491,9 +491,10 @@ void SimplifyBooleanExprCheck::check(con
>>>  bool containsDiscardedTokens(
>>>  const ast_matchers::MatchFinder::MatchResult &Result,
>>>  CharSourceRange CharRange) {
>>> -  StringRef ReplacementText =
>>> +  std::string ReplacementText =
>>>Lexer::getSourceText(CharRange, *Result.SourceManager,
>>> -   Result.Context->getLangOpts()).str();
>>> +   Result.Context->getLangOpts())
>>> +  .str();
>>>Lexer Lex(CharRange.getBegin(), Result.Context->getLangOpts(),
>>>  ReplacementText.data(), ReplacementText.data(),
>>>  ReplacementText.data() + ReplacementText.size());
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-01-05 Thread Renato Golin via cfe-commits
rengolin added a comment.

Well, I only saw later that these are propositions from another patch...

I don't see why this can't be part of the original patch, but I'm ok with no 
tests if they're used (and tested) on the final patch.

I'll defer to Logan to decide. :)


http://reviews.llvm.org/D15883



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


Re: [PATCH] D15603: [OpenCL] Pipe type support

2016-01-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:108
@@ +107,3 @@
+PipeTy = llvm::PointerType::get(llvm::StructType::create(
+  CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc);
+  }

pxli168 wrote:
> Anastasia wrote:
> > Yes, I think we might, otherwise I don't see how we are going to allows any 
> > element type (including user defined types) for pipe without adding a 
> > template like functionality to C parsing.
> OK, I will send a patch only for these two builtin function (I don't think 
> other pipe functions need to be built-in), and I think we can discuss about 
> the function mangle for them, now I have a version without mangle and a hard 
> code version.
I am afraid we might need to add all of the pipe functions as builtins in order 
to allow them to be called with any pipe element type including user defined 
types.

Otherwise, feel free to propose other ideas.

If you have a patch already, let's start the review and we will see how to move 
forward.


http://reviews.llvm.org/D15603



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


Re: [PATCH] D15858: Warn undeclared identifiers in CUDA kernel calls

2016-01-05 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: test/SemaCUDA/kernel-call.cu:27
@@ -26,1 +26,3 @@
+
+  g1<<>>(42); // expected-error {{use of undeclared identifier 
'undeclared'}}
 }

We set four things in setConfig -- does this test fail if any one of them is 
commented out?  If not, is it hard to add additional tests that will cover the 
changes?


http://reviews.llvm.org/D15858



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


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-01-05 Thread Timon Van Overveldt via cfe-commits
timonvo added a comment.

In http://reviews.llvm.org/D15883#319445, @rengolin wrote:

> Tests?


Sure, I could add some. But is it common practice to test constants? The tests 
would end up being a duplication of the definition, I'm not sure how valuable 
that would be. I also couldn't find tests for any of the existing constants, at 
least not through a quick search under Clang's test/ directory.

Or were you thinking of some other type of test?


http://reviews.llvm.org/D15883



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


r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-05 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Jan  5 12:02:24 2016
New Revision: 256854

URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
Log:
[OpenMP] Allow file ID to be signed in the offloading metadata.

This fixes a regression introduced by rL256842.


Modified:
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue Jan  5 12:02:24 
2016
@@ -407,7 +407,7 @@ int bar(int a){
 
 // Check metadata is properly generated:
 // CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
+// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}
@@ -421,7 +421,7 @@ int bar(int a){
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev", i32 185, 
i32 13, i32 {{[0-9]}}+}
 
 // TCHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
+// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
 // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
 // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
 // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}

Modified: cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp?rev=256854&r1=256853&r2=256854&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp Tue Jan  5 
12:02:24 2016
@@ -57,10 +57,10 @@ int nested(int a){
 
 // Check metadata is properly generated:
 // CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]", i32 
[[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]", i32 
[[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]", i32 
[[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]", i32 
[[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
 
 // TCHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}}
-// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]", i32 
[[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
-// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]", i32 
[[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
+// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]", i32 
[[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
+// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]", i32 
[[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
 #endif


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


Re: [PATCH] D12834: add gcc abi_tag support

2016-01-05 Thread Tavian Barnes via cfe-commits
tavianator added a subscriber: tavianator.


Comment at: lib/AST/ItaniumMangle.cpp:1120
@@ -880,2 +1119,3 @@
 mangleSourceName(qualifier->getAsIdentifier());
+writeAbiTags(qualifier->getAsNamespaceAlias());
 break;

This looks bogus, should be `writeAbiTags(qualifier)` right?


Repository:
  rL LLVM

http://reviews.llvm.org/D12834



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


r256855 - [PGO] Enable clang to pass compiler-rt profile support library to linker on Windows

2016-01-05 Thread Nathan Slingerland via cfe-commits
Author: slingn
Date: Tue Jan  5 12:27:06 2016
New Revision: 256855

URL: http://llvm.org/viewvc/llvm-project?rev=256855&view=rev
Log:
[PGO] Enable clang to pass compiler-rt profile support library to linker on 
Windows

Summary: This change enables clang to automatically link binaries built with 
the -fprofile-instr-generate against the clang_rt.profile-i386.lib library.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/instrprof-ld.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256855&r1=256854&r2=256855&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan  5 12:27:06 2016
@@ -9473,6 +9473,8 @@ void visualstudio::Linker::ConstructJob(
 A.renderAsInput(Args, CmdArgs);
   }
 
+  TC.addProfileRTLibs(Args, CmdArgs);
+
   // We need to special case some linker paths.  In the case of lld, we need to
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.

Modified: cfe/trunk/test/Driver/instrprof-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/instrprof-ld.c?rev=256855&r1=256854&r2=256855&view=diff
==
--- cfe/trunk/test/Driver/instrprof-ld.c (original)
+++ cfe/trunk/test/Driver/instrprof-ld.c Tue Jan  5 12:27:06 2016
@@ -105,3 +105,19 @@
 //
 // CHECK-WATCHOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-WATCHOS-ARMV7: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_watchos.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-pc-win32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-I386 %s
+//
+// CHECK-WINDOWS-I386: "{{.*}}link{{(.exe)?}}"
+// CHECK-WINDOWS-I386: "{{.*}}clang_rt.profile-i386.lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-pc-win32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64 %s
+//
+// CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
+// CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"


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


Re: [PATCH] D15833: [PGO] Enable clang to pass compiler-rt profile support library to linker on Windows

2016-01-05 Thread Nathan Slingerland via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256855: [PGO] Enable clang to pass compiler-rt profile 
support library to linker on… (authored by slingn).

Changed prior to commit:
  http://reviews.llvm.org/D15833?vs=44017&id=44023#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15833

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/instrprof-ld.c

Index: cfe/trunk/test/Driver/instrprof-ld.c
===
--- cfe/trunk/test/Driver/instrprof-ld.c
+++ cfe/trunk/test/Driver/instrprof-ld.c
@@ -105,3 +105,19 @@
 //
 // CHECK-WATCHOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-WATCHOS-ARMV7: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_watchos.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-pc-win32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-I386 %s
+//
+// CHECK-WINDOWS-I386: "{{.*}}link{{(.exe)?}}"
+// CHECK-WINDOWS-I386: "{{.*}}clang_rt.profile-i386.lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-pc-win32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64 %s
+//
+// CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
+// CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9473,6 +9473,8 @@
 A.renderAsInput(Args, CmdArgs);
   }
 
+  TC.addProfileRTLibs(Args, CmdArgs);
+
   // We need to special case some linker paths.  In the case of lld, we need to
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.


Index: cfe/trunk/test/Driver/instrprof-ld.c
===
--- cfe/trunk/test/Driver/instrprof-ld.c
+++ cfe/trunk/test/Driver/instrprof-ld.c
@@ -105,3 +105,19 @@
 //
 // CHECK-WATCHOS-ARMV7: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-WATCHOS-ARMV7: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}darwin{{/|}}libclang_rt.profile_watchos.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-pc-win32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-I386 %s
+//
+// CHECK-WINDOWS-I386: "{{.*}}link{{(.exe)?}}"
+// CHECK-WINDOWS-I386: "{{.*}}clang_rt.profile-i386.lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-pc-win32 -fprofile-instr-generate \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64 %s
+//
+// CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}"
+// CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9473,6 +9473,8 @@
 A.renderAsInput(Args, CmdArgs);
   }
 
+  TC.addProfileRTLibs(Args, CmdArgs);
+
   // We need to special case some linker paths.  In the case of lld, we need to
   // translate 'lld' into 'lld-link', and in the case of the regular msvc
   // linker, we need to use a special search algorithm.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name

2016-01-05 Thread Artem Belevich via cfe-commits
tra added a comment.

A better description of the problem would help. PR itself is somewhat short on 
details.
If I understand it correctly, the problem is that if we create multiple 
definitions with the same mangled name, clang does not always report it as an 
error and only emits one of those instances.



Comment at: lib/CodeGen/CodeGenModule.cpp:1235-1236
@@ -1235,7 +1234,4 @@
 // different type.
-// FIXME: Support for variables is not implemented yet.
-if (isa(D.getDecl()))
-  GV = cast(GetAddrOfGlobal(D, 
/*IsForDefinition=*/true));
-else
-  if (!GV)
-GV = GetGlobalValue(getMangledName(D));
+llvm::Constant *GVC = GetAddrOfGlobal(D, /*IsForDefinition=*/true);
+llvm::GlobalValue *GV = dyn_cast(GVC);
+

andreybokhanko wrote:
> You are right -- I missed this case. Fixed.
> 
> Patch updated.
Minor nit -- you could just do dyn_cast<...>(GetAddrOfGlobal()), considering 
that GVC is not used anywhere else.


Comment at: lib/CodeGen/CodeGenModule.cpp:1250
@@ -1248,3 +1249,3 @@
 // ignore these cases.
-if (GV && !GV->isDeclaration())
+if (!GV->isDeclaration())
   continue;

GetGlobalValue() may return nullptr and existing code did check for that.
I'd add an assert(GV).


Comment at: lib/CodeGen/CodeGenModule.cpp:2184-2188
@@ -2140,7 +2183,7 @@
+
   if (!MustBeEmitted(D)) {
 // If we have not seen a reference to this variable yet, place it
 // into the deferred declarations table to be emitted if needed
 // later.
-StringRef MangledName = getMangledName(D);
-if (!GetGlobalValue(MangledName)) {
+if (!GV) {
   DeferredDecls[MangledName] = D;

This may be collapsed into a single if() now.


Comment at: lib/CodeGen/CodeGenModule.cpp:2197-2198
@@ +2196,4 @@
+  // definition).
+  if (GV && !GV->isDeclaration())
+return;
+

This can be moved above if (!MustBeEmitted()) -- no point calling 
MustBeEmitted() in this case if GV != nullptr.


Comment at: lib/CodeGen/CodeGenModule.h:704
@@ -704,1 +703,3 @@
+ llvm::Type *Ty = nullptr,
+ bool IsForDefinition = false);
 

It would be good to document what IsForDefinition does.



Comment at: lib/CodeGen/CodeGenModule.h:1140
@@ -1139,1 +1139,3 @@
+const VarDecl *D,
+bool IsForDefinition = false);
 

Ditto here.


Comment at: lib/CodeGen/CodeGenModule.h:1151
@@ -1148,3 +1150,3 @@
   void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
-  void EmitGlobalVarDefinition(const VarDecl *D);
+  void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
   void EmitAliasDefinition(GlobalDecl GD);

And for IsTentative, too.



http://reviews.llvm.org/D15686



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


Re: r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-05 Thread Artem Belevich via cfe-commits
Samuel,

The tests are still failing:
http://lab.llvm.org:8011/builders/clang-bpf-build/builds/5759



On Tue, Jan 5, 2016 at 10:02 AM, Samuel Antao via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sfantao
> Date: Tue Jan  5 12:02:24 2016
> New Revision: 256854
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
> Log:
> [OpenMP] Allow file ID to be signed in the offloading metadata.
>
> This fixes a regression introduced by rL256842.
>
>
> Modified:
> cfe/trunk/test/OpenMP/target_codegen_registration.cpp
> cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
>
> Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff
>
> ==
> --- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue Jan  5
> 12:02:24 2016
> @@ -407,7 +407,7 @@ int bar(int a){
>
>  // Check metadata is properly generated:
>  // CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}},
> !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
> !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
> -// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]],
> !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
> +// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]],
> !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
>  // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32
> 210, i32 13, i32 {{[0-9]}}+}
>  // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32
> 226, i32 13, i32 {{[0-9]}}+}
>  // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32
> 232, i32 13, i32 {{[0-9]}}+}
> @@ -421,7 +421,7 @@ int bar(int a){
>  // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev", i32
> 185, i32 13, i32 {{[0-9]}}+}
>
>  // TCHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}},
> !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
> !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
> -// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]],
> !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
> +// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]],
> !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
>  // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32
> 210, i32 13, i32 {{[0-9]}}+}
>  // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32
> 226, i32 13, i32 {{[0-9]}}+}
>  // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32
> 232, i32 13, i32 {{[0-9]}}+}
>
> Modified: cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp?rev=256854&r1=256853&r2=256854&view=diff
>
> ==
> --- cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp Tue Jan
> 5 12:02:24 2016
> @@ -57,10 +57,10 @@ int nested(int a){
>
>  // Check metadata is properly generated:
>  // CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}}
> -// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
> i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
> -// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
> i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
> +// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]",
> i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
> +// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]",
> i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
>
>  // TCHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}}
> -// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
> i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
> -// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
> i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
> +// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]",
> i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
> +// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]",
> i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
>  #endif
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



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


Re: r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-05 Thread Samuel F Antao via cfe-commits

Hi Art,

That only fixed one of the problems. The other one I am having some trouble
to replicate. I am trying a few things and hopefully will get a fix soon.

Sorry for the trouble,
Samuel



From:   Artem Belevich 
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits 
Date:   01/05/2016 01:54 PM
Subject:Re: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.



Samuel,

The tests are still failing:
http://lab.llvm.org:8011/builders/clang-bpf-build/builds/5759



On Tue, Jan 5, 2016 at 10:02 AM, Samuel Antao via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
  Author: sfantao
  Date: Tue Jan  5 12:02:24 2016
  New Revision: 256854

  URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
  Log:
  [OpenMP] Allow file ID to be signed in the offloading metadata.

  This fixes a regression introduced by rL256842.


  Modified:
      cfe/trunk/test/OpenMP/target_codegen_registration.cpp
      cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

  Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
  URL:
  
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff

  ==

  --- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
  +++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue Jan  5
  12:02:24 2016
  @@ -407,7 +407,7 @@ int bar(int a){

   // Check metadata is properly generated:
   // CHECK:     !omp_offload.info
  = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}}

  -// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
  +// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32
  210, i32 13, i32 {{[0-9]}}+}
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32
  226, i32 13, i32 {{[0-9]}}+}
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32
  232, i32 13, i32 {{[0-9]}}+}
  @@ -421,7 +421,7 @@ int bar(int a){
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev", i32
  185, i32 13, i32 {{[0-9]}}+}

   // TCHECK:     !omp_offload.info
  = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}}

  -// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
  +// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
   // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev",
  i32 210, i32 13, i32 {{[0-9]}}+}
   // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev",
  i32 226, i32 13, i32 {{[0-9]}}+}
   // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev",
  i32 232, i32 13, i32 {{[0-9]}}+}

  Modified: cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
  URL:
  
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp?rev=256854&r1=256853&r2=256854&view=diff

  ==

  --- cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
  (original)
  +++ cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp Tue Jan
  5 12:02:24 2016
  @@ -57,10 +57,10 @@ int nested(int a){

   // Check metadata is properly generated:
   // CHECK:     !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}}
  -// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
  i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
  -// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
  i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
  +// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]",
  i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
  +// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]",
  i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}

   // TCHECK:     !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}}
  -// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
  i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
  -// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]",
  i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
  +// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32
  {{-?[0-9]+}}, !"[[NNAME]]", i32 [[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
  +// TCHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32
  {{-?[0-9]+}}, !"[[NNAME]]", i32 [[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
   #endif


  ___
  cfe-commits mailing list
  cfe-commi

Re: [PATCH] D15882: Avoid assert failure on some invalid cc1 options.

2016-01-05 Thread Paul Robinson via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


http://reviews.llvm.org/D15882



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


Re: [PATCH] D15888: [Analyzer] Change the default SA checkers for PS4

2016-01-05 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Driver/Tools.cpp:3609
@@ -3602,2 +3608,3 @@
 
   // Enable the following experimental checkers for testing.
+  if (!IsPS4CPU) {

These are no longer experimental. Could you remove this comment along with your 
change?


http://reviews.llvm.org/D15888



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


Re: [PATCH] D15455: [Driver] Let -static override the toolchain default PIC setting.

2016-01-05 Thread Bob Wilson via cfe-commits
bob.wilson accepted this revision.
bob.wilson added a reviewer: bob.wilson.
bob.wilson added a comment.
This revision is now accepted and ready to land.

I applied a Darwin-specific change for this to clang in r256026.


http://reviews.llvm.org/D15455



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


[libcxx] r256859 - First half of LWG#2354: 'Unnecessary copying when inserting into maps with braced-init syntax'

2016-01-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jan  5 13:32:41 2016
New Revision: 256859

URL: http://llvm.org/viewvc/llvm-project?rev=256859&view=rev
Log:
First half of LWG#2354: 'Unnecessary copying when inserting into maps with 
braced-init syntax'

Modified:
libcxx/trunk/include/__tree
libcxx/trunk/include/map

libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
libcxx/trunk/test/support/MoveOnly.h

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=256859&r1=256858&r2=256859&view=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Tue Jan  5 13:32:41 2016
@@ -909,6 +909,13 @@ public:
 iterator __insert_multi(const value_type& __v);
 iterator __insert_multi(const_iterator __p, const value_type& __v);
 
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+pair __insert_unique(value_type&& __v);
+iterator __insert_unique(const_iterator __p, value_type&& __v);
+iterator __insert_multi(value_type&& __v);
+iterator __insert_multi(const_iterator __p, value_type&& __v);
+#endif
+
 pair __node_insert_unique(__node_pointer __nd);
 iterator __node_insert_unique(const_iterator __p,
   __node_pointer __nd);
@@ -1730,6 +1737,28 @@ __tree<_Tp, _Compare, _Allocator>::__emp
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 template 
+pair::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__insert_unique(value_type&& __v)
+{
+__node_holder __h = __construct_node(_VSTD::forward(__v));
+pair __r = __node_insert_unique(__h.get());
+if (__r.second)
+__h.release();
+return __r;
+}
+
+template 
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, 
value_type&& __v)
+{
+__node_holder __h = __construct_node(_VSTD::forward(__v));
+iterator __r = __node_insert_unique(__p, __h.get());
+if (__r.__ptr_ == __h.get())
+__h.release();
+return __r;
+}
+
+template 
 template 
 pair::iterator, bool>
 __tree<_Tp, _Compare, _Allocator>::__insert_unique(_Vp&& __v)
@@ -1754,6 +1783,28 @@ __tree<_Tp, _Compare, _Allocator>::__ins
 }
 
 template 
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__insert_multi(value_type&& __v)
+{
+__node_base_pointer __parent;
+__node_base_pointer& __child = __find_leaf_high(__parent, __v);
+__node_holder __h = __construct_node(_VSTD::forward(__v));
+__insert_node_at(__parent, __child, 
static_cast<__node_base_pointer>(__h.get()));
+return iterator(__h.release());
+}
+
+template 
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, 
value_type&& __v)
+{
+__node_base_pointer __parent;
+__node_base_pointer& __child = __find_leaf(__p, __parent, __v);
+__node_holder __h = __construct_node(_VSTD::forward(__v));
+__insert_node_at(__parent, __child, 
static_cast<__node_base_pointer>(__h.get()));
+return iterator(__h.release());
+}
+
+template 
 template 
 typename __tree<_Tp, _Compare, _Allocator>::iterator
 __tree<_Tp, _Compare, _Allocator>::__insert_multi(_Vp&& __v)

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=256859&r1=256858&r2=256859&view=diff
==
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Tue Jan  5 13:32:41 2016
@@ -126,9 +126,11 @@ public:
 template 
 iterator emplace_hint(const_iterator position, Args&&... args);
 pair insert(const value_type& v);
+pair insert(  value_type&& v); 
   // C++17
 template 
 pair insert(P&& p);
 iterator insert(const_iterator position, const value_type& v);
+iterator insert(const_iterator position,   value_type&& v);
   // C++17
 template 
 iterator insert(const_iterator position, P&& p);
 template 
@@ -336,9 +338,11 @@ public:
 template 
 iterator emplace_hint(const_iterator position, Args&&... args);
 iterator insert(const value_type& v);
+iterator insert(  value_type&& v); 
   // C++17
 template 
 iterator insert(P&& p);
 iterator insert(const_iterator position, const value_type& v);
+iterator insert(const_iterator position,   value_type&& v);
   // C++17
 template

[libcxx] r256861 - Remove some test scaffolding that I added and then didn't need. No functional change

2016-01-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jan  5 13:44:58 2016
New Revision: 256861

URL: http://llvm.org/viewvc/llvm-project?rev=256861&view=rev
Log:
Remove some test scaffolding that I added and then didn't need. No functional 
change

Modified:
libcxx/trunk/test/support/MoveOnly.h

Modified: libcxx/trunk/test/support/MoveOnly.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/MoveOnly.h?rev=256861&r1=256860&r2=256861&view=diff
==
--- libcxx/trunk/test/support/MoveOnly.h (original)
+++ libcxx/trunk/test/support/MoveOnly.h Tue Jan  5 13:44:58 2016
@@ -35,29 +35,6 @@ public:
 bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}
 };
 
-class MoveOnly2
-{
-MoveOnly2(const MoveOnly&);
-MoveOnly2& operator=(const MoveOnly2&);
-
-int data_;
-public:
-MoveOnly2(int data = 1) : data_(data) {}
-MoveOnly2(MoveOnly2&& x)
-: data_(x.data_) {x.data_ = 0;}
-MoveOnly2& operator=(MoveOnly2&& x)
-{data_ = x.data_; x.data_ = 0; return *this;}
-MoveOnly2(MoveOnly&& x)
-: data_(x.data_) {x.data_ = 0;}
-MoveOnly2& operator=(MoveOnly&& x)
-{data_ = x.data_; x.data_ = 0; return *this;}
-
-int get() const {return data_;}
-
-bool operator==(const MoveOnly2& x) const {return data_ == x.data_;}
-bool operator< (const MoveOnly2& x) const {return data_ <  x.data_;}
-};
-
 namespace std {
 
 template <>
@@ -67,12 +44,6 @@ struct hash
 std::size_t operator()(const MoveOnly& x) const {return x.get();}
 };
 
-template <>
-struct hash
-: public std::unary_function
-{
-std::size_t operator()(const MoveOnly2& x) const {return x.get();}
-};
 }
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES


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


[PATCH] D15897: [libc++] Silence warning about padding inserted at the tail of struct _Rep_base

2016-01-05 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a subscriber: cfe-commits.

This patch fixes a warning that is issued when -Wpadded is on clang's command 
line. The following warning is from the build log of 
http://lab.llvm.org:8080/green/view/Libcxx/job/libcxx_abi/554/consoleText (note 
that I see this warning issued only from builders that use lib/buildit):

In file included from ../src/stdexcept.cpp:10:
../include/__refstring:30:12: warning: padding size of 
'std::__1::__libcpp_refstring::_Rep_base' with 4 bytes to alignment boundary 
[-Wpadded]
struct _Rep_base
   ^
1 warning generated.


http://reviews.llvm.org/D15897

Files:
  include/__refstring

Index: include/__refstring
===
--- include/__refstring
+++ include/__refstring
@@ -27,13 +27,21 @@
 
 typedef int count_t;
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
 struct _Rep_base
 {
 std::size_t len;
 std::size_t cap;
 count_t count;
 };
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 static
 _Rep_base*
 rep_from_data(const char *data_) _NOEXCEPT


Index: include/__refstring
===
--- include/__refstring
+++ include/__refstring
@@ -27,13 +27,21 @@
 
 typedef int count_t;
 
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
 struct _Rep_base
 {
 std::size_t len;
 std::size_t cap;
 count_t count;
 };
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 static
 _Rep_base*
 rep_from_data(const char *data_) _NOEXCEPT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r256864 - Add explicit include directives; the file was getting implicitly included already. NFC

2016-01-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jan  5 13:53:31 2016
New Revision: 256864

URL: http://llvm.org/viewvc/llvm-project?rev=256864&view=rev
Log:
Add explicit include directives; the file was getting implicitly included 
already. NFC

Modified:

libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp?rev=256864&r1=256863&r2=256864&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
 Tue Jan  5 13:53:31 2016
@@ -19,6 +19,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp?rev=256864&r1=256863&r2=256864&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
 Tue Jan  5 13:53:31 2016
@@ -20,6 +20,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp?rev=256864&r1=256863&r2=256864&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
 Tue Jan  5 13:53:31 2016
@@ -19,6 +19,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp?rev=256864&r1=256863&r2=256864&view=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
 Tue Jan  5 13:53:31 2016
@@ -19,6 +19,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {


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


r256865 - [Clang/Support/Windows/Unix] Command lines created by clang may exceed the command length limit set by the OS

2016-01-05 Thread Oleg Ranevskyy via cfe-commits
Author: oleg
Date: Tue Jan  5 13:54:39 2016
New Revision: 256865

URL: http://llvm.org/viewvc/llvm-project?rev=256865&view=rev
Log:
[Clang/Support/Windows/Unix] Command lines created by clang may exceed the 
command length limit set by the OS

Summary:
LLVM part of the patch is D15831.

When clang runs an external tool such as a linker it may create a command line 
that exceeds the length limit.

Clang uses the llvm::sys::argumentsFitWithinSystemLimits function to check if 
command line length fits the OS 

limitation. There are two problems in this function that may cause exceeding of 
the limit:

1. It ignores the length of the program path in its calculations. On the other 
hand, clang adds the program 

path to the command line when it runs the program.

2. It assumes no space character is inserted after the last argument, which is 
not true for Windows. The flattenArgs function adds the trailing space for 
*each* argument. The result of this is that the terminating NULL character is 
not counted and may be placed beyond the length limit if the command line is 
exactly 32768 characters long. The WinAPI's CreateProcess does not find the 
NULL character and fails.


Reviewers: rafael, asl

Subscribers: asl, llvm-commits

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

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=256865&r1=256864&r2=256865&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Jan  5 13:54:39 2016
@@ -699,11 +699,11 @@ void Driver::generateCompilationDiagnost
 }
 
 void Driver::setUpResponseFiles(Compilation &C, Command &Cmd) {
-  // Since argumentsFitWithinSystemLimits() may underestimate system's capacity
+  // Since commandLineFitsWithinSystemLimits() may underestimate system's 
capacity
   // if the tool does not support response files, there is a chance/ that 
things
   // will just work without a response file, so we silently just skip it.
   if (Cmd.getCreator().getResponseFilesSupport() == Tool::RF_None ||
-  llvm::sys::argumentsFitWithinSystemLimits(Cmd.getArguments()))
+  llvm::sys::commandLineFitsWithinSystemLimits(Cmd.getExecutable(), 
Cmd.getArguments()))
 return;
 
   std::string TmpName = GetTemporaryPath("response", "txt");


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


[PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Dimitry Andric via cfe-commits
dim created this revision.
dim added reviewers: davide, echristo, dexonsmith.
dim added subscribers: emaste, ahatanak, cfe-commits, davide.
Herald added subscribers: rengolin, aemerson.

In rL256641, @davide turned off movt generation by default for FreeBSD.
This was because our ld is very old, and did not support the relocations
for it.  However, Ian Lepore added the support very recently, so we
would like to revert rL256641, and replace it with a new `-fno-movt`
frontend option.  This way, it can be turned off when needed.

http://reviews.llvm.org/D15899

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/arm-no-movt.c

Index: test/Driver/arm-no-movt.c
===
--- test/Driver/arm-no-movt.c
+++ test/Driver/arm-no-movt.c
@@ -4,11 +4,11 @@
 // RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-KERNEL
 
-// RUN: %clang -target armv7-gnueabi-freebsd11 -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-FREEBSD
+// RUN: %clang -target armv7-none-gnueabi -fno-movt -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MOVT
 
 // CHECK-DEFAULT-NOT: "-target-feature" "+no-movt"
 
 // CHECK-KERNEL: "-target-feature" "+no-movt"
 
-// CHECK-FREEBSD: "-target-feature" "+no-movt"
+// CHECK-NO-MOVT: "-target-feature" "+no-movt"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -938,8 +938,8 @@
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
-  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
-  if (KernelOrKext || Triple.isOSFreeBSD())
+  // The kext linker doesn't know how to deal with movw/movt.
+  if (KernelOrKext || Args.hasArg(options::OPT_fno_movt))
 Features.push_back("+no-movt");
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1385,6 +1385,8 @@
 def marm : Flag<["-"], "marm">, Alias;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
+def fno_movt : Flag<["-"], "fno-movt">, Group,
+  HelpText<"Disallow use of movt/movw pairs (ARM only)">;
 def mcrc : Flag<["-"], "mcrc">, Group,
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,


Index: test/Driver/arm-no-movt.c
===
--- test/Driver/arm-no-movt.c
+++ test/Driver/arm-no-movt.c
@@ -4,11 +4,11 @@
 // RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-KERNEL
 
-// RUN: %clang -target armv7-gnueabi-freebsd11 -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-FREEBSD
+// RUN: %clang -target armv7-none-gnueabi -fno-movt -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MOVT
 
 // CHECK-DEFAULT-NOT: "-target-feature" "+no-movt"
 
 // CHECK-KERNEL: "-target-feature" "+no-movt"
 
-// CHECK-FREEBSD: "-target-feature" "+no-movt"
+// CHECK-NO-MOVT: "-target-feature" "+no-movt"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -938,8 +938,8 @@
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
-  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
-  if (KernelOrKext || Triple.isOSFreeBSD())
+  // The kext linker doesn't know how to deal with movw/movt.
+  if (KernelOrKext || Args.hasArg(options::OPT_fno_movt))
 Features.push_back("+no-movt");
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1385,6 +1385,8 @@
 def marm : Flag<["-"], "marm">, Alias;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
+def fno_movt : Flag<["-"], "fno-movt">, Group,
+  HelpText<"Disallow use of movt/movw pairs (ARM only)">;
 def mcrc : Flag<["-"], "mcrc">, Group,
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Davide Italiano via cfe-commits
davide added a comment.

I'm not opposed to this but ... this will likely it only 11 (and maybe 10.3 if 
backported) -- what about people running <= 10.2 ? Isn't this a problem for 
them?


http://reviews.llvm.org/D15899



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Davide Italiano via cfe-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

Hmm, probably they can use the new frontend options so it's fine. LGTM.


http://reviews.llvm.org/D15899



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Ed Maste via cfe-commits
emaste accepted this revision.
emaste added a reviewer: emaste.
emaste added a comment.

This LGTM


http://reviews.llvm.org/D15899



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.

Sure.

-eric


http://reviews.llvm.org/D15899



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Dimitry Andric via cfe-commits
dim added a comment.

In http://reviews.llvm.org/D15899#319902, @davide wrote:

> I'm not opposed to this but ... this will likely it only 11 (and maybe 10.3 
> if backported) -- what about people running <= 10.2 ? Isn't this a problem 
> for them?


People running ports-provided or hand-built clang 3.8.0 or higher on older 
FreeBSD's can use `-fno-movt`.  For clang versions 3.7.x and earlier, they can 
still use the old style `-mllvm -arm-use-movt=0`.

We'll fix the FreeBSD build system so it uses the right options for older and 
newer clang versions.


http://reviews.llvm.org/D15899



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Davide Italiano via cfe-commits
davide added a comment.

In http://reviews.llvm.org/D15899#319918, @dim wrote:

> In http://reviews.llvm.org/D15899#319902, @davide wrote:
>
> > I'm not opposed to this but ... this will likely it only 11 (and maybe 10.3 
> > if backported) -- what about people running <= 10.2 ? Isn't this a problem 
> > for them?
>
>
> People running ports-provided or hand-built clang 3.8.0 or higher on older 
> FreeBSD's can use `-fno-movt`.  For clang versions 3.7.x and earlier, they 
> can still use the old style `-mllvm -arm-use-movt=0`.
>
> We'll fix the FreeBSD build system so it uses the right options for older and 
> newer clang versions.


Sounds like a plan.


http://reviews.llvm.org/D15899



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jan 05, 2016 at 08:12:34PM +, Dimitry Andric via cfe-commits wrote:
> In rL256641, @davide turned off movt generation by default for FreeBSD.
> This was because our ld is very old, and did not support the relocations
> for it.  However, Ian Lepore added the support very recently, so we
> would like to revert rL256641, and replace it with a new `-fno-movt`
> frontend option.  This way, it can be turned off when needed.

Is there a precendent for the option name? It should be -m* and not -f*,
since it is not target independent.

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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Eric Christopher via cfe-commits
On Tue, Jan 5, 2016 at 12:29 PM Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Jan 05, 2016 at 08:12:34PM +, Dimitry Andric via cfe-commits
> wrote:
> > In rL256641, @davide turned off movt generation by default for FreeBSD.
> > This was because our ld is very old, and did not support the relocations
> > for it.  However, Ian Lepore added the support very recently, so we
> > would like to revert rL256641, and replace it with a new `-fno-movt`
> > frontend option.  This way, it can be turned off when needed.
>
> Is there a precendent for the option name? It should be -m* and not -f*,
> since it is not target independent.
>
>
Yes, agreed, thanks for the catch Joerg.

-eric


> 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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Ed Maste via cfe-commits
>> Is there a precendent for the option name? It should be -m* and not -f*,
>> since it is not target independent.
>
> Yes, agreed, thanks for the catch Joerg.

Presumably -ffixed_r9 should become -mfixed_r9 as well?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Eric Christopher via cfe-commits
On Tue, Jan 5, 2016 at 12:43 PM Ed Maste  wrote:

> >> Is there a precendent for the option name? It should be -m* and not -f*,
> >> since it is not target independent.
> >
> > Yes, agreed, thanks for the catch Joerg.
>
> Presumably -ffixed_r9 should become -mfixed_r9 as well?
>

That's a bit different in that it matches the -ffixed- command line
option from gcc - just hardcoded to r9.

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


Re: [PATCH] D15584: [CMake] Support a simple case for bootstrap builds to generate PGO data

2016-01-05 Thread Justin Bogner via cfe-commits
Chris Bieneman  writes:
> beanz updated this revision to Diff 43192.
> beanz added a comment.
>
> One more dependency hookup fix, this one makes it so that stage2
> doesn't depend on the stage2-instrumented compiler-rt, and avoids
> building it when you invoke the 'stage2' target.

Please update the cache file names to better match the updated target
naming scheme, but otherwise this LGTM.

>
> http://reviews.llvm.org/D15584
>
> Files:
>   CMakeLists.txt
>   cmake/caches/PGO-stage2.cmake
>   cmake/caches/PGO-stage3.cmake
>   cmake/caches/PGO.cmake
>
> Index: cmake/caches/PGO.cmake
> ===
> --- /dev/null
> +++ cmake/caches/PGO.cmake
> @@ -0,0 +1,17 @@
> +set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
> +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
> +set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
> +
> +set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
> +set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
> +set(CLANG_BOOTSTRAP_TARGETS
> +  generate-profdata
> +  stage2
> +  stage2-check-all
> +  stage2-check-llvm
> +  stage2-check-clang
> +  stage2-test-suite CACHE STRING "")
> +
> +set(CLANG_BOOTSTRAP_CMAKE_ARGS
> +  -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake
> +  CACHE STRING "")
> Index: cmake/caches/PGO-stage3.cmake
> ===
> --- /dev/null
> +++ cmake/caches/PGO-stage3.cmake
> @@ -0,0 +1,2 @@
> +set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
> +set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
> Index: cmake/caches/PGO-stage2.cmake
> ===
> --- /dev/null
> +++ cmake/caches/PGO-stage2.cmake
> @@ -0,0 +1,9 @@
> +set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
> +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
> +set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
> +
> +set(CLANG_BOOTSTRAP_TARGETS check-all check-llvm check-clang test-suite 
> CACHE STRING "")
> +
> +set(CLANG_BOOTSTRAP_CMAKE_ARGS
> +  -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage3.cmake
> +  CACHE STRING "")
> Index: CMakeLists.txt
> ===
> --- CMakeLists.txt
> +++ CMakeLists.txt
> @@ -631,11 +631,19 @@
>  
>string(REGEX MATCH "stage([0-9]*)" MATCHED_STAGE "${CLANG_STAGE}")
>if(MATCHED_STAGE)
> -math(EXPR STAGE_NUM "${MATCHED_STAGE} + 1")
> -set(NEXT_CLANG_STAGE stage${STAGE_NUM})
> +if(NOT LLVM_BUILD_INSTRUMENTED)
> +  math(EXPR STAGE_NUM "${CMAKE_MATCH_1} + 1")
> +  set(NEXT_CLANG_STAGE stage${STAGE_NUM})
> +else()
> +  set(NEXT_CLANG_STAGE stage${CMAKE_MATCH_1})
> +endif()
>else()
>  set(NEXT_CLANG_STAGE bootstrap)
>endif()
> +
> +  if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
> +set(NEXT_CLANG_STAGE ${NEXT_CLANG_STAGE}-instrumented)
> +  endif()
>message(STATUS "Setting next clang stage to: ${NEXT_CLANG_STAGE}")
>
>
> @@ -681,6 +689,26 @@
>  set(RUNTIME_DEP compiler-rt)
>endif()
>  
> +  set(COMPILER_OPTIONS
> +-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
> +-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
> +-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
> +
> +  if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
> +set(PGO_DEP llvm-profdata)
> +set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
> +  endif()
> +
> +  if(LLVM_BUILD_INSTRUMENTED)
> +set(PGO_DEP generate-profdata)
> +set(PGO_OPT 
> -DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata)
> +set(COMPILER_OPTIONS
> +  -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
> +  -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
> +  -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER})
> +set(RUNTIME_DEP) # Don't set runtime dependencies
> +  endif()
> +
># Find all variables that start with BOOTSTRAP_ and populate a variable 
> with
># them.
>get_cmake_property(variableNames VARIABLES)
> @@ -703,7 +731,7 @@
>endforeach()
>  
>ExternalProject_Add(${NEXT_CLANG_STAGE}
> -DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP}
> +DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP} ${PGO_DEP}
>  PREFIX ${NEXT_CLANG_STAGE}
>  SOURCE_DIR ${CMAKE_SOURCE_DIR}
>  STAMP_DIR ${STAMP_DIR}
> @@ -715,11 +743,9 @@
>  -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
>  ${CLANG_BOOTSTRAP_CMAKE_ARGS}
>  ${PASSTHROUGH_VARIABLES}
> --DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
> --DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
> --DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
> --DCLANG_STAGE=${NEXT_CLANG_STAGE}
> -${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose}
> + -DCLANG_STAGE=${NEXT_CLANG_STAGE}
> +${COMPILER_OPTIONS}
> +${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${P

Re: r252960 - [modules] Simplify and generalize the existing rule for finding hidden

2016-01-05 Thread Adrian Prantl via cfe-commits

> On Dec 16, 2015, at 5:19 PM, Bob Wilson via cfe-commits 
>  wrote:
> 
>> 
>> On Nov 12, 2015, at 2:19 PM, Richard Smith via cfe-commits 
>>  wrote:
>> 
>> Author: rsmith
>> Date: Thu Nov 12 16:19:45 2015
>> New Revision: 252960
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=252960&view=rev
>> Log:
>> [modules] Simplify and generalize the existing rule for finding hidden
>> declarations in redeclaration lookup. A declaration is now visible to
>> lookup if:
>> 
>> * It is visible (not in a module, or in an imported module), or
>> * We're doing redeclaration lookup and it's externally-visible, or
>> * We're doing typo correction and looking for unimported decls.
>> 
>> We now support multiple modules having different internal-linkage or 
>> no-linkage
>> definitions of the same name for all entities, not just for functions,
>> variables, and some typedefs. As previously, if multiple such entities are
>> visible, any attempt to use them will result in an ambiguity error.
>> 
>> This patch fixes the linkage calculation for a number of entities where we
>> previously didn't need to get it right (using-declarations, namespace 
>> aliases,
>> and so on).  It also classifies enumerators as always having no linkage, 
>> which
>> is a slight deviation from the C++ standard's definition, but not an 
>> observable
>> change outside modules (this change is being discussed on the -core reflector
>> currently).
>> 
>> This also removes the prior special case for tag lookup, which made some 
>> cases
>> of this work, but also led to bizarre, bogus "must use 'struct' to refer to 
>> type
>> 'Foo' in this scope" diagnostics in C++.
> 
> We’re seeing a build failure that seems like it is due to this change. The 
> following code used to compile successfully:
> 
> namespace llvm {
> template  class AllocatorBase {};
> namespace filter {
> class Node {
>  class NodeBits {};
>  class UniformBits {};
>  union {
>UniformBits UniformBits;
>  };
>  static_assert(sizeof(UniformBits) <= 8, "fits in an uint64_6");
> };
> }
> }
> 
> but now we get "error: reference to 'UniformBits' is ambiguous” from the 
> static_assert. It looks to me like this really is ambiguous and that the code 
> should be changed. Can you confirm that?

[class.union] §9.5.5 states that "The names of the members of an anonymous 
union shall be distinct from the names of any other entity in the scope in 
which the anonymous union is declared.”

I read that as a confirmation that this is indeed illegal.

-- adrian

> 
> I also noticed that we get a duplicated diagnostic in this case. I noticed 
> that you fixed a related case in r252967, but it seems to be missing this 
> case.
> 
>> 
>> Added:
>>   cfe/trunk/test/Modules/Inputs/no-linkage/
>>   cfe/trunk/test/Modules/Inputs/no-linkage/decls.h
>>   cfe/trunk/test/Modules/Inputs/no-linkage/empty.h
>>   cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap
>>   cfe/trunk/test/Modules/no-linkage.cpp
>> Modified:
>>   cfe/trunk/include/clang/Sema/Lookup.h
>>   cfe/trunk/lib/AST/Decl.cpp
>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>   cfe/trunk/test/Index/linkage.c
>>   cfe/trunk/test/Index/usrs.m
>>   cfe/trunk/test/Modules/decldef.m
>>   cfe/trunk/test/Modules/merge-enumerators.cpp
>>   cfe/trunk/test/Modules/module-private.cpp
>>   cfe/trunk/test/Modules/submodule-visibility-cycles.cpp
>>   cfe/trunk/test/Modules/submodules-merge-defs.cpp
>> 
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=252960&r1=252959&r2=252960&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Nov 12 16:19:45 2015
>> @@ -139,8 +139,7 @@ public:
>>  Redecl(Redecl != Sema::NotForRedeclaration),
>>  HideTags(true),
>>  Diagnose(Redecl == Sema::NotForRedeclaration),
>> -  AllowHidden(Redecl == Sema::ForRedeclaration),
>> -  AllowHiddenInternal(AllowHidden),
>> +  AllowHidden(false),
>>  Shadowed(false)
>>  {
>>configure();
>> @@ -162,8 +161,7 @@ public:
>>  Redecl(Redecl != Sema::NotForRedeclaration),
>>  HideTags(true),
>>  Diagnose(Redecl == Sema::NotForRedeclaration),
>> -  AllowHidden(Redecl == Sema::ForRedeclaration),
>> -  AllowHiddenInternal(AllowHidden),
>> +  AllowHidden(false),
>>  Shadowed(false)
>>  {
>>configure();
>> @@ -184,7 +182,6 @@ public:
>>  HideTags(Other.HideTags),
>>  Diagnose(false),
>>  AllowHidden(Other.AllowHidden),
>> -  AllowHiddenInternal(Other.AllowHiddenInternal),
>>  Shadowed(false)
>>  {}
>> 
>> @@ -226,27 +223,16 @@ public:
>>  /// \brief Specify whether hidden declarations are visible, e.g.,
>>  /// for recovery reasons.
>>  void setAllowHidden(bool AH) {
>> -AllowHiddenInternal = AllowHidden = AH;
>> -  }
>> -
>> -  /// \brief Specify whethe

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-05 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44056.
jlebar marked 2 inline comments as done.
jlebar added a comment.

Address tra's review comments.


http://reviews.llvm.org/D15596

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/cuda-lib-dir.cu

Index: test/Driver/cuda-lib-dir.cu
===
--- /dev/null
+++ test/Driver/cuda-lib-dir.cu
@@ -0,0 +1,22 @@
+// Checks that we do -L /path/to/cuda/lib{,64} as appropriate when compiling CUDA code.
+
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// # If we can't find CUDA, don't include it in our library search path.
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/no-cuda-there %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+// NOCUDA-NOT: "-L" "{{.*}}/no-cuda-there/{{.*}}"
+//
+// RUN: %clang -### -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix CUDA-x86_32
+// CUDA-x86_32: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib"
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix CUDA-x86_64
+// CUDA-x86_64: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
+//
+// RUN: %clang -### -v --target=x86_64-unknown-linux -nocudalib \
+// RUN:   --sysroot=%S/Inputs/CUDA %s 2>&1 | FileCheck %s -check-prefix NOCUDA
+// NOCUDA-NOT: "-L" "{{.*}}/Inputs/CUDA/usr/local/cuda/lib64"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -224,8 +224,16 @@
   }
 }
 
-static void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
-const ArgList &Args, ArgStringList &CmdArgs) {
+// Is the given action, or any of its inputs, a CUDA action?
+static bool isCudaAction(const Action* A) {
+  return isa(A) || isa(A) ||
+ std::any_of(A->getInputs().begin(), A->getInputs().end(),
+ isCudaAction);
+}
+
+static void AddLinkerInputs(const Compilation &C, const ToolChain &TC,
+const InputInfoList &Inputs, const ArgList &Args,
+ArgStringList &CmdArgs) {
   const Driver &D = TC.getDriver();
 
   // Add extra linker input arguments which are not treated as inputs
@@ -264,6 +272,10 @@
   //and only supported on native toolchains.
   if (!TC.isCrossCompiling())
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+  // Add -L/path/to/cuda/lib if any of our inputs are .cu files.
+  if (std::any_of(C.getActions().begin(), C.getActions().end(), isCudaAction))
+TC.AddCudaLinkerArgs(Args, CmdArgs);
 }
 
 /// \brief Determine whether Objective-C automated reference counting is
@@ -6409,7 +6421,7 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_u_Group});
 
-  AddLinkerInputs(HTC, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, HTC, Inputs, Args, CmdArgs);
 
   //
   // Libraries
@@ -6472,7 +6484,7 @@
   CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");
   CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
@@ -6500,7 +6512,7 @@
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
@@ -6803,7 +6815,7 @@
   if (D.isUsingLTO())
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
 
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, ToolChain, Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (D.CCCIsCXX())
@@ -7173,7 +7185,7 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(C, getToolChain(), Inputs, Args, CmdArgs);
   // Build the input file for -filelist (list of linker input files) in case we
   // need it later
   for (const auto &II : Inputs) {
@@ -7391,7 +7403,7 @@
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_r});
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  AddLinkerInputs(

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-05 Thread Justin Lebar via cfe-commits
jlebar added a comment.

I'm sorry I sat on this for so long; I failed at email somehow, and only came 
back to ping this patch.  :)



Comment at: lib/Driver/ToolChains.cpp:4125
@@ +4124,3 @@
+  ArgStringList &LDArgs) const {
+  if (DriverArgs.hasArg(options::OPT_nocudalib) || !CudaInstallation.isValid())
+return;

tra wrote:
> We may need a new option as -nocudalib is currently used to disable linking 
> with libdevice bitcode library.
Hm...I don't want to over-complicated the UI.  Is there prior art for what 
we're doing here that we could crib off?


http://reviews.llvm.org/D15596



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


Re: [PATCH] D15899: Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Dimitry Andric via cfe-commits
dim updated this revision to Diff 44059.
dim added a comment.

Rename `-fno-movt` to `-mno-movt`.


http://reviews.llvm.org/D15899

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/arm-no-movt.c

Index: test/Driver/arm-no-movt.c
===
--- test/Driver/arm-no-movt.c
+++ test/Driver/arm-no-movt.c
@@ -4,11 +4,11 @@
 // RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-KERNEL
 
-// RUN: %clang -target armv7-gnueabi-freebsd11 -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-FREEBSD
+// RUN: %clang -target armv7-none-gnueabi -mno-movt -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MOVT
 
 // CHECK-DEFAULT-NOT: "-target-feature" "+no-movt"
 
 // CHECK-KERNEL: "-target-feature" "+no-movt"
 
-// CHECK-FREEBSD: "-target-feature" "+no-movt"
+// CHECK-NO-MOVT: "-target-feature" "+no-movt"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -938,8 +938,8 @@
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
-  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
-  if (KernelOrKext || Triple.isOSFreeBSD())
+  // The kext linker doesn't know how to deal with movw/movt.
+  if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))
 Features.push_back("+no-movt");
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1385,6 +1385,8 @@
 def marm : Flag<["-"], "marm">, Alias;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
+def mno_movt : Flag<["-"], "mno-movt">, Group,
+  HelpText<"Disallow use of movt/movw pairs (ARM only)">;
 def mcrc : Flag<["-"], "mcrc">, Group,
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,


Index: test/Driver/arm-no-movt.c
===
--- test/Driver/arm-no-movt.c
+++ test/Driver/arm-no-movt.c
@@ -4,11 +4,11 @@
 // RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-KERNEL
 
-// RUN: %clang -target armv7-gnueabi-freebsd11 -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-FREEBSD
+// RUN: %clang -target armv7-none-gnueabi -mno-movt -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MOVT
 
 // CHECK-DEFAULT-NOT: "-target-feature" "+no-movt"
 
 // CHECK-KERNEL: "-target-feature" "+no-movt"
 
-// CHECK-FREEBSD: "-target-feature" "+no-movt"
+// CHECK-NO-MOVT: "-target-feature" "+no-movt"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -938,8 +938,8 @@
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
-  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
-  if (KernelOrKext || Triple.isOSFreeBSD())
+  // The kext linker doesn't know how to deal with movw/movt.
+  if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))
 Features.push_back("+no-movt");
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1385,6 +1385,8 @@
 def marm : Flag<["-"], "marm">, Alias;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
+def mno_movt : Flag<["-"], "mno-movt">, Group,
+  HelpText<"Disallow use of movt/movw pairs (ARM only)">;
 def mcrc : Flag<["-"], "mcrc">, Group,
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-05 Thread Liao, Michael via cfe-commits
Hi Samual

The change in CL#256842 has undefined behavior according to C++. Attached patch 
will avoid side-effect code during argument evaluation of a function call. That 
solves the problem for me on Linux with GCC 4.9.

Thanks
- Michael

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Samuel F Antao via cfe-commits
Sent: Tuesday, January 5, 2016 10:57 AM
To: Artem Belevich 
Cc: cfe-commits 
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the offloading 
metadata.


Hi Art,

That only fixed one of the problems. The other one I am having some trouble to 
replicate. I am trying a few things and hopefully will get a fix soon.

Sorry for the trouble,
Samuel

[Inactive hide details for Artem Belevich ---01/05/2016 01:54:02 PM---Samuel, 
The tests are still failing:]Artem Belevich ---01/05/2016 01:54:02 PM---Samuel, 
The tests are still failing:

From: Artem Belevich mailto:t...@google.com>>
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Date: 01/05/2016 01:54 PM
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the offloading 
metadata.





Samuel,

The tests are still failing:
http://lab.llvm.org:8011/builders/clang-bpf-build/builds/5759



On Tue, Jan 5, 2016 at 10:02 AM, Samuel Antao via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: sfantao
Date: Tue Jan  5 12:02:24 2016
New Revision: 256854

URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
Log:
[OpenMP] Allow file ID to be signed in the offloading metadata.

This fixes a regression introduced by rL256842.


Modified:
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue Jan  5 12:02:24 
2016
@@ -407,7 +407,7 @@ int bar(int a){

 // Check metadata is properly generated:
 // CHECK: !omp_offload.info = !{!{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
+// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}
@@ -421,7 +421,7 @@ int bar(int a){
 // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev", i32 185, 
i32 13, i32 {{[0-9]}}+}

 // TCHECK: !omp_offload.info = !{!{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
+// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
 // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
 // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
 // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}

Modified: cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp?rev=256854&r1=256853&r2=256854&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp Tue Jan  5 
12:02:24 2016
@@ -57,10 +57,10 @@ int nested(int a){

 // Check metadata is properly generated:
 // CHECK: !omp_offload.info = !{!{{[0-9]+}}, 
!{{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]", i32 
[[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{[0-9]+}}, !"[[NNAME]]", i32 
[[T2L]], i32 [[T2C]], i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 {{[0-9]+}}, i32 {{-?[0-9]+}}, !"[[NNAME]]", i32 
[[T1L]], i32 [[T1C]], i32 {{[0-9]+}}}
+// CHECK-DAG: = !{i32 0, i32 

Re: [libcxx] r249798 - Split out of .

2016-01-05 Thread Nico Weber via cfe-commits
On Wed, Dec 30, 2015 at 8:28 PM, Richard Smith 
wrote:

> On Wed, Dec 30, 2015 at 1:17 PM, Nico Weber  wrote:
>
>> One problem with this patch: stdio.h can be used in .c files, and when
>> building .c files with -gnu99 -pedantic,
>>
>
> Do you mean -std=gnu89?
>
>
>> clang will complain about // comments. Not only does this stdio.h have //
>> comments, it also pulls in some libc++ headers (__config) that have //
>> comments as well. I suppose all the comments in header files pulled in by C
>> headers need to become /* */ comments?
>>
>
> I suppose so too. Your configuration is probably somewhat broken if
> libc++'s headers are in your include path while building C code, but it
> doesn't seem unreasonable to properly support that mode, and my changes
> were already trying to do so.
>
> Eric, Marshall, what do you think about using only /*...*/-style comments
> in these headers, to handle the case where libc++ is somehow in the include
> path for a C89 compilation?
>

Eric, Marshall: Ping ^


>
>
>> On Tue, Oct 13, 2015 at 7:34 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Tue, Oct 13, 2015 at 3:26 PM, Eric Fiselier  wrote:
>>>
 This change LGTM. Let's hold off on the using "_Static_assert" until we
 understand how that would work with "-pedantic" when the macro is expanded
 in user code.

>>>
>>> Committed as r250247, thanks.
>>>
>>>
 /Eric

 On Tue, Oct 13, 2015 at 4:19 PM, Richard Smith 
 wrote:

> On Tue, Oct 13, 2015 at 2:12 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> I would rather not do this if possible but I understand why we need
>> to do it.
>>
>> Richard is there a cost associated with the 'extern "C++"' construct?
>> or by forcing the compiler to switch modes in general?
>>
>
> Not a significant one compared to the cost of the code wrapped in the
> 'extern "C++"' here. (Also, this is wrapped in an #ifdef that only applies
> in C++98; we could further reduce the set of cases when this happens by
> using _Static_assert when available instead of this static_assert
> emulation.)
>
>
>> On Mon, Oct 12, 2015 at 12:27 PM, Richard Smith <
>> rich...@metafoo.co.uk> wrote:
>>
>>> On Mon, Oct 12, 2015 at 9:41 AM, Steven Wu via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Hi Richard

 Your splitting seems causing problem when using extern "C". Here is
 a test case:

 $ cat test.cpp
 #ifdef __cplusplus
 extern "C" {
 #endif
 #include 
 #ifdef __cplusplus
 }
 #endif

 Error:
 clang -fsyntax-only test.cpp
 In file included from test.cpp:4:
 In file included from /usr/bin/../include/c++/v1/stdio.h:102:
 /usr/bin/../include/c++/v1/__config:593:1: error:
   templates must have C++ linkage
 template  struct __static_assert_test;
 ^~~
 /usr/bin/../include/c++/v1/__config:594:20: error:
   explicit specialization of non-template struct
 '__static_assert_test'
 template <> struct __static_assert_test {};
^   ~~
 /usr/bin/../include/c++/v1/__config:595:1: error:
   templates must have C++ linkage
 template  struct __static_assert_check {};
 ^~~
 3 errors generated.

 Because the code is actually compiled in C++, the guard in the
 header failed to exclude the templates. In the meantime, I don't know 
 if
 there are ways to detect the header is in extern "C".

>>>
>>> This was supposed to work, but apparently I only tested it when
>>> compiling as C++11; the static_assert emulation in C++98 mode needs some
>>> massaging to cope with this.
>>>
>>> Eric, Marshall: Are you OK with the attached patch? The idea is to
>>> make <__config> be fine to include in extern "C" or extern "C++" modes 
>>> (and
>>> likewise for the  headers). This is something that comes up 
>>> pretty
>>> often in practice (people wrap an include of a C header in 'extern "C"',
>>> and that C header includes a  file that libc++ provides).
>>>
>>>
 Steven


 > On Oct 8, 2015, at 6:29 PM, Richard Smith via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:
 >
 > Author: rsmith
 > Date: Thu Oct  8 20:29:09 2015
 > New Revision: 249798
 >
 > URL: http://llvm.org/viewvc/llvm-project?rev=249798&view=rev
 > Log:
 > Split  out of .
 >
 > As with , skip our custom header if __need_FILE or
 __need___FILE is defined.
 >
 > Added:
 >libcxx/trunk/include/stdio.h
 >

Re: [PATCH] D15705: Adding a scripted test for PR25717

2016-01-05 Thread Yunzhong Gao via cfe-commits
ygao added a comment.

In llvm/utils/lit/lit/TestRunner.py line#202 inside function executeShCmd(), 
the test is spawned by
subprocess.Popen(command, ..., stdout = subprocess.PIPE, stderr = 
subprocess.PIPE, ...)
And the test passes. I can verify with a small python script doing just a 
subprocess.Popen.

If the test is spawned with stdout = None instead, the test will crash as 
expected.

I could not find a way to trick TestRunner into leaving stdout as None. Is 
there supposed to be
a command-line option to lit? Or maybe a special redirection mark on the RUN 
line? Maybe a lit
expert can help me here.


http://reviews.llvm.org/D15705



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


[PATCH] D15907: Allow various function attributes to be specified on Objective-C blocks too.

2016-01-05 Thread Nicholas Allegra via cfe-commits
comex created this revision.
comex added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This mostly "just works" by adding Block to the subject list, but there is an
issue with warnings in attribute handlers tied to the return type, which for
blocks can be inferred.  My solution to this is a bit ugly but seems to do the
right thing.

The list: always_inline, noinline, cold, hot, minsize, malloc,
disable_tail_calls, noalias, noduplicate, nonnull, returns_nonnull, optnone.

nonnull already partially worked on blocks, but fix applying it to parameters
on them; also, improve the error message and add additional tests.

Most of these attributes only make sense when the target of a function call is
known; since blocks are always called indirectly via pointers, these will only
work if the optimizer is able to replace the indirect calls with direct calls
(ergo not at all at -O0).  However, this can still be useful in practice.

For now, all of them only apply to the block implementation function itself, as
opposed to the copy and dispose helpers.  For those it might make sense to
propagate always_inline in particular, or perhaps to just add some explicit
syntax for putting attributes on them, but it's not essential.

Incidentally, for some of these attributes and some not included, such as
returns_nonnull, printf, warn_unused_result, etc., it would be somewhat useful
and more principled to allow them as part of function types rather than just
functions themselves, for the sake of both standard function pointer calls and
blocks.  Currently only a handful of attributes can be used on types: noreturn,
ns_returns_retained, regparm, and calling convention.  However, that would be a
larger change and orthogonal to this patch.


http://reviews.llvm.org/D15907

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p1.cpp
  test/CodeGen/always-inline.c
  test/CodeGen/attr-disable-tail-calls.c
  test/CodeGen/attr-noinline.c
  test/CodeGen/attr-optnone.c
  test/CodeGen/nonnull.c
  test/Parser/cxx0x-attributes.cpp
  test/Sema/attr-capabilities.c
  test/Sema/attr-coldhot.c
  test/Sema/attr-disable-tail-calls.c
  test/Sema/attr-malloc.c
  test/Sema/attr-minsize.c
  test/Sema/attr-noinline.c
  test/Sema/nonnull.c
  test/SemaObjC/attr-cf_returns.m
  test/SemaObjC/objcbridge-attribute-arc.m
  test/SemaObjC/objcbridge-attribute.m
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2363,10 +2363,12 @@
 case GenericRecord:
   return "(S.getLangOpts().CPlusPlus ? ExpectedStructOrUnionOrClass : "
"ExpectedStructOrUnion)";
+case Func | Block: return "ExpectedFunctionOrBlock";
 case Func | ObjCMethod | Block: return "ExpectedFunctionMethodOrBlock";
 case Func | ObjCMethod | Class: return "ExpectedFunctionMethodOrClass";
 case Func | Param:
 case Func | ObjCMethod | Param: return "ExpectedFunctionMethodOrParameter";
+case Func | ObjCMethod | Block | Param: return "ExpectedFunctionMethodBlockOrParameter";
 case Func | ObjCMethod: return "ExpectedFunctionOrMethod";
 case Func | Var: return "ExpectedVariableOrFunction";
 
Index: test/SemaObjC/objcbridge-attribute.m
===
--- test/SemaObjC/objcbridge-attribute.m
+++ test/SemaObjC/objcbridge-attribute.m
@@ -38,7 +38,7 @@
 
 @interface I
 {
-   __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to structs, unions, and typedefs}};
+   __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to structs, unions and typedefs}};
 }
 @end
 
Index: test/SemaObjC/objcbridge-attribute-arc.m
===
--- test/SemaObjC/objcbridge-attribute-arc.m
+++ test/SemaObjC/objcbridge-attribute-arc.m
@@ -32,7 +32,7 @@
 
 @interface I
 {
-   __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to structs, unions, and typedefs}};
+   __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to structs, unions and typedefs}};
 }
 @end
 
Index: test/SemaObjC/attr-cf_returns.m
===
--- test/SemaObjC/attr-cf_returns.m
+++ test/SemaObjC/attr-cf_returns.m
@@ -10,8 +10,8 @@
 #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
 #define CF_RETURNS_NOT_RETAINED __attribute__(

r256873 - [CMake] Support a simple case for bootstrap builds to generate PGO data

2016-01-05 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Jan  5 17:51:42 2016
New Revision: 256873

URL: http://llvm.org/viewvc/llvm-project?rev=256873&view=rev
Log:
[CMake] Support a simple case for bootstrap builds to generate PGO data

Summary:
This patch adds support for the clang multi-stage bootstrapping to support PGO 
profdata generation, and can build a 2 or 3 stage compiler.

With this patch applied you can configure your build directory with the 
following invocation of CMake:

cmake -G  -C /cmake/caches/PGO.cmake 

After configuration the following additional targets will be generated:

stage2-instrumented:
Builds a stage1 x86 compiler, runtime, and required tools (llvm-config, 
llvm-profdata) then uses that compiler to build an instrumented stage2 compiler.

stage2-instrumented-generate-profdata:
Depends on "stage2-instrumented" and will use the instrumented compiler to 
generate profdata based on the training files in /utils/perf-training

stage2:
Depends on "stage2-instrumented-generate-profdata" and will use the stage1 
compiler with the stage2 profdata to build a PGO-optimized compiler.

stage2-check-llvm:
Depends on stage2 and runs check-llvm using the stage3 compiler.

stage2-check-clang:
Depends on stage2 and runs check-clang using the stage3 compiler.

stage2-check-all:
Depends on stage2 and runs check-all using the stage3 compiler.

stage2-test-suite:
Depends on stage2 and runs the test-suite using the stage3 compiler (requires 
in-tree test-suite).

Reviewers: bogner, silvas, chandlerc

Subscribers: cfe-commits

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

Added:
cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
cfe/trunk/cmake/caches/PGO-stage2.cmake
cfe/trunk/cmake/caches/PGO.cmake
Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=256873&r1=256872&r2=256873&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Jan  5 17:51:42 2016
@@ -631,11 +631,19 @@ if (CLANG_ENABLE_BOOTSTRAP)
 
   string(REGEX MATCH "stage([0-9]*)" MATCHED_STAGE "${CLANG_STAGE}")
   if(MATCHED_STAGE)
-math(EXPR STAGE_NUM "${MATCHED_STAGE} + 1")
-set(NEXT_CLANG_STAGE stage${STAGE_NUM})
+if(NOT LLVM_BUILD_INSTRUMENTED)
+  math(EXPR STAGE_NUM "${CMAKE_MATCH_1} + 1")
+  set(NEXT_CLANG_STAGE stage${STAGE_NUM})
+else()
+  set(NEXT_CLANG_STAGE stage${CMAKE_MATCH_1})
+endif()
   else()
 set(NEXT_CLANG_STAGE bootstrap)
   endif()
+
+  if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
+set(NEXT_CLANG_STAGE ${NEXT_CLANG_STAGE}-instrumented)
+  endif()
   message(STATUS "Setting next clang stage to: ${NEXT_CLANG_STAGE}")
   
   
@@ -681,6 +689,26 @@ if (CLANG_ENABLE_BOOTSTRAP)
 set(RUNTIME_DEP compiler-rt)
   endif()
 
+  set(COMPILER_OPTIONS
+-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
+
+  if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED)
+set(PGO_DEP llvm-profdata)
+set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata)
+  endif()
+
+  if(LLVM_BUILD_INSTRUMENTED)
+set(PGO_DEP generate-profdata)
+set(PGO_OPT 
-DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata)
+set(COMPILER_OPTIONS
+  -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+  -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+  -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER})
+set(RUNTIME_DEP) # Don't set runtime dependencies
+  endif()
+
   # Find all variables that start with BOOTSTRAP_ and populate a variable with
   # them.
   get_cmake_property(variableNames VARIABLES)
@@ -703,7 +731,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
   endforeach()
 
   ExternalProject_Add(${NEXT_CLANG_STAGE}
-DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP}
+DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP} ${PGO_DEP}
 PREFIX ${NEXT_CLANG_STAGE}
 SOURCE_DIR ${CMAKE_SOURCE_DIR}
 STAMP_DIR ${STAMP_DIR}
@@ -715,11 +743,9 @@ if (CLANG_ENABLE_BOOTSTRAP)
 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
 ${PASSTHROUGH_VARIABLES}
--DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
--DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
--DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
--DCLANG_STAGE=${NEXT_CLANG_STAGE}
-${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose}
+ -DCLANG_STAGE=${NEXT_CLANG_STAGE}
+${COMPILER_OPTIONS}
+${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${PGO_OPT}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
 ${cmake_3_4_USES_TERMINAL_OPTIONS}

Added: cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
URL: 
http://llvm

Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.

2016-01-05 Thread Artem Belevich via cfe-commits
tra added a comment.

ping.


http://reviews.llvm.org/D15305



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


r256874 - Fix a typo in testcase and increase its coverage!

2016-01-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Jan  5 17:54:01 2016
New Revision: 256874

URL: http://llvm.org/viewvc/llvm-project?rev=256874&view=rev
Log:
Fix a typo in testcase and increase its coverage!

Modified:
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=256874&r1=256873&r2=256874&view=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Tue Jan  5 17:54:01 2016
@@ -13,7 +13,7 @@
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
-fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
-debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
-// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
+// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 #ifdef MODULES
 @import DebugCXX;


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


Re: [PATCH] D15448: [analyzer] SVal Visitor.

2016-01-05 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def:31
@@ +30,3 @@
+// is both instantiated and derived from.
+// Additionally, its kind is not its name with "Kind" suffix,
+// unlike all other regions.

I'd rather rename the "Kind" suffix. Is that possible?

Having REGION and NORMAL_REGION is strange.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def:13
@@ +12,3 @@
+// hardcoded, because it is too peculiar and explicit to be handled uniformly.
+// SVal kind-enum values (both base-kinds and sub-kinds) are written out
+// explicitly because those are often named in an unobvious manner.

Again, we should go ahead and change the kind values if it would make things 
more uniform. (Can be done in a separate patch committed before this one.)


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def:27
@@ +26,3 @@
+//
+// LOC_SVAL(Id, Kind, Parent) - for sub-kinds of Loc,
+//

Loc and NonLoc have not been defined yet.


http://reviews.llvm.org/D15448



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


RE: r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-05 Thread Samuel F Antao via cfe-commits

Hi Michael,

Thanks for the patch! I am not sure I understand why the behavior is
unspecified if Idx is captured by reference, but that is good to know that
it fixes the problem. I reverted the patch in the meantime given that I am
still trying to replicate a problem I get from the ARM bots, but I will
incorporate your fix when I am ready to reapply the patch.

Thanks again!
Samuel



From:   "Liao, Michael" 
To: Samuel F Antao/Watson/IBM@IBMUS, Artem Belevich

Cc: cfe-commits 
Date:   01/05/2016 05:17 PM
Subject:RE: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.



Hi Samual

The change in CL#256842 has undefined behavior according to C++. Attached
patch will avoid side-effect code during argument evaluation of a function
call. That solves the problem for me on Linux with GCC 4.9.

Thanks
- Michael

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
Samuel F Antao via cfe-commits
Sent: Tuesday, January 5, 2016 10:57 AM
To: Artem Belevich 
Cc: cfe-commits 
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.



Hi Art,

That only fixed one of the problems. The other one I am having some trouble
to replicate. I am trying a few things and hopefully will get a fix soon.

Sorry for the trouble,
Samuel

Inactive hide details for Artem Belevich ---01/05/2016 01:54:02
PM---Samuel, The tests are still failing:Artem Belevich ---01/05/2016
01:54:02 PM---Samuel, The tests are still failing:

From: Artem Belevich 
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits 
Date: 01/05/2016 01:54 PM
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the
offloading metadata.




Samuel,

The tests are still failing:
http://lab.llvm.org:8011/builders/clang-bpf-build/builds/5759



On Tue, Jan 5, 2016 at 10:02 AM, Samuel Antao via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
  Author: sfantao
  Date: Tue Jan  5 12:02:24 2016
  New Revision: 256854

  URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
  Log:
  [OpenMP] Allow file ID to be signed in the offloading metadata.

  This fixes a regression introduced by rL256842.


  Modified:
  cfe/trunk/test/OpenMP/target_codegen_registration.cpp
  cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

  Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
  URL:
  
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff

  
==

  --- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
  +++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue Jan  5
  12:02:24 2016
  @@ -407,7 +407,7 @@ int bar(int a){

   // Check metadata is properly generated:
   // CHECK: !omp_offload.info
  = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}}

  -// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
  +// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32
  {{[0-9]}}+}
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev",
  i32 210, i32 13, i32 {{[0-9]}}+}
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev",
  i32 226, i32 13, i32 {{[0-9]}}+}
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev",
  i32 232, i32 13, i32 {{[0-9]}}+}
  @@ -421,7 +421,7 @@ int bar(int a){
   // CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev",
  i32 185, i32 13, i32 {{[0-9]}}+}

   // TCHECK: !omp_offload.info
  = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}}

  -// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
  +// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32
  [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 160, i32 13, i32
  {{[0-9]}}+}
   // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32
  [[FILEID]] !"_ZN2SDD2Ev", i32 210, i32 13, i32 {{[0-9]}}+}
   // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32
  [[FILEID]] !"_ZN2SEC2Ev", i32 226, i32 13, i32 {{[0-9]}}+}
   // TCHECK-DAG = !{i32 0, i32 [[DEVID]], i32
  [[FILEID]] !"_ZN2SED2Ev", i32 232, i32 13, i32 {{[0-9]}}+}

  Modified:
  cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp
  URL:
  
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp?rev=256854&r1=256853&r2=256854&view=diff

  
=

r256886 - [analyzer] Suppress reports coming from std::__independent_bits_engine

2016-01-05 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Tue Jan  5 18:32:52 2016
New Revision: 256886

URL: http://llvm.org/viewvc/llvm-project?rev=256886&view=rev
Log:
[analyzer] Suppress reports coming from std::__independent_bits_engine

The analyzer reports a shift by a negative value in the constructor. The bug can
be easily triggered by calling std::random_shuffle on a vector
().

(The shift by a negative value is reported because __w0_ gets constrained to
63 by the conditions along the path:__w0_ < _WDt && __w0_ >= _WDt-1,
where _WDt is 64. In normal execution, __w0_ is not 63, it is 1 and there is
no overflow. The path is infeasible, but the analyzer does not know about that.)

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/inlining/stl.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=256886&r1=256885&r2=256886&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Jan  5 
18:32:52 2016
@@ -1542,6 +1542,16 @@ LikelyFalsePositiveSuppressionBRVisitor:
 }
   }
 
+  // The analyzer issues a false positive when the constructor of
+  // std::__independent_bits_engine from algorithms is used.
+  if (const CXXConstructorDecl *MD = dyn_cast(D)) {
+const CXXRecordDecl *CD = MD->getParent();
+if (CD->getName() == "__independent_bits_engine") {
+  BR.markInvalid(getTag(), nullptr);
+  return nullptr;
+}
+  }
+
   // The analyzer issues a false positive on
   //   std::basic_string v; v.push_back(1);
   // and

Modified: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h?rev=256886&r1=256885&r2=256886&view=diff
==
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h (original)
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h Tue Jan  5 
18:32:52 2016
@@ -198,6 +198,25 @@ namespace std {
   storage.assignExternal(new _CharT[4]);
 }
   };
+
+template
+class __independent_bits_engine {
+public:
+  // constructors and seeding functions
+  __independent_bits_engine(_Engine& __e, size_t __w);
+};
+
+template
+__independent_bits_engine<_Engine, _UIntType>
+::__independent_bits_engine(_Engine& __e, size_t __w)
+{
+  // Fake error trigger.
+  // No warning is expected as we are suppressing warning coming
+  // out of std::basic_string.
+  int z = 0;
+  z = 5/z;
+}
+
 }
 
 void* operator new(std::size_t, const std::nothrow_t&) throw();

Modified: cfe/trunk/test/Analysis/inlining/stl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/stl.cpp?rev=256886&r1=256885&r2=256886&view=diff
==
--- cfe/trunk/test/Analysis/inlining/stl.cpp (original)
+++ cfe/trunk/test/Analysis/inlining/stl.cpp Tue Jan  5 18:32:52 2016
@@ -47,3 +47,8 @@ void testBasicStringSuppression_assign(s
const std::basic_string &v2) {
   v = v2;
 }
+
+class MyEngine;
+void testSupprerssion_independent_bits_engine(MyEngine& e) {
+  std::__independent_bits_engine x(e, 64); // 
no-warning
+}


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


r256885 - [analyzer] Don't report null dereferences on address_space annotated memory

2016-01-05 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Tue Jan  5 18:32:49 2016
New Revision: 256885

URL: http://llvm.org/viewvc/llvm-project?rev=256885&view=rev
Log:
[analyzer] Don't report null dereferences on address_space annotated memory

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Analysis/nullptr.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=256885&r1=256884&r2=256885&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Tue Jan  5 
18:32:49 2016
@@ -34,8 +34,7 @@ class DereferenceChecker
   mutable std::unique_ptr BT_null;
   mutable std::unique_ptr BT_undef;
 
-  void reportBug(ProgramStateRef State, const Stmt *S, CheckerContext &C,
- bool IsBind = false) const;
+  void reportBug(ProgramStateRef State, const Stmt *S, CheckerContext &C) 
const;
 
 public:
   void checkLocation(SVal location, bool isLoad, const Stmt* S,
@@ -89,8 +88,31 @@ DereferenceChecker::AddDerefSource(raw_o
   }
 }
 
+static const Expr *getDereferenceExpr(const Stmt *S, bool IsBind=false){
+  const Expr *E = nullptr;
+
+  // Walk through lvalue casts to get the original expression
+  // that syntactically caused the load.
+  if (const Expr *expr = dyn_cast(S))
+E = expr->IgnoreParenLValueCasts();
+
+  if (IsBind) {
+const VarDecl *VD;
+const Expr *Init;
+std::tie(VD, Init) = parseAssignment(S);
+if (VD && Init)
+  E = Init;
+  }
+  return E;
+}
+
+static bool suppressReport(const Expr *E) {
+  // Do not report dereferences on memory in non-default address spaces.
+  return E->getType().getQualifiers().hasAddressSpace();
+}
+
 void DereferenceChecker::reportBug(ProgramStateRef State, const Stmt *S,
-   CheckerContext &C, bool IsBind) const {
+   CheckerContext &C) const {
   // Generate an error node.
   ExplodedNode *N = C.generateErrorNode(State);
   if (!N)
@@ -106,19 +128,6 @@ void DereferenceChecker::reportBug(Progr
 
   SmallVector Ranges;
 
-  // Walk through lvalue casts to get the original expression
-  // that syntactically caused the load.
-  if (const Expr *expr = dyn_cast(S))
-S = expr->IgnoreParenLValueCasts();
-
-  if (IsBind) {
-const VarDecl *VD;
-const Expr *Init;
-std::tie(VD, Init) = parseAssignment(S);
-if (VD && Init)
-  S = Init;
-  }
-
   switch (S->getStmtClass()) {
   case Stmt::ArraySubscriptExprClass: {
 os << "Array access";
@@ -209,8 +218,11 @@ void DereferenceChecker::checkLocation(S
   // The explicit NULL case.
   if (nullState) {
 if (!notNullState) {
-  reportBug(nullState, S, C);
-  return;
+  const Expr *expr = getDereferenceExpr(S);
+  if (!suppressReport(expr)) {
+reportBug(nullState, expr, C);
+return;
+  }
 }
 
 // Otherwise, we have the case where the location could either be
@@ -248,8 +260,11 @@ void DereferenceChecker::checkBind(SVal
 
   if (StNull) {
 if (!StNonNull) {
-  reportBug(StNull, S, C, /*isBind=*/true);
-  return;
+  const Expr *expr = getDereferenceExpr(S, /*IsBind=*/true);
+  if (!suppressReport(expr)) {
+reportBug(StNull, expr, C);
+return;
+  }
 }
 
 // At this point the value could be either null or non-null.

Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=256885&r1=256884&r2=256885&view=diff
==
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Tue Jan  5 18:32:49 2016
@@ -311,3 +311,21 @@ int foo10595327(int b) {
   return *p; // no-warning
   return 0;
 }
+
+#define AS_ATTRIBUTE volatile __attribute__((address_space(256)))
+#define _get_base() ((void * AS_ATTRIBUTE *)0)
+void* test_address_space_array(unsigned long slot) {
+  return _get_base()[slot]; // no-warning
+}
+void test_address_space_condition(int AS_ATTRIBUTE *cpu_data) {
+   if (cpu_data == 0) {
+*cpu_data = 3; // no-warning
+  }
+}
+struct X { int member; };
+int test_address_space_member() {
+  struct X AS_ATTRIBUTE *data = (struct X AS_ATTRIBUTE *)0UL;
+  int ret;
+  ret = data->member; // no-warning
+  return ret;
+}

Modified: cfe/trunk/test/Analysis/nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullptr.cpp?rev=256885&r1=256884&r2=256885&view=diff
==
--- cfe/trunk/test/Analysis/nullptr.cpp (original)
+++ cfe/trunk/test/Analysis/nullptr.cpp Tue Jan  5 18:32:49 2016
@@ -126,3 +126,22 @@ dec

r256887 - [analyzer] Fix false warning about memory leak for QApplication::postEvent

2016-01-05 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Tue Jan  5 18:32:56 2016
New Revision: 256887

URL: http://llvm.org/viewvc/llvm-project?rev=256887&view=rev
Log:
[analyzer] Fix false warning about memory leak for QApplication::postEvent

According to Qt documentation Qt takes care of memory allocated for QEvent:
http://doc.qt.io/qt-4.8/qcoreapplication.html#postEvent

A patch by Evgeniy Dushistov!

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

Added:
cfe/trunk/test/Analysis/Inputs/qt-simulator.h
cfe/trunk/test/Analysis/qt_malloc.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=256887&r1=256886&r2=256887&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Tue Jan  5 18:32:56 
2016
@@ -2508,6 +2508,16 @@ bool MallocChecker::mayFreeAnyEscapedMem
 return true;
   }
 
+  if (FName == "postEvent" &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+return true;
+  }
+
+  if (FName == "postEvent" &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the

Added: cfe/trunk/test/Analysis/Inputs/qt-simulator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/qt-simulator.h?rev=256887&view=auto
==
--- cfe/trunk/test/Analysis/Inputs/qt-simulator.h (added)
+++ cfe/trunk/test/Analysis/Inputs/qt-simulator.h Tue Jan  5 18:32:56 2016
@@ -0,0 +1,16 @@
+#pragma clang system_header
+
+struct QObject {
+};
+
+struct QEvent {
+  enum Type { None };
+  QEvent(Type) {}
+};
+
+struct QCoreApplication : public QObject {
+  static void postEvent(QObject *receiver, QEvent *event);
+  static QCoreApplication *instance();
+};
+
+struct QApplication : public QCoreApplication {};

Added: cfe/trunk/test/Analysis/qt_malloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/qt_malloc.cpp?rev=256887&view=auto
==
--- cfe/trunk/test/Analysis/qt_malloc.cpp (added)
+++ cfe/trunk/test/Analysis/qt_malloc.cpp Tue Jan  5 18:32:56 2016
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus
 -analyzer-store=region -verify %s
+// expected-no-diagnostics
+#include "Inputs/qt-simulator.h"
+
+void send(QObject *obj)
+{
+  QEvent *e1 = new QEvent(QEvent::None);
+  static_cast(QCoreApplication::instance())->postEvent(obj, 
e1);
+  QEvent *e2 = new QEvent(QEvent::None);
+  QCoreApplication::instance()->postEvent(obj, e2);
+  QEvent *e3 = new QEvent(QEvent::None);
+  QCoreApplication::postEvent(obj, e3);
+  QEvent *e4 = new QEvent(QEvent::None);
+  QApplication::postEvent(obj, e4);
+}


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


Re: [PATCH] D14170: Fix false positive warning about memory leak for QApplication::postEvent

2016-01-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256887: [analyzer] Fix false warning about memory leak for 
QApplication::postEvent (authored by zaks).

Changed prior to commit:
  http://reviews.llvm.org/D14170?vs=40596&id=44070#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14170

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/test/Analysis/Inputs/qt-simulator.h
  cfe/trunk/test/Analysis/qt_malloc.cpp

Index: cfe/trunk/test/Analysis/Inputs/qt-simulator.h
===
--- cfe/trunk/test/Analysis/Inputs/qt-simulator.h
+++ cfe/trunk/test/Analysis/Inputs/qt-simulator.h
@@ -0,0 +1,16 @@
+#pragma clang system_header
+
+struct QObject {
+};
+
+struct QEvent {
+  enum Type { None };
+  QEvent(Type) {}
+};
+
+struct QCoreApplication : public QObject {
+  static void postEvent(QObject *receiver, QEvent *event);
+  static QCoreApplication *instance();
+};
+
+struct QApplication : public QCoreApplication {};
Index: cfe/trunk/test/Analysis/qt_malloc.cpp
===
--- cfe/trunk/test/Analysis/qt_malloc.cpp
+++ cfe/trunk/test/Analysis/qt_malloc.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus
 -analyzer-store=region -verify %s
+// expected-no-diagnostics
+#include "Inputs/qt-simulator.h"
+
+void send(QObject *obj)
+{
+  QEvent *e1 = new QEvent(QEvent::None);
+  static_cast(QCoreApplication::instance())->postEvent(obj, 
e1);
+  QEvent *e2 = new QEvent(QEvent::None);
+  QCoreApplication::instance()->postEvent(obj, e2);
+  QEvent *e3 = new QEvent(QEvent::None);
+  QCoreApplication::postEvent(obj, e3);
+  QEvent *e4 = new QEvent(QEvent::None);
+  QApplication::postEvent(obj, e4);
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2508,6 +2508,16 @@
 return true;
   }
 
+  if (FName == "postEvent" &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+return true;
+  }
+
+  if (FName == "postEvent" &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the


Index: cfe/trunk/test/Analysis/Inputs/qt-simulator.h
===
--- cfe/trunk/test/Analysis/Inputs/qt-simulator.h
+++ cfe/trunk/test/Analysis/Inputs/qt-simulator.h
@@ -0,0 +1,16 @@
+#pragma clang system_header
+
+struct QObject {
+};
+
+struct QEvent {
+  enum Type { None };
+  QEvent(Type) {}
+};
+
+struct QCoreApplication : public QObject {
+  static void postEvent(QObject *receiver, QEvent *event);
+  static QCoreApplication *instance();
+};
+
+struct QApplication : public QCoreApplication {};
Index: cfe/trunk/test/Analysis/qt_malloc.cpp
===
--- cfe/trunk/test/Analysis/qt_malloc.cpp
+++ cfe/trunk/test/Analysis/qt_malloc.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus -analyzer-store=region -verify %s
+// expected-no-diagnostics
+#include "Inputs/qt-simulator.h"
+
+void send(QObject *obj)
+{
+  QEvent *e1 = new QEvent(QEvent::None);
+  static_cast(QCoreApplication::instance())->postEvent(obj, e1);
+  QEvent *e2 = new QEvent(QEvent::None);
+  QCoreApplication::instance()->postEvent(obj, e2);
+  QEvent *e3 = new QEvent(QEvent::None);
+  QCoreApplication::postEvent(obj, e3);
+  QEvent *e4 = new QEvent(QEvent::None);
+  QApplication::postEvent(obj, e4);
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2508,6 +2508,16 @@
 return true;
   }
 
+  if (FName == "postEvent" &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+return true;
+  }
+
+  if (FName == "postEvent" &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+return true;
+  }
+
   // Handle cases where we know a buffer's /address/ can escape.
   // Note that the above checks handle some special cases where we know that
   // even though the address escapes, it's still our responsibility to free the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

Re: [PATCH] D15227: [analyzer] Valist checkers.

2016-01-05 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/ValistChecker.cpp:31
@@ +30,3 @@
+struct VAListAcceptingFunc {
+  mutable IdentifierInfo *II;
+  StringRef FuncName;

It does not support ObjC methods.

I think this is most useful to checker writes, so how about placing it in 
CheckerContext? (I am fine with CallEven as well if you think it has wider 
applicability.)


Comment at: lib/StaticAnalyzer/Checkers/ValistChecker.cpp:205
@@ +204,3 @@
+  if (!TReg)
+return nullptr;
+  return TReg;

How about we commit your implementation as a general utility and point the 
other review to it? You can make it as a separate commit for clarity.


Comment at: test/Analysis/valist-uninitialized.c:135
@@ +134,3 @@
+}
+
+// NOTE: this is invalid, as the man page of va_end requires that "Each 
invocation of va_start()

Please, make that clear in the comment, for example, you can say "We should 
produce a warning here..".


http://reviews.llvm.org/D15227



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


RE: r256854 - [OpenMP] Allow file ID to be signed in the offloading metadata.

2016-01-05 Thread Liao, Michael via cfe-commits
Hi Samuel

The issue is not related to capture feature but the order of evaluation which 
is not specified for arguments in a function call in C/C++. With the side 
effect in each argument evaluation, it causes the trouble.

Thanks
- Michael

From: Samuel F Antao [mailto:sfan...@us.ibm.com]
Sent: Tuesday, January 5, 2016 4:25 PM
To: Liao, Michael 
Cc: cfe-commits ; Artem Belevich 
Subject: RE: r256854 - [OpenMP] Allow file ID to be signed in the offloading 
metadata.


Hi Michael,

Thanks for the patch! I am not sure I understand why the behavior is 
unspecified if Idx is captured by reference, but that is good to know that it 
fixes the problem. I reverted the patch in the meantime given that I am still 
trying to replicate a problem I get from the ARM bots, but I will incorporate 
your fix when I am ready to reapply the patch.

Thanks again!
Samuel

[Inactive hide details for "Liao, Michael" ---01/05/2016 05:17:13 PM---Hi 
Samual The change in CL#256842 has undefined behavior]"Liao, Michael" 
---01/05/2016 05:17:13 PM---Hi Samual The change in CL#256842 has undefined 
behavior according to C++. Attached patch will avoid

From: "Liao, Michael" mailto:michael.l...@intel.com>>
To: Samuel F Antao/Watson/IBM@IBMUS, Artem Belevich 
mailto:t...@google.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Date: 01/05/2016 05:17 PM
Subject: RE: r256854 - [OpenMP] Allow file ID to be signed in the offloading 
metadata.





Hi Samual

The change in CL#256842 has undefined behavior according to C++. Attached patch 
will avoid side-effect code during argument evaluation of a function call. That 
solves the problem for me on Linux with GCC 4.9.

Thanks
- Michael

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Samuel F Antao via cfe-commits
Sent: Tuesday, January 5, 2016 10:57 AM
To: Artem Belevich mailto:t...@google.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the offloading 
metadata.

Hi Art,

That only fixed one of the problems. The other one I am having some trouble to 
replicate. I am trying a few things and hopefully will get a fix soon.

Sorry for the trouble,
Samuel

[Inactive hide details for Artem Belevich ---01/05/2016 01:54:02 PM---Samuel, 
The tests are still failing:]Artem Belevich ---01/05/2016 01:54:02 PM---Samuel, 
The tests are still failing:

From: Artem Belevich mailto:t...@google.com>>
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Date: 01/05/2016 01:54 PM
Subject: Re: r256854 - [OpenMP] Allow file ID to be signed in the offloading 
metadata.






Samuel,

The tests are still failing:
http://lab.llvm.org:8011/builders/clang-bpf-build/builds/5759



On Tue, Jan 5, 2016 at 10:02 AM, Samuel Antao via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: sfantao
Date: Tue Jan 5 12:02:24 2016
New Revision: 256854

URL: http://llvm.org/viewvc/llvm-project?rev=256854&view=rev
Log:
[OpenMP] Allow file ID to be signed in the offloading metadata.

This fixes a regression introduced by rL256842.


Modified:
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_codegen_registration_naming.cpp

Modified: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen_registration.cpp?rev=256854&r1=256853&r2=256854&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp Tue Jan 5 12:02:24 
2016
@@ -407,7 +407,7 @@ int bar(int a){

// Check metadata is properly generated:
// CHECK: !omp_offload.info = !{!{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
+// CHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:-?[0-9]+]], 
!"_ZN2SB3fooEv", i32 160, i32 13, i32 {{[0-9]}}+}
// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SDD2Ev", i32 210, 
i32 13, i32 {{[0-9]}}+}
// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SEC2Ev", i32 226, 
i32 13, i32 {{[0-9]}}+}
// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SED2Ev", i32 232, 
i32 13, i32 {{[0-9]}}+}
@@ -421,7 +421,7 @@ int bar(int a){
// CHECK-DAG = !{i32 0, i32 [[DEVID]], i32 [[FILEID]] !"_ZN2SCC2Ev", i32 185, 
i32 13, i32 {{[0-9]}}+}

// TCHECK: !omp_offload.info = !{!{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 
!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// TCHECK-DAG = !{i32 0, i32 [[DEVID:[0-9]+]], i32 [[FILEID:[

Re: [PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.

2016-01-05 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Driver/ToolChains.cpp:4125
@@ +4124,3 @@
+  ArgStringList &LDArgs) const {
+  if (DriverArgs.hasArg(options::OPT_nocudalib) || !CudaInstallation.isValid())
+return;

I'd rename -nocudalib to -nocudalibdevice (or -nocudabclib) to better reflect 
what it currently does -- disables linking with CUDA's libdevice bitcode.

Then you could use -nocudalib to control automatic addition of CUDA 
library-related options which would be closer to what '-nostdlib' does.

While you're at it, you may consider adding linker flags to link with static 
libcudart. nvcc always adds "-lcudart_static  -lrt -lpthread  -ldl" at the end. 
If user explicitly requests linking with dynamic version of libcudart, then it 
gets linked first, and linker then ignores all the symbols from static lib.



http://reviews.llvm.org/D15596



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


r256897 - Avoid assert failure on some invalid cc1 options.

2016-01-05 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Jan  5 19:37:57 2016
New Revision: 256897

URL: http://llvm.org/viewvc/llvm-project?rev=256897&view=rev
Log:
Avoid assert failure on some invalid cc1 options.

Addressing review comment in D13221.

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=256897&r1=256896&r2=256897&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jan  5 19:37:57 2016
@@ -399,18 +399,29 @@ static bool ParseCodeGenArgs(CodeGenOpti
   }
 
   if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
-Opts.setDebugInfo(
-llvm::StringSwitch(A->getValue())
+unsigned Val =
+llvm::StringSwitch(A->getValue())
 .Case("line-tables-only", CodeGenOptions::DebugLineTablesOnly)
 .Case("limited", CodeGenOptions::LimitedDebugInfo)
-.Case("standalone", CodeGenOptions::FullDebugInfo));
+.Case("standalone", CodeGenOptions::FullDebugInfo)
+.Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< A->getValue();
+else
+  Opts.setDebugInfo(static_cast(Val));
   }
   if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
-Opts.setDebuggerTuning(
-llvm::StringSwitch(A->getValue())
-.Case("gdb", CodeGenOptions::DebuggerKindGDB)
-.Case("lldb", CodeGenOptions::DebuggerKindLLDB)
-.Case("sce", CodeGenOptions::DebuggerKindSCE));
+unsigned Val = llvm::StringSwitch(A->getValue())
+   .Case("gdb", CodeGenOptions::DebuggerKindGDB)
+   .Case("lldb", CodeGenOptions::DebuggerKindLLDB)
+   .Case("sce", CodeGenOptions::DebuggerKindSCE)
+   .Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< A->getValue();
+else
+  Opts.setDebuggerTuning(static_cast(Val));
   }
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
   Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=256897&r1=256896&r2=256897&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Tue Jan  5 19:37:57 2016
@@ -169,3 +169,8 @@
 // NOCI-NOT: "-dwarf-column-info"
 //
 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" 
"-debug-info-kind={{standalone|limited}}"
+
+// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck 
-check-prefix=BADSTRING1 %s
+// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
+// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck 
-check-prefix=BADSTRING2 %s
+// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'


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


Re: [PATCH] D15882: Avoid assert failure on some invalid cc1 options.

2016-01-05 Thread Douglas Katzman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256897: Avoid assert failure on some invalid cc1 options. 
(authored by dougk).

Changed prior to commit:
  http://reviews.llvm.org/D15882?vs=43958&id=44074#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15882

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Driver/debug-options.c

Index: cfe/trunk/test/Driver/debug-options.c
===
--- cfe/trunk/test/Driver/debug-options.c
+++ cfe/trunk/test/Driver/debug-options.c
@@ -169,3 +169,8 @@
 // NOCI-NOT: "-dwarf-column-info"
 //
 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" 
"-debug-info-kind={{standalone|limited}}"
+
+// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck 
-check-prefix=BADSTRING1 %s
+// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
+// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck 
-check-prefix=BADSTRING2 %s
+// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -399,18 +399,29 @@
   }
 
   if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
-Opts.setDebugInfo(
-llvm::StringSwitch(A->getValue())
+unsigned Val =
+llvm::StringSwitch(A->getValue())
 .Case("line-tables-only", CodeGenOptions::DebugLineTablesOnly)
 .Case("limited", CodeGenOptions::LimitedDebugInfo)
-.Case("standalone", CodeGenOptions::FullDebugInfo));
+.Case("standalone", CodeGenOptions::FullDebugInfo)
+.Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< A->getValue();
+else
+  Opts.setDebugInfo(static_cast(Val));
   }
   if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
-Opts.setDebuggerTuning(
-llvm::StringSwitch(A->getValue())
-.Case("gdb", CodeGenOptions::DebuggerKindGDB)
-.Case("lldb", CodeGenOptions::DebuggerKindLLDB)
-.Case("sce", CodeGenOptions::DebuggerKindSCE));
+unsigned Val = llvm::StringSwitch(A->getValue())
+   .Case("gdb", CodeGenOptions::DebuggerKindGDB)
+   .Case("lldb", CodeGenOptions::DebuggerKindLLDB)
+   .Case("sce", CodeGenOptions::DebuggerKindSCE)
+   .Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< A->getValue();
+else
+  Opts.setDebuggerTuning(static_cast(Val));
   }
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
   Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);


Index: cfe/trunk/test/Driver/debug-options.c
===
--- cfe/trunk/test/Driver/debug-options.c
+++ cfe/trunk/test/Driver/debug-options.c
@@ -169,3 +169,8 @@
 // NOCI-NOT: "-dwarf-column-info"
 //
 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}"
+
+// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
+// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
+// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
+// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -399,18 +399,29 @@
   }
 
   if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
-Opts.setDebugInfo(
-llvm::StringSwitch(A->getValue())
+unsigned Val =
+llvm::StringSwitch(A->getValue())
 .Case("line-tables-only", CodeGenOptions::DebugLineTablesOnly)
 .Case("limited", CodeGenOptions::LimitedDebugInfo)
-.Case("standalone", CodeGenOptions::FullDebugInfo));
+.Case("standalone", CodeGenOptions::FullDebugInfo)
+.Default(~0U);
+if (Val == ~0U)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< A->getValue();
+else
+  Opts.setDebugInfo(static_cast(Val));
   }
   if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
-Opts.setDebuggerTuning(
-llvm::StringSwitch(A->getValue())
-.Case("gdb", CodeGenOptions::DebuggerKindGDB)
-.Case("lldb", CodeGenOptions::DebuggerKindLLDB)
-.Case("sce", CodeGenOptions::Debugg

[PATCH] D15911: Switch Action and ActionList over to using std::shared_ptr.

2016-01-05 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: echristo.
jlebar added a subscriber: cfe-commits.
jlebar added a dependency: D15910: Make isa, cast, dyn_cast, etc. work with 
std::unique_ptr and std::shared_ptr..
Herald added a subscriber: klimek.

This makes constructing Action graphs which are DAGs much simpler.  It
also just simplifies in general the ownership semantics of Actions.

Depends on D15910.

http://reviews.llvm.org/D15911

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  include/clang/Driver/Util.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  lib/Tooling/CompilationDatabase.cpp

Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -141,7 +141,7 @@
 
 for (driver::ActionList::const_iterator I = A->begin(), E = A->end();
  I != E; ++I)
-  runImpl(*I, CollectChildren);
+  runImpl(I->get(), CollectChildren);
   }
 };
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2455,7 +2455,7 @@
 return true;
 
   for (const auto &Act : *A)
-if (ContainsCompileAction(Act))
+if (ContainsCompileAction(Act.get()))
   return true;
 
   return false;
@@ -2472,7 +2472,7 @@
   if (RelaxDefault) {
 RelaxDefault = false;
 for (const auto &Act : C.getActions()) {
-  if (ContainsCompileAction(Act)) {
+  if (ContainsCompileAction(Act.get())) {
 RelaxDefault = true;
 break;
   }
@@ -5922,7 +5922,7 @@
   const Action *SourceAction = &JA;
   while (SourceAction->getKind() != Action::InputClass) {
 assert(!SourceAction->getInputs().empty() && "unexpected root action!");
-SourceAction = SourceAction->getInputs()[0];
+SourceAction = SourceAction->getInputs()[0].get();
   }
 
   // Forward -g and handle debug info related flags, assuming we are dealing
@@ -6833,7 +6833,7 @@
   const Action *SourceAction = &JA;
   while (SourceAction->getKind() != Action::InputClass) {
 assert(!SourceAction->getInputs().empty() && "unexpected root action!");
-SourceAction = SourceAction->getInputs()[0];
+SourceAction = SourceAction->getInputs()[0].get();
   }
 
   // If -fno-integrated-as is used add -Q to the darwin assember driver to make
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -934,36 +934,36 @@
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
-static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+static unsigned PrintActions1(const Compilation &C, const Action *A,
+  std::map &Ids) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
   os << Action::getClassName(A->getKind()) << ", ";
-  if (InputAction *IA = dyn_cast(A)) {
+  if (const InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
-  } else if (BindArchAction *BIA = dyn_cast(A)) {
+  } else if (const BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->begin(), Ids) << "}";
-  } else if (CudaDeviceAction *CDA = dyn_cast(A)) {
+   << PrintActions1(C, BIA->begin()->get(), Ids) << "}";
+  } else if (const CudaDeviceAction *CDA = dyn_cast(A)) {
 os << '"' << CDA->getGpuArchName() << '"' << ", {"
-   << PrintActions1(C, *CDA->begin(), Ids) << "}";
+   << PrintActions1(C, CDA->begin()->get(), Ids) << "}";
   } else {
 const ActionList *AL;
-if (CudaHostAction *CHA = dyn_cast(A)) {
-  os << "{" << PrintActions1(C, *CHA->begin(), Ids) << "}"
+if (const CudaHostAction *CHA = dyn_cast(A)) {
+  os << "{" << PrintActions1(C, CHA->begin()->get(), Ids) << "}"
  << ", gpu binaries ";
   AL = &CHA->getDeviceActions();
 } else
   AL = &A->getInputs();
 
 if (AL->size()) {
   const char *Prefix = "{";
-  for (Action *PreRequisite : *AL) {
-os << Prefix << PrintActions1(C, PreRequisite, Ids);
+  for (const std::shared_ptr &PreRequisite : *AL) {
+os << Prefix << PrintActions1(C, PreRequisite.get(), Ids);
 Prefix = ", ";
   }
   os << "}";
@@ -982,9 +982,9 @@
 // Print the action graphs in a compilation C.
 // For example "clang -c file1.c file2.c" is composed of two subgraphs.
 void Driver::PrintActions(const Compilation &C) const {
-  std::map Ids;
-  for (Action *A : C.getActions())
-PrintActions1(C, A, Ids);
+  std::map Ids;
+  for (const std::

Re: r252960 - [modules] Simplify and generalize the existing rule for finding hidden

2016-01-05 Thread Richard Smith via cfe-commits
On Tue, Jan 5, 2016 at 1:32 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> > On Dec 16, 2015, at 5:19 PM, Bob Wilson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >> On Nov 12, 2015, at 2:19 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: rsmith
> >> Date: Thu Nov 12 16:19:45 2015
> >> New Revision: 252960
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=252960&view=rev
> >> Log:
> >> [modules] Simplify and generalize the existing rule for finding hidden
> >> declarations in redeclaration lookup. A declaration is now visible to
> >> lookup if:
> >>
> >> * It is visible (not in a module, or in an imported module), or
> >> * We're doing redeclaration lookup and it's externally-visible, or
> >> * We're doing typo correction and looking for unimported decls.
> >>
> >> We now support multiple modules having different internal-linkage or
> no-linkage
> >> definitions of the same name for all entities, not just for functions,
> >> variables, and some typedefs. As previously, if multiple such entities
> are
> >> visible, any attempt to use them will result in an ambiguity error.
> >>
> >> This patch fixes the linkage calculation for a number of entities where
> we
> >> previously didn't need to get it right (using-declarations, namespace
> aliases,
> >> and so on).  It also classifies enumerators as always having no
> linkage, which
> >> is a slight deviation from the C++ standard's definition, but not an
> observable
> >> change outside modules (this change is being discussed on the -core
> reflector
> >> currently).
> >>
> >> This also removes the prior special case for tag lookup, which made
> some cases
> >> of this work, but also led to bizarre, bogus "must use 'struct' to
> refer to type
> >> 'Foo' in this scope" diagnostics in C++.
> >
> > We’re seeing a build failure that seems like it is due to this change.
> The following code used to compile successfully:
> >
> > namespace llvm {
> > template  class AllocatorBase {};
> > namespace filter {
> > class Node {
> >  class NodeBits {};
> >  class UniformBits {};
> >  union {
> >UniformBits UniformBits;
> >  };
> >  static_assert(sizeof(UniformBits) <= 8, "fits in an uint64_6");
> > };
> > }
> > }
> >
> > but now we get "error: reference to 'UniformBits' is ambiguous” from the
> static_assert. It looks to me like this really is ambiguous and that the
> code should be changed. Can you confirm that?
>
> [class.union] §9.5.5 states that "The names of the members of an anonymous
> union shall be distinct from the names of any other entity in the scope in
> which the anonymous union is declared.”
>
> I read that as a confirmation that this is indeed illegal.
>

Yes, but we're diagnosing it the wrong way -- it's ill-formed even before
the ambiguous lookup that we now diagnose.


> -- adrian
>
> >
> > I also noticed that we get a duplicated diagnostic in this case. I
> noticed that you fixed a related case in r252967, but it seems to be
> missing this case.
> >
> >>
> >> Added:
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/decls.h
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/empty.h
> >>   cfe/trunk/test/Modules/Inputs/no-linkage/module.modulemap
> >>   cfe/trunk/test/Modules/no-linkage.cpp
> >> Modified:
> >>   cfe/trunk/include/clang/Sema/Lookup.h
> >>   cfe/trunk/lib/AST/Decl.cpp
> >>   cfe/trunk/lib/Sema/SemaDecl.cpp
> >>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> >>   cfe/trunk/test/Index/linkage.c
> >>   cfe/trunk/test/Index/usrs.m
> >>   cfe/trunk/test/Modules/decldef.m
> >>   cfe/trunk/test/Modules/merge-enumerators.cpp
> >>   cfe/trunk/test/Modules/module-private.cpp
> >>   cfe/trunk/test/Modules/submodule-visibility-cycles.cpp
> >>   cfe/trunk/test/Modules/submodules-merge-defs.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> >> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=252960&r1=252959&r2=252960&view=diff
> >>
> ==
> >> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> >> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Nov 12 16:19:45 2015
> >> @@ -139,8 +139,7 @@ public:
> >>  Redecl(Redecl != Sema::NotForRedeclaration),
> >>  HideTags(true),
> >>  Diagnose(Redecl == Sema::NotForRedeclaration),
> >> -  AllowHidden(Redecl == Sema::ForRedeclaration),
> >> -  AllowHiddenInternal(AllowHidden),
> >> +  AllowHidden(false),
> >>  Shadowed(false)
> >>  {
> >>configure();
> >> @@ -162,8 +161,7 @@ public:
> >>  Redecl(Redecl != Sema::NotForRedeclaration),
> >>  HideTags(true),
> >>  Diagnose(Redecl == Sema::NotForRedeclaration),
> >> -  AllowHidden(Redecl == Sema::ForRedeclaration),
> >> -  AllowHiddenInternal(AllowHidden),
> >> +  AllowHidden(false),
> >>  Shadowed(false)
> >>  {
> >>configure();
> >> @@ -184,7 +182,6 @@ public:

r256907 - [modules] When a tag type that was imported from a module is referenced via an

2016-01-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jan  5 21:52:10 2016
New Revision: 256907

URL: http://llvm.org/viewvc/llvm-project?rev=256907&view=rev
Log:
[modules] When a tag type that was imported from a module is referenced via an
elaborated-type-specifier, create a declaration of it to track that the current
module makes it visible too.

Added:
cfe/trunk/test/Modules/tag-injection.cpp
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=256907&r1=256906&r2=256907&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan  5 21:52:10 2016
@@ -12277,16 +12277,35 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
 if (!Invalid) {
   // If this is a use, just return the declaration we found, unless
   // we have attributes.
-
-  // FIXME: In the future, return a variant or some other clue
-  // for the consumer of this Decl to know it doesn't own it.
-  // For our current ASTs this shouldn't be a problem, but will
-  // need to be changed with DeclGroups.
-  if (!Attr &&
-  ((TUK == TUK_Reference &&
-(!PrevTagDecl->getFriendObjectKind() || 
getLangOpts().MicrosoftExt))
-   || TUK == TUK_Friend))
-return PrevTagDecl;
+  if (TUK == TUK_Reference || TUK == TUK_Friend) {
+if (Attr) {
+  // FIXME: Diagnose these attributes. For now, we create a new
+  // declaration to hold them.
+} else if (TUK == TUK_Reference &&
+   (PrevTagDecl->getFriendObjectKind() ==
+Decl::FOK_Undeclared ||
+getOwningModule(PrevDecl) !=
+PP.getModuleContainingLocation(KWLoc)) &&
+   SS.isEmpty()) {
+  // This declaration is a reference to an existing entity, but
+  // has different visibility from that entity: it either makes
+  // a friend visible or it makes a type visible in a new module.
+  // In either case, create a new declaration. We only do this if
+  // the declaration would have meant the same thing if no prior
+  // declaration were found, that is, if it was found in the same
+  // scope where we would have injected a declaration.
+  DeclContext *InjectedDC = CurContext;
+  while (!InjectedDC->isFileContext() &&
+ !InjectedDC->isFunctionOrMethod())
+InjectedDC = InjectedDC->getParent();
+  if (!InjectedDC->getRedeclContext()->Equals(
+  PrevDecl->getDeclContext()->getRedeclContext()))
+return PrevTagDecl;
+  // This is in the injected scope, create a new declaration.
+} else {
+  return PrevTagDecl;
+}
+  }
 
   // Diagnose attempts to redefine a tag.
   if (TUK == TUK_Definition) {

Added: cfe/trunk/test/Modules/tag-injection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/tag-injection.cpp?rev=256907&view=auto
==
--- cfe/trunk/test/Modules/tag-injection.cpp (added)
+++ cfe/trunk/test/Modules/tag-injection.cpp Tue Jan  5 21:52:10 2016
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: touch %t/a.h
+// RUN: echo 'struct X {};' > %t/b.h
+// RUN: echo 'module X { module a { header "a.h" } module b { header "b.h" } 
}' > %t/x.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ 
-fmodule-map-file=%t/x.modulemap %s -I%t -verify 
-fmodules-local-submodule-visibility -std=c++11
+
+#include "a.h"
+
+struct A {
+  // This use of 'struct X' makes the declaration (but not definition) of X 
visible.
+  virtual void f(struct X *p);
+};
+
+namespace N {
+  struct B : A {
+void f(struct X *q) override;
+  };
+}
+
+X x; // expected-error {{definition of 'X' must be imported from module 'X.b' 
before it is required}}
+// expected-note@b.h:1 {{here}}


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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2016-01-05 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4282
@@ +4281,3 @@
+  EXPECT_TRUE(matches("void f(int i);", functionProtoType()));
+  EXPECT_TRUE(matches("void f();", functionProtoType(parameterCountIs(0;
+  EXPECT_TRUE(

aaron.ballman wrote:
> This isn't quite what I had in mind. The test you added is a good one to add, 
> but I wanted a test that functionProtoType() does *not* match f() (because it 
> has no prototype), and another test for parameterCountIs() that it does't 
> explode on a function without a prototype in C.
I don't  understand what would be tested by adding a test for 
`parameterCountIs()` on a function that doesn't have a prototype since it is a 
nested matcher passed to `functionProtoType()` and since the function doesn't 
have a prototype, that outer matcher won't match.


http://reviews.llvm.org/D8149



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


[PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-05 Thread Xiuli PAN via cfe-commits
pxli168 created this revision.
pxli168 added reviewers: pekka.jaaskelainen, Anastasia.
pxli168 added subscribers: cfe-commits, bader.

Support for the pipe built-in functions.
The pipe packet type can be user defined structure, we need to handle this in 
clang frontend.
This version is based on bader's opencl support patches. It transform all kinds 
of pipe type in anonymous pipe and identify the actual type by packet size in 
byte, and bitcast pointers to void* to get one function definition.
We may discuss how to handle these pipe built-in functions, I have tried few 
ways and none of them seems to be a perfect solution.

http://reviews.llvm.org/D15914

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -258,6 +258,194 @@
   return false;
 }
 
+/// Returns readable name for a call.
+static StringRef getFunctionName(CallExpr *call) {
+  return cast(call->getCalleeDecl())->getName();
+}
+
+/// Returns OpenCL access qual.
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())
+return D->getAttr();
+  return nullptr;
+}
+
+/// Returns true if pipe element type is different from the pointer.
+static bool checkOpenCLPipeArg(Sema &S, CallExpr *call) {
+  const Expr *Arg0 = call->getArg(0);
+  // First argument type should always be pipe.
+  if (!Arg0->getType()->isPipeType()) {
+S.Diag(call->getLocStart(), diag::err_builtin_pipe_first_arg)
+<< getFunctionName(call) << Arg0->getSourceRange();
+return true;
+  }
+  OpenCLImageAccessAttr *AccessQual =
+  getOpenCLImageAcces(cast(Arg0)->getDecl());
+  // Validates the access modifier is compatible with the call.
+  // From OpenCL C Specification 6.13.16 the access qualifiers for
+  // pipe should only be read_only and write_only, and assumed to
+  // be read_only if no qualifier is specified.
+  bool isValid = true;
+  // TODO: For all pipe built-in read is for read_only?
+  if (getFunctionName(call).find("read") != StringRef::npos)
+// if (getFunctionName(call).startswith("read"))
+isValid = AccessQual == nullptr || AccessQual->isReadOnly();
+  else
+isValid = AccessQual != nullptr && AccessQual->isWriteOnly();
+  if (!isValid) {
+bool ReadOnly = getFunctionName(call).startswith("read");
+const char *AM = ReadOnly ? "read_only" : "write_only";
+S.Diag(Arg0->getLocStart(), diag::err_builtin_pipe_invalid_access_modifier)
+<< AM << Arg0->getSourceRange();
+return true;
+  }
+
+  return false;
+}
+
+/// Returns true if pipe element type is different from the pointer.
+static bool checkOpenCLPipePacketType(Sema &S, CallExpr *call, unsigned idx) {
+  const Expr *Arg0 = call->getArg(0);
+  const Expr *Argidx = call->getArg(idx);
+  const PipeType *PipeTy = cast(Arg0->getType());
+  const Type *EltTy = PipeTy->getElementType().getTypePtr();
+  const PointerType *ArgTy =
+  dyn_cast(Argidx->getType().getTypePtr());
+  // The idx argument should be a pointer and the type of the pointer and
+  // the type of pipe element should also be the same.
+  if (!Argidx->getType()->isPointerType() || !ArgTy ||
+  EltTy != ArgTy->getPointeeType().getTypePtr()) {
+S.Diag(call->getLocStart(), diag::err_builtin_pipe_invalid_arg)
+<< getFunctionName(call)
+<< S.Context.getPointerType(PipeTy->getElementType())
+<< Argidx->getSourceRange();
+return true;
+  }
+  return false;
+}
+
+// \brief Performs semantic analysis for the read/write_pipe call.
+// \param S Reference to the semantic analyzer.
+// \param call A pointer to the builtin call.
+// \return True if a semantic error has been found, false otherwise.
+static bool SemaBuiltinRWPipe(Sema &S, CallExpr *call) {
+
+  if (checkOpenCLPipeArg(S, call))
+return true;
+
+  // Two kinds of read/write pipe
+  // From OpenCL C Specification 6.13.16.2 the built-in read/write
+  // functions have following forms.
+  switch (call->getNumArgs()) {
+  case 2: {
+// The call with 2 arguments should be
+// read/write_pipe(pipe T, T*)
+// check packet type T
+if (checkOpenCLPipePacketType(S, call, 1))
+  return true;
+  } break;
+
+  case 4: {
+// The call with 4 arguments should be
+// read/write_pipe(pipe T, reserve_id_t, uint, T*)
+// check reserve_id_t
+if (!call->getArg(1)->getType()->isReserveIDT()) {
+  S.Diag(call->getLocStart(), diag::err_builtin_pipe_invalid_arg)
+  << getFunctionName(call) << S.Context.OCLReserveIDTy
+  << call->getArg(1)->getSourceRange();
+  return true;
+}
+
+// check the index
+const Expr *Arg2 = call->getArg(2);
+if (!Arg2->getType()->isIntegerType() &&
+!Arg2->getType()->isUnsignedInt

Re: [PATCH] D15911: Switch Action and ActionList over to using std::shared_ptr.

2016-01-05 Thread Justin Lebar via cfe-commits
jlebar added a comment.

The main reason I want this is for CUDA.  The way CUDA compilation will work, 
once I finish my patch, is: For each GPU arch, we compile device code to 
assembly (ptx) and then assemble the ptx into an object file (cubin).  We then 
pass the cubins *and* ptx files to nVidia's fatbinary program, which "links" 
them into one blob.  We then embed the blob in the host code.

So in this scheme, our Action graph is a DAG: The ptx is used as an input both 
to the cubin and fatbin actions.  Making this DAG work in the absence of this 
patch is...pretty unpleasant.


http://reviews.llvm.org/D15911



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


r256919 - Change the set of actions built for external gcc tools.

2016-01-05 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Jan  6 01:24:45 2016
New Revision: 256919

URL: http://llvm.org/viewvc/llvm-project?rev=256919&view=rev
Log:
Change the set of actions built for external gcc tools.

A gcc tool has an "integrated" assembler (usually gas) that it
will call to produce an object. Let it use that assembler so
that we don't have to deal with assembly syntax incompatibilities.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/fortran.f95

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256919&r1=256918&r2=256919&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 01:24:45 2016
@@ -6179,6 +6179,11 @@ void gcc::Compiler::RenderExtraToolArgs(
   case types::TY_LTO_BC:
 CmdArgs.push_back("-c");
 break;
+  // We assume we've got an "integrated" assembler in that gcc will produce an
+  // object file itself.
+  case types::TY_Object:
+CmdArgs.push_back("-c");
+break;
   case types::TY_PP_Asm:
 CmdArgs.push_back("-S");
 break;

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=256919&r1=256918&r2=256919&view=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Wed Jan  6 01:24:45 2016
@@ -149,6 +149,10 @@ public:
   Common(const char *Name, const char *ShortName, const ToolChain &TC)
   : GnuTool(Name, ShortName, TC) {}
 
+  // A gcc tool has an "integrated" assembler that it will call to produce an
+  // object. Let it use that assembler so that we don't have to deal with
+  // assembly syntax incompatibilities.
+  bool hasIntegratedAssembler() const override { return true; }
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
 const llvm::opt::ArgList &TCArgs,

Modified: cfe/trunk/test/Driver/fortran.f95
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fortran.f95?rev=256919&r1=256918&r2=256919&view=diff
==
--- cfe/trunk/test/Driver/fortran.f95 (original)
+++ cfe/trunk/test/Driver/fortran.f95 Wed Jan  6 01:24:45 2016
@@ -1,9 +1,15 @@
 // Check that the clang driver can invoke gcc to compile Fortran.
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -c %s -### 2>&1 
\
-// RUN:   | FileCheck %s
-// CHECK: gcc
-// CHECK: "-S"
-// CHECK: "-x" "f95"
-// CHECK: clang
-// CHECK: "-cc1as"
+// RUN:   | FileCheck --check-prefix=CHECK-OBJECT %s
+// CHECK-OBJECT: gcc
+// CHECK-OBJECT: "-c"
+// CHECK-OBJECT: "-x" "f95"
+// CHECK-OBJECT-NOT: cc1as
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 
\
+// RUN:   | FileCheck --check-prefix=CHECK-ASM %s
+// CHECK-ASM: gcc
+// CHECK-ASM: "-S"
+// CHECK-ASM: "-x" "f95"
+// CHECK-ASM-NOT: cc1


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


r256920 - Add -fno-movt frontend option, to disable movt/movw on ARM

2016-01-05 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Wed Jan  6 01:42:18 2016
New Revision: 256920

URL: http://llvm.org/viewvc/llvm-project?rev=256920&view=rev
Log:
Add -fno-movt frontend option, to disable movt/movw on ARM

Summary:
In rL256641, @davide turned off movt generation by default for FreeBSD.
This was because our ld is very old, and did not support the relocations
for it.  However, Ian Lepore added the support very recently, so we
would like to revert rL256641, and replace it with a new `-fno-movt`
frontend option.  This way, it can be turned off when needed.

Reviewers: dexonsmith, echristo, emaste, davide

Subscribers: andrew, aemerson, rengolin, davide, cfe-commits, ahatanak, emaste

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/arm-no-movt.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=256920&r1=256919&r2=256920&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan  6 01:42:18 2016
@@ -1385,6 +1385,8 @@ def mno_restrict_it: Flag<["-"], "mno-re
 def marm : Flag<["-"], "marm">, Alias;
 def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group,
   HelpText<"Reserve the r9 register (ARM only)">;
+def mno_movt : Flag<["-"], "mno-movt">, Group,
+  HelpText<"Disallow use of movt/movw pairs (ARM only)">;
 def mcrc : Flag<["-"], "mcrc">, Group,
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256920&r1=256919&r2=256920&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan  6 01:42:18 2016
@@ -938,8 +938,8 @@ static void getARMTargetFeatures(const T
   if (Args.hasArg(options::OPT_ffixed_r9))
 Features.push_back("+reserve-r9");
 
-  // The kext and FreeBSD linkers don't know how to deal with movw/movt.
-  if (KernelOrKext || Triple.isOSFreeBSD())
+  // The kext linker doesn't know how to deal with movw/movt.
+  if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))
 Features.push_back("+no-movt");
 }
 

Modified: cfe/trunk/test/Driver/arm-no-movt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-no-movt.c?rev=256920&r1=256919&r2=256920&view=diff
==
--- cfe/trunk/test/Driver/arm-no-movt.c (original)
+++ cfe/trunk/test/Driver/arm-no-movt.c Wed Jan  6 01:42:18 2016
@@ -4,11 +4,11 @@
 // RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-KERNEL
 
-// RUN: %clang -target armv7-gnueabi-freebsd11 -### %s 2>&1 \
-// RUN:| FileCheck %s -check-prefix CHECK-FREEBSD
+// RUN: %clang -target armv7-none-gnueabi -mno-movt -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MOVT
 
 // CHECK-DEFAULT-NOT: "-target-feature" "+no-movt"
 
 // CHECK-KERNEL: "-target-feature" "+no-movt"
 
-// CHECK-FREEBSD: "-target-feature" "+no-movt"
+// CHECK-NO-MOVT: "-target-feature" "+no-movt"


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