[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-14 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

It might be the case, that the test is run with -no-stdinc (or similar),
so the standard library is not available.

Am 13.06.2018 um 23:08 schrieb Shuai Wang via Phabricator:

> shuaiwang added a comment.
> 
> In https://reviews.llvm.org/D45679#1131115, @aaron.ballman wrote:
> 
>> I had to revert due to failing tests. The revert was done in r334606 and 
>> this is an example of a failing bot: 
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/31500
> 
> Apparently I can't include  in unit test cases (somehow that works 
> on my machine :p)
>  Changed to just forward declare std::type_info instead.
> 
> Repository:
> 
>   rCTE Clang Tools Extra
> 
> https://reviews.llvm.org/D45679


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679



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


[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-06-14 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:10107-10112
+case 0x0b: // FALSE_OQ
+case 0x1b: // FALSE_OS
+  return llvm::Constant::getNullValue(ConvertType(E->getType()));
+case 0x0f: // TRUE_UQ
+case 0x1f: // TRUE_US
+  return llvm::Constant::getAllOnesValue(ConvertType(E->getType()));

spatel wrote:
> On 2nd thought, why are we optimizing when we have matching IR predicates for 
> these?
> Just translate to FCMP_TRUE / FCMP_FALSE instead of special-casing these 
> values.
> InstSimplify can handle the constant folding if optimization is on.
I don't know, these TRUE/FALSE cases were already handled here, I only 
rearranged the code.
Does this cause any problems? I mean, if it meant an extra dozen lines of code 
I would get it, but as it is, does it hurt anything?


https://reviews.llvm.org/D45616



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


[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-06-14 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334692: [clang-format] Add SpaceBeforeCpp11BracedList 
option. (authored by hans, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46024?vs=150984&id=151308#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46024

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -1495,6 +1495,17 @@
   /// \endcode
   bool SpaceBeforeAssignmentOperators;
 
+  /// If ``true``, a space will be inserted before a C++11 braced list
+  /// used to initialize an object (after the preceding identifier or type).
+  /// \code
+  ///true:  false:
+  ///Foo foo { bar };   vs. Foo foo{ bar };
+  ///Foo {};Foo{};
+  ///vector { 1, 2, 3 };   vector{ 1, 2, 3 };
+  ///new int[3] { 1, 2, 3 };new int[3]{ 1, 2, 3 };
+  /// \endcode
+  bool SpaceBeforeCpp11BracedList;
+
   /// If ``false``, spaces will be removed before constructor initializer
   /// colon.
   /// \code
@@ -1738,6 +1749,7 @@
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
+   SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2548,6 +2548,9 @@
   if (Style.isCpp()) {
 if (Left.is(tok::kw_operator))
   return Right.is(tok::coloncolon);
+if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit &&
+!Left.opensScope() && Style.SpaceBeforeCpp11BracedList)
+  return true;
   } else if (Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Right.is(tok::period) &&
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -449,6 +449,8 @@
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
+IO.mapOptional("SpaceBeforeCpp11BracedList",
+   Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
 IO.mapOptional("SpaceBeforeInheritanceColon",
@@ -697,6 +699,7 @@
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
+  LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpacesInAngles = false;
 
   LLVMStyle.PenaltyBreakAssignment = prec::Assignment;
@@ -892,6 +895,7 @@
   Style.ObjCBlockIndentWidth = 4;
   Style.ObjCSpaceAfterProperty = true;
   Style.PointerAlignment = FormatStyle::PAS_Left;
+  Style.SpaceBeforeCpp11BracedList = true;
   return Style;
 }
 
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -7019,6 +7019,11 @@
"  { \"c\", 2 }\n"
"};",
ExtraSpaces);
+
+  FormatStyle SpaceBeforeBrace = getLLVMStyle();
+  SpaceBeforeBrace.SpaceBeforeCpp11BracedList = true;
+  verifyFormat("vector x {1, 2, 3, 4};", SpaceBeforeBrace);
+  verifyFormat("f({}, {{}, {}}, MyMap[{k, v}]);", SpaceBeforeBrace);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
@@ -10622,6 +10627,7 @@
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceAfterTemplateKeyword);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpaceBeforeCpp11BracedList);
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
Index: cfe/trunk/docs/ClangFormatStyleOptions.rst
===
--- cfe/trunk/docs/ClangFormatStyleOptions.rst
+++ 

r334692 - [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-06-14 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Jun 14 01:01:09 2018
New Revision: 334692

URL: http://llvm.org/viewvc/llvm-project?rev=334692&view=rev
Log:
[clang-format] Add SpaceBeforeCpp11BracedList option.

WebKit C++ style for object initialization is as follows:

  Foo foo { bar };

Yet using clang-format -style=webkit changes this to:

  Foo foo{ bar };

As there is no existing combination of rules that will ensure a space
before a braced list in this fashion, this patch adds a new
SpaceBeforeCpp11BracedList rule.

Patch by Ross Kirsling!

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=334692&r1=334691&r2=334692&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Jun 14 01:01:09 2018
@@ -1791,6 +1791,18 @@ the configuration (without a prefix: ``A
  int a = 5; vs. int a=5;
  a += 42a+=42;
 
+**SpaceBeforeCpp11BracedList** (``bool``)
+  If ``true``, a space will be inserted before a C++11 braced list
+  used to initialize an object (after the preceding identifier or type).
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo foo { bar };   vs. Foo foo{ bar };
+ Foo {};Foo{};
+ vector { 1, 2, 3 };   vector{ 1, 2, 3 };
+ new int[3] { 1, 2, 3 };new int[3]{ 1, 2, 3 };
+
 **SpaceBeforeCtorInitializerColon** (``bool``)
   If ``false``, spaces will be removed before constructor initializer
   colon.

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=334692&r1=334691&r2=334692&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Jun 14 01:01:09 2018
@@ -1495,6 +1495,17 @@ struct FormatStyle {
   /// \endcode
   bool SpaceBeforeAssignmentOperators;
 
+  /// If ``true``, a space will be inserted before a C++11 braced list
+  /// used to initialize an object (after the preceding identifier or type).
+  /// \code
+  ///true:  false:
+  ///Foo foo { bar };   vs. Foo foo{ bar };
+  ///Foo {};Foo{};
+  ///vector { 1, 2, 3 };   vector{ 1, 2, 3 };
+  ///new int[3] { 1, 2, 3 };new int[3]{ 1, 2, 3 };
+  /// \endcode
+  bool SpaceBeforeCpp11BracedList;
+
   /// If ``false``, spaces will be removed before constructor initializer
   /// colon.
   /// \code
@@ -1738,6 +1749,7 @@ struct FormatStyle {
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
+   SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=334692&r1=334691&r2=334692&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Jun 14 01:01:09 2018
@@ -449,6 +449,8 @@ template <> struct MappingTraitshttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=334692&r1=334691&r2=334692&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jun 14 01:01:09 2018
@@ -2548,6 +2548,9 @@ bool TokenAnnotator::spaceRequiredBefore
   if (Style.isCpp()) {
 if (Left.is(tok::kw_operator))
   return Right.is(tok::coloncolon);
+if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit &&
+!Left.opensScope() && Style.SpaceBeforeCpp11BracedList)
+  return true;
   } else if (Style.Language == FormatStyle::LK_Proto ||
  Style.Language == FormatStyle::LK_TextProto) {
 if (Right.is(tok::period) &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=334692&r1=334691&r2=334692&view=diff

r334693 - [AArch64] Added support for the vcvta_u16_f16 instrinsic for FP16 Armv8.2-A

2018-06-14 Thread Luke Geeson via cfe-commits
Author: lukegeeson
Date: Thu Jun 14 01:28:56 2018
New Revision: 334693

URL: http://llvm.org/viewvc/llvm-project?rev=334693&view=rev
Log:
[AArch64] Added support for the vcvta_u16_f16 instrinsic for FP16 Armv8.2-A

Added:
cfe/trunk/CodeGen/
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334693&r1=334692&r2=334693&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 14 01:28:56 2018
@@ -3998,6 +3998,7 @@ static const NeonIntrinsicInfo ARMSIMDIn
   NEONMAP0(vcvt_u32_v),
   NEONMAP0(vcvt_u64_v),
   NEONMAP1(vcvta_s16_v, arm_neon_vcvtas, 0),
+  NEONMAP1(vcvta_u16_v, arm_neon_vcvtau, 0),
   NEONMAP1(vcvta_s32_v, arm_neon_vcvtas, 0),
   NEONMAP1(vcvta_s64_v, arm_neon_vcvtas, 0),
   NEONMAP1(vcvta_u32_v, arm_neon_vcvtau, 0),
@@ -4882,6 +4883,7 @@ Value *CodeGenFunction::EmitCommonNeonBu
 : Builder.CreateFPToSI(Ops[0], Ty, "vcvt");
   }
   case NEON::BI__builtin_neon_vcvta_s16_v:
+  case NEON::BI__builtin_neon_vcvta_u16_v:
   case NEON::BI__builtin_neon_vcvta_s32_v:
   case NEON::BI__builtin_neon_vcvta_s64_v:
   case NEON::BI__builtin_neon_vcvta_u32_v:
@@ -7623,6 +7625,7 @@ Value *CodeGenFunction::EmitAArch64Built
 return Builder.CreateFPToSI(Ops[0], Ty);
   }
   case NEON::BI__builtin_neon_vcvta_s16_v:
+  case NEON::BI__builtin_neon_vcvta_u16_v:
   case NEON::BI__builtin_neon_vcvta_s32_v:
   case NEON::BI__builtin_neon_vcvtaq_s16_v:
   case NEON::BI__builtin_neon_vcvtaq_s32_v:

Modified: cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c?rev=334693&r1=334692&r2=334693&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c Thu Jun 14 01:28:56 
2018
@@ -164,6 +164,13 @@ int16x4_t test_vcvta_s16_f16 (float16x4_
   return vcvta_s16_f16(a);
 }
 
+// CHECK-LABEL: test_vcvta_u16_f16
+// CHECK:  [[VCVT:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.fcvtau.v4i16.v4f16(<4 x half> %a)
+// CHECK:  ret <4 x i16> [[VCVT]]
+int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
+  return vcvta_u16_f16(a);
+}
+
 // CHECK-LABEL: test_vcvtaq_s16_f16
 // CHECK:  [[VCVT:%.*]] = call <8 x i16> 
@llvm.aarch64.neon.fcvtas.v8i16.v8f16(<8 x half> %a)
 // CHECK:  ret <8 x i16> [[VCVT]]

Modified: cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c?rev=334693&r1=334692&r2=334693&view=diff
==
--- cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c Thu Jun 14 01:28:56 2018
@@ -164,6 +164,13 @@ int16x4_t test_vcvta_s16_f16 (float16x4_
   return vcvta_s16_f16(a);
 }
 
+// CHECK-LABEL: test_vcvta_u16_f16
+// CHECK:  [[VCVT:%.*]] = call <4 x i16> @llvm.arm.neon.fcvtau.v4i16.v4f16(<4 
x half> %a)
+// CHECK:  ret <4 x i16> [[VCVT]]
+int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
+   return vcvta_u16_f16(a);
+}
+
 // CHECK-LABEL: test_vcvtaq_s16_f16
 // CHECK:  [[VCVT:%.*]] = call <8 x i16> @llvm.arm.neon.vcvtas.v8i16.v8f16(<8 
x half> %a)
 // CHECK:  ret <8 x i16> [[VCVT]]


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


r334694 - Removed trunk-Codegen directory added in error

2018-06-14 Thread Luke Geeson via cfe-commits
Author: lukegeeson
Date: Thu Jun 14 01:51:52 2018
New Revision: 334694

URL: http://llvm.org/viewvc/llvm-project?rev=334694&view=rev
Log:
Removed trunk-Codegen directory added in error

Removed:
cfe/trunk/CodeGen/

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


r334696 - [AArch64] reverting rC334693 due to build failures

2018-06-14 Thread Luke Geeson via cfe-commits
Author: lukegeeson
Date: Thu Jun 14 01:59:33 2018
New Revision: 334696

URL: http://llvm.org/viewvc/llvm-project?rev=334696&view=rev
Log:
[AArch64] reverting rC334693 due to build failures

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334696&r1=334695&r2=334696&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 14 01:59:33 2018
@@ -3998,7 +3998,6 @@ static const NeonIntrinsicInfo ARMSIMDIn
   NEONMAP0(vcvt_u32_v),
   NEONMAP0(vcvt_u64_v),
   NEONMAP1(vcvta_s16_v, arm_neon_vcvtas, 0),
-  NEONMAP1(vcvta_u16_v, arm_neon_vcvtau, 0),
   NEONMAP1(vcvta_s32_v, arm_neon_vcvtas, 0),
   NEONMAP1(vcvta_s64_v, arm_neon_vcvtas, 0),
   NEONMAP1(vcvta_u32_v, arm_neon_vcvtau, 0),
@@ -4883,7 +4882,6 @@ Value *CodeGenFunction::EmitCommonNeonBu
 : Builder.CreateFPToSI(Ops[0], Ty, "vcvt");
   }
   case NEON::BI__builtin_neon_vcvta_s16_v:
-  case NEON::BI__builtin_neon_vcvta_u16_v:
   case NEON::BI__builtin_neon_vcvta_s32_v:
   case NEON::BI__builtin_neon_vcvta_s64_v:
   case NEON::BI__builtin_neon_vcvta_u32_v:
@@ -7625,7 +7623,6 @@ Value *CodeGenFunction::EmitAArch64Built
 return Builder.CreateFPToSI(Ops[0], Ty);
   }
   case NEON::BI__builtin_neon_vcvta_s16_v:
-  case NEON::BI__builtin_neon_vcvta_u16_v:
   case NEON::BI__builtin_neon_vcvta_s32_v:
   case NEON::BI__builtin_neon_vcvtaq_s16_v:
   case NEON::BI__builtin_neon_vcvtaq_s32_v:

Modified: cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c?rev=334696&r1=334695&r2=334696&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c Thu Jun 14 01:59:33 
2018
@@ -164,13 +164,6 @@ int16x4_t test_vcvta_s16_f16 (float16x4_
   return vcvta_s16_f16(a);
 }
 
-// CHECK-LABEL: test_vcvta_u16_f16
-// CHECK:  [[VCVT:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.fcvtau.v4i16.v4f16(<4 x half> %a)
-// CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
-  return vcvta_u16_f16(a);
-}
-
 // CHECK-LABEL: test_vcvtaq_s16_f16
 // CHECK:  [[VCVT:%.*]] = call <8 x i16> 
@llvm.aarch64.neon.fcvtas.v8i16.v8f16(<8 x half> %a)
 // CHECK:  ret <8 x i16> [[VCVT]]

Modified: cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c?rev=334696&r1=334695&r2=334696&view=diff
==
--- cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/arm-v8.2a-neon-intrinsics.c Thu Jun 14 01:59:33 2018
@@ -164,13 +164,6 @@ int16x4_t test_vcvta_s16_f16 (float16x4_
   return vcvta_s16_f16(a);
 }
 
-// CHECK-LABEL: test_vcvta_u16_f16
-// CHECK:  [[VCVT:%.*]] = call <4 x i16> @llvm.arm.neon.fcvtau.v4i16.v4f16(<4 
x half> %a)
-// CHECK:  ret <4 x i16> [[VCVT]]
-int16x4_t test_vcvta_u16_f16 (float16x4_t a) {
-   return vcvta_u16_f16(a);
-}
-
 // CHECK-LABEL: test_vcvtaq_s16_f16
 // CHECK:  [[VCVT:%.*]] = call <8 x i16> @llvm.arm.neon.vcvtas.v8i16.v8f16(<8 
x half> %a)
 // CHECK:  ret <8 x i16> [[VCVT]]


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


[PATCH] D48098: clang-format-diff: Switch to python3 by default, support python 2.7

2018-06-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: tools/clang-format/clang-format-diff.py:1
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #

lebedev.ri wrote:
> Why do you need to *switch* the default?
> What's wrong with [at least starting with] just making sure it works with 
> both python 2 and 3?
+1: I'm not an expert, but IMO python2.7 is more prevalent.


https://reviews.llvm.org/D48098



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


[PATCH] D48161: Fix documentation generation

2018-06-14 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Typz added reviewers: krasimir, djasper, klimek.

  It seems that the changes done to `ClangFormatStyleOptions.rst` @334408 are 
causing the generation of the documentation to fail, with the following error:
  
  Warning, treated as error:
/llvm/tools/clang/docs/ClangFormatStyleOptions.rst:1060: WARNING: 
Definition list ends without a blank line; unexpected unindent.
  
  This is due to missing indent in some code block, and fixed by this patch.


Repository:
  rC Clang

https://reviews.llvm.org/D48161

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -840,24 +840,24 @@
   enum BreakConstructorInitializersStyle {
 /// Break constructor initializers before the colon and after the commas.
 /// \code
-/// Constructor()
-/// : initializer1(),
-///   initializer2()
+///Constructor()
+///: initializer1(),
+///  initializer2()
 /// \endcode
 BCIS_BeforeColon,
 /// Break constructor initializers before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///Constructor()
+///: initializer1()
+///, initializer2()
 /// \endcode
 BCIS_BeforeComma,
 /// Break constructor initializers after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///Constructor() :
+///initializer1(),
+///initializer2()
 /// \endcode
 BCIS_AfterColon
   };
@@ -897,25 +897,25 @@
   enum BreakInheritanceListStyle {
 /// Break inheritance list before the colon and after the commas.
 /// \code
-/// class Foo
-/// : Base1,
-///   Base2
-/// {};
+///class Foo
+///: Base1,
+///  Base2
+///{};
 /// \endcode
 BILS_BeforeColon,
 /// Break inheritance list before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///class Foo
+///: Base1
+///, Base2
 /// \endcode
 BILS_BeforeComma,
 /// Break inheritance list after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///class Foo :
+///Base1,
+///Base2
 /// \endcode
 BILS_AfterColon
   };
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -1019,28 +1019,28 @@
 
 .. code-block:: c++
 
-Constructor()
-: initializer1(),
-  initializer2()
+   Constructor()
+   : initializer1(),
+ initializer2()
 
   * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break constructor initializers before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   Constructor()
+   : initializer1()
+   , initializer2()
 
   * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
 Break constructor initializers after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   Constructor() :
+   initializer1(),
+   initializer2()
 
 
 
@@ -1054,29 +1054,29 @@
 
 .. code-block:: c++
 
-class Foo
-: Base1,
-  Base2
-{};
+   class Foo
+   : Base1,
+ Base2
+   {};
 
   * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break inheritance list before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   class Foo
+   : Base1
+   , Base2
 
   * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
 Break inheritance list after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   class Foo :
+   Base1,
+   Base2
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48161: clang-format: Fix documentation generation

2018-06-14 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 151313.
Typz added a comment.

Add missing block, for consistency


Repository:
  rC Clang

https://reviews.llvm.org/D48161

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -840,24 +840,24 @@
   enum BreakConstructorInitializersStyle {
 /// Break constructor initializers before the colon and after the commas.
 /// \code
-/// Constructor()
-/// : initializer1(),
-///   initializer2()
+///Constructor()
+///: initializer1(),
+///  initializer2()
 /// \endcode
 BCIS_BeforeColon,
 /// Break constructor initializers before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///Constructor()
+///: initializer1()
+///, initializer2()
 /// \endcode
 BCIS_BeforeComma,
 /// Break constructor initializers after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///Constructor() :
+///initializer1(),
+///initializer2()
 /// \endcode
 BCIS_AfterColon
   };
@@ -897,25 +897,27 @@
   enum BreakInheritanceListStyle {
 /// Break inheritance list before the colon and after the commas.
 /// \code
-/// class Foo
-/// : Base1,
-///   Base2
-/// {};
+///class Foo
+///: Base1,
+///  Base2
+///{};
 /// \endcode
 BILS_BeforeColon,
 /// Break inheritance list before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///class Foo
+///: Base1
+///, Base2
+///{};
 /// \endcode
 BILS_BeforeComma,
 /// Break inheritance list after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///class Foo :
+///Base1,
+///Base2
+///{};
 /// \endcode
 BILS_AfterColon
   };
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -1019,28 +1019,28 @@
 
 .. code-block:: c++
 
-Constructor()
-: initializer1(),
-  initializer2()
+   Constructor()
+   : initializer1(),
+ initializer2()
 
   * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break constructor initializers before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   Constructor()
+   : initializer1()
+   , initializer2()
 
   * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
 Break constructor initializers after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   Constructor() :
+   initializer1(),
+   initializer2()
 
 
 
@@ -1054,29 +1054,31 @@
 
 .. code-block:: c++
 
-class Foo
-: Base1,
-  Base2
-{};
+   class Foo
+   : Base1,
+ Base2
+   {};
 
   * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break inheritance list before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   class Foo
+   : Base1
+   , Base2
+   {};
 
   * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
 Break inheritance list after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   class Foo :
+   Base1,
+   Base2
+   {};
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46651: [OpenCL] Support new/delete in Sema

2018-06-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D46651



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


[PATCH] D47957: [clangd] Prototype of overload folding

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 151315.
sammccall added a comment.

Turn prototype into something we could ship:

- move bundling behind an option (off by default)
- don't fold together items if they may insert different headers
- clean up code and add tests


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47957

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -32,6 +32,7 @@
 using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::HasSubstr;
 using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
@@ -1065,6 +1066,57 @@
   }
 }
 
+TEST(CompletionTest, OverloadBundling) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  std::string Context = R"cpp(
+struct X {
+  // Overload with int
+  int a(int);
+  // Overload with bool
+  int a(bool);
+  int b(float);
+};
+int GFuncC(int);
+int GFuncD(int);
+  )cpp";
+
+  // Member completions are bundled.
+  EXPECT_THAT(completions(Context + "int y = X().^", {}, Opts).items,
+  UnorderedElementsAre(Labeled("a(...)"), Labeled("b(float)")));
+
+  // Non-member completions are bundled, including index+sema.
+  Symbol NoArgsGFunc = func("GFuncC");
+  EXPECT_THAT(
+  completions(Context + "int y = GFunc^", {NoArgsGFunc}, Opts).items,
+  UnorderedElementsAre(Labeled("GFuncC(...)"), Labeled("GFuncD(int)")));
+
+  // Differences in header-to-insert suppress bundling.
+  Symbol::Details Detail;
+  std::string DeclFile = URI::createFile(testPath("foo")).toString();
+  NoArgsGFunc.CanonicalDeclaration.FileURI = DeclFile;
+  Detail.IncludeHeader = "";
+  NoArgsGFunc.Detail = &Detail;
+  EXPECT_THAT(
+  completions(Context + "int y = GFunc^", {NoArgsGFunc}, Opts).items,
+  UnorderedElementsAre(AllOf(Named("GFuncC"), InsertInclude("")),
+   Labeled("GFuncC(int)"), Labeled("GFuncD(int)")));
+
+  // Examine a bundled completion in detail.
+  auto A = completions(Context + "int y = X().a^", {}, Opts).items.front();
+  EXPECT_EQ(A.label, "a(...)");
+  EXPECT_EQ(A.detail, "[2 overloads]");
+  EXPECT_EQ(A.insertText, "a");
+  EXPECT_EQ(A.kind, CompletionItemKind::Method);
+  // For now we just return one of the doc strings arbitrarily.
+  EXPECT_THAT(A.documentation, AnyOf(HasSubstr("Overload with int"),
+ HasSubstr("Overload with bool")));
+  Opts.EnableSnippets = true;
+  A = completions(Context + "int y = X().a^", {}, Opts).items.front();
+  EXPECT_EQ(A.insertText, "a(${0})");
+}
+
 TEST(CompletionTest, DocumentationFromChangedFileCrash) {
   MockFSProvider FS;
   auto FooH = testPath("foo.h");
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -59,6 +59,23 @@
llvm::cl::desc("Number of async workers used by clangd"),
llvm::cl::init(getDefaultAsyncThreadsCount()));
 
+// TODO: also support "plain" style where signatures are always omitted.
+enum CompletionStyleFlag {
+  Detailed,
+  Bundled,
+};
+static llvm::cl::opt CompletionStyle(
+"completion-style",
+llvm::cl::desc("Granularity of code completion suggestions"),
+llvm::cl::values(
+clEnumValN(Detailed, "detailed",
+   "One completion item for each semantically distinct "
+   "completion, with full type information."),
+clEnumValN(Bundled, "bundled",
+   "Similar completion items (e.g. function overloads) are "
+   "combined. Type information shown where possible.")),
+llvm::cl::init(Detailed));
+
 // FIXME: Flags are the wrong mechanism for user preferences.
 // We should probably read a dotfile or similar.
 static llvm::cl::opt IncludeIneligibleResults(
@@ -233,6 +250,7 @@
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
   CCOpts.Limit = LimitResults;
+  CCOpts.BundleOverloads = CompletionStyle != Detailed;
 
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, Opts);
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -53,6 +53,9 @@
   /// For example, private members are usually inaccessible.
   bool IncludeIneligibleResults = false;
 
+  /// Combine overloads into a single completion item where possible.
+  bool BundleOverloads = false;
+
   /// Limit the number of results returned (0 means no limit).
   /// If more results are available, we set Co

[PATCH] D47957: [clangd] Add option to fold overloads into a single completion item.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 151316.
sammccall added a comment.

Give ScoredBundleGreater a better name/location.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47957

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -32,6 +32,7 @@
 using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::HasSubstr;
 using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
@@ -1065,6 +1066,57 @@
   }
 }
 
+TEST(CompletionTest, OverloadBundling) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  std::string Context = R"cpp(
+struct X {
+  // Overload with int
+  int a(int);
+  // Overload with bool
+  int a(bool);
+  int b(float);
+};
+int GFuncC(int);
+int GFuncD(int);
+  )cpp";
+
+  // Member completions are bundled.
+  EXPECT_THAT(completions(Context + "int y = X().^", {}, Opts).items,
+  UnorderedElementsAre(Labeled("a(...)"), Labeled("b(float)")));
+
+  // Non-member completions are bundled, including index+sema.
+  Symbol NoArgsGFunc = func("GFuncC");
+  EXPECT_THAT(
+  completions(Context + "int y = GFunc^", {NoArgsGFunc}, Opts).items,
+  UnorderedElementsAre(Labeled("GFuncC(...)"), Labeled("GFuncD(int)")));
+
+  // Differences in header-to-insert suppress bundling.
+  Symbol::Details Detail;
+  std::string DeclFile = URI::createFile(testPath("foo")).toString();
+  NoArgsGFunc.CanonicalDeclaration.FileURI = DeclFile;
+  Detail.IncludeHeader = "";
+  NoArgsGFunc.Detail = &Detail;
+  EXPECT_THAT(
+  completions(Context + "int y = GFunc^", {NoArgsGFunc}, Opts).items,
+  UnorderedElementsAre(AllOf(Named("GFuncC"), InsertInclude("")),
+   Labeled("GFuncC(int)"), Labeled("GFuncD(int)")));
+
+  // Examine a bundled completion in detail.
+  auto A = completions(Context + "int y = X().a^", {}, Opts).items.front();
+  EXPECT_EQ(A.label, "a(...)");
+  EXPECT_EQ(A.detail, "[2 overloads]");
+  EXPECT_EQ(A.insertText, "a");
+  EXPECT_EQ(A.kind, CompletionItemKind::Method);
+  // For now we just return one of the doc strings arbitrarily.
+  EXPECT_THAT(A.documentation, AnyOf(HasSubstr("Overload with int"),
+ HasSubstr("Overload with bool")));
+  Opts.EnableSnippets = true;
+  A = completions(Context + "int y = X().a^", {}, Opts).items.front();
+  EXPECT_EQ(A.insertText, "a(${0})");
+}
+
 TEST(CompletionTest, DocumentationFromChangedFileCrash) {
   MockFSProvider FS;
   auto FooH = testPath("foo.h");
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -59,6 +59,23 @@
llvm::cl::desc("Number of async workers used by clangd"),
llvm::cl::init(getDefaultAsyncThreadsCount()));
 
+// TODO: also support "plain" style where signatures are always omitted.
+enum CompletionStyleFlag {
+  Detailed,
+  Bundled,
+};
+static llvm::cl::opt CompletionStyle(
+"completion-style",
+llvm::cl::desc("Granularity of code completion suggestions"),
+llvm::cl::values(
+clEnumValN(Detailed, "detailed",
+   "One completion item for each semantically distinct "
+   "completion, with full type information."),
+clEnumValN(Bundled, "bundled",
+   "Similar completion items (e.g. function overloads) are "
+   "combined. Type information shown where possible.")),
+llvm::cl::init(Detailed));
+
 // FIXME: Flags are the wrong mechanism for user preferences.
 // We should probably read a dotfile or similar.
 static llvm::cl::opt IncludeIneligibleResults(
@@ -233,6 +250,7 @@
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
   CCOpts.Limit = LimitResults;
+  CCOpts.BundleOverloads = CompletionStyle != Detailed;
 
   // Initialize and run ClangdLSPServer.
   ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, Opts);
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -53,6 +53,9 @@
   /// For example, private members are usually inaccessible.
   bool IncludeIneligibleResults = false;
 
+  /// Combine overloads into a single completion item where possible.
+  bool BundleOverloads = false;
+
   /// Limit the number of results returned (0 means no limit).
   /// If more results are available, we set CompletionList.isIncomplete.
   size_t Limit = 0;
Index: clangd/CodeComplete.cpp
===

[PATCH] D47957: [clangd] Add option to fold overloads into a single completion item.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Plan regarding hiding signatures, and configuration:

- internally, keep these options independent (programmatic users know what 
they're doing)
- as a CLI flag, make it a tristate (detailed/bundled/simple), because !Bundle 
&& !Signatures doesn't make sense.

Not 100% sure on this (particularly flag naming), WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47957



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


r334700 - [OpenCL] Support new/delete in Sema

2018-06-14 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Thu Jun 14 02:51:54 2018
New Revision: 334700

URL: http://llvm.org/viewvc/llvm-project?rev=334700&view=rev
Log:
[OpenCL] Support new/delete in Sema

Reject uses of the default new/delete operators with a diagnostic
instead of a crash in OpenCL C++ mode and accept user-defined forms.

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

Added:
cfe/trunk/test/SemaOpenCLCXX/newdelete.cl
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=334700&r1=334699&r2=334700&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jun 14 02:51:54 2018
@@ -13007,6 +13007,13 @@ CheckOperatorNewDeleteDeclarationScope(S
   return false;
 }
 
+static QualType
+RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
+  QualType QTy = PtrTy->getPointeeType();
+  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
+  return SemaRef.Context.getPointerType(QTy);
+}
+
 static inline bool
 CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
 CanQualType ExpectedResultType,
@@ -13022,6 +13029,13 @@ CheckOperatorNewDeleteTypes(Sema &SemaRe
 diag::err_operator_new_delete_dependent_result_type)
 << FnDecl->getDeclName() << ExpectedResultType;
 
+  // OpenCL C++: the operator is valid on any address space.
+  if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
+if (auto *PtrTy = ResultType->getAs()) {
+  ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+}
+  }
+
   // Check that the result type is what we expect.
   if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType)
 return SemaRef.Diag(FnDecl->getLocation(),
@@ -13047,6 +13061,13 @@ CheckOperatorNewDeleteTypes(Sema &SemaRe
   << FnDecl->getDeclName() << ExpectedFirstParamType;
 
   // Check that the first parameter type is what we expect.
+  if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
+// OpenCL C++: the operator is valid on any address space.
+if (auto *PtrTy =
+FnDecl->getParamDecl(0)->getType()->getAs()) {
+  FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+}
+  }
   if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() !=
   ExpectedFirstParamType)
 return SemaRef.Diag(FnDecl->getLocation(), InvalidParamTypeDiag)

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=334700&r1=334699&r2=334700&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jun 14 02:51:54 2018
@@ -2146,7 +2146,8 @@ bool Sema::CheckAllocatedType(QualType A
   else if (AllocType->isVariablyModifiedType())
 return Diag(Loc, diag::err_variably_modified_new_type)
  << AllocType;
-  else if (AllocType.getAddressSpace() != LangAS::Default)
+  else if (AllocType.getAddressSpace() != LangAS::Default &&
+   !getLangOpts().OpenCLCPlusPlus)
 return Diag(Loc, diag::err_address_space_qualified_new)
   << AllocType.getUnqualifiedType()
   << AllocType.getQualifiers().getAddressSpaceAttributePrintValue();
@@ -2362,6 +2363,11 @@ bool Sema::FindAllocationFunctions(Sourc
   LookupQualifiedName(R, Context.getTranslationUnitDecl());
 }
 
+if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
+  Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  return true;
+}
+
 assert(!R.empty() && "implicitly declared allocation functions not found");
 assert(!R.isAmbiguous() && "global allocation functions are ambiguous");
 
@@ -2597,6 +2603,11 @@ void Sema::DeclareGlobalNewDelete() {
   if (GlobalNewDeleteDeclared)
 return;
 
+  // OpenCL C++ 1.0 s2.9: the implicitly declared new and delete operators
+  // are not supported.
+  if (getLangOpts().OpenCLCPlusPlus)
+return;
+
   // C++ [basic.std.dynamic]p2:
   //   [...] The following allocation and deallocation functions (18.4) are
   //   implicitly declared in global scope in each translation unit of a
@@ -3230,7 +3241,8 @@ Sema::ActOnCXXDelete(SourceLocation Star
 QualType Pointee = Type->getAs()->getPointeeType();
 QualType PointeeElem = Context.getBaseElementType(Pointee);
 
-if (Pointee.getAddressSpace() != LangAS::Default)
+if (Pointee.getAddressSpace() != LangAS::Default &&
+!getLangOpts().OpenCLCPlusPlus)
   return Diag(Ex.get()->getLocStart(),
   diag::err_address_space_qualified_delete)
<< Pointee.getUnqualifiedType()
@@ -3305,6 +3317,11 @@ Sema::ActOnCXXDelete(SourceLocation Star
 }
 
 

[PATCH] D46651: [OpenCL] Support new/delete in Sema

2018-06-14 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334700: [OpenCL] Support new/delete in Sema (authored by 
svenvh, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46651

Files:
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCLCXX/newdelete.cl

Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -2146,7 +2146,8 @@
   else if (AllocType->isVariablyModifiedType())
 return Diag(Loc, diag::err_variably_modified_new_type)
  << AllocType;
-  else if (AllocType.getAddressSpace() != LangAS::Default)
+  else if (AllocType.getAddressSpace() != LangAS::Default &&
+   !getLangOpts().OpenCLCPlusPlus)
 return Diag(Loc, diag::err_address_space_qualified_new)
   << AllocType.getUnqualifiedType()
   << AllocType.getQualifiers().getAddressSpaceAttributePrintValue();
@@ -2362,6 +2363,11 @@
   LookupQualifiedName(R, Context.getTranslationUnitDecl());
 }
 
+if (getLangOpts().OpenCLCPlusPlus && R.empty()) {
+  Diag(StartLoc, diag::err_openclcxx_not_supported) << "default new";
+  return true;
+}
+
 assert(!R.empty() && "implicitly declared allocation functions not found");
 assert(!R.isAmbiguous() && "global allocation functions are ambiguous");
 
@@ -2597,6 +2603,11 @@
   if (GlobalNewDeleteDeclared)
 return;
 
+  // OpenCL C++ 1.0 s2.9: the implicitly declared new and delete operators
+  // are not supported.
+  if (getLangOpts().OpenCLCPlusPlus)
+return;
+
   // C++ [basic.std.dynamic]p2:
   //   [...] The following allocation and deallocation functions (18.4) are
   //   implicitly declared in global scope in each translation unit of a
@@ -3230,7 +3241,8 @@
 QualType Pointee = Type->getAs()->getPointeeType();
 QualType PointeeElem = Context.getBaseElementType(Pointee);
 
-if (Pointee.getAddressSpace() != LangAS::Default)
+if (Pointee.getAddressSpace() != LangAS::Default &&
+!getLangOpts().OpenCLCPlusPlus)
   return Diag(Ex.get()->getLocStart(),
   diag::err_address_space_qualified_delete)
<< Pointee.getUnqualifiedType()
@@ -3305,6 +3317,11 @@
 }
 
 if (!OperatorDelete) {
+  if (getLangOpts().OpenCLCPlusPlus) {
+Diag(StartLoc, diag::err_openclcxx_not_supported) << "default delete";
+return ExprError();
+  }
+
   bool IsComplete = isCompleteType(StartLoc, Pointee);
   bool CanProvideSize =
   IsComplete && (!ArrayForm || UsualArrayDeleteWantsSize ||
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13007,6 +13007,13 @@
   return false;
 }
 
+static QualType
+RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
+  QualType QTy = PtrTy->getPointeeType();
+  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
+  return SemaRef.Context.getPointerType(QTy);
+}
+
 static inline bool
 CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
 CanQualType ExpectedResultType,
@@ -13022,6 +13029,13 @@
 diag::err_operator_new_delete_dependent_result_type)
 << FnDecl->getDeclName() << ExpectedResultType;
 
+  // OpenCL C++: the operator is valid on any address space.
+  if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
+if (auto *PtrTy = ResultType->getAs()) {
+  ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+}
+  }
+
   // Check that the result type is what we expect.
   if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType)
 return SemaRef.Diag(FnDecl->getLocation(),
@@ -13047,6 +13061,13 @@
   << FnDecl->getDeclName() << ExpectedFirstParamType;
 
   // Check that the first parameter type is what we expect.
+  if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
+// OpenCL C++: the operator is valid on any address space.
+if (auto *PtrTy =
+FnDecl->getParamDecl(0)->getType()->getAs()) {
+  FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
+}
+  }
   if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() !=
   ExpectedFirstParamType)
 return SemaRef.Diag(FnDecl->getLocation(), InvalidParamTypeDiag)
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7173,8 +7173,9 @@
   // The default address space name for arguments to a function in a
   // program, or local variables of a function is __private. All function
   // arguments shall be in the __private address space.
-  if (State.getSema().getLangOpts().OpenCLVersion <= 120) {
-  ImpAddr = LangAS::opencl_private;
+  if (State.getSema().getLangOpts().OpenCLVersion <= 120 &&
+  !State.getSema().getLa

[PATCH] D48163: [clangd] UI for completion items that would trigger include insertion.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: sammccall, ilya-biryukov, hokein.
Herald added subscribers: cfe-commits, jkorous, MaskRay.

For completion items that would trigger include insertions (i.e. index symbols
that are not #included yet), add a visual indicator "+" before the completion
label. The inserted headers will appear in the completion detail.

Open to suggestions for better visual indicators; "+" was picked because it
seems cleaner than a few other candidates I've tried (*, #, @ ...).

The displayed header would be like a/b/c.h (without quote) or  for 
system
headers. I didn't add quotation or "#include" because they can take up limited
space and do not provide additional information after users know what the
headers are. I think a header alone should be obvious for users to infer that
this is an include header..

To align indentation, also prepend ' ' to labels of candidates that would not
trigger include insertions (only for completions where index results are
possible).

(Placeholder: add screenshots)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48163

Files:
  clangd/CodeComplete.cpp
  clangd/Headers.cpp
  clangd/Headers.h
  test/clangd/completion-snippets.test
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -106,7 +106,7 @@
 } else {
   EXPECT_FALSE(ExpectError);
 }
-return std::move(*Path);
+return Path->second ? std::move(Path->first) : "";
   }
 
   Expected>
@@ -123,9 +123,13 @@
 for (const auto &Inc : ExistingInclusions)
   Inserter.addExisting(Inc);
 
-auto Edit = Inserter.insert(DeclaringHeader, InsertedHeader);
+auto HeaderAndEdit = Inserter.insert(DeclaringHeader, InsertedHeader);
 Action.EndSourceFile();
-return Edit;
+if (!HeaderAndEdit)
+  return HeaderAndEdit.takeError();
+if (!HeaderAndEdit->second)
+  return llvm::None;
+return *(HeaderAndEdit->second);
   }
 
   MockFSProvider FS;
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -566,17 +566,17 @@
   int main() { ns::^ }
   )cpp",
  {Sym});
-  EXPECT_THAT(Results.items,
-  ElementsAre(AllOf(Named("X"), InsertInclude("\"bar.h\"";
+  EXPECT_THAT(Results.items, ElementsAre(AllOf(Named("X"), Labeled("+X"),
+   InsertInclude("\"bar.h\"";
   // Duplicate based on inclusions in preamble.
   Results = completions(Server,
 R"cpp(
   #include "sub/bar.h"  // not shortest, so should only match resolved.
   int main() { ns::^ }
   )cpp",
 {Sym});
-  EXPECT_THAT(Results.items,
-  ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits();
+  EXPECT_THAT(Results.items, ElementsAre(AllOf(Named("X"), Labeled(" X"),
+   Not(HasAdditionalEdits();
 }
 
 TEST(CompletionTest, NoIncludeInsertionWhenDeclFoundInFile) {
Index: test/clangd/completion-snippets.test
===
--- test/clangd/completion-snippets.test
+++ test/clangd/completion-snippets.test
@@ -32,7 +32,7 @@
 # CHECK-NEXT:  "insertText": "func_with_args(${1:int a}, ${2:int b})",
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
-# CHECK-NEXT:  "label": "func_with_args(int a, int b)",
+# CHECK-NEXT:  "label": " func_with_args(int a, int b)",
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:}
 # CHECK-NEXT:]
Index: clangd/Headers.h
===
--- clangd/Headers.h
+++ clangd/Headers.h
@@ -60,11 +60,12 @@
 /// InsertedHeader e.g. the header that declares a symbol.
 /// \param InsertedHeader The preferred header to be inserted. This could be the
 /// same as DeclaringHeader but must be provided.
-//  \return A quoted "path" or . This returns an empty string if:
+/// \return A quoted "path" or  to be included and a boolean that is true
+/// if the include can be added, and false if:
 ///   - Either \p DeclaringHeader or \p InsertedHeader is already (directly)
 ///   in \p Inclusions (including those included via different paths).
 ///   - \p DeclaringHeader or \p InsertedHeader is the same as \p File.
-llvm::Expected calculateIncludePath(
+llvm::Expected> calculateIncludePath(
 PathRef File, StringRef BuildDir, HeaderSearch &HeaderSearchInfo,
 const std::vector &Inclusions, const HeaderFile &DeclaringHeader,
 const HeaderFile &InsertedHeader);
@@ -81,16 +82,18 @@
 
   void addExisting(Inclusion Inc) { Inclusions.push

[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this looks much clearer/more modular/more extensible to me!
A couple of notes on the abstractions before digging into details again.




Comment at: clangd/Quality.h:71
 
+class SymbolRelevanceContext {
+  public:

This is ambiguously a couple of different (and good!) things:
 - an encapsulation of the proximitypaths state and logic
 - a grouping together of the "query-dependent, symbol-invariant" inputs to the 
relevance calculation.

There's a place for both of these, but I'd argue for separating them (and only 
doing the second in this patch). Reasons:
 - the former doesn't need to be in this file if it gets complex (FuzzyMatch.h 
is a similar case), while the latter does
 - easier to understand/name if this hierarchy is expressed explicitly
 - I suspect we may want the context to be a separate struct, passed to 
SymbolRelevanceSignals::evaluate(), rather than a member of 
SymbolRelevanceSignals. That would add more churn than needs to be in this 
patch though.

If this makes sense to you then I think this class looks great but should be 
called something specific like `FileProximityMatcher`.



Comment at: clangd/Quality.h:91
 struct SymbolRelevanceSignals {
+  explicit SymbolRelevanceSignals(const SymbolRelevanceContext &Context)
+  : Context(Context) {}

One of the simplifying assumptions in the model is that all signals are 
optional - can we make Context a pointer `= nullptr` and drop the constructor?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935



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


[PATCH] D46190: For a referenced declaration, mark any associated usings as referenced.

2018-06-14 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

Ping.

The review

https://reviews.llvm.org/D44826

is already approved and it is dependent on this patch being reviewed.

@rsmith Is there anything I can add to this patch?

Thanks


https://reviews.llvm.org/D46190



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


[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 151321.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- addressed review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/URITests.cpp

Index: unittests/clangd/URITests.cpp
===
--- unittests/clangd/URITests.cpp
+++ unittests/clangd/URITests.cpp
@@ -14,46 +14,20 @@
 
 namespace clang {
 namespace clangd {
+
+// Force the unittest URI scheme to be linked,
+extern volatile int UnittestSchemeAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED UnittestSchemeAnchorDest =
+UnittestSchemeAnchorSource;
+
 namespace {
 
 using ::testing::AllOf;
 
 MATCHER_P(Scheme, S, "") { return arg.scheme() == S; }
 MATCHER_P(Authority, A, "") { return arg.authority() == A; }
 MATCHER_P(Body, B, "") { return arg.body() == B; }
 
-// Assume all files in the schema have a "test-root/" root directory, and the
-// schema path is the relative path to the root directory.
-// So the schema of "/some-dir/test-root/x/y/z" is "test:x/y/z".
-class TestScheme : public URIScheme {
-public:
-  static const char *Scheme;
-
-  static const char *TestRoot;
-
-  llvm::Expected
-  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
-  llvm::StringRef HintPath) const override {
-auto Pos = HintPath.find(TestRoot);
-assert(Pos != llvm::StringRef::npos);
-return (HintPath.substr(0, Pos + llvm::StringRef(TestRoot).size()) + Body)
-.str();
-  }
-
-  llvm::Expected
-  uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
-auto Pos = AbsolutePath.find(TestRoot);
-assert(Pos != llvm::StringRef::npos);
-return URI(Scheme, /*Authority=*/"",
-   AbsolutePath.substr(Pos + llvm::StringRef(TestRoot).size()));
-  }
-};
-
-const char *TestScheme::Scheme = "unittest";
-const char *TestScheme::TestRoot = "/test-root/";
-
-static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schema");
-
 std::string createOrDie(llvm::StringRef AbsolutePath,
 llvm::StringRef Scheme = "file") {
   auto Uri = URI::create(AbsolutePath, Scheme);
Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "URI.h"
 #include "llvm/Support/Errc.h"
 #include "gtest/gtest.h"
 
@@ -62,5 +63,50 @@
   return Path.str();
 }
 
+// Assume all files in the schema have a "test-root/" root directory, and the
+// schema path is the relative path to the root directory.
+// So the schema of "/some-dir/test-root/x/y/z" is "test:x/y/z".
+class TestScheme : public URIScheme {
+public:
+  static const char *Scheme;
+
+  static const char *TestRoot;
+
+  llvm::Expected
+  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
+  llvm::StringRef HintPath) const override {
+auto Pos = HintPath.find(TestRoot);
+assert(Pos != llvm::StringRef::npos);
+return (HintPath.substr(0, Pos + llvm::StringRef(TestRoot).size()) + Body)
+.str();
+  }
+
+  llvm::Expected
+  uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
+auto Pos = AbsolutePath.find(TestRoot);
+if (Pos == llvm::StringRef::npos)
+  return llvm::make_error(
+  llvm::Twine("Directory ") + TestRoot + " not found in path " +
+  AbsolutePath,
+  llvm::inconvertibleErrorCode());
+
+return URI(Scheme, /*Authority=*/"",
+   AbsolutePath.substr(Pos + llvm::StringRef(TestRoot).size()));
+  }
+};
+
+const char *TestScheme::Scheme = "unittest";
+#ifdef _WIN32
+const char *TestScheme::TestRoot = "\\test-root\\";
+#else
+const char *TestScheme::TestRoot = "/test-root/";
+#endif
+
+static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schema");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the plugin.
+volatile int UnittestSchemeAnchorSource = 0;
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -18,12 +18,19 @@
 //===--===//
 
 #include "Quality.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
+
+// Force the unittest URI

[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 151322.
ioeric added a comment.

- Rebase...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935

Files:
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/QualityTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/URITests.cpp

Index: unittests/clangd/URITests.cpp
===
--- unittests/clangd/URITests.cpp
+++ unittests/clangd/URITests.cpp
@@ -14,46 +14,20 @@
 
 namespace clang {
 namespace clangd {
+
+// Force the unittest URI scheme to be linked,
+extern volatile int UnittestSchemeAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED UnittestSchemeAnchorDest =
+UnittestSchemeAnchorSource;
+
 namespace {
 
 using ::testing::AllOf;
 
 MATCHER_P(Scheme, S, "") { return arg.scheme() == S; }
 MATCHER_P(Authority, A, "") { return arg.authority() == A; }
 MATCHER_P(Body, B, "") { return arg.body() == B; }
 
-// Assume all files in the schema have a "test-root/" root directory, and the
-// schema path is the relative path to the root directory.
-// So the schema of "/some-dir/test-root/x/y/z" is "test:x/y/z".
-class TestScheme : public URIScheme {
-public:
-  static const char *Scheme;
-
-  static const char *TestRoot;
-
-  llvm::Expected
-  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
-  llvm::StringRef HintPath) const override {
-auto Pos = HintPath.find(TestRoot);
-assert(Pos != llvm::StringRef::npos);
-return (HintPath.substr(0, Pos + llvm::StringRef(TestRoot).size()) + Body)
-.str();
-  }
-
-  llvm::Expected
-  uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
-auto Pos = AbsolutePath.find(TestRoot);
-assert(Pos != llvm::StringRef::npos);
-return URI(Scheme, /*Authority=*/"",
-   AbsolutePath.substr(Pos + llvm::StringRef(TestRoot).size()));
-  }
-};
-
-const char *TestScheme::Scheme = "unittest";
-const char *TestScheme::TestRoot = "/test-root/";
-
-static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schema");
-
 std::string createOrDie(llvm::StringRef AbsolutePath,
 llvm::StringRef Scheme = "file") {
   auto Uri = URI::create(AbsolutePath, Scheme);
Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "URI.h"
 #include "llvm/Support/Errc.h"
 #include "gtest/gtest.h"
 
@@ -62,5 +63,50 @@
   return Path.str();
 }
 
+// Assume all files in the schema have a "test-root/" root directory, and the
+// schema path is the relative path to the root directory.
+// So the schema of "/some-dir/test-root/x/y/z" is "test:x/y/z".
+class TestScheme : public URIScheme {
+public:
+  static const char *Scheme;
+
+  static const char *TestRoot;
+
+  llvm::Expected
+  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
+  llvm::StringRef HintPath) const override {
+auto Pos = HintPath.find(TestRoot);
+assert(Pos != llvm::StringRef::npos);
+return (HintPath.substr(0, Pos + llvm::StringRef(TestRoot).size()) + Body)
+.str();
+  }
+
+  llvm::Expected
+  uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
+auto Pos = AbsolutePath.find(TestRoot);
+if (Pos == llvm::StringRef::npos)
+  return llvm::make_error(
+  llvm::Twine("Directory ") + TestRoot + " not found in path " +
+  AbsolutePath,
+  llvm::inconvertibleErrorCode());
+
+return URI(Scheme, /*Authority=*/"",
+   AbsolutePath.substr(Pos + llvm::StringRef(TestRoot).size()));
+  }
+};
+
+const char *TestScheme::Scheme = "unittest";
+#ifdef _WIN32
+const char *TestScheme::TestRoot = "\\test-root\\";
+#else
+const char *TestScheme::TestRoot = "/test-root/";
+#endif
+
+static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schema");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the plugin.
+volatile int UnittestSchemeAnchorSource = 0;
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -18,12 +18,19 @@
 //===--===//
 
 #include "Quality.h"
+#include "TestFS.h"
 #include "TestTU.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
+
+// Force the unittest URI scheme to be linked,
+extern volatile int UnittestSchemeAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED UnittestSchemeAnchorDest =
+UnittestSchemeAnchorSource;
+
 namespace {
 
 TEST(QualityTests, SymbolQualitySignalExtraction) {
@@

[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Quality.h:71
 
+class SymbolRelevanceContext {
+  public:

sammccall wrote:
> This is ambiguously a couple of different (and good!) things:
>  - an encapsulation of the proximitypaths state and logic
>  - a grouping together of the "query-dependent, symbol-invariant" inputs to 
> the relevance calculation.
> 
> There's a place for both of these, but I'd argue for separating them (and 
> only doing the second in this patch). Reasons:
>  - the former doesn't need to be in this file if it gets complex 
> (FuzzyMatch.h is a similar case), while the latter does
>  - easier to understand/name if this hierarchy is expressed explicitly
>  - I suspect we may want the context to be a separate struct, passed to 
> SymbolRelevanceSignals::evaluate(), rather than a member of 
> SymbolRelevanceSignals. That would add more churn than needs to be in this 
> patch though.
> 
> If this makes sense to you then I think this class looks great but should be 
> called something specific like `FileProximityMatcher`.
Sounds good. Thanks for the explanation!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935



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


[PATCH] D48100: Append new attributes to the end of an AttributeList.

2018-06-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

Thank you for working on this odd detail of attributes!

Can you also simplify `hasSameOverloadableAttrs()` in ASTReaderDecl.cpp similar 
to what you did in SemaOverload.cpp (the copy seems spurious)?




Comment at: include/clang/Sema/AttributeList.h:767
 assert(newAttr->getNext() == nullptr);
-newAttr->setNext(list);
-list = newAttr;
+addAllAtEnd(newAttr);
   }

This now means adding an attribute requires walking the entire attribute list 
to get to the end of it. I don't think this is a huge issue (attribute lists 
tend to be short), but it might be good to leave a comment explaining the issue 
and why it's acceptable for now.


Repository:
  rC Clang

https://reviews.llvm.org/D48100



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


[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, just details now!




Comment at: clangd/Quality.cpp:185
+  }
+  if (F == Fs.begin() && T == Ts.begin()) // No common directory.
+return 0;

why is this a special case?
 - /x/a/b vs /x/a/c is 1 up + 1 down --> 0.59
 - /a/b vs /a/c is 1 up + 1 down --> 0.59
 - /b vs /c is unrelated --> 0

I don't doubt the assertion that these are unrelated paths, but I'm not sure 
fixing just this case is an improvement overall. (In a perfect world, we'd 
define the algorithm so that this case yields 0 without a discontinuity)



Comment at: clangd/Quality.cpp:216
+  const FileProximityMatcher &M) {
+  OS << formatv("=== File proximity matcher ===\n");
+  OS << formatv(

For composability, you could consider styling more tersely e.g. as 
ProximityPaths{/path/to/file}, and in the RelevanceSignals operator<< including 
it like other fields, yielding:
```
== Symbol relevance: 0.8 ==
 Name match: 0.7
 File proximity matcher: ProximityPaths{/path/to/file}
 ...
```



Comment at: clangd/Quality.h:78
+
+/// Calculates the best proximity score from proximity paths to the 
symbol's
+/// URI. When a path cannot be encoded into the same scheme as \p 
SymbolURI,

Should mention the semantics of the score, maybe via the other extreme: when 
the SymbolURI exactly matches a proximity path, score is 1.



Comment at: clangd/Quality.h:98
+  /// closest.
+  float IndexProximityScore = 0;
+  llvm::StringRef IndexSymbolURI;

This is redundant with (IndexSymbolURI, FileProximityMatch) I think, and will 
only be correctly set if FileProximityMatch is set before calling merge(Symbol).

Can we defer calculation until evaluate()?
(If you want to dump this intermediate score, you can recompute it in 
operator<<, I'm not sure it's necessary).



Comment at: unittests/clangd/TestFS.cpp:66
 
+// Assume all files in the schema have a "test-root/" root directory, and the
+// schema path is the relative path to the root directory.

These helpers would be more coherent if this used the same test root as above - 
any reason we can't do that?

Then this comment could just be "unittest: is a scheme that refers to files 
relative to testRoot()"



Comment at: unittests/clangd/TestFS.cpp:107
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the plugin.

This is really surprising to me - is this the common pattern for registries?
(i.e. we don't have something more declarative like bazel's 
`cc_library.alwayslink`)?

If so, can we move the declaration to TestFS.h and give a usage example, so the 
consuming libraries don't have to repeat the decl?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935



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


[PATCH] D46190: For a referenced declaration, mark any associated usings as referenced.

2018-06-14 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

@dblaikie is @rsmith back from the standards meeting yet? I hate to be a pest 
but this is blocking other work Carlos has in progress.


https://reviews.llvm.org/D46190



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


[PATCH] D46915: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

2018-06-14 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:89
+  // corresponding unsaturated types.
+  unsigned char ShortAccumFBits, ShortAccumIBits;
+  unsigned char AccumFBits, AccumIBits;

leonardchan wrote:
> ebevhan wrote:
> > leonardchan wrote:
> > > ebevhan wrote:
> > > > leonardchan wrote:
> > > > > ebevhan wrote:
> > > > > > I suspect it's still possible to calculate the ibits based on the 
> > > > > > fbits, even for _Accum.
> > > > > > 
> > > > > > Are the unsigned values needed? The fbits for unsigned _Fract are 
> > > > > > the same as for signed _Fract if SameFBits is set, and +1 
> > > > > > otherwise. The same should go for unsigned _Accum, but I don't 
> > > > > > think it's entirely clear how this affects the integral part.
> > > > > Similar to the previous comment, if we choose to make SameFBits 
> > > > > dependent on/controlled by the target, then I think it would be 
> > > > > better for the target to explicitly specify the integral bits since 
> > > > > there could be some cases where there may be padding (such as for 
> > > > > unsigned _Accum types if this flag is set), and in this case, I think 
> > > > > it should be explicit that the `bit_width != IBits + FBits`.
> > > > > 
> > > > > We also can't fill in that padding for the unsigned _Accum types as 
> > > > > an extra integral bit since the standard says that `"each signed 
> > > > > accum type has at least as many integral bits as its corresponding 
> > > > > unsigned accum type".`
> > > > > 
> > > > > For the unsigned _Fract values, I think we can get rid of them if we 
> > > > > choose to keep the flag instead, but it would no longer apply to 
> > > > > unsigned _Accum types since it would allow for extra padding in these 
> > > > > types and would conflict with the logic of `bit_width == IBits + 
> > > > > FBits`
> > > > > 
> > > > > For now, I actually think the simplest option is to keep these target 
> > > > > properties, but have the target override them individually, with 
> > > > > checks to make sure the values adhere to the standard.
> > > > Is it not the case that `bitwidth != IBits + FBits` for signed types 
> > > > only? Signed types require a sign bit (which is neither a fractional 
> > > > bit nor an integral bit, according to spec) but unsigned types do not, 
> > > > and if IBits and FBits for the signed and unsigned types are the same, 
> > > > the MSB is simply a padding bit, at least for _Accum (for _Fract 
> > > > everything above the fbits is padding). 
> > > > 
> > > > My reasoning for keeping the number of configurable values down was to 
> > > > limit the number of twiddly knobs to make the implementation simpler. 
> > > > Granting a lot of freedom is nice, but I suspect that it will be quite 
> > > > hard to get the implementation working properly for every valid 
> > > > configuration. I also don't really see much of a reason for `FBits != 
> > > > UFBits` in general. I know the spec gives a recommendation to implement 
> > > > it that way, but I think the benefit of normalizing the signed and 
> > > > unsigned representations outweighs the lost bit in the unsigned type.
> > > > 
> > > > It's hard to say what the differences are beyond that since I'm not 
> > > > sure how you plan on treating padding bits. In our implementation, 
> > > > padding bits (the MSB in all of the unsigned types for us) after any 
> > > > operation are zeroed.
> > > I see. The implementation would be much simpler this way. The initial 
> > > idea was to treat the padding bits as "don't care" bits where we would 
> > > mask only the data bits when doing operations like comparisons that look 
> > > at the whole integer.
> > That does work, but for binary operations it means you might need multiple 
> > maskings per operation. If you mask after every operation instead, you only 
> > need one. In our implementation, the only padding bit we have is the MSB in 
> > the unsigned types. We simply insert a 'bit clear' after every operation 
> > that produces an unsigned type (with some exceptions).
> > 
> > The E-C spec says that padding bits are 'unspecified', but 
> > implementation-wise, they have to be defined to something in order to 
> > operate on them. So long as you ensure that it is never possible to observe 
> > anything but zero in those bits from a program perspective, most operations 
> > just work. Naturally, there are ways to subvert this design. If you have a 
> > `signed _Fract *` and cast it to an `unsigned _Fract *` and the values 
> > happen to be negative, the padding bit will be set and you'll get exciting 
> > behavior.
> > 
> > Although... I just realized that the topmost half of the `_Fract`s in your 
> > configuration is all padding. That might make things a bit more complicated 
> > for things like signed types... Ideally the sign bit would be extended into 
> > the padding for those.
> Yeah, I initially had 2 general purpose ideas for handling the pad

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D45679#1132086, @JonasToth wrote:

> It might be the case, that the test is run with -no-stdinc (or similar),
>  so the standard library is not available.


Tests should be self-contained and must not depend on any system headers. 
Standard library implementations may differ, which would make tests brittle. 
Instead, tests should mock implementations of the APIs they work with (if 
necessary, multiple times - once for every distinct standard library version 
the check supports).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45679



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


[PATCH] D48169: [mips] Add '-mcrc', '-mno-crc' options to enable/disable CRC ASE

2018-06-14 Thread Vladimir Stefanovic via Phabricator via cfe-commits
vstefanovic created this revision.
vstefanovic added reviewers: sdardis, bogden.
Herald added a reviewer: javed.absar.
Herald added subscribers: cfe-commits, atanasyan, kristof.beyls, arichardson.

'-mcrc' is shared with ARM.
'-mno-crc' is Mips-only (ARM uses '-mnocrc').


Repository:
  rC Clang

https://reviews.llvm.org/D48169

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/mips-features.c


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -408,3 +408,15 @@
 // RUN:-mindirect-jump=hazard 2>&1 \
 // RUN:   | FileCheck --check-prefix=INDIRECT-BH %s
 // INDIRECT-BH: "-target-feature" "+use-indirect-jump-hazard"
+//
+// -mcrc
+// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
+// RUN: -mno-crc -mcrc 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRC %s
+// CHECK-CRC: "-target-feature" "+crc"
+//
+// -mno-crc
+// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
+// RUN: -mcrc -mno-crc 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-CRC %s
+// CHECK-NO-CRC: "-target-feature" "-crc"
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -352,6 +352,8 @@
   AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4,
"nomadd4");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, 
"mt");
+  AddTargetFeature(Args, Features, options::OPT_mcrc, options::OPT_mno_crc,
+   "crc");
 
   if (Arg *A = Args.getLastArg(options::OPT_mindirect_jump_EQ)) {
 StringRef Val = StringRef(A->getValue());
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1992,8 +1992,8 @@
   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 mcrc : Flag<["-"], "mcrc">, Group,
+  HelpText<"Allow use of CRC instructions (ARM/Mips only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,
   HelpText<"Disallow use of CRC instructions (ARM only)">;
 def mno_neg_immediates: Flag<["-"], "mno-neg-immediates">, 
Group,
@@ -2211,6 +2211,8 @@
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;
 def mno_abicalls : Flag<["-"], "mno-abicalls">, Group,
   HelpText<"Disable SVR4-style position-independent code (Mips only)">;
+def mno_crc : Flag<["-"], "mno-crc">, Group,
+  HelpText<"Disallow use of CRC instructions (Mips only)">;
 def mips1 : Flag<["-"], "mips1">,
   Alias, AliasArgs<["mips1"]>, Group,
   HelpText<"Equivalent to -march=mips1">, Flags<[HelpHidden]>;


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -408,3 +408,15 @@
 // RUN:-mindirect-jump=hazard 2>&1 \
 // RUN:   | FileCheck --check-prefix=INDIRECT-BH %s
 // INDIRECT-BH: "-target-feature" "+use-indirect-jump-hazard"
+//
+// -mcrc
+// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
+// RUN: -mno-crc -mcrc 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRC %s
+// CHECK-CRC: "-target-feature" "+crc"
+//
+// -mno-crc
+// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
+// RUN: -mcrc -mno-crc 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-CRC %s
+// CHECK-NO-CRC: "-target-feature" "-crc"
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -352,6 +352,8 @@
   AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4,
"nomadd4");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, "mt");
+  AddTargetFeature(Args, Features, options::OPT_mcrc, options::OPT_mno_crc,
+   "crc");
 
   if (Arg *A = Args.getLastArg(options::OPT_mindirect_jump_EQ)) {
 StringRef Val = StringRef(A->getValue());
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1992,8 +1992,8 @@
   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 mcrc : Flag<["-"], "mcrc">, Group,
+  HelpText<"Allow use of CRC instructions (ARM/Mips only)">;
 def mnocrc : Flag<["-"], 

[PATCH] D48161: clang-format: Fix documentation generation

2018-06-14 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 151342.
Typz added a comment.

rebase


Repository:
  rC Clang

https://reviews.llvm.org/D48161

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -840,24 +840,24 @@
   enum BreakConstructorInitializersStyle {
 /// Break constructor initializers before the colon and after the commas.
 /// \code
-/// Constructor()
-/// : initializer1(),
-///   initializer2()
+///Constructor()
+///: initializer1(),
+///  initializer2()
 /// \endcode
 BCIS_BeforeColon,
 /// Break constructor initializers before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///Constructor()
+///: initializer1()
+///, initializer2()
 /// \endcode
 BCIS_BeforeComma,
 /// Break constructor initializers after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///Constructor() :
+///initializer1(),
+///initializer2()
 /// \endcode
 BCIS_AfterColon
   };
@@ -897,25 +897,27 @@
   enum BreakInheritanceListStyle {
 /// Break inheritance list before the colon and after the commas.
 /// \code
-/// class Foo
-/// : Base1,
-///   Base2
-/// {};
+///class Foo
+///: Base1,
+///  Base2
+///{};
 /// \endcode
 BILS_BeforeColon,
 /// Break inheritance list before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///class Foo
+///: Base1
+///, Base2
+///{};
 /// \endcode
 BILS_BeforeComma,
 /// Break inheritance list after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///class Foo :
+///Base1,
+///Base2
+///{};
 /// \endcode
 BILS_AfterColon
   };
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -1019,28 +1019,28 @@
 
 .. code-block:: c++
 
-Constructor()
-: initializer1(),
-  initializer2()
+   Constructor()
+   : initializer1(),
+ initializer2()
 
   * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break constructor initializers before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   Constructor()
+   : initializer1()
+   , initializer2()
 
   * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
 Break constructor initializers after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   Constructor() :
+   initializer1(),
+   initializer2()
 
 
 
@@ -1054,29 +1054,31 @@
 
 .. code-block:: c++
 
-class Foo
-: Base1,
-  Base2
-{};
+   class Foo
+   : Base1,
+ Base2
+   {};
 
   * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break inheritance list before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   class Foo
+   : Base1
+   , Base2
+   {};
 
   * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
 Break inheritance list after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   class Foo :
+   Base1,
+   Base2
+   {};
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48161: clang-format: Fix documentation generation

2018-06-14 Thread Francois Ferrand via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334709: clang-format: Fix documentation generation (authored 
by Typz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48161

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -840,24 +840,24 @@
   enum BreakConstructorInitializersStyle {
 /// Break constructor initializers before the colon and after the commas.
 /// \code
-/// Constructor()
-/// : initializer1(),
-///   initializer2()
+///Constructor()
+///: initializer1(),
+///  initializer2()
 /// \endcode
 BCIS_BeforeColon,
 /// Break constructor initializers before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///Constructor()
+///: initializer1()
+///, initializer2()
 /// \endcode
 BCIS_BeforeComma,
 /// Break constructor initializers after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///Constructor() :
+///initializer1(),
+///initializer2()
 /// \endcode
 BCIS_AfterColon
   };
@@ -897,25 +897,27 @@
   enum BreakInheritanceListStyle {
 /// Break inheritance list before the colon and after the commas.
 /// \code
-/// class Foo
-/// : Base1,
-///   Base2
-/// {};
+///class Foo
+///: Base1,
+///  Base2
+///{};
 /// \endcode
 BILS_BeforeColon,
 /// Break inheritance list before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///class Foo
+///: Base1
+///, Base2
+///{};
 /// \endcode
 BILS_BeforeComma,
 /// Break inheritance list after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///class Foo :
+///Base1,
+///Base2
+///{};
 /// \endcode
 BILS_AfterColon
   };
Index: cfe/trunk/docs/ClangFormatStyleOptions.rst
===
--- cfe/trunk/docs/ClangFormatStyleOptions.rst
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst
@@ -1019,28 +1019,28 @@
 
 .. code-block:: c++
 
-Constructor()
-: initializer1(),
-  initializer2()
+   Constructor()
+   : initializer1(),
+ initializer2()
 
   * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break constructor initializers before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   Constructor()
+   : initializer1()
+   , initializer2()
 
   * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
 Break constructor initializers after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   Constructor() :
+   initializer1(),
+   initializer2()
 
 
 
@@ -1054,29 +1054,31 @@
 
 .. code-block:: c++
 
-class Foo
-: Base1,
-  Base2
-{};
+   class Foo
+   : Base1,
+ Base2
+   {};
 
   * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break inheritance list before the colon and commas, and align
 the commas with the colon.
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   class Foo
+   : Base1
+   , Base2
+   {};
 
   * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
 Break inheritance list after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   class Foo :
+   Base1,
+   Base2
+   {};
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334709 - clang-format: Fix documentation generation

2018-06-14 Thread Francois Ferrand via cfe-commits
Author: typz
Date: Thu Jun 14 06:32:14 2018
New Revision: 334709

URL: http://llvm.org/viewvc/llvm-project?rev=334709&view=rev
Log:
clang-format: Fix documentation generation

Summary:
It seems that the changes done to `ClangFormatStyleOptions.rst` @334408 are 
causing the generation of the documentation to fail, with the following error:

  Warning, treated as error:
/llvm/tools/clang/docs/ClangFormatStyleOptions.rst:1060: WARNING: 
Definition list ends without a blank line; unexpected unindent.

This is due to missing indent in some code block, and fixed by this patch.

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=334709&r1=334708&r2=334709&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Jun 14 06:32:14 2018
@@ -1019,9 +1019,9 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-Constructor()
-: initializer1(),
-  initializer2()
+   Constructor()
+   : initializer1(),
+ initializer2()
 
   * ``BCIS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break constructor initializers before the colon and commas, and align
@@ -1029,18 +1029,18 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   Constructor()
+   : initializer1()
+   , initializer2()
 
   * ``BCIS_AfterColon`` (in configuration: ``AfterColon``)
 Break constructor initializers after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   Constructor() :
+   initializer1(),
+   initializer2()
 
 
 
@@ -1054,10 +1054,10 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-class Foo
-: Base1,
-  Base2
-{};
+   class Foo
+   : Base1,
+ Base2
+   {};
 
   * ``BILS_BeforeComma`` (in configuration: ``BeforeComma``)
 Break inheritance list before the colon and commas, and align
@@ -1065,18 +1065,20 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-Constructor()
-: initializer1()
-, initializer2()
+   class Foo
+   : Base1
+   , Base2
+   {};
 
   * ``BILS_AfterColon`` (in configuration: ``AfterColon``)
 Break inheritance list after the colon and commas.
 
 .. code-block:: c++
 
-Constructor() :
-initializer1(),
-initializer2()
+   class Foo :
+   Base1,
+   Base2
+   {};
 
 
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=334709&r1=334708&r2=334709&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Jun 14 06:32:14 2018
@@ -840,24 +840,24 @@ struct FormatStyle {
   enum BreakConstructorInitializersStyle {
 /// Break constructor initializers before the colon and after the commas.
 /// \code
-/// Constructor()
-/// : initializer1(),
-///   initializer2()
+///Constructor()
+///: initializer1(),
+///  initializer2()
 /// \endcode
 BCIS_BeforeColon,
 /// Break constructor initializers before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer1()
-/// , initializer2()
+///Constructor()
+///: initializer1()
+///, initializer2()
 /// \endcode
 BCIS_BeforeComma,
 /// Break constructor initializers after the colon and commas.
 /// \code
-/// Constructor() :
-/// initializer1(),
-/// initializer2()
+///Constructor() :
+///initializer1(),
+///initializer2()
 /// \endcode
 BCIS_AfterColon
   };
@@ -897,25 +897,27 @@ struct FormatStyle {
   enum BreakInheritanceListStyle {
 /// Break inheritance list before the colon and after the commas.
 /// \code
-/// class Foo
-/// : Base1,
-///   Base2
-/// {};
+///class Foo
+///: Base1,
+///  Base2
+///{};
 /// \endcode
 BILS_BeforeColon,
 /// Break inheritance list before the colon and commas, and align
 /// the commas with the colon.
 /// \code
-/// Constructor()
-/// : initializer

[clang-tools-extra] r334711 - [clangd] Boost keyword completions.

2018-06-14 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jun 14 06:42:21 2018
New Revision: 334711

URL: http://llvm.org/viewvc/llvm-project?rev=334711&view=rev
Log:
[clangd] Boost keyword completions.

Summary: These have few signals other than being keywords, so the boost is high.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/Quality.cpp
clang-tools-extra/trunk/clangd/Quality.h
clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=334711&r1=334710&r2=334711&view=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Thu Jun 14 06:42:21 2018
@@ -59,6 +59,29 @@ static SymbolQualitySignals::SymbolCateg
   return Switch().Visit(&ND);
 }
 
+static SymbolQualitySignals::SymbolCategory categorize(const 
CodeCompletionResult &R) {
+  if (R.Declaration)
+return categorize(*R.Declaration);
+  if (R.Kind == CodeCompletionResult::RK_Macro)
+return SymbolQualitySignals::Macro;
+  // Everything else is a keyword or a pattern. Patterns are mostly keywords
+  // too, except a few which we recognize by cursor kind.
+  switch (R.CursorKind) {
+case CXCursor_CXXMethod:
+  return SymbolQualitySignals::Function;
+case CXCursor_ModuleImportDecl:
+  return SymbolQualitySignals::Namespace;
+case CXCursor_MacroDefinition:
+  return SymbolQualitySignals::Macro;
+case CXCursor_TypeRef:
+  return SymbolQualitySignals::Type;
+case CXCursor_MemberRef:
+  return SymbolQualitySignals::Variable;
+default:
+  return SymbolQualitySignals::Keyword;
+  }
+}
+
 static SymbolQualitySignals::SymbolCategory
 categorize(const index::SymbolInfo &D) {
   switch (D.Kind) {
@@ -103,10 +126,7 @@ void SymbolQualitySignals::merge(const C
   if (SemaCCResult.Availability == CXAvailability_Deprecated)
 Deprecated = true;
 
-  if (SemaCCResult.Declaration)
-Category = categorize(*SemaCCResult.Declaration);
-  else if (SemaCCResult.Kind == CodeCompletionResult::RK_Macro)
-Category = Macro;
+  Category = categorize(SemaCCResult);
 
   if (SemaCCResult.Declaration) {
 if (auto *ID = SemaCCResult.Declaration->getIdentifier())
@@ -135,6 +155,9 @@ float SymbolQualitySignals::evaluate() c
 Score *= 0.1f;
 
   switch (Category) {
+case Keyword:  // Usually relevant, but misses most signals.
+  Score *= 10;
+  break;
 case Type:
 case Function:
 case Variable:

Modified: clang-tools-extra/trunk/clangd/Quality.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.h?rev=334711&r1=334710&r2=334711&view=diff
==
--- clang-tools-extra/trunk/clangd/Quality.h (original)
+++ clang-tools-extra/trunk/clangd/Quality.h Thu Jun 14 06:42:21 2018
@@ -50,12 +50,13 @@ struct SymbolQualitySignals {
   unsigned References = 0;
 
   enum SymbolCategory {
+Unknown = 0,
 Variable,
 Macro,
 Type,
 Function,
 Namespace,
-Unknown,
+Keyword,
   } Category = Unknown;
 
   void merge(const CodeCompletionResult &SemaCCResult);

Modified: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp?rev=334711&r1=334710&r2=334711&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Thu Jun 14 
06:42:21 2018
@@ -58,6 +58,10 @@ TEST(QualityTests, SymbolQualitySignalEx
   EXPECT_FALSE(Quality.ReservedName);
   EXPECT_EQ(Quality.References, SymbolQualitySignals().References);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
+
+  Quality = {};
+  Quality.merge(CodeCompletionResult("if"));
+  EXPECT_EQ(Quality.Category, SymbolQualitySignals::Keyword);
 }
 
 TEST(QualityTests, SymbolRelevanceSignalExtraction) {
@@ -125,10 +129,12 @@ TEST(QualityTests, SymbolQualitySignalsS
   EXPECT_GT(WithReferences.evaluate(), Default.evaluate());
   EXPECT_GT(ManyReferences.evaluate(), WithReferences.evaluate());
 
-  SymbolQualitySignals Variable, Macro;
+  SymbolQualitySignals Keyword, Variable, Macro;
+  Keyword.Category = SymbolQualitySignals::Keyword;
   Variable.Category = SymbolQualitySignals::Variable;
   Macro.Category = SymbolQualitySignals::Macro;
   EXPECT_GT(Variable.evaluate(), Default.evaluate());
+  EXPECT_GT(Keyword.evaluate(), Variable.evaluate());
   EXPECT_LT(Macro.evaluate(), Default.evaluate());
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.o

[PATCH] D48083: [clangd] Boost keyword completions.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334711: [clangd] Boost keyword completions. (authored by 
sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D48083

Files:
  clang-tools-extra/trunk/clangd/Quality.cpp
  clang-tools-extra/trunk/clangd/Quality.h
  clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
@@ -58,6 +58,10 @@
   EXPECT_FALSE(Quality.ReservedName);
   EXPECT_EQ(Quality.References, SymbolQualitySignals().References);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
+
+  Quality = {};
+  Quality.merge(CodeCompletionResult("if"));
+  EXPECT_EQ(Quality.Category, SymbolQualitySignals::Keyword);
 }
 
 TEST(QualityTests, SymbolRelevanceSignalExtraction) {
@@ -125,10 +129,12 @@
   EXPECT_GT(WithReferences.evaluate(), Default.evaluate());
   EXPECT_GT(ManyReferences.evaluate(), WithReferences.evaluate());
 
-  SymbolQualitySignals Variable, Macro;
+  SymbolQualitySignals Keyword, Variable, Macro;
+  Keyword.Category = SymbolQualitySignals::Keyword;
   Variable.Category = SymbolQualitySignals::Variable;
   Macro.Category = SymbolQualitySignals::Macro;
   EXPECT_GT(Variable.evaluate(), Default.evaluate());
+  EXPECT_GT(Keyword.evaluate(), Variable.evaluate());
   EXPECT_LT(Macro.evaluate(), Default.evaluate());
 }
 
Index: clang-tools-extra/trunk/clangd/Quality.cpp
===
--- clang-tools-extra/trunk/clangd/Quality.cpp
+++ clang-tools-extra/trunk/clangd/Quality.cpp
@@ -59,6 +59,29 @@
   return Switch().Visit(&ND);
 }
 
+static SymbolQualitySignals::SymbolCategory categorize(const CodeCompletionResult &R) {
+  if (R.Declaration)
+return categorize(*R.Declaration);
+  if (R.Kind == CodeCompletionResult::RK_Macro)
+return SymbolQualitySignals::Macro;
+  // Everything else is a keyword or a pattern. Patterns are mostly keywords
+  // too, except a few which we recognize by cursor kind.
+  switch (R.CursorKind) {
+case CXCursor_CXXMethod:
+  return SymbolQualitySignals::Function;
+case CXCursor_ModuleImportDecl:
+  return SymbolQualitySignals::Namespace;
+case CXCursor_MacroDefinition:
+  return SymbolQualitySignals::Macro;
+case CXCursor_TypeRef:
+  return SymbolQualitySignals::Type;
+case CXCursor_MemberRef:
+  return SymbolQualitySignals::Variable;
+default:
+  return SymbolQualitySignals::Keyword;
+  }
+}
+
 static SymbolQualitySignals::SymbolCategory
 categorize(const index::SymbolInfo &D) {
   switch (D.Kind) {
@@ -103,10 +126,7 @@
   if (SemaCCResult.Availability == CXAvailability_Deprecated)
 Deprecated = true;
 
-  if (SemaCCResult.Declaration)
-Category = categorize(*SemaCCResult.Declaration);
-  else if (SemaCCResult.Kind == CodeCompletionResult::RK_Macro)
-Category = Macro;
+  Category = categorize(SemaCCResult);
 
   if (SemaCCResult.Declaration) {
 if (auto *ID = SemaCCResult.Declaration->getIdentifier())
@@ -135,6 +155,9 @@
 Score *= 0.1f;
 
   switch (Category) {
+case Keyword:  // Usually relevant, but misses most signals.
+  Score *= 10;
+  break;
 case Type:
 case Function:
 case Variable:
Index: clang-tools-extra/trunk/clangd/Quality.h
===
--- clang-tools-extra/trunk/clangd/Quality.h
+++ clang-tools-extra/trunk/clangd/Quality.h
@@ -50,12 +50,13 @@
   unsigned References = 0;
 
   enum SymbolCategory {
+Unknown = 0,
 Variable,
 Macro,
 Type,
 Function,
 Namespace,
-Unknown,
+Keyword,
   } Category = Unknown;
 
   void merge(const CodeCompletionResult &SemaCCResult);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-06-14 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:10107-10112
+case 0x0b: // FALSE_OQ
+case 0x1b: // FALSE_OS
+  return llvm::Constant::getNullValue(ConvertType(E->getType()));
+case 0x0f: // TRUE_UQ
+case 0x1f: // TRUE_US
+  return llvm::Constant::getAllOnesValue(ConvertType(E->getType()));

GBuella wrote:
> spatel wrote:
> > On 2nd thought, why are we optimizing when we have matching IR predicates 
> > for these?
> > Just translate to FCMP_TRUE / FCMP_FALSE instead of special-casing these 
> > values.
> > InstSimplify can handle the constant folding if optimization is on.
> I don't know, these TRUE/FALSE cases were already handled here, I only 
> rearranged the code.
> Does this cause any problems? I mean, if it meant an extra dozen lines of 
> code I would get it, but as it is, does it hurt anything?
It's mostly about being consistent. I think it's generally out-of-bounds for 
clang to optimize code. That's not its job.

The potential end user difference is that in unoptimized code, a user might 
expect to see the vcmpXX asm corresponding to the source-level intrinsic when 
debugging.

I agree that this is changing existing behavior, so it's better if we make this 
change before or after this patch.


https://reviews.llvm.org/D45616



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


[clang-tools-extra] r334712 - [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"

2018-06-14 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jun 14 06:50:30 2018
New Revision: 334712

URL: http://llvm.org/viewvc/llvm-project?rev=334712&view=rev
Log:
[clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"

Summary:
This is a small code change but vastly reduces noise in code completion results.
The intent of allowing this was to let [sc] ~ "strncpy" and [strcpy] ~ "strncpy"
however the benefits for unsegmented names aren't IMO worth the costs.

Test cases should be representative of the changes here.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
clang-tools-extra/trunk/clangd/FuzzyMatch.h
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=334712&r1=334711&r2=334712&view=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Thu Jun 14 06:50:30 2018
@@ -261,33 +261,37 @@ void FuzzyMatcher::buildGraph() {
 ? ScoreInfo{MatchMissScore, Match}
 : ScoreInfo{MissMissScore, Miss};
 
-  if (!allowMatch(P, W)) {
-Score[Match] = {AwfulScore, Miss};
-  } else {
-auto &PreMatch = Scores[P][W];
-auto MatchMatchScore = PreMatch[Match].Score + matchBonus(P, W, Match);
-auto MissMatchScore = PreMatch[Miss].Score + matchBonus(P, W, Miss);
-Score[Match] = (MatchMatchScore > MissMatchScore)
-   ? ScoreInfo{MatchMatchScore, Match}
-   : ScoreInfo{MissMatchScore, Miss};
-  }
+  auto &PreMatch = Scores[P][W];
+  auto MatchMatchScore =
+  allowMatch(P, W, Match)
+  ? PreMatch[Match].Score + matchBonus(P, W, Match)
+  : AwfulScore;
+  auto MissMatchScore = allowMatch(P, W, Miss)
+? PreMatch[Miss].Score + matchBonus(P, W, Miss)
+: AwfulScore;
+  Score[Match] = (MatchMatchScore > MissMatchScore)
+ ? ScoreInfo{MatchMatchScore, Match}
+ : ScoreInfo{MissMatchScore, Miss};
 }
   }
 }
 
-bool FuzzyMatcher::allowMatch(int P, int W) const {
+bool FuzzyMatcher::allowMatch(int P, int W, Action Last) const {
   if (LowPat[P] != LowWord[W])
 return false;
-  // We require a "strong" match for the first pattern character only.
-  if (P > 0)
-return true;
-  // Obvious "strong match" for first char: match against a word head.
-  // We're banning matches outright, so conservatively accept some other cases
-  // where our segmentation might be wrong:
-  //  - allow matching B in ABCDef (but not in NDEBUG)
-  //  - we'd like to accept print in sprintf, but too many false positives
-  return WordRole[W] != Tail ||
- (Word[W] != LowWord[W] && WordTypeSet & 1 << Lower);
+  // We require a "strong" match:
+  // - for the first pattern character.  [foo] !~ "barefoot"
+  // - after a gap.  [pat] !~ "patnther"
+  if (Last == Miss) {
+// We're banning matches outright, so conservatively accept some other 
cases
+// where our segmentation might be wrong:
+//  - allow matching B in ABCDef (but not in NDEBUG)
+//  - we'd like to accept print in sprintf, but too many false positives
+if (WordRole[W] == Tail &&
+(Word[W] == LowWord[W] || !(WordTypeSet & 1 << Lower)))
+  return false;
+  }
+  return true;
 }
 
 int FuzzyMatcher::skipPenalty(int W, Action Last) const {

Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.h?rev=334712&r1=334711&r2=334712&view=diff
==
--- clang-tools-extra/trunk/clangd/FuzzyMatch.h (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.h Thu Jun 14 06:50:30 2018
@@ -50,16 +50,18 @@ private:
   constexpr static int MaxPat = 63, MaxWord = 127;
   enum CharRole : unsigned char; // For segmentation.
   enum CharType : unsigned char; // For segmentation.
-  // Action should be an enum, but this causes bitfield problems:
+  // Action describes how a word character was matched to the pattern.
+  // It should be an enum, but this causes bitfield problems:
   //   - for MSVC the enum type must be explicitly unsigned for correctness
   //   - GCC 4.8 complains not all values fit if the type is unsigned
   using Action = bool;
-  constexpr static Action Miss = false, Match = true;
+  constexpr static Action Miss = false; // Word character was skipped.
+  constexpr static Action Match =

[PATCH] D47950: [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked 3 inline comments as done.
Closed by commit rL334712: [clangd] FuzzyMatch: forbid tail-tail matches after 
a miss: [pat] !~ "panther" (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47950?vs=151104&id=151347#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47950

Files:
  clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
  clang-tools-extra/trunk/clangd/FuzzyMatch.h
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
  clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp

Index: clang-tools-extra/trunk/clangd/FuzzyMatch.h
===
--- clang-tools-extra/trunk/clangd/FuzzyMatch.h
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.h
@@ -50,33 +50,35 @@
   constexpr static int MaxPat = 63, MaxWord = 127;
   enum CharRole : unsigned char; // For segmentation.
   enum CharType : unsigned char; // For segmentation.
-  // Action should be an enum, but this causes bitfield problems:
+  // Action describes how a word character was matched to the pattern.
+  // It should be an enum, but this causes bitfield problems:
   //   - for MSVC the enum type must be explicitly unsigned for correctness
   //   - GCC 4.8 complains not all values fit if the type is unsigned
   using Action = bool;
-  constexpr static Action Miss = false, Match = true;
+  constexpr static Action Miss = false; // Word character was skipped.
+  constexpr static Action Match = true; // Matched against a pattern character.
 
   bool init(llvm::StringRef Word);
   void buildGraph();
   void calculateRoles(const char *Text, CharRole *Out, int &Types, int N);
-  bool allowMatch(int P, int W) const;
+  bool allowMatch(int P, int W, Action Last) const;
   int skipPenalty(int W, Action Last) const;
   int matchBonus(int P, int W, Action Last) const;
 
   // Pattern data is initialized by the constructor, then constant.
   char Pat[MaxPat]; // Pattern data
   int PatN; // Length
   char LowPat[MaxPat];  // Pattern in lowercase
   CharRole PatRole[MaxPat]; // Pattern segmentation info
-  int PatTypeSet;   // Bitmask of 1< MissMatchScore)
-   ? ScoreInfo{MatchMatchScore, Match}
-   : ScoreInfo{MissMatchScore, Miss};
-  }
+  auto &PreMatch = Scores[P][W];
+  auto MatchMatchScore =
+  allowMatch(P, W, Match)
+  ? PreMatch[Match].Score + matchBonus(P, W, Match)
+  : AwfulScore;
+  auto MissMatchScore = allowMatch(P, W, Miss)
+? PreMatch[Miss].Score + matchBonus(P, W, Miss)
+: AwfulScore;
+  Score[Match] = (MatchMatchScore > MissMatchScore)
+ ? ScoreInfo{MatchMatchScore, Match}
+ : ScoreInfo{MissMatchScore, Miss};
 }
   }
 }
 
-bool FuzzyMatcher::allowMatch(int P, int W) const {
+bool FuzzyMatcher::allowMatch(int P, int W, Action Last) const {
   if (LowPat[P] != LowWord[W])
 return false;
-  // We require a "strong" match for the first pattern character only.
-  if (P > 0)
-return true;
-  // Obvious "strong match" for first char: match against a word head.
-  // We're banning matches outright, so conservatively accept some other cases
-  // where our segmentation might be wrong:
-  //  - allow matching B in ABCDef (but not in NDEBUG)
-  //  - we'd like to accept print in sprintf, but too many false positives
-  return WordRole[W] != Tail ||
- (Word[W] != LowWord[W] && WordTypeSet & 1 << Lower);
+  // We require a "strong" match:
+  // - for the first pattern character.  [foo] !~ "barefoot"
+  // - after a gap.  [pat] !~ "patnther"
+  if (Last == Miss) {
+// We're banning matches outright, so conservatively accept some other cases
+// where our segmentation might be wrong:
+//  - allow matching B in ABCDef (but not in NDEBUG)
+//  - we'd like to accept print in sprintf, but too many false positives
+if (WordRole[W] == Tail &&
+(Word[W] == LowWord[W] || !(WordTypeSet & 1 << Lower)))
+  return false;
+  }
+  return true;
 }
 
 int FuzzyMatcher::skipPenalty(int W, Action Last) const {
Index: clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp
@@ -79,7 +79,7 @@
   EXPECT_THAT("", matches("unique_ptr"));
   EXPECT_THAT("u_p", matches("[u]nique[_p]tr"));
   EXPECT_THAT("up", matches("[u]nique_[p]tr"));
-  EXPECT_THAT("uq", matches("[u]ni[q]ue_ptr"));
+  EXPECT_THAT("uq", Not(matches("unique_ptr")));
   EXPECT_THAT("qp", Not(matches("unique_ptr")));
   EXPECT_THAT("log", Not(matches("SVGFEMorphologyElem

[PATCH] D47987: Provide only one declaration of __throw_runtime_error

2018-06-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I'm not really happy with gcc's redundant declaration warnings; I think they're 
"nannying" rather than useful.

That being said, why not just remove the declaration in `__locale`?
`__locale` includes `string`, which includes `stdexcept`.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47987



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


[PATCH] D48163: [clangd] UI for completion items that would trigger include insertion.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Ooh, bikeshed first!




Comment at: clangd/CodeComplete.cpp:278
+if (AllowIndexCompletion)
+  I.label = (InsertingInclude ? "+" : " ") + I.label;
 I.scoreInfo = Scores;

I think we should avoid tokens that occur commonly in C++ (possibly with the 
exception of # which is used for this purpose. We should also avoid doublewide 
chars because of alignment (even assuming a monospace font is risky...)

Ideas:
- something like "external link" icon on wikipedia - but no such thing in 
unicode :-(🔗(U+1F517 link) looks truly terrible in at least some fonts
- variant on plus like ⊕ (U+2295 circled plus) - can't find one I like a lot
- some kind of arrow like ☇ (U+2607 lightning) or ⇱ (U+21F1 north west arrow to 
corner) or ⮣ (upwards triangle-headed arrow with long head rightwards)
- variant on hash like ﹟(U+FE5F  small number sign)
- something unrelated but "special" like ※ (U+203B reference mark)

I'm not really happy with any of these :-(


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48163



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


r334718 - [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-06-14 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 14 07:53:51 2018
New Revision: 334718

URL: http://llvm.org/viewvc/llvm-project?rev=334718&view=rev
Log:
[Fixed Point Arithmetic] Addition of the remaining fixed point types and their 
saturated equivalents

This diff includes changes for the remaining _Fract and _Sat fixed point types.

```
signed short _Fract s_short_fract;
signed _Fract s_fract;
signed long _Fract s_long_fract;
unsigned short _Fract u_short_fract;
unsigned _Fract u_fract;
unsigned long _Fract u_long_fract;

// Aliased fixed point types
short _Accum short_accum;
_Accum accum;
long _Accum long_accum;
short _Fract short_fract;
_Fract fract;
long _Fract long_fract;

// Saturated fixed point types
_Sat signed short _Accum sat_s_short_accum;
_Sat signed _Accum sat_s_accum;
_Sat signed long _Accum sat_s_long_accum;
_Sat unsigned short _Accum sat_u_short_accum;
_Sat unsigned _Accum sat_u_accum;
_Sat unsigned long _Accum sat_u_long_accum;
_Sat signed short _Fract sat_s_short_fract;
_Sat signed _Fract sat_s_fract;
_Sat signed long _Fract sat_s_long_fract;
_Sat unsigned short _Fract sat_u_short_fract;
_Sat unsigned _Fract sat_u_fract;
_Sat unsigned long _Fract sat_u_long_fract;

// Aliased saturated fixed point types
_Sat short _Accum sat_short_accum;
_Sat _Accum sat_accum;
_Sat long _Accum sat_long_accum;
_Sat short _Fract sat_short_fract;
_Sat _Fract sat_fract;
_Sat long _Fract sat_long_fract;
```

This diff only allows for declaration of these fixed point types. Assignment 
and other operations done on fixed point types according to 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
future patches.

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Frontend/fixed_point.c
cfe/trunk/test/Frontend/fixed_point_bit_widths.c
cfe/trunk/test/Frontend/fixed_point_errors.c
cfe/trunk/test/Frontend/fixed_point_errors.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=334718&r1=334717&r2=334718&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jun 14 07:53:51 2018
@@ -1010,6 +1010,14 @@ public:
   CanQualType ShortAccumTy, AccumTy,
   LongAccumTy;  // ISO/IEC JTC1 SC22 WG14 N1169 Extension
   CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy;
+  CanQualType ShortFractTy, FractTy, LongFractTy;
+  CanQualType UnsignedShortFractTy, UnsignedFractTy, UnsignedLongFractTy;
+  CanQualType SatShortAccumTy, SatAccumTy, SatLongAccumTy;
+  CanQualType SatUnsignedShortAccumTy, SatUnsignedAccumTy,
+  SatUnsignedLongAccumTy;
+  CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
+  CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
+  SatUnsignedLongFractTy;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
   CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
@@ -2543,8 +2551,15 @@ public:
   // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
   // unsigned integer type.  This method takes a signed type, and returns the
   // corresponding unsigned integer type.
+  // With the introduction of fixed point types in ISO N1169, this method also
+  // accepts fixed point types and returns the corresponding unsigned type for
+  // a given fixed point type.
   QualType getCorrespondingUnsignedType(QualType T) const;
 
+  // Per ISO N1169, this method accepts fixed point types and returns the
+  // corresponding saturated type for a given fixed point type.
+  QualType getCorrespondingSaturatedType(QualType Ty) const;
+
  

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-06-14 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334718: [Fixed Point Arithmetic] Addition of the remaining 
fixed point types and their… (authored by leonardchan, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D46911

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/TargetInfo.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_bit_widths.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_errors.cpp

Index: test/Frontend/fixed_point_errors.cpp
===
--- test/Frontend/fixed_point_errors.cpp
+++ test/Frontend/fixed_point_errors.cpp
@@ -1,5 +1,9 @@
+// RUN: %clang_cc1 -x c++ %s -verify
 // RUN: %clang_cc1 -x c++ -ffixed-point %s -verify
 
 // Name namgling is not provided for fixed point types in c++
 
 _Accum accum;   // expected-error{{unknown type name '_Accum'}}
+_Fract fract;   // expected-error{{unknown type name '_Fract'}}
+_Sat _Accum sat_accum;  // expected-error{{unknown type name '_Sat'}}
+// expected-error@-1{{expected ';' after top level declarator}}
Index: test/Frontend/fixed_point_bit_widths.c
===
--- test/Frontend/fixed_point_bit_widths.c
+++ test/Frontend/fixed_point_bit_widths.c
@@ -3,44 +3,194 @@
 // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=ppc64 %s | FileCheck %s
 // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-windows10pro-fast %s | FileCheck %s
 
+/* Primary signed _Accum */
+
 int size_SsA = sizeof(signed short _Accum);
 int size_SA  = sizeof(signed _Accum);
 int size_SlA = sizeof(signed long _Accum);
 int align_SsA = __alignof(signed short _Accum);
 int align_SA  = __alignof(signed _Accum);
 int align_SlA = __alignof(signed long _Accum);
 
-int size_UsA = sizeof(unsigned short _Accum);
-int size_UA  = sizeof(unsigned _Accum);
-int size_UlA = sizeof(unsigned long _Accum);
-int align_UsA = __alignof(unsigned short _Accum);
-int align_UA  = __alignof(unsigned _Accum);
-int align_UlA = __alignof(unsigned long _Accum);
-
-int size_sA = sizeof(short _Accum);
-int size_A  = sizeof(_Accum);
-int size_lA = sizeof(long _Accum);
-int align_sA = __alignof(short _Accum);
-int align_A  = __alignof(_Accum);
-int align_lA = __alignof(long _Accum);
-
 // CHECK:  @size_SsA  = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @size_SA   = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @size_SlA  = {{.*}}global i{{[0-9]+}} 8
 // CHECK-NEXT: @align_SsA = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @align_SA  = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @align_SlA = {{.*}}global i{{[0-9]+}} 8
 
+/* Primary unsigned _Accum */
+
+int size_UsA = sizeof(unsigned short _Accum);
+int size_UA  = sizeof(unsigned _Accum);
+int size_UlA = sizeof(unsigned long _Accum);
+int align_UsA = __alignof(unsigned short _Accum);
+int align_UA  = __alignof(unsigned _Accum);
+int align_UlA = __alignof(unsigned long _Accum);
+
 // CHECK-NEXT: @size_UsA  = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @size_UA   = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @size_UlA  = {{.*}}global i{{[0-9]+}} 8
 // CHECK-NEXT: @align_UsA = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @align_UA  = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @align_UlA = {{.*}}global i{{[0-9]+}} 8
 
+/* Primary signed _Fract */
+
+int size_SsF = sizeof(signed short _Fract);
+int size_SF  = sizeof(signed _Fract);
+int size_SlF = sizeof(signed long _Fract);
+int align_SsF = __alignof(signed short _Fract);
+int align_SF  = __alignof(signed _Fract);
+int align_SlF = __alignof(signed long _Fract);
+
+// CHECK-NEXT: @size_SsF  = {{.*}}global i{{[0-9]+}} 2
+// CHECK-NEXT: @size_SF   = {{.*}}global i{{[0-9]+}} 4
+// CHECK-NEXT: @size_SlF  = {{.*}}global i{{[0-9]+}} 8
+// CHECK-NEXT: @align_SsF = {{.*}}global i{{[0-9]+}} 2
+// CHECK-NEXT: @align_SF  = {{.*}}global i{{[0-9]+}} 4
+// CHECK-NEXT: @align_SlF = {{.*}}global i{{[0-9]+}} 8
+
+/* Primary unsigned _Fract */
+
+int size_UsF = sizeof(unsigned short _Fract);
+int size_UF  = sizeof(uns

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-06-14 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334718: [Fixed Point Arithmetic] Addition of the remaining 
fixed point types and their… (authored by leonardchan, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46911?vs=151184&id=151352#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46911

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/BuiltinTypes.def
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/Specifiers.h
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/include/clang/Basic/TokenKinds.def
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/NSAPI.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypeLoc.cpp
  cfe/trunk/lib/Analysis/PrintfFormatString.cpp
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Serialization/ASTCommon.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/Frontend/fixed_point.c
  cfe/trunk/test/Frontend/fixed_point_bit_widths.c
  cfe/trunk/test/Frontend/fixed_point_errors.c
  cfe/trunk/test/Frontend/fixed_point_errors.cpp

Index: cfe/trunk/test/Frontend/fixed_point_bit_widths.c
===
--- cfe/trunk/test/Frontend/fixed_point_bit_widths.c
+++ cfe/trunk/test/Frontend/fixed_point_bit_widths.c
@@ -3,44 +3,194 @@
 // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=ppc64 %s | FileCheck %s
 // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-windows10pro-fast %s | FileCheck %s
 
+/* Primary signed _Accum */
+
 int size_SsA = sizeof(signed short _Accum);
 int size_SA  = sizeof(signed _Accum);
 int size_SlA = sizeof(signed long _Accum);
 int align_SsA = __alignof(signed short _Accum);
 int align_SA  = __alignof(signed _Accum);
 int align_SlA = __alignof(signed long _Accum);
 
-int size_UsA = sizeof(unsigned short _Accum);
-int size_UA  = sizeof(unsigned _Accum);
-int size_UlA = sizeof(unsigned long _Accum);
-int align_UsA = __alignof(unsigned short _Accum);
-int align_UA  = __alignof(unsigned _Accum);
-int align_UlA = __alignof(unsigned long _Accum);
-
-int size_sA = sizeof(short _Accum);
-int size_A  = sizeof(_Accum);
-int size_lA = sizeof(long _Accum);
-int align_sA = __alignof(short _Accum);
-int align_A  = __alignof(_Accum);
-int align_lA = __alignof(long _Accum);
-
 // CHECK:  @size_SsA  = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @size_SA   = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @size_SlA  = {{.*}}global i{{[0-9]+}} 8
 // CHECK-NEXT: @align_SsA = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @align_SA  = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @align_SlA = {{.*}}global i{{[0-9]+}} 8
 
+/* Primary unsigned _Accum */
+
+int size_UsA = sizeof(unsigned short _Accum);
+int size_UA  = sizeof(unsigned _Accum);
+int size_UlA = sizeof(unsigned long _Accum);
+int align_UsA = __alignof(unsigned short _Accum);
+int align_UA  = __alignof(unsigned _Accum);
+int align_UlA = __alignof(unsigned long _Accum);
+
 // CHECK-NEXT: @size_UsA  = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @size_UA   = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @size_UlA  = {{.*}}global i{{[0-9]+}} 8
 // CHECK-NEXT: @align_UsA = {{.*}}global i{{[0-9]+}} 2
 // CHECK-NEXT: @align_UA  = {{.*}}global i{{[0-9]+}} 4
 // CHECK-NEXT: @align_UlA = {{.*}}global i{{[0-9]+}} 8
 
+/* Primary signed _Fract */
+
+int size_SsF = sizeof(signed short _Fract);
+int size_SF  = sizeof(signed _Fract);
+int size_SlF = sizeof(signed long _Fract);
+int align_SsF = __alignof(signed short _Fract);
+int align_SF  = __alignof(signed _Fract);
+int align_SlF = __alignof(signed long _Fract);
+
+// CHECK-NEXT: @size_SsF  = {{.*}}global i{{[0-9]+}} 2
+// CHECK-NEXT: @size_SF   = {{.*}}global i{{[0-9]+}} 4
+// CHECK-NEXT: @size_SlF  = {{.*}}global i{{[0-9]+}} 8
+// CHECK-NEXT: @align_SsF = {{.*}}global i{{[0-9]+}} 2
+// CHECK-NEXT: @align_SF  = {{.*}}global i{{[0-9]+}} 4
+// CHECK-NEXT: @align_SlF = {{.*}}global i{{[0-9]+}} 8
+
+/* Primary unsigned _Fract */
+
+int size_UsF = sizeof(unsigned short _Fract);
+int size_UF  = sizeof(unsigned _Fract);
+int size_UlF = sizeof(unsigned long _Fract);
+int align_UsF = __alignof(unsigned short _Fract);
+int align_UF  = __alignof(unsigned _Fract);
+int align_UlF = __alignof(unsigned long _Fract);
+
+// CHECK-NEXT: @size_UsF  = {{.*}}global i{{[0-9]+}}

[PATCH] D48171: [clangd] Do not report comments that only have special chars.

2018-06-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, ioeric, hokein.
Herald added subscribers: jkorous, MaskRay.

Like the following:

  // ---
  // ===
  // ***

It does not cover all the cases, but those are definitely not very
useful.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48171

Files:
  clangd/CodeCompletionStrings.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1105,6 +1105,65 @@
   Contains(AllOf(Not(IsDocumented()), Named("func";
 }
 
+TEST(CompletionTest, NonDocComments) {
+  MockFSProvider FS;
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = "";
+
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  Annotations Source(R"cpp(
+// --
+int comments_foo();
+
+// A comment and a decl are separated by newlines.
+// Therefore, the comment shouldn't show up as doc comment.
+
+int comments_bar();
+
+// this comment should be in the results.
+int comments_baz();
+
+
+template 
+struct Struct {
+  int comments_qux();
+  int comments_quux();
+};
+
+
+// This comment should not be there.
+
+template 
+int Struct::comments_qux() {
+}
+
+// This comment **should** be in results.
+template 
+int Struct::comments_quux() {
+  int a = comments^;
+}
+  )cpp");
+  Server.addDocument(FooCpp, Source.code(), WantDiagnostics::Yes);
+  CompletionList Completions = cantFail(runCodeComplete(
+  Server, FooCpp, Source.point(), clangd::CodeCompleteOptions()));
+
+  // We should not get any of those comments in completion.
+  EXPECT_THAT(
+  Completions.items,
+  UnorderedElementsAre(AllOf(Not(IsDocumented()), Named("comments_foo")),
+   AllOf(IsDocumented(), Named("comments_baz")),
+   AllOf(IsDocumented(), Named("comments_quux")),
+   // FIXME(ibiryukov): the following items should have
+   // empty documentation, since they are separated from
+   // a comment with an empty line. Unfortunately, I
+   // couldn't make Sema tests pass if we ignore those.
+   AllOf(IsDocumented(), Named("comments_bar")),
+   AllOf(IsDocumented(), Named("comments_qux";
+}
+
 TEST(CompletionTest, CompleteOnInvalidLine) {
   auto FooCpp = testPath("foo.cpp");
 
Index: clangd/CodeCompletionStrings.cpp
===
--- clangd/CodeCompletionStrings.cpp
+++ clangd/CodeCompletionStrings.cpp
@@ -151,6 +151,16 @@
   const ObjCPropertyDecl *PDecl = M ? M->findPropertyDecl() : nullptr;
   return !PDecl || canRequestForDecl(*PDecl);
 }
+
+bool LooksLikeDocComment(llvm::StringRef CommentText) {
+  // We don't report comments that only contain "special" chars.
+  // This avoids reporting various delimiters, like:
+  //   =
+  //   -
+  //   *
+  return CommentText.find_first_not_of("/*-= \t\r\n") != llvm::StringRef::npos;
+}
+
 } // namespace
 
 std::string getDocComment(const ASTContext &Ctx,
@@ -167,7 +177,10 @@
   const RawComment *RC = getCompletionComment(Ctx, Decl);
   if (!RC)
 return "";
-  return RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+  std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+  if (!LooksLikeDocComment(Doc))
+return "";
+  return Doc;
 }
 
 std::string
@@ -180,7 +193,10 @@
   const RawComment *RC = getParameterComment(Ctx, Result, ArgIndex);
   if (!RC)
 return "";
-  return RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+  std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
+  if (!LooksLikeDocComment(Doc))
+return "";
+  return Doc;
 }
 
 void getLabelAndInsertText(const CodeCompletionString &CCS, std::string *Label,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r330382 - [CFG] [analyzer] Add construction contexts for loop condition variables.

2018-06-14 Thread Alexander Kornienko via cfe-commits
This commit seems to have introduced
https://bugs.llvm.org/show_bug.cgi?id=37769. Could you take a look?

On Fri, Apr 20, 2018 at 1:33 AM Artem Dergachev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dergachev
> Date: Thu Apr 19 16:30:15 2018
> New Revision: 330382
>
> URL: http://llvm.org/viewvc/llvm-project?rev=330382&view=rev
> Log:
> [CFG] [analyzer] Add construction contexts for loop condition variables.
>
> Loop condition variables, eg.
>
>   while (shared_ptr P = getIntPtr()) { ... })
>
> weren't handled in r324794 because they don't go through the common
> CFGBuilder::VisitDeclStmt method. Which means that they regressed
> after r324800.
>
> Fix the regression by duplicating the necessary construction context scan
> in
> the loop visiting code.
>
> Differential Revision: https://reviews.llvm.org/D45706
>
> Modified:
> cfe/trunk/lib/Analysis/CFG.cpp
> cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
> cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
> cfe/trunk/test/Analysis/scopes-cfg-output.cpp
>
> Modified: cfe/trunk/lib/Analysis/CFG.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=330382&r1=330381&r2=330382&view=diff
>
> ==
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Thu Apr 19 16:30:15 2018
> @@ -3169,7 +3169,13 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
>if (VarDecl *VD = F->getConditionVariable()) {
>  if (Expr *Init = VD->getInit()) {
>autoCreateBlock();
> -  appendStmt(Block, F->getConditionVariableDeclStmt());
> +  const DeclStmt *DS = F->getConditionVariableDeclStmt();
> +  assert(DS->isSingleDecl());
> +  findConstructionContexts(
> +
> ConstructionContextLayer::create(cfg->getBumpVectorContext(),
> +   const_cast *>(DS)),
> +  Init);
> +  appendStmt(Block, DS);
>EntryConditionBlock = addStmt(Init);
>assert(Block == EntryConditionBlock);
>maybeAddScopeBeginForVarDecl(EntryConditionBlock, VD, C);
> @@ -3494,7 +3500,13 @@ CFGBlock *CFGBuilder::VisitWhileStmt(Whi
>  if (VarDecl *VD = W->getConditionVariable()) {
>if (Expr *Init = VD->getInit()) {
>  autoCreateBlock();
> -appendStmt(Block, W->getConditionVariableDeclStmt());
> +const DeclStmt *DS = W->getConditionVariableDeclStmt();
> +assert(DS->isSingleDecl());
> +findConstructionContexts(
> +ConstructionContextLayer::create(cfg->getBumpVectorContext(),
> + const_cast(DS)),
> +Init);
> +appendStmt(Block, DS);
>  EntryConditionBlock = addStmt(Init);
>  assert(Block == EntryConditionBlock);
>  maybeAddScopeBeginForVarDecl(EntryConditionBlock, VD, C);
>
> Modified: cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp?rev=330382&r1=330381&r2=330382&view=diff
>
> ==
> --- cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp (original)
> +++ cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp Thu Apr 19
> 16:30:15 2018
> @@ -388,7 +388,8 @@ void test_if_jumps() {
>  // CHECK:  [B4]
>  // CHECK-NEXT:   1: a
>  // CHECK-NEXT:   2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
> -// CHECK-NEXT:   3: [B4.2] (CXXConstructExpr, class A)
> +// WARNINGS-NEXT:   3: [B4.2] (CXXConstructExpr, class A)
> +// ANALYZER-NEXT:   3: [B4.2] (CXXConstructExpr, [B4.4], class A)
>  // CHECK-NEXT:   4: A b = a;
>  // CHECK-NEXT:   5: b
>  // CHECK-NEXT:   6: [B4.5] (ImplicitCastExpr, NoOp, const class A)
> @@ -478,7 +479,8 @@ void test_while_implicit_scope() {
>  // CHECK:  [B10]
>  // CHECK-NEXT:   1: a
>  // CHECK-NEXT:   2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
> -// CHECK-NEXT:   3: [B10.2] (CXXConstructExpr, class A)
> +// WARNINGS-NEXT:   3: [B10.2] (CXXConstructExpr, class A)
> +// ANALYZER-NEXT:   3: [B10.2] (CXXConstructExpr, [B10.4], class A)
>  // CHECK-NEXT:   4: A b = a;
>  // CHECK-NEXT:   5: b
>  // CHECK-NEXT:   6: [B10.5] (ImplicitCastExpr, NoOp, const class A)
> @@ -761,7 +763,8 @@ void test_switch_jumps() {
>  // CHECK:  [B4]
>  // CHECK-NEXT:   1: a
>  // CHECK-NEXT:   2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
> -// CHECK-NEXT:   3: [B4.2] (CXXConstructExpr, class A)
> +// WARNINGS-NEXT:   3: [B4.2] (CXXConstructExpr, class A)
> +// ANALYZER-NEXT:   3: [B4.2] (CXXConstructExpr, [B4.4], class A)
>  // CHECK-NEXT:   4: A b = a;
>  // CHECK-NEXT:   5: b
>  // CHECK-NEXT:   6: [B4.5] (ImplicitCastExpr, NoOp, const class A)
> @@ -851,7 +854,8 @@ void test_for_implicit_scope() {
>  // CHECK:  [B10]
>  // CHECK-NEXT:   1: b
>  // CHECK-NEXT:   2: [B

[PATCH] D41168: [X86] Lowering X86 avx512 sqrt intrinsics to IR

2018-06-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:9222
+if (CC != 4)
+  return nullptr;
+Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0);

What does returning nullptr here do?



Comment at: lib/CodeGen/CGBuiltin.cpp:9246
+if (CC != 4)
+  return nullptr;
+Function *F = CGM.getIntrinsic(Intrinsic::sqrt, Ops[0]->getType());

Again  don't know what the caller is going to do with nullptr.


Repository:
  rC Clang

https://reviews.llvm.org/D41168



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


[PATCH] D48163: [clangd] UI for completion items that would trigger include insertion.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 151357.
ioeric added a comment.

- s/+/•/ and make the icon an code completion option to avoid hardcodes in 
multiple places.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48163

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Headers.cpp
  clangd/Headers.h
  test/clangd/completion-snippets.test
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/HeadersTests.cpp

Index: unittests/clangd/HeadersTests.cpp
===
--- unittests/clangd/HeadersTests.cpp
+++ unittests/clangd/HeadersTests.cpp
@@ -106,7 +106,7 @@
 } else {
   EXPECT_FALSE(ExpectError);
 }
-return std::move(*Path);
+return Path->second ? std::move(Path->first) : "";
   }
 
   Expected>
@@ -123,9 +123,13 @@
 for (const auto &Inc : ExistingInclusions)
   Inserter.addExisting(Inc);
 
-auto Edit = Inserter.insert(DeclaringHeader, InsertedHeader);
+auto HeaderAndEdit = Inserter.insert(DeclaringHeader, InsertedHeader);
 Action.EndSourceFile();
-return Edit;
+if (!HeaderAndEdit)
+  return HeaderAndEdit.takeError();
+if (!HeaderAndEdit->second)
+  return llvm::None;
+return *(HeaderAndEdit->second);
   }
 
   MockFSProvider FS;
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -566,17 +566,21 @@
   int main() { ns::^ }
   )cpp",
  {Sym});
-  EXPECT_THAT(Results.items,
-  ElementsAre(AllOf(Named("X"), InsertInclude("\"bar.h\"";
+  EXPECT_THAT(
+  Results.items,
+  ElementsAre(
+  AllOf(Named("X"),
+Labeled(CodeCompleteOptions().IncludeInsertionIndicator + "X"),
+InsertInclude("\"bar.h\"";
   // Duplicate based on inclusions in preamble.
   Results = completions(Server,
 R"cpp(
   #include "sub/bar.h"  // not shortest, so should only match resolved.
   int main() { ns::^ }
   )cpp",
 {Sym});
-  EXPECT_THAT(Results.items,
-  ElementsAre(AllOf(Named("X"), Not(HasAdditionalEdits();
+  EXPECT_THAT(Results.items, ElementsAre(AllOf(Named("X"), Labeled(" X"),
+   Not(HasAdditionalEdits();
 }
 
 TEST(CompletionTest, NoIncludeInsertionWhenDeclFoundInFile) {
Index: test/clangd/completion-snippets.test
===
--- test/clangd/completion-snippets.test
+++ test/clangd/completion-snippets.test
@@ -32,7 +32,7 @@
 # CHECK-NEXT:  "insertText": "func_with_args(${1:int a}, ${2:int b})",
 # CHECK-NEXT:  "insertTextFormat": 2,
 # CHECK-NEXT:  "kind": 3,
-# CHECK-NEXT:  "label": "func_with_args(int a, int b)",
+# CHECK-NEXT:  "label": " func_with_args(int a, int b)",
 # CHECK-NEXT:  "sortText": "{{.*}}func_with_args"
 # CHECK-NEXT:}
 # CHECK-NEXT:]
Index: clangd/Headers.h
===
--- clangd/Headers.h
+++ clangd/Headers.h
@@ -60,11 +60,12 @@
 /// InsertedHeader e.g. the header that declares a symbol.
 /// \param InsertedHeader The preferred header to be inserted. This could be the
 /// same as DeclaringHeader but must be provided.
-//  \return A quoted "path" or . This returns an empty string if:
+/// \return A quoted "path" or  to be included and a boolean that is true
+/// if the include can be added, and false if:
 ///   - Either \p DeclaringHeader or \p InsertedHeader is already (directly)
 ///   in \p Inclusions (including those included via different paths).
 ///   - \p DeclaringHeader or \p InsertedHeader is the same as \p File.
-llvm::Expected calculateIncludePath(
+llvm::Expected> calculateIncludePath(
 PathRef File, StringRef BuildDir, HeaderSearch &HeaderSearchInfo,
 const std::vector &Inclusions, const HeaderFile &DeclaringHeader,
 const HeaderFile &InsertedHeader);
@@ -81,16 +82,18 @@
 
   void addExisting(Inclusion Inc) { Inclusions.push_back(std::move(Inc)); }
 
-  /// Returns a TextEdit that inserts a new header; if the header is not
-  /// inserted e.g. it's an existing header, this returns None. If any header is
-  /// invalid, this returns error.
+  /// Returns a  pair where Header is verbatim
+  /// (e.g. ) and Edit, if not None, inserts the entire include
+  /// directive. Edit is None is the header is not suitable to include e.g.
+  /// it's already included. If any header is invalid, this returns error.
   ///
   /// \param DeclaringHeader is the original header corresponding to \p
   /// InsertedHeader e.g. the header that declares a symbol.
   /// \param InsertedHeader The preferred header to be inserted. This could be
   /// the same as DeclaringHeader but must be provided.
-  Expected> insert(const Heade

[PATCH] D48163: [clangd] UI for completion items that would trigger include insertion.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/CodeComplete.cpp:278
+if (AllowIndexCompletion)
+  I.label = (InsertingInclude ? "+" : " ") + I.label;
 I.scoreInfo = Scores;

sammccall wrote:
> I think we should avoid tokens that occur commonly in C++ (possibly with the 
> exception of # which is used for this purpose. We should also avoid 
> doublewide chars because of alignment (even assuming a monospace font is 
> risky...)
> 
> Ideas:
> - something like "external link" icon on wikipedia - but no such thing in 
> unicode :-(🔗(U+1F517 link) looks truly terrible in at least some fonts
> - variant on plus like ⊕ (U+2295 circled plus) - can't find one I like a lot
> - some kind of arrow like ☇ (U+2607 lightning) or ⇱ (U+21F1 north west arrow 
> to corner) or ⮣ (upwards triangle-headed arrow with long head rightwards)
> - variant on hash like ﹟(U+FE5F  small number sign)
> - something unrelated but "special" like ※ (U+203B reference mark)
> 
> I'm not really happy with any of these :-(
Thanks for the suggestions! 

After playing around with different options, we decided to go with `•` which is 
simple and also aligns well in vim and vscode. We tried to avoid symbols that 
are meaningful/complicated because they tend to add noise when users are used 
to the existence of the icon, and they appear less elegant when there are a 
whole list of indicators in the completion results.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48163



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


[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 151358.
ioeric marked 6 inline comments as done.
ioeric added a comment.

- addressed review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935

Files:
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/QualityTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestFS.h
  unittests/clangd/URITests.cpp

Index: unittests/clangd/URITests.cpp
===
--- unittests/clangd/URITests.cpp
+++ unittests/clangd/URITests.cpp
@@ -14,46 +14,19 @@
 
 namespace clang {
 namespace clangd {
+
+// Force the unittest URI scheme to be linked,
+static int LLVM_ATTRIBUTE_UNUSED UnittestSchemeAnchorDest =
+UnittestSchemeAnchorSource;
+
 namespace {
 
 using ::testing::AllOf;
 
 MATCHER_P(Scheme, S, "") { return arg.scheme() == S; }
 MATCHER_P(Authority, A, "") { return arg.authority() == A; }
 MATCHER_P(Body, B, "") { return arg.body() == B; }
 
-// Assume all files in the schema have a "test-root/" root directory, and the
-// schema path is the relative path to the root directory.
-// So the schema of "/some-dir/test-root/x/y/z" is "test:x/y/z".
-class TestScheme : public URIScheme {
-public:
-  static const char *Scheme;
-
-  static const char *TestRoot;
-
-  llvm::Expected
-  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
-  llvm::StringRef HintPath) const override {
-auto Pos = HintPath.find(TestRoot);
-assert(Pos != llvm::StringRef::npos);
-return (HintPath.substr(0, Pos + llvm::StringRef(TestRoot).size()) + Body)
-.str();
-  }
-
-  llvm::Expected
-  uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
-auto Pos = AbsolutePath.find(TestRoot);
-assert(Pos != llvm::StringRef::npos);
-return URI(Scheme, /*Authority=*/"",
-   AbsolutePath.substr(Pos + llvm::StringRef(TestRoot).size()));
-  }
-};
-
-const char *TestScheme::Scheme = "unittest";
-const char *TestScheme::TestRoot = "/test-root/";
-
-static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schema");
-
 std::string createOrDie(llvm::StringRef AbsolutePath,
 llvm::StringRef Scheme = "file") {
   auto Uri = URI::create(AbsolutePath, Scheme);
@@ -167,12 +140,12 @@
 #else
   EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c");
   EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "/a/b/c");
-  EXPECT_EQ(resolveOrDie(parseOrDie("unittest:a/b/c"), "/dir/test-root/x/y/z"),
-"/dir/test-root/a/b/c");
   EXPECT_THAT(resolveOrDie(parseOrDie("file://au%3dth/%28x%29/y/%20z")),
   "/(x)/y/ z");
   EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:/x/y/z");
 #endif
+  EXPECT_EQ(resolveOrDie(parseOrDie("unittest:a"), testPath("x")),
+testPath("a"));
 }
 
 TEST(URITest, Platform) {
Index: unittests/clangd/TestFS.h
===
--- unittests/clangd/TestFS.h
+++ unittests/clangd/TestFS.h
@@ -56,6 +56,10 @@
 // Returns a suitable absolute path for this OS.
 std::string testPath(PathRef File);
 
+// This anchor is used to force the linker to link in the generated object file
+// and thus register unittest: URI scheme plugin.
+extern volatile int UnittestSchemeAnchorSource;
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -7,7 +7,11 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "URI.h"
+#include "clang/AST/DeclCXX.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -62,5 +66,38 @@
   return Path.str();
 }
 
+/// unittest: is a scheme that refers to files relative to testRoot()
+class TestScheme : public URIScheme {
+public:
+  static const char *Scheme;
+
+  llvm::Expected
+  getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
+  llvm::StringRef HintPath) const override {
+assert(HintPath.startswith(testRoot()));
+llvm::SmallString<16> Path(Body.begin(), Body.end());
+llvm::sys::path::native(Path);
+return testPath(Path);
+  }
+
+  llvm::Expected
+  uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
+llvm::StringRef Body = AbsolutePath;
+if (!Body.consume_front(testRoot()))
+  return llvm::make_error(
+  AbsolutePath + "does not start with " + testRoot(),
+  llvm::inconvertibleErrorCode());
+
+return URI(Scheme, /*Authority=*/"",
+   llvm::sys::path::convert_to_slash(Body));
+  }
+};
+
+const char *TestScheme::Scheme = "unittest";
+
+static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schem

[PATCH] D47935: [clangd] Boost completion score according to file proximity.

2018-06-14 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Quality.cpp:185
+  }
+  if (F == Fs.begin() && T == Ts.begin()) // No common directory.
+return 0;

sammccall wrote:
> why is this a special case?
>  - /x/a/b vs /x/a/c is 1 up + 1 down --> 0.59
>  - /a/b vs /a/c is 1 up + 1 down --> 0.59
>  - /b vs /c is unrelated --> 0
> 
> I don't doubt the assertion that these are unrelated paths, but I'm not sure 
> fixing just this case is an improvement overall. (In a perfect world, we'd 
> define the algorithm so that this case yields 0 without a discontinuity)
The intuition is that when we hit the root, it's very likely that we are 
switching projects. But we could leave this out of the patch and evaluate 
whether this is an improvement later.



Comment at: clangd/Quality.h:98
+  /// closest.
+  float IndexProximityScore = 0;
+  llvm::StringRef IndexSymbolURI;

sammccall wrote:
> This is redundant with (IndexSymbolURI, FileProximityMatch) I think, and will 
> only be correctly set if FileProximityMatch is set before calling 
> merge(Symbol).
> 
> Can we defer calculation until evaluate()?
> (If you want to dump this intermediate score, you can recompute it in 
> operator<<, I'm not sure it's necessary).
Done.

> (If you want to dump this intermediate score, you can recompute it in 
> operator<<, I'm not sure it's necessary).
I think the proximity score would be useful for debugging, no?



Comment at: unittests/clangd/TestFS.cpp:66
 
+// Assume all files in the schema have a "test-root/" root directory, and the
+// schema path is the relative path to the root directory.

sammccall wrote:
> These helpers would be more coherent if this used the same test root as above 
> - any reason we can't do that?
> 
> Then this comment could just be "unittest: is a scheme that refers to files 
> relative to testRoot()"
Good idea.



Comment at: unittests/clangd/TestFS.cpp:107
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the plugin.

sammccall wrote:
> This is really surprising to me - is this the common pattern for registries?
> (i.e. we don't have something more declarative like bazel's 
> `cc_library.alwayslink`)?
> 
> If so, can we move the declaration to TestFS.h and give a usage example, so 
> the consuming libraries don't have to repeat the decl?
yeah... this pattern is also used in `tooling::CompilationDatabase` (e.g. 
https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/CompilationDatabase.cpp#L398),
 and I'm not aware of a good way to deal without `alwayslink`.

>If so, can we move the declaration to TestFS.h and give a usage example, so 
>the consuming libraries don't have to repeat the decl?
Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47935



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


[PATCH] D48163: [clangd] UI for completion items that would trigger include insertion.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:187
+  // Whether or not this candidate is in a completion where index is allowed.
+  // This can affect how items are built (e.g. indent label to align with 
visual
+  // indicator in index results).

Hmm, I'm not sure this should be conditional.
Especially in editors that render [icon]label, inconsistently having a space or 
not for no obvious reason seems disorienting to users.

And it adds some complexity (especially in conjunction with bundling...)



Comment at: clangd/CodeComplete.cpp:266
+  } else {
+InsertingInclude = static_cast(HeaderAndEdit->second);
+if (InsertingInclude) {

nit: .hasValue() would be clearer than static_cast



Comment at: clangd/CodeComplete.cpp:278
+if (AllowIndexCompletion)
+  I.label = (InsertingInclude ? "+" : " ") + I.label;
 I.scoreInfo = Scores;

ioeric wrote:
> sammccall wrote:
> > I think we should avoid tokens that occur commonly in C++ (possibly with 
> > the exception of # which is used for this purpose. We should also avoid 
> > doublewide chars because of alignment (even assuming a monospace font is 
> > risky...)
> > 
> > Ideas:
> > - something like "external link" icon on wikipedia - but no such thing in 
> > unicode :-(🔗(U+1F517 link) looks truly terrible in at least some fonts
> > - variant on plus like ⊕ (U+2295 circled plus) - can't find one I like a lot
> > - some kind of arrow like ☇ (U+2607 lightning) or ⇱ (U+21F1 north west 
> > arrow to corner) or ⮣ (upwards triangle-headed arrow with long head 
> > rightwards)
> > - variant on hash like ﹟(U+FE5F  small number sign)
> > - something unrelated but "special" like ※ (U+203B reference mark)
> > 
> > I'm not really happy with any of these :-(
> Thanks for the suggestions! 
> 
> After playing around with different options, we decided to go with `•` which 
> is simple and also aligns well in vim and vscode. We tried to avoid symbols 
> that are meaningful/complicated because they tend to add noise when users are 
> used to the existence of the icon, and they appear less elegant when there 
> are a whole list of indicators in the completion results.
this is going to be slightly tricky with bundling, where we take the 
CompletionItem for an arbitrary item, and recompute the label as Name + "(...)".

Note that if we're unconditionally adding the padding character, we can just 
grab it out of the old CompletionItem.label :-) Yes it's a hack, but otherwise 
we need to pass this information around or factor quite differently.



Comment at: clangd/Headers.cpp:75
 /// path is not shortened.
-llvm::Expected calculateIncludePath(
+llvm::Expected> calculateIncludePath(
 PathRef File, StringRef BuildDir, HeaderSearch &HeaderSearchInfo,

we don't need Expected here anymore?



Comment at: clangd/Headers.h:63
 /// same as DeclaringHeader but must be provided.
-//  \return A quoted "path" or . This returns an empty string if:
+/// \return A quoted "path" or  to be included and a boolean that is true
+/// if the include can be added, and false if:

why the change from empty string here? does this anticipate adding the path to 
the detail/doc unconditionally in a future patch?

This is quite a hard signature to understand and describe. At first glance it 
seems we can just split function into `bool shouldAddInclude()` and 
`calculateIncludePath()`, they won't overlap?



Comment at: clangd/Headers.h:94
   /// the same as DeclaringHeader but must be provided.
-  Expected> insert(const HeaderFile &DeclaringHeader,
-  const HeaderFile &InsertedHeader) const;
+  Expected>>
+  insert(const HeaderFile &DeclaringHeader,

this signature is scary :-)

One option is to separate:
- `bool shouldInsert(Declaring, Inserted)` (probably just log errors and return 
false)
- `string spell(Inserted)`
- `TextEdit insert(Spelled)`

another is a struct, but I think making the flow a little more explicit at the 
callsite might be clearer.



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48163



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


[PATCH] D48163: [clangd] UI for completion items that would trigger include insertion.

2018-06-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Oops, forgot to link to the bundling patch: https://reviews.llvm.org/D47957
We should expect some conflicts one way or the other.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48163



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


[PATCH] D46915: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

2018-06-14 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:1248
+  bool RHSFixed = RHSType->isFixedPointType();
+
+  if (LHSFixed && RHSFixed) {

ebevhan wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > leonardchan wrote:
> > > > ebevhan wrote:
> > > > > I don't see how these semantics work properly. The specification 
> > > > > requires that operations be done in the full precision of both types. 
> > > > > You cannot convert the types before performing the operation like 
> > > > > this, since the operation will not be done in full precision in that 
> > > > > case.
> > > > > 
> > > > > The operator semantics of Embedded-C require the operand types of 
> > > > > binary operators to be different. It's only when you've performed the 
> > > > > operation that you are allowed to convert the result to the resulting 
> > > > > type.
> > > > Initially the idea was to convert both sides to fixed point types, then 
> > > > perform standard binary operations between the fixed point types.
> > > > 
> > > > For the example, a `fract * int` would have the int converted to a 
> > > > fixed point type by left shifting it by the scale of the fract, 
> > > > multiplying, then right shifting by the scale again to get the 
> > > > resulting fract. The only unhandled thing is overflow, but the 
> > > > precision of the fract remains the same. The operands would also be 
> > > > casted up beforehand so there was enough space to store the result, 
> > > > which was casted down back to the original fract after performing the 
> > > > right shift by the scale.
> > > > 
> > > > Operations between fixed point types would follow a similar process of 
> > > > casting both operands to the higher rank fixed point type, and 
> > > > depending on the operation, more underlying shifting and casting would 
> > > > be done to retain full precision of the higher ranked type.
> > > > 
> > > > Though I will admit that I did not realize until now that multiplying a 
> > > > fixed point type by an integer does not require shifting the integer.
> > > I see how you've reasoned; this is how C normally works. The `fract` is 
> > > of higher rank than `int` and therefore is the 'common type' of the 
> > > operation. However, even though it is higher rank there is no guarantee 
> > > that you can perform the operation without overflowing. And overflow 
> > > matters here; the spec says that it must be done in the full precision 
> > > (integral + fractional) of both types.
> > > 
> > > > The only unhandled thing is overflow, but the precision of the fract 
> > > > remains the same. The operands would also be casted up beforehand so 
> > > > there was enough space to store the result, which was casted down back 
> > > > to the original fract after performing the right shift by the scale.
> > > 
> > > The precision remains the same (and while it doesn't have to be the same 
> > > to perform an operation, it makes the implementation more regular; things 
> > > like addition and subtraction 'just work'), but you cannot perform a 
> > > conversion to `fract` *before* the operation itself, since if you do, 
> > > there's nothing to 'cast up'. Casting up is needed for things like `fract 
> > > * fract` to prevent overflow, but for `fract * int` you need to cast to a 
> > > type that can fit both all values of the int and all values of the fract, 
> > > and *then* you can cast up before doing the multiplication.
> > > 
> > > > Operations between fixed point types would follow a similar process of 
> > > > casting both operands to the higher rank fixed point type, and 
> > > > depending on the operation, more underlying shifting and casting would 
> > > > be done to retain full precision of the higher ranked type.
> > > 
> > > This might work, but I feel there could be edge cases. The E-C 
> > > fixed-point ranks are very odd as they don't reflect reality; `short 
> > > _Accum` cannot be considered strictly 'above' `long _Fract`, but the 
> > > former has a higher rank than the latter. Depending on how the types are 
> > > specified for a target, implicit casts between fixed-point types might 
> > > inadvertantly discard bits, even though the spec says that operations 
> > > must be done in full precision.
> > I see, so just to confirm, something like a `fract * int` would not result 
> > in any implicit casting between either operand, but any special arithmetic, 
> > like intermediate storage types or saturation handling, would be handled by 
> > the underlying IR?
> > 
> > So should really no conversions/implicit type casting should be performed 
> > here and instead all handling of arithmetic operations should happen 
> > somewhere during the codegen stage?
> > 
> > I see, so just to confirm, something like a fract * int would not result in 
> > any implicit casting between either operand, but any special arithmetic, 
> > like intermediate storage types or saturation handling, would be handled by 
> > the under

[PATCH] D47393: [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 📜

2018-06-14 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

I'll just land it for you.


Repository:
  rC Clang

https://reviews.llvm.org/D47393



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


[PATCH] D44788: Add an option to support debug fission on implicit ThinLTO.

2018-06-14 Thread Yunlian Jiang via Phabricator via cfe-commits
yunlian added a comment.

ping?


https://reviews.llvm.org/D44788



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


[PATCH] D48100: Append new attributes to the end of an AttributeList.

2018-06-14 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 151378.
Meinersbur marked an inline comment as done.
Meinersbur added a comment.

- Remove FIXME
- Add comment about O(n^2) execution time when adding attributes
- Do not store enable_if attributes in temporary list


Repository:
  rC Clang

https://reviews.llvm.org/D48100

Files:
  include/clang/Sema/AttributeList.h
  lib/AST/ItaniumMangle.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTReaderDecl.cpp
  test/Index/annotate-comments-availability-attrs.cpp
  test/Index/complete-with-annotations.cpp
  test/Misc/ast-print-pragmas.cpp
  test/PCH/pragma-loop.cpp
  test/Parser/pragma-loop-safety.cpp
  test/Parser/pragma-loop.cpp
  test/Parser/pragma-unroll.cpp
  test/Sema/attr-availability-tvos.c
  test/Sema/attr-availability.c
  test/Sema/attr-coldhot.c
  test/Sema/attr-disable-tail-calls.c
  test/Sema/attr-long-call.c
  test/Sema/attr-micromips.c
  test/Sema/attr-notail.c
  test/Sema/attr-ownership.c
  test/Sema/attr-ownership.cpp
  test/Sema/attr-print.c
  test/Sema/attr-swiftcall.c
  test/Sema/attr-target-mv.c
  test/Sema/attr-visibility.c
  test/Sema/internal_linkage.c
  test/Sema/mips-interrupt-attr.c
  test/Sema/ms_abi-sysv_abi.c
  test/Sema/nullability.c
  test/Sema/stdcall-fastcall.c
  test/SemaCXX/attr-print.cpp
  test/SemaCXX/attr-swiftcall.cpp
  test/SemaCXX/decl-microsoft-call-conv.cpp
  test/SemaCXX/ms-uuid.cpp
  test/SemaOpenCL/address-spaces.cl
  test/SemaTemplate/attributes.cpp

Index: test/SemaTemplate/attributes.cpp
===
--- test/SemaTemplate/attributes.cpp
+++ test/SemaTemplate/attributes.cpp
@@ -55,11 +55,11 @@
 }
 
 // CHECK: FunctionTemplateDecl {{.*}} HasAnnotations
-// CHECK:   AnnotateAttr {{.*}} "ANNOTATE_BAR"
 // CHECK:   AnnotateAttr {{.*}} "ANNOTATE_FOO"
+// CHECK:   AnnotateAttr {{.*}} "ANNOTATE_BAR"
 // CHECK: FunctionDecl {{.*}} HasAnnotations
 // CHECK:   TemplateArgument type 'int'
-// CHECK:   AnnotateAttr {{.*}} "ANNOTATE_BAR"
 // CHECK:   AnnotateAttr {{.*}} "ANNOTATE_FOO"
+// CHECK:   AnnotateAttr {{.*}} "ANNOTATE_BAR"
 template [[clang::annotate("ANNOTATE_FOO"), clang::annotate("ANNOTATE_BAR")]] void HasAnnotations();
 void UseAnnotations() { HasAnnotations(); }
Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -58,8 +58,8 @@
 
 void func_multiple_addr(void) {
   typedef __private int private_int_t;
-  __local __private int var1;   // expected-error {{multiple address spaces specified for type}}
-  __local __private int *var2;  // expected-error {{multiple address spaces specified for type}}
+  __private __local int var1;   // expected-error {{multiple address spaces specified for type}}
+  __private __local int *var2;  // expected-error {{multiple address spaces specified for type}}
   __local private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
   __local private_int_t *var4;  // expected-error {{multiple address spaces specified for type}}
 }
Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -62,14 +62,14 @@
 [uuid("22A0---C000-0049")] class C4 {};
 
 // Both cl and clang-cl error out on this:
-// expected-note@+1 {{previous uuid specified here}}
-class __declspec(uuid("00A0---C000-0049"))
 // expected-error@+1 {{uuid does not match previous declaration}}
+class __declspec(uuid("00A0---C000-0049"))
+// expected-note@+1 {{previous uuid specified here}}
   __declspec(uuid("11A0---C000-0049")) C5;
 
-// expected-note@+1 {{previous uuid specified here}}
-[uuid("00A0---C000-0049"),
 // expected-error@+1 {{uuid does not match previous declaration}}
+[uuid("00A0---C000-0049"),
+// expected-note@+1 {{previous uuid specified here}}
  uuid("11A0---C000-0049")] class C6;
 
 // cl doesn't diagnose having one uuid each as []-style attributes and as
Index: test/SemaCXX/decl-microsoft-call-conv.cpp
===
--- test/SemaCXX/decl-microsoft-call-conv.cpp
+++ test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -161,7 +161,7 @@
 // expected-error@+3 {{vectorcall and cdecl attributes are not compatible}}
 // expected-error@+2 {{stdcall and cdecl attributes are not compatible}}
 // expected-error@+1 {{fastcall and cdecl attributes are not compatible}}
-void __cdecl __cdecl __stdcall __cdecl __fastcall __vectorcall multi_cc(int x);
+void __vectorcall __fastcall __cdecl __stdcall __cdecl __cdecl multi_cc(int x);
 
 template  void __stdcall StdcallTemplate(T) {}
 template <> void StdcallTemplate(int) {}
Index: test/SemaCXX/attr-swiftcall.cpp

[PATCH] D47393: [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 📜

2018-06-14 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334739: [clang-format] Disable 
AlwaysBreakBeforeMultilineStrings in Google style for… (authored by 
benhamilton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47393?vs=149338&id=151379#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47393

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp


Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -1218,6 +1218,17 @@
"}");
 }
 
+TEST_F(FormatTestObjC, AlwaysBreakBeforeMultilineStrings) {
+  Style = getGoogleStyle(FormatStyle::LK_ObjC);
+  Style.ColumnLimit = 40;
+  verifyFormat(" = @\"\"\n"
+   "   @\"\";");
+  verifyFormat("(@\"\"\n"
+   " @\"\");");
+  verifyFormat("(qqq, @\"\"\n"
+   "  @\"\");");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -823,6 +823,7 @@
 // has been implemented.
 GoogleStyle.BreakStringLiterals = false;
   } else if (Language == FormatStyle::LK_ObjC) {
+GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
   }
 


Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -1218,6 +1218,17 @@
"}");
 }
 
+TEST_F(FormatTestObjC, AlwaysBreakBeforeMultilineStrings) {
+  Style = getGoogleStyle(FormatStyle::LK_ObjC);
+  Style.ColumnLimit = 40;
+  verifyFormat(" = @\"\"\n"
+   "   @\"\";");
+  verifyFormat("(@\"\"\n"
+   " @\"\");");
+  verifyFormat("(qqq, @\"\"\n"
+   "  @\"\");");
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -823,6 +823,7 @@
 // has been implemented.
 GoogleStyle.BreakStringLiterals = false;
   } else if (Language == FormatStyle::LK_ObjC) {
+GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.ColumnLimit = 100;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47979: [X86] Lowering Mask Scalar add/sub/mul/div intrinsics to native IR (Clang part)

2018-06-14 Thread Tomasz Krupa via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334741: [X86] Lowering Mask Scalar intrinsics to native IR 
(Clang part) (authored by tkrupa, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47979?vs=150617&id=151381#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47979

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -2302,12 +2302,29 @@
 }
 __m128 test_mm_mask_add_ss(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) {
   // CHECK-LABEL: @test_mm_mask_add_ss
-  // CHECK: @llvm.x86.avx512.mask.add.ss.round
+  // CHECK-NOT: @llvm.x86.avx512.mask.add.ss.round
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: fadd float %{{.*}}, %{{.*}}
+  // CHECK: insertelement <4 x float> %{{.*}}, i32 0
+  // CHECK: and i32 {{.*}}, 1
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: br {{.*}}, {{.*}}, {{.*}}
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
   return _mm_mask_add_ss(__W,__U,__A,__B); 
 }
 __m128 test_mm_maskz_add_ss(__mmask8 __U, __m128 __A, __m128 __B) {
   // CHECK-LABEL: @test_mm_maskz_add_ss
-  // CHECK: @llvm.x86.avx512.mask.add.ss.round
+  // CHECK-NOT: @llvm.x86.avx512.mask.add.ss.round
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: fadd float %{{.*}}, %{{.*}}
+  // CHECK: insertelement <4 x float> %{{.*}}, i32 0
+  // CHECK: and i32 {{.*}}, 1
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: br {{.*}}, {{.*}}, {{.*}}
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
   return _mm_maskz_add_ss(__U,__A,__B); 
 }
 __m128d test_mm_add_round_sd(__m128d __A, __m128d __B) {
@@ -2327,12 +2344,29 @@
 }
 __m128d test_mm_mask_add_sd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) {
   // CHECK-LABEL: @test_mm_mask_add_sd
-  // CHECK: @llvm.x86.avx512.mask.add.sd.round
+  // CHECK-NOT: @llvm.x86.avx512.mask.add.sd.round
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: fadd double %{{.*}}, %{{.*}}
+  // CHECK: insertelement <2 x double> {{.*}}, i32 0
+  // CHECK: and i32 {{.*}}, 1
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: br {{.*}}, {{.*}}, {{.*}}
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
   return _mm_mask_add_sd(__W,__U,__A,__B); 
 }
 __m128d test_mm_maskz_add_sd(__mmask8 __U, __m128d __A, __m128d __B) {
   // CHECK-LABEL: @test_mm_maskz_add_sd
-  // CHECK: @llvm.x86.avx512.mask.add.sd.round
+  // CHECK-NOT: @llvm.x86.avx512.mask.add.sd.round
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
+  // CHECK: fadd double %{{.*}}, %{{.*}}
+  // CHECK: insertelement <2 x double> {{.*}}, i32 0
+  // CHECK: and i32 {{.*}}, 1
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: br {{.*}}, {{.*}}, {{.*}}
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0
   return _mm_maskz_add_sd(__U,__A,__B); 
 }
 __m512d test_mm512_sub_round_pd(__m512d __A, __m512d __B) {
@@ -2410,12 +2444,29 @@
 }
 __m128 test_mm_mask_sub_ss(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) {
   // CHECK-LABEL: @test_mm_mask_sub_ss
-  // CHECK: @llvm.x86.avx512.mask.sub.ss.round
+  // CHECK-NOT: @llvm.x86.avx512.mask.sub.ss.round
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: fsub float %{{.*}}, %{{.*}}
+  // CHECK: insertelement <4 x float> {{.*}}, i32 0
+  // CHECK: and i32 {{.*}}, 1
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: br {{.*}}, {{.*}}, {{.*}}
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
   return _mm_mask_sub_ss(__W,__U,__A,__B); 
 }
 __m128 test_mm_maskz_sub_ss(__mmask8 __U, __m128 __A, __m128 __B) {
   // CHECK-LABEL: @test_mm_maskz_sub_ss
-  // CHECK: @llvm.x86.avx512.mask.sub.ss.round
+  // CHECK-NOT: @llvm.x86.avx512.mask.sub.ss.round
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: extractelement <4 x float> %{{.*}}, i32 0
+  // CHECK: fsub float %{{.*}}, %{{.*}}
+  // CHECK: insertelement <4 x float> {{.*}}, i32 0
+  // CHECK: and i32 {{.*}}, 1
+  // CHECK: icmp ne i32 %{{.*}}, 0
+  // CHECK: br {{.*}}, {{.*}}, {{.*}}
+  // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 0
   return _mm_maskz_sub_ss(__U,__A,__B); 
 }
 __m128d test_mm_sub_round_sd(__m128d __A, __m128d __B) {
@@ -2435,12 +2486,29 @@
 }
 __m128d test_mm_mask_sub_sd(__m128d __W, __mmask8 __U, __m1

[PATCH] D48100: Append new attributes to the end of an AttributeList.

2018-06-14 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur marked an inline comment as done.
Meinersbur added a comment.

In https://reviews.llvm.org/D48100#1132208, @aaron.ballman wrote:

> Can you also simplify `hasSameOverloadableAttrs()` in ASTReaderDecl.cpp 
> similar to what you did in SemaOverload.cpp (the copy seems spurious)?


Changed `hasSameOverloadableAttrs`. Apart to the comment about that the 
reversal of attributes being unimportant, it does not seem related to the new 
attribute order, though.
I made the iteration over `AEnableIfAttrs` and `BEnableIfAttrs` symmetric (and 
IMHO easier to understand), which unfortunately is not possible with a foreach 
(there are also a zip-iterators, but I am not sure how to check for different 
lengths without `std::distance` iterating over it separately).
I can change `compareEnableIfAttrs` as well on request.


Repository:
  rC Clang

https://reviews.llvm.org/D48100



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


[PATCH] D41168: [X86] Lowering X86 avx512 sqrt intrinsics to IR

2018-06-14 Thread Tomasz Krupa via Phabricator via cfe-commits
tkrupa updated this revision to Diff 151382.
tkrupa added a comment.

Fixed rounding mode calls.


Repository:
  rC Clang

https://reviews.llvm.org/D41168

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/sse-builtins.c
  test/CodeGen/sse2-builtins.c

Index: test/CodeGen/sse2-builtins.c
===
--- test/CodeGen/sse2-builtins.c
+++ test/CodeGen/sse2-builtins.c
@@ -1190,17 +1190,15 @@
 
 __m128d test_mm_sqrt_pd(__m128d A) {
   // CHECK-LABEL: test_mm_sqrt_pd
-  // CHECK: call <2 x double> @llvm.x86.sse2.sqrt.pd(<2 x double> %{{.*}})
+  // CHECK: call <2 x double> @llvm.sqrt.v2f64(<2 x double> %{{.*}})
   return _mm_sqrt_pd(A);
 }
 
 __m128d test_mm_sqrt_sd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_sqrt_sd
-  // CHECK: call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %{{.*}})
-  // CHECK: extractelement <2 x double> %{{.*}}, i32 0
-  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 0
-  // CHECK: extractelement <2 x double> %{{.*}}, i32 1
-  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 1
+  // CHECK: extractelement <2 x double> %{{.*}}, i64 0
+  // CHECK: call double @llvm.sqrt.f64(double {{.*}})
+  // CHECK: insertelement <2 x double> %{{.*}}, double %{{.*}}, i64 0
   return _mm_sqrt_sd(A, B);
 }
 
Index: test/CodeGen/sse-builtins.c
===
--- test/CodeGen/sse-builtins.c
+++ test/CodeGen/sse-builtins.c
@@ -639,13 +639,15 @@
 
 __m128 test_mm_sqrt_ps(__m128 x) {
   // CHECK-LABEL: test_mm_sqrt_ps
-  // CHECK: call <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float> {{.*}})
+  // CHECK: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
   return _mm_sqrt_ps(x);
 }
 
 __m128 test_sqrt_ss(__m128 x) {
   // CHECK: define {{.*}} @test_sqrt_ss
-  // CHECK: call <4 x float> @llvm.x86.sse.sqrt.ss
+  // CHECK: extractelement <4 x float> {{.*}}, i64 0
+  // CHECK: call float @llvm.sqrt.f32(float {{.*}})
+  // CHECK: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
   return _mm_sqrt_ss(x);
 }
 
Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -3506,49 +3506,49 @@
 }
 __m128d test_mm_mask_sqrt_pd(__m128d __W, __mmask8 __U, __m128d __A) {
   // CHECK-LABEL: @test_mm_mask_sqrt_pd
-  // CHECK: @llvm.x86.sse2.sqrt.pd
+  // CHECK: @llvm.sqrt.v2f64
   // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}
   return _mm_mask_sqrt_pd(__W,__U,__A); 
 }
 __m128d test_mm_maskz_sqrt_pd(__mmask8 __U, __m128d __A) {
   // CHECK-LABEL: @test_mm_maskz_sqrt_pd
-  // CHECK: @llvm.x86.sse2.sqrt.pd
+  // CHECK: @llvm.sqrt.v2f64
   // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}
   return _mm_maskz_sqrt_pd(__U,__A); 
 }
 __m256d test_mm256_mask_sqrt_pd(__m256d __W, __mmask8 __U, __m256d __A) {
   // CHECK-LABEL: @test_mm256_mask_sqrt_pd
-  // CHECK: @llvm.x86.avx.sqrt.pd.256
+  // CHECK: @llvm.sqrt.v4f64
   // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}}
   return _mm256_mask_sqrt_pd(__W,__U,__A); 
 }
 __m256d test_mm256_maskz_sqrt_pd(__mmask8 __U, __m256d __A) {
   // CHECK-LABEL: @test_mm256_maskz_sqrt_pd
-  // CHECK: @llvm.x86.avx.sqrt.pd.256
+  // CHECK: @llvm.sqrt.v4f64
   // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}}
   return _mm256_maskz_sqrt_pd(__U,__A); 
 }
 __m128 test_mm_mask_sqrt_ps(__m128 __W, __mmask8 __U, __m128 __A) {
   // CHECK-LABEL: @test_mm_mask_sqrt_ps
-  // CHECK: @llvm.x86.sse.sqrt.ps
+  // CHECK: @llvm.sqrt.v4f32
   // CHECK: select <4 x i1> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}
   return _mm_mask_sqrt_ps(__W,__U,__A); 
 }
 __m128 test_mm_maskz_sqrt_ps(__mmask8 __U, __m128 __A) {
   // CHECK-LABEL: @test_mm_maskz_sqrt_ps
-  // CHECK: @llvm.x86.sse.sqrt.ps
+  // CHECK: @llvm.sqrt.v4f32
   // CHECK: select <4 x i1> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}
   return _mm_maskz_sqrt_ps(__U,__A); 
 }
 __m256 test_mm256_mask_sqrt_ps(__m256 __W, __mmask8 __U, __m256 __A) {
   // CHECK-LABEL: @test_mm256_mask_sqrt_ps
-  // CHECK: @llvm.x86.avx.sqrt.ps.256
+  // CHECK: @llvm.sqrt.v8f32
   // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
   return _mm256_mask_sqrt_ps(__W,__U,__A); 
 }
 __m256 test_mm256_maskz_sqrt_ps(__mmask8 __U, __m256 __A) {
   // CHECK-LABEL: @test_mm256_maskz_sqrt_ps
-  // CHECK: @llvm.x86.avx.sqrt.ps.256
+  // CHECK: @llvm.sqrt.v8f32
   // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
   return _mm256_maskz_sqrt_ps(__U,__A); 
 }
Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -5,84 +

r334747 - [CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

2018-06-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jun 14 11:20:04 2018
New Revision: 334747

URL: http://llvm.org/viewvc/llvm-project?rev=334747&view=rev
Log:
[CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

On MacOS, if CMAKE_OSX_SYSROOT is used and the user has command line tools
installed, we currently get the include path for libxml2 as
/usr/include/libxml2, instead of ${CMAKE_OSX_SYSROOT}/usr/include/libxml2.

Make it consistent on MacOS by prefixing ${CMAKE_OSX_SYSROOT} when
possible.

rdar://problem/41103601

Modified:
cfe/trunk/tools/c-index-test/CMakeLists.txt

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=334747&r1=334746&r2=334747&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Thu Jun 14 11:20:04 2018
@@ -40,7 +40,11 @@ set_target_properties(c-index-test
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
+include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
+  else()
+include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+  endif()
   target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
 endif()
 


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


r334751 - [X86] Add inline assembly versions of _InterlockedExchange_HLEAcquire/Release and _InterlockedCompareExchange_HLEAcquire/Release for MSVC compatibility.

2018-06-14 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 14 11:43:52 2018
New Revision: 334751

URL: http://llvm.org/viewvc/llvm-project?rev=334751&view=rev
Log:
[X86] Add inline assembly versions of _InterlockedExchange_HLEAcquire/Release 
and _InterlockedCompareExchange_HLEAcquire/Release for MSVC compatibility.

Clang/LLVM doesn't have a way to pass an HLE hint through to the X86 backend to 
emit HLE prefixed instructions. So this is a good short term fix.

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

Modified:
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/test/CodeGen/bitscan-builtins.c
cfe/trunk/test/CodeGen/ms-intrinsics.c

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=334751&r1=334750&r2=334751&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Thu Jun 14 11:43:52 2018
@@ -380,4 +380,88 @@ _writegsbase_u64(unsigned long long __V)
 #include 
 #endif
 
+#ifdef _MSC_VER
+/* Define the default attributes for these intrinsics */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**\
+|* Interlocked Exchange HLE
+\**/
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedExchange_HLEAcquire(long volatile *_Target, long _Value) {
+  __asm__ __volatile__(".byte 0xf2 ; lock ; xchg %0, %1"
+   : "+r" (_Value), "+m" (*_Target) :: "memory");
+  return _Value;
+}
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedExchange_HLERelease(long volatile *_Target, long _Value) {
+  __asm__ __volatile__(".byte 0xf3 ; lock ; xchg %0, %1"
+   : "+r" (_Value), "+m" (*_Target) :: "memory");
+  return _Value;
+}
+#endif
+#if defined(__x86_64__)
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedExchange64_HLEAcquire(__int64 volatile *_Target, __int64 _Value) {
+  __asm__ __volatile__(".byte 0xf2 ; lock ; xchg %0, %1"
+   : "+r" (_Value), "+m" (*_Target) :: "memory");
+  return _Value;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedExchange64_HLERelease(__int64 volatile *_Target, __int64 _Value) {
+  __asm__ __volatile__(".byte 0xf3 ; lock ; xchg %0, %1"
+   : "+r" (_Value), "+m" (*_Target) :: "memory");
+  return _Value;
+}
+#endif
+/**\
+|* Interlocked Compare Exchange HLE
+\**/
+#if defined(__i386__) || defined(__x86_64__)
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange_HLEAcquire(long volatile *_Destination,
+  long _Exchange, long _Comparand) {
+  __asm__ __volatile__(".byte 0xf2 ; lock ; cmpxchg %2, %1"
+   : "+a" (_Comparand), "+m" (*_Destination)
+   : "r" (_Exchange) : "memory");
+  return _Comparand;
+}
+static __inline__ long __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange_HLERelease(long volatile *_Destination,
+  long _Exchange, long _Comparand) {
+  __asm__ __volatile__(".byte 0xf3 ; lock ; cmpxchg %2, %1"
+   : "+a" (_Comparand), "+m" (*_Destination)
+   : "r" (_Exchange) : "memory");
+  return _Comparand;
+}
+#endif
+#if defined(__x86_64__)
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange64_HLEAcquire(__int64 volatile *_Destination,
+  __int64 _Exchange, __int64 _Comparand) {
+  __asm__ __volatile__(".byte 0xf2 ; lock ; cmpxchg %2, %1"
+   : "+a" (_Comparand), "+m" (*_Destination)
+   : "r" (_Exchange) : "memory");
+  return _Comparand;
+}
+static __inline__ __int64 __DEFAULT_FN_ATTRS
+_InterlockedCompareExchange64_HLERelease(__int64 volatile *_Destination,
+  __int64 _Exchange, __int64 _Comparand) {
+  __asm__ __volatile__(".byte 0xf3 ; lock ; cmpxchg %2, %1"
+   : "+a" (_Comparand), "+m" (*_Destination)
+   : "r" (_Exchange) : "memory");
+  return _Comparand;
+}
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif /* _MSC_VER */
+
 #endif /* __IMMINTRIN_H */

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=334751&r1=334750&r2=334751&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Jun 14 11:43:52 2018
@@ -170,12 +170,6 @@ void __cd

[PATCH] D47672: [Headers] Add _Interlocked*_HLEAcquire/_HLERelease

2018-06-14 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334751: [X86] Add inline assembly versions of 
_InterlockedExchange_HLEAcquire/Release… (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47672?vs=151100&id=151390#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47672

Files:
  cfe/trunk/lib/Headers/immintrin.h
  cfe/trunk/lib/Headers/intrin.h
  cfe/trunk/test/CodeGen/bitscan-builtins.c
  cfe/trunk/test/CodeGen/ms-intrinsics.c

Index: cfe/trunk/test/CodeGen/bitscan-builtins.c
===
--- cfe/trunk/test/CodeGen/bitscan-builtins.c
+++ cfe/trunk/test/CodeGen/bitscan-builtins.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
 
 // PR33722
-// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -D_MSC_VER -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - %s | FileCheck %s
 
 #include 
 
Index: cfe/trunk/test/CodeGen/ms-intrinsics.c
===
--- cfe/trunk/test/CodeGen/ms-intrinsics.c
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c
@@ -455,6 +455,55 @@
 
 #endif
 
+#if defined(__i386__) || defined(__x86_64__)
+long test_InterlockedExchange_HLEAcquire(long volatile *Target, long Value) {
+// CHECK-INTEL: define{{.*}} i32 @test_InterlockedExchange_HLEAcquire(i32*{{[a-z_ ]*}}%Target, i32{{[a-z_ ]*}}%Value)
+// CHECK-INTEL: call i32 asm sideeffect ".byte 0xf2 ; lock ; xchg $0, $1", "=r,=*m,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Target, i32 %Value, i32* %Target)
+  return _InterlockedExchange_HLEAcquire(Target, Value);
+}
+long test_InterlockedExchange_HLERelease(long volatile *Target, long Value) {
+// CHECK-INTEL: define{{.*}} i32 @test_InterlockedExchange_HLERelease(i32*{{[a-z_ ]*}}%Target, i32{{[a-z_ ]*}}%Value)
+// CHECK-INTEL: call i32 asm sideeffect ".byte 0xf3 ; lock ; xchg $0, $1", "=r,=*m,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Target, i32 %Value, i32* %Target)
+  return _InterlockedExchange_HLERelease(Target, Value);
+}
+long test_InterlockedCompareExchange_HLEAcquire(long volatile *Destination,
+long Exchange, long Comparand) {
+// CHECK-INTEL: define{{.*}} i32 @test_InterlockedCompareExchange_HLEAcquire(i32*{{[a-z_ ]*}}%Destination, i32{{[a-z_ ]*}}%Exchange, i32{{[a-z_ ]*}}%Comparand)
+// CHECK-INTEL: call i32 asm sideeffect ".byte 0xf2 ; lock ; cmpxchg $2, $1", "={ax},=*m,r,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Destination, i32 %Exchange, i32 %Comparand, i32* %Destination)
+  return _InterlockedCompareExchange_HLEAcquire(Destination, Exchange, Comparand);
+}
+long test_InterlockedCompareExchange_HLERelease(long volatile *Destination,
+long Exchange, long Comparand) {
+// CHECK-INTEL: define{{.*}} i32 @test_InterlockedCompareExchange_HLERelease(i32*{{[a-z_ ]*}}%Destination, i32{{[a-z_ ]*}}%Exchange, i32{{[a-z_ ]*}}%Comparand)
+// CHECK-INTEL: call i32 asm sideeffect ".byte 0xf3 ; lock ; cmpxchg $2, $1", "={ax},=*m,r,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i32* %Destination, i32 %Exchange, i32 %Comparand, i32* %Destination)
+  return _InterlockedCompareExchange_HLERelease(Destination, Exchange, Comparand);
+}
+#endif
+#if defined(__x86_64__)
+__int64 test_InterlockedExchange64_HLEAcquire(__int64 volatile *Target, __int64 Value) {
+// CHECK-X64: define{{.*}} i64 @test_InterlockedExchange64_HLEAcquire(i64*{{[a-z_ ]*}}%Target, i64{{[a-z_ ]*}}%Value)
+// CHECK-X64: call i64 asm sideeffect ".byte 0xf2 ; lock ; xchg $0, $1", "=r,=*m,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %Target, i64 %Value, i64* %Target)
+  return _InterlockedExchange64_HLEAcquire(Target, Value);
+}
+__int64 test_InterlockedExchange64_HLERelease(__int64 volatile *Target, __int64 Value) {
+// CHECK-X64: define{{.*}} i64 @test_InterlockedExchange64_HLERelease(i64*{{[a-z_ ]*}}%Target, i64{{[a-z_ ]*}}%Value)
+// CHECK-X64: call i64 asm sideeffect ".byte 0xf3 ; lock ; xchg $0, $1", "=r,=*m,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %Target, i64 %Value, i64* %Target)
+  return _InterlockedExchange64_HLERelease(Target, Value);
+}
+__int64 test_InterlockedCompareExchange64_HLEAcquire(__int64 volatile *Destination,
+ __int64 Exchange, __int64 Comparand) {
+// CHECK-X64: define{{.*}} i64 @test_InterlockedCompareExchange64_HLEAcquire(i64*{{[a-z_ ]*}}%Destination, i64{{[a-z_ ]*}}%Exchange, i64{{[a-z_ ]*}}%Comparand)
+// CHECK-X64: call i64 asm sideeffect ".byte 0xf2 ; lock ; cmpxchg $2, $1", "={ax},=*m,r,0,*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i64* %Destination, i64 %Exchange, i64 %Comparand, i64* %Destination)
+  return _Interlo

r334741 - [X86] Lowering Mask Scalar intrinsics to native IR (Clang part)

2018-06-14 Thread Tomasz Krupa via cfe-commits
Author: tkrupa
Date: Thu Jun 14 10:36:23 2018
New Revision: 334741

URL: http://llvm.org/viewvc/llvm-project?rev=334741&view=rev
Log:
[X86] Lowering Mask Scalar intrinsics to native IR (Clang part)

Summary: Lowering add, sub, mul, and div mask scalar intrinsic calls
to native IR.

Reviewers: craig.topper, RKSimon, spatel, sroland

Reviewed By: craig.topper

Subscribers: cfe-commits

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


Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334741&r1=334740&r2=334741&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 14 10:36:23 2018
@@ -9982,6 +9982,35 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_pternlogq256_maskz:
 return EmitX86Ternlog(*this, /*ZeroMask*/true, Ops);
 
+  case X86::BI__builtin_ia32_divss_round_mask:
+  case X86::BI__builtin_ia32_divsd_round_mask: {
+Intrinsic::ID ID;
+switch (BuiltinID) {
+default: llvm_unreachable("Unsupported intrinsic!");
+case X86::BI__builtin_ia32_divss_round_mask:
+  ID = Intrinsic::x86_avx512_mask_div_ss_round; break;
+case X86::BI__builtin_ia32_divsd_round_mask:
+  ID = Intrinsic::x86_avx512_mask_div_sd_round; break;
+}
+Function *Intr = CGM.getIntrinsic(ID);
+
+// If round parameter is not _MM_FROUND_CUR_DIRECTION, don't lower.
+if (cast(Ops[4])->getZExtValue() != (uint64_t)4)
+  return Builder.CreateCall(Intr, Ops);
+
+Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0);
+Value *B = Builder.CreateExtractElement(Ops[1], (uint64_t)0);
+Value *C = Builder.CreateExtractElement(Ops[2], (uint64_t)0);
+Value *Mask = Ops[3];
+Value *Div = Builder.CreateFDiv(A, B);
+llvm::VectorType *MaskTy = llvm::VectorType::get(Builder.getInt1Ty(),
+ 
cast(Mask->getType())->getBitWidth());
+Mask = Builder.CreateBitCast(Mask, MaskTy);
+Mask = Builder.CreateExtractElement(Mask, (uint64_t)0);
+Value *Select = Builder.CreateSelect(Mask, Div, C);
+return Builder.CreateInsertElement(Ops[0], Select, (uint64_t)0);
+  }
+
   // 3DNow!
   case X86::BI__builtin_ia32_pswapdsf:
   case X86::BI__builtin_ia32_pswapdsi: {

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=334741&r1=334740&r2=334741&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jun 14 10:36:23 2018
@@ -1962,20 +1962,16 @@ _mm512_maskz_abs_epi32 (__mmask16 __U, _
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_add_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) {
-  return (__m128) __builtin_ia32_addss_round_mask ((__v4sf) __A,
-(__v4sf) __B,
-(__v4sf) __W,
-(__mmask8) __U,
-_MM_FROUND_CUR_DIRECTION);
+  __A = _mm_add_ss(__A, __B);
+  __A[0] = (__U & 1) ? __A[0] : __W[0];
+  return __A;
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_maskz_add_ss(__mmask8 __U,__m128 __A, __m128 __B) {
-  return (__m128) __builtin_ia32_addss_round_mask ((__v4sf) __A,
-(__v4sf) __B,
-(__v4sf)  _mm_setzero_ps (),
-(__mmask8) __U,
-_MM_FROUND_CUR_DIRECTION);
+  __A = _mm_add_ss(__A, __B);
+  __A[0] = (__U & 1) ? __A[0] : 0;
+  return __A;
 }
 
 #define _mm_add_round_ss(A, B, R) \
@@ -1998,20 +1994,16 @@ _mm_maskz_add_ss(__mmask8 __U,__m128 __A
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_mask_add_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) {
-  return (__m128d) __builtin_ia32_addsd_round_mask ((__v2df) __A,
-(__v2df) __B,
-(__v2df) __W,
-(__mmask8) __U,
-_MM_FROUND_CUR_DIRECTION);
+  __A = _mm_add_sd(__A, __B);
+  __A[0] = (__U & 1) ? __A[0] : __W[0];
+  return __A;
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_maskz_add_sd(__mmask8 __U,__m128d __A, __m128d __B) {
-  return (__m128d) __builtin_ia32_addsd_round_mask ((__v2df) __A,
-(__v2df) __B,
-(__v2df)  _mm_setzero_pd (),
-(__mmask8) __U,
-_MM_FROUND_CUR_DIRECTION);
+  __A = _mm_add_sd(__A, __B);
+  __A[0] = (__U & 1) ? __A[0] : 0;
+  return __A;
 }
 #define _mm_add_round_sd(A, B, R) \
   (__m128d)__builtin_ia32_addsd_round_mask((__v2df)(__m128d)(A), \
@@ -2089,20 +2081,16 @@ _mm512_maskz_add_ps(__mmask16 __U, __m51
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_sub_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) {
-  r

[PATCH] D41168: [X86] Lowering X86 avx512 sqrt intrinsics to IR

2018-06-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D41168



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


[PATCH] D48187: [Intrinsics] Add/move some builtin declarations in intrin.h to get ms-intrinsics.c to not issue warnings

2018-06-14 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added a reviewer: rnk.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.

__ud2 and __int2c were missing declarations entirely. And the bitscans were 
only under __x86_64__, but they seem to be in BuiltinsARM.def as well and are 
tested by ms_intrinsics.c


https://reviews.llvm.org/D48187

Files:
  lib/Headers/intrin.h


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -83,6 +83,7 @@
 void __incfsword(unsigned long);
 unsigned long __indword(unsigned short);
 void __indwordstring(unsigned short, unsigned long *, unsigned long);
+void __int2c(void);
 void __invlpg(void *);
 unsigned short __inword(unsigned short);
 void __inwordstring(unsigned short, unsigned short *, unsigned long);
@@ -140,6 +141,7 @@
 void __svm_vmload(size_t);
 void __svm_vmrun(size_t);
 void __svm_vmsave(size_t);
+void __ud2(void);
 unsigned __int64 __ull_rshift(unsigned __int64, int);
 void __vmx_off(void);
 void __vmx_vmptrst(unsigned __int64 *);
@@ -246,10 +248,6 @@
 void __writegsdword(unsigned long, unsigned long);
 void __writegsqword(unsigned long, unsigned __int64);
 void __writegsword(unsigned long, unsigned short);
-static __inline__
-unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
-static __inline__
-unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 unsigned char _bittest64(__int64 const *, __int64);
 unsigned char _bittestandcomplement64(__int64 *, __int64);
 unsigned char _bittestandreset64(__int64 *, __int64);
@@ -304,6 +302,11 @@
 #if defined(__x86_64__) || defined(__arm__)
 
 static __inline__
+unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+static __inline__
+unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
+
+static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__
 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -83,6 +83,7 @@
 void __incfsword(unsigned long);
 unsigned long __indword(unsigned short);
 void __indwordstring(unsigned short, unsigned long *, unsigned long);
+void __int2c(void);
 void __invlpg(void *);
 unsigned short __inword(unsigned short);
 void __inwordstring(unsigned short, unsigned short *, unsigned long);
@@ -140,6 +141,7 @@
 void __svm_vmload(size_t);
 void __svm_vmrun(size_t);
 void __svm_vmsave(size_t);
+void __ud2(void);
 unsigned __int64 __ull_rshift(unsigned __int64, int);
 void __vmx_off(void);
 void __vmx_vmptrst(unsigned __int64 *);
@@ -246,10 +248,6 @@
 void __writegsdword(unsigned long, unsigned long);
 void __writegsqword(unsigned long, unsigned __int64);
 void __writegsword(unsigned long, unsigned short);
-static __inline__
-unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
-static __inline__
-unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 unsigned char _bittest64(__int64 const *, __int64);
 unsigned char _bittestandcomplement64(__int64 *, __int64);
 unsigned char _bittestandreset64(__int64 *, __int64);
@@ -304,6 +302,11 @@
 #if defined(__x86_64__) || defined(__arm__)
 
 static __inline__
+unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
+static __inline__
+unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
+
+static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__
 __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48188: [SPIR] Prevent SPIR targets from using half conversion intrinsics

2018-06-14 Thread Stephen McGroarty via Phabricator via cfe-commits
smcgro created this revision.
smcgro added reviewers: SjoerdMeijer, rsmith.
Herald added a subscriber: cfe-commits.

The SPIR target currently allows for half precision floating point types to use 
the LLVM intrinsic functions to convert to floats and doubles. This is illegal 
in SPIR as the only intrinsic allowed by SPIR is memcpy, as per section 3 of 
the SPIR specification. This lead to an assert being hit when attempting to use 
a constant or literal _Float16 type in a comparison operation on a SPIR or 
SPIR64 target. This patch prevents SPIR targets from using these intrinsics and 
marks SPIR targets as having a legal half type.


Repository:
  rC Clang

https://reviews.llvm.org/D48188

Files:
  lib/Basic/Targets/SPIR.h
  test/CodeGen/spir-half-type.cpp

Index: test/CodeGen/spir-half-type.cpp
===
--- /dev/null
+++ test/CodeGen/spir-half-type.cpp
@@ -0,0 +1,148 @@
+// RUN: %clang_cc1 -O0 -triple spir -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O0 -triple spir64 -emit-llvm %s -o - | FileCheck %s
+
+// This file tests that using the _Float16 type with the spir target will not use the llvm intrinsics but instead will use the half arithmetic instructions directly.
+
+// Previously attempting to use a constant _Float16 with a comparison instruction when the target is spir or spir64 lead to an assert being hit.
+bool fcmp_const() {
+  _Float16 a = 0.0f16;
+  const _Float16 b = 1.0f16;
+
+  // CHECK-NOT: llvm.convert.to.fp16
+  // CHECK-NOT: llvm.convert.from.fp16
+
+  // CHECK: [[REG1:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp olt half [[REG1]], 0xH3C00
+
+  // CHECK: [[REG2:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp olt half [[REG2]], 0xH4000
+
+  // CHECK: [[REG3:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp ogt half [[REG3]], 0xH3C00
+
+  // CHECK: [[REG4:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp ogt half [[REG4]], 0xH4200
+
+  // CHECK: [[REG5:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp oeq half [[REG5]], 0xH3C00
+
+  // CHECK: [[REG7:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp oeq half [[REG7]], 0xH4400
+
+  // CHECK: [[REG8:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp une half [[REG8]], 0xH3C00
+
+  // CHECK: [[REG9:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp une half [[REG9]], 0xH4500
+
+  // CHECK: [[REG10:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp ole half [[REG10]], 0xH3C00
+
+  // CHECK: [[REG11:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp ole half [[REG11]], 0xH4600
+
+  // CHECK: [[REG12:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp oge half [[REG12]], 0xH3C00
+
+  // CHECK: [[REG13:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: fcmp oge half [[REG13]], 0xH4700
+  return a < b || a < 2.0f16 ||
+ a > b || a > 3.0f16 ||
+ a == b || a == 4.0f16 ||
+ a != b || a != 5.0f16 ||
+ a <= b || a <= 6.0f16 ||
+ a >= b || a >= 7.0f16;
+}
+
+bool fcmp() {
+  _Float16 a = 0.0f16;
+  _Float16 b = 1.0f16;
+
+  // CHECK-NOT: llvm.convert.to.fp16
+  // CHECK-NOT: llvm.convert.from.fp16
+  // CHECK: [[REG1:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG2:%.*]] = load half, half* %b, align 2
+  // CHECK-NEXT: fcmp olt half [[REG1]], [[REG2]]
+
+  // CHECK: [[REG3:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG4:%.*]] = load half, half* %b, align 2
+  // CHECK-NEXT: fcmp ogt half [[REG3]], [[REG4]]
+
+  // CHECK: [[REG5:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG6:%.*]] = load half, half* %b, align 2
+  // CHECK-NEXT: fcmp oeq half [[REG5]], [[REG6]]
+
+  // CHECK: [[REG7:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG8:%.*]] = load half, half* %b, align 2
+  // CHECK-NEXT: fcmp une half [[REG7]], [[REG8]]
+
+  // CHECK: [[REG7:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG8:%.*]] = load half, half* %b, align 2
+  // CHECK-NEXT: fcmp ole half [[REG7]], [[REG8]]
+
+  // CHECK: [[REG7:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG8:%.*]] = load half, half* %b, align 2
+  // CHECK-NEXT: fcmp oge half [[REG7]], [[REG8]]
+  return a < b ||
+ a > b ||
+ a == b ||
+ a != b ||
+ a <= b ||
+ a >= b;
+}
+
+_Float16 fadd() {
+  _Float16 a = 1.0f16;
+  const _Float16 b = 2.0f16;
+
+  // CHECK-NOT: llvm.convert.to.fp16
+  // CHECK-NOT: llvm.convert.from.fp16
+
+  // CHECK: [[REG1:%.*]] = load half, half* %a, align 2
+  // CHECK-NEXT: [[REG2:%.*]] = fadd half [[REG1]], 0xH4000
+  // CHECK-NEXT: [[REG3:%.*]] = fadd half [[REG2]], 0xH4200
+  // CHECK-NEXT: ret half [[REG3]]
+  return a + b + 3.0f16;
+}
+
+_Float16 fsub() {
+  _Float16 a = 1.0f16;
+  const _Float16 b = 2.0f16;
+
+  // CHECK-NOT: llvm.convert.to.fp16
+  // CHECK-NOT: llvm.convert.from.fp16
+
+  // CHECK: [[REG1:%.*]] = load half, half* %a, align 2
+  // 

r334763 - [c++17] If a class inherits virtual functions from a base class, it is

2018-06-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun 14 13:03:22 2018
New Revision: 334763

URL: http://llvm.org/viewvc/llvm-project?rev=334763&view=rev
Log:
[c++17] If a class inherits virtual functions from a base class, it is
not an aggregtae.

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=334763&r1=334762&r2=334763&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Jun 14 13:03:22 2018
@@ -259,9 +259,13 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
 // C++ [class.virtual]p1:
 //   A class that declares or inherits a virtual function is called a 
 //   polymorphic class.
-if (BaseClassDecl->isPolymorphic())
+if (BaseClassDecl->isPolymorphic()) {
   data().Polymorphic = true;
 
+  //   An aggregate is a class with [...] no virtual functions.
+  data().Aggregate = false;
+}
+
 // C++0x [class]p7:
 //   A standard-layout class is a class that: [...]
 //-- has no non-standard-layout base classes

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp?rev=334763&r1=334762&r2=334763&view=diff
==
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp Thu Jun 14 
13:03:22 2018
@@ -111,6 +111,11 @@ struct NonAggr6 { // expected-note 3 {{c
 };
 NonAggr6 na6 = { 42 }; // expected-error {{no matching constructor for 
initialization of 'NonAggr6'}}
 
+struct NonAggr7 : NonAggr6 { // expected-note 3 {{candidate constructor}}
+  int n;
+};
+NonAggr7 na7 = {{}, 42}; // expected-error {{no matching constructor for 
initialization of 'NonAggr7'}}
+
 struct DefaultedAggr {
   int n;
 


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


[PATCH] D46915: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

2018-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:89
+  // corresponding unsaturated types.
+  unsigned char ShortAccumFBits, ShortAccumIBits;
+  unsigned char AccumFBits, AccumIBits;

ebevhan wrote:
> leonardchan wrote:
> > ebevhan wrote:
> > > leonardchan wrote:
> > > > ebevhan wrote:
> > > > > leonardchan wrote:
> > > > > > ebevhan wrote:
> > > > > > > I suspect it's still possible to calculate the ibits based on the 
> > > > > > > fbits, even for _Accum.
> > > > > > > 
> > > > > > > Are the unsigned values needed? The fbits for unsigned _Fract are 
> > > > > > > the same as for signed _Fract if SameFBits is set, and +1 
> > > > > > > otherwise. The same should go for unsigned _Accum, but I don't 
> > > > > > > think it's entirely clear how this affects the integral part.
> > > > > > Similar to the previous comment, if we choose to make SameFBits 
> > > > > > dependent on/controlled by the target, then I think it would be 
> > > > > > better for the target to explicitly specify the integral bits since 
> > > > > > there could be some cases where there may be padding (such as for 
> > > > > > unsigned _Accum types if this flag is set), and in this case, I 
> > > > > > think it should be explicit that the `bit_width != IBits + FBits`.
> > > > > > 
> > > > > > We also can't fill in that padding for the unsigned _Accum types as 
> > > > > > an extra integral bit since the standard says that `"each signed 
> > > > > > accum type has at least as many integral bits as its corresponding 
> > > > > > unsigned accum type".`
> > > > > > 
> > > > > > For the unsigned _Fract values, I think we can get rid of them if 
> > > > > > we choose to keep the flag instead, but it would no longer apply to 
> > > > > > unsigned _Accum types since it would allow for extra padding in 
> > > > > > these types and would conflict with the logic of `bit_width == 
> > > > > > IBits + FBits`
> > > > > > 
> > > > > > For now, I actually think the simplest option is to keep these 
> > > > > > target properties, but have the target override them individually, 
> > > > > > with checks to make sure the values adhere to the standard.
> > > > > Is it not the case that `bitwidth != IBits + FBits` for signed types 
> > > > > only? Signed types require a sign bit (which is neither a fractional 
> > > > > bit nor an integral bit, according to spec) but unsigned types do 
> > > > > not, and if IBits and FBits for the signed and unsigned types are the 
> > > > > same, the MSB is simply a padding bit, at least for _Accum (for 
> > > > > _Fract everything above the fbits is padding). 
> > > > > 
> > > > > My reasoning for keeping the number of configurable values down was 
> > > > > to limit the number of twiddly knobs to make the implementation 
> > > > > simpler. Granting a lot of freedom is nice, but I suspect that it 
> > > > > will be quite hard to get the implementation working properly for 
> > > > > every valid configuration. I also don't really see much of a reason 
> > > > > for `FBits != UFBits` in general. I know the spec gives a 
> > > > > recommendation to implement it that way, but I think the benefit of 
> > > > > normalizing the signed and unsigned representations outweighs the 
> > > > > lost bit in the unsigned type.
> > > > > 
> > > > > It's hard to say what the differences are beyond that since I'm not 
> > > > > sure how you plan on treating padding bits. In our implementation, 
> > > > > padding bits (the MSB in all of the unsigned types for us) after any 
> > > > > operation are zeroed.
> > > > I see. The implementation would be much simpler this way. The initial 
> > > > idea was to treat the padding bits as "don't care" bits where we would 
> > > > mask only the data bits when doing operations like comparisons that 
> > > > look at the whole integer.
> > > That does work, but for binary operations it means you might need 
> > > multiple maskings per operation. If you mask after every operation 
> > > instead, you only need one. In our implementation, the only padding bit 
> > > we have is the MSB in the unsigned types. We simply insert a 'bit clear' 
> > > after every operation that produces an unsigned type (with some 
> > > exceptions).
> > > 
> > > The E-C spec says that padding bits are 'unspecified', but 
> > > implementation-wise, they have to be defined to something in order to 
> > > operate on them. So long as you ensure that it is never possible to 
> > > observe anything but zero in those bits from a program perspective, most 
> > > operations just work. Naturally, there are ways to subvert this design. 
> > > If you have a `signed _Fract *` and cast it to an `unsigned _Fract *` and 
> > > the values happen to be negative, the padding bit will be set and you'll 
> > > get exciting behavior.
> > > 
> > > Although... I just realized that the topmost half of the `_Fract`s in 
> > > your configuration is all padding. That might make things a bit more 
>

[PATCH] D47953: [builtin] Add bitfield support for __builtin_dump_struct

2018-06-14 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

ping :) @aaron.ballman


Repository:
  rC Clang

https://reviews.llvm.org/D47953



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


[PATCH] D47953: [builtin] Add bitfield support for __builtin_dump_struct

2018-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This seems to be missing tests.


Repository:
  rC Clang

https://reviews.llvm.org/D47953



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


r334773 - [X86] Rename __builtin_ia32_pslldqi128 to __builtin_ia32_pslldqi128_byteshift and similar for other sizes. Remove the multiply by 8 from the header files.

2018-06-14 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 14 15:02:35 2018
New Revision: 334773

URL: http://llvm.org/viewvc/llvm-project?rev=334773&view=rev
Log:
[X86] Rename __builtin_ia32_pslldqi128 to __builtin_ia32_pslldqi128_byteshift 
and similar for other sizes. Remove the multiply by 8 from the header files.

The previous names took the shift amount in bits to match gcc and required a 
multiply by 8 in the header. This creates a misleading error message when we 
check the range of the immediate to the builtin since the allowed range also 
got multiplied by 8.

This commit changes the builtins to use a byte shift amount to match the 
underlying instruction and the Intel intrinsic.

Fixes the remaining issue from PR37795.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334773&r1=334772&r2=334773&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun 14 15:02:35 2018
@@ -363,8 +363,8 @@ TARGET_BUILTIN(__builtin_ia32_psrlqi128,
 TARGET_BUILTIN(__builtin_ia32_psrawi128, "V8sV8si", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psradi128, "V4iV4ii", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaddwd128, "V4iV8sV8s", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_pslldqi128, "V2LLiV2LLiIi", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_psrldqi128, "V2LLiV2LLiIi", "nc", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pslldqi128_byteshift, "V2LLiV2LLiIi", "nc", 
"sse2")
+TARGET_BUILTIN(__builtin_ia32_psrldqi128_byteshift, "V2LLiV2LLiIi", "nc", 
"sse2")
 
 TARGET_BUILTIN(__builtin_ia32_monitor, "vv*UiUi", "n", "sse3")
 TARGET_BUILTIN(__builtin_ia32_mwait, "vUiUi", "n", "sse3")
@@ -613,7 +613,7 @@ TARGET_BUILTIN(__builtin_ia32_psignw256,
 TARGET_BUILTIN(__builtin_ia32_psignd256, "V8iV8iV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psllwi256, "V16sV16si", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psllw256, "V16sV16sV8s", "nc", "avx2")
-TARGET_BUILTIN(__builtin_ia32_pslldqi256, "V4LLiV4LLiIi", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pslldqi256_byteshift, "V4LLiV4LLiIi", "nc", 
"avx2")
 TARGET_BUILTIN(__builtin_ia32_pslldi256, "V8iV8ii", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pslld256, "V8iV8iV4i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psllqi256, "V4LLiV4LLii", "nc", "avx2")
@@ -622,7 +622,7 @@ TARGET_BUILTIN(__builtin_ia32_psrawi256,
 TARGET_BUILTIN(__builtin_ia32_psraw256, "V16sV16sV8s", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psradi256, "V8iV8ii", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrad256, "V8iV8iV4i", "nc", "avx2")
-TARGET_BUILTIN(__builtin_ia32_psrldqi256, "V4LLiV4LLiIi", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_psrldqi256_byteshift, "V4LLiV4LLiIi", "nc", 
"avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlwi256, "V16sV16si", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlw256, "V16sV16sV8s", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrldi256, "V8iV8ii", "nc", "avx2")
@@ -1399,8 +1399,8 @@ TARGET_BUILTIN(__builtin_ia32_psraw512,
 TARGET_BUILTIN(__builtin_ia32_psrawi512, "V32sV32si", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlw512, "V32sV32sV8s", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlwi512, "V32sV32si", "nc", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pslldqi512, "V8LLiV8LLiIi", "nc", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_psrldqi512, "V8LLiV8LLiIi", "nc", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pslldqi512_byteshift, "V8LLiV8LLiIi", "nc", 
"avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psrldqi512_byteshift, "V8LLiV8LLiIi", "nc", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load128_mask, "V4iV4i*V4iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load256_mask, "V8iV8i*V8iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load512_mask, "V16iV16iC*V16iUs", "n", 
"avx512f")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334773&r1=334772&r2=334773&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 14 15:02:35 2018
@@ -9690,11 +9690,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
"vperm");
   }
 
-  case X86::BI__builtin_ia32_pslldqi128:
-  case X86::BI__builtin_ia32_pslldqi256:
-  case X86::BI__builtin_ia32_pslldqi512: {
-// Shift value is in bits so divide by 8.
-unsigned ShiftVal = cast(Ops[1])->getZExtValue() >> 3;
+  case X86::BI__builtin_ia32_pslldqi128_byteshift:
+  case X86::B

[PATCH] D46915: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

2018-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 151431.
leonardchan added a comment.

Removed FractFBits property. Fractional bits for _Fract types are now one less 
the _Fract width unless `SameFBits` is specified. In that case, the number of 
FBits in unsigned _Fract is the same as that of signed _Fract, leaving one 
padding bit that would've been the sign.


Repository:
  rC Clang

https://reviews.llvm.org/D46915

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Expr.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TargetInfo.h
  include/clang/Driver/Options.td
  include/clang/Lex/LiteralSupport.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/Type.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Index/USRGeneration.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_bit_widths.c
  test/Frontend/fixed_point_declarations.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_same_fbits.c
  test/Frontend/fixed_point_validation.c
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -305,6 +305,10 @@
 K = CXCursor_IntegerLiteral;
 break;
 
+  case Stmt::FixedPointLiteralClass:
+llvm_unreachable("No cursor for FixedPointLiteralClass");
+break;
+
   case Stmt::FloatingLiteralClass:
 K = CXCursor_FloatingLiteral;
 break;
Index: test/Frontend/fixed_point_validation.c
===
--- /dev/null
+++ test/Frontend/fixed_point_validation.c
@@ -0,0 +1,19 @@
+// RUN: %clang -ffixed-point -S -emit-llvm -o - %s | lli -force-interpreter=true
+
+// Run simple validation tests
+
+#define assert(b) if (!(b)) { return 1; }
+
+int main(){
+  short _Accum s_accum = 0.0hk;
+  short _Accum s_accum2 = 2.0hk;
+  short _Fract s_fract = 0.999hr;
+  short _Fract s_fract2 = -0.999hr;
+
+  assert(s_accum == 0);
+
+  s_accum = s_accum2;
+
+  assert(s_accum == s_accum2);
+  assert(s_accum == 2);
+}
Index: test/Frontend/fixed_point_same_fbits.c
===
--- /dev/null
+++ test/Frontend/fixed_point_same_fbits.c
@@ -0,0 +1,28 @@
+// RUN: %clang -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang -ffixed-point -fsame-fbits -S -emit-llvm -o - %s | FileCheck %s -check-prefix=SAME
+
+/* The scale for unsigned fixed point types should be the same as that of signed
+ * fixed point types when -fsame-fbits is enabled. */
+
+void func() {
+  unsigned short _Accum u_short_accum = 0.5uhk;
+  unsigned _Accum u_accum = 0.5uk;
+  unsigned long _Accum u_long_accum = 0.5ulk;
+  unsigned short _Fract u_short_fract = 0.5uhr;
+  unsigned _Fract u_fract = 0.5ur;
+  unsigned long _Fract u_long_fract = 0.5ulr;
+
+// DEFAULT: store i16 128, i16* %u_short_accum, align 2
+// DEFAULT: store i32 32768, i32* %u_accum, align 4
+// DEFAULT: store i64 2147483648, i64* %u_long_accum, align 8
+// DEFAULT: store i8  -128, i8* %u_short_fract, align 1
+// DEFAULT: store i16 -32768, i16* %u_fract, align 2
+// DEFAULT: store i32 -2147483648, i32* %u_long_fract, align 4
+
+// SAME: store i16 64, i16* %u_short_accum, align 2
+// SAME: store i32 16384, i32* %u_accum, align 4
+// SAME: store i64 1073741824, i64* %u_long_accum, align 8
+// SAME: store i8  64, i8* %u_short_fract, align 1
+// SAME: store i16 16384, i16* %u_fract, align 2
+// SAME: store i32 1073741824, i32* %u_long_fract, align 4
+}
Index: test/Frontend/fixed_point_errors.c
===
--- test/Frontend/fixed_point_errors.c
+++ test/Frontend/fixed_point_errors.c
@@ -13,7 +13,6 @@
 _Sat long long _Fract sat_longlong_fract; // expected-error{{'long long _Fract' is invalid}}
 _Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
 
-
 /* Although _Complex types work with floating point numbers, the extension
  * provides no info for complex 

[PATCH] D47759: [Format] Do not use a global static value for EOF within ScopedMacroState.

2018-06-14 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

Ping...


Repository:
  rC Clang

https://reviews.llvm.org/D47759



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


[PATCH] D46915: [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

2018-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 151433.
leonardchan added a comment.

- Removed the functions for performing casting between fixed point types to a 
common type when performing a binary operation since operations should be 
performed on the types as is. Also this patch is meant more for declaring fixed 
point literals. Binary operations will come in later patches, but it's good to 
catch these types of things early.
- Removed `fixed_point_validation.c` since that was the test for the logic 
described above.


Repository:
  rC Clang

https://reviews.llvm.org/D46915

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Expr.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TargetInfo.h
  include/clang/Driver/Options.td
  include/clang/Lex/LiteralSupport.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/Type.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Index/USRGeneration.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point.c
  test/Frontend/fixed_point_bit_widths.c
  test/Frontend/fixed_point_declarations.c
  test/Frontend/fixed_point_errors.c
  test/Frontend/fixed_point_same_fbits.c
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -305,6 +305,10 @@
 K = CXCursor_IntegerLiteral;
 break;
 
+  case Stmt::FixedPointLiteralClass:
+llvm_unreachable("No cursor for FixedPointLiteralClass");
+break;
+
   case Stmt::FloatingLiteralClass:
 K = CXCursor_FloatingLiteral;
 break;
Index: test/Frontend/fixed_point_same_fbits.c
===
--- /dev/null
+++ test/Frontend/fixed_point_same_fbits.c
@@ -0,0 +1,28 @@
+// RUN: %clang -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang -ffixed-point -fsame-fbits -S -emit-llvm -o - %s | FileCheck %s -check-prefix=SAME
+
+/* The scale for unsigned fixed point types should be the same as that of signed
+ * fixed point types when -fsame-fbits is enabled. */
+
+void func() {
+  unsigned short _Accum u_short_accum = 0.5uhk;
+  unsigned _Accum u_accum = 0.5uk;
+  unsigned long _Accum u_long_accum = 0.5ulk;
+  unsigned short _Fract u_short_fract = 0.5uhr;
+  unsigned _Fract u_fract = 0.5ur;
+  unsigned long _Fract u_long_fract = 0.5ulr;
+
+// DEFAULT: store i16 128, i16* %u_short_accum, align 2
+// DEFAULT: store i32 32768, i32* %u_accum, align 4
+// DEFAULT: store i64 2147483648, i64* %u_long_accum, align 8
+// DEFAULT: store i8  -128, i8* %u_short_fract, align 1
+// DEFAULT: store i16 -32768, i16* %u_fract, align 2
+// DEFAULT: store i32 -2147483648, i32* %u_long_fract, align 4
+
+// SAME: store i16 64, i16* %u_short_accum, align 2
+// SAME: store i32 16384, i32* %u_accum, align 4
+// SAME: store i64 1073741824, i64* %u_long_accum, align 8
+// SAME: store i8  64, i8* %u_short_fract, align 1
+// SAME: store i16 16384, i16* %u_fract, align 2
+// SAME: store i32 1073741824, i32* %u_long_fract, align 4
+}
Index: test/Frontend/fixed_point_errors.c
===
--- test/Frontend/fixed_point_errors.c
+++ test/Frontend/fixed_point_errors.c
@@ -13,7 +13,6 @@
 _Sat long long _Fract sat_longlong_fract; // expected-error{{'long long _Fract' is invalid}}
 _Sat unsigned long long _Fract sat_u_longlong_fract;  // expected-error{{'long long _Fract' is invalid}}
 
-
 /* Although _Complex types work with floating point numbers, the extension
  * provides no info for complex fixed point types. */
 
@@ -78,6 +77,50 @@
 _Sat int i;   // expected-error{{'_Sat' specifier is only valid on '_Fract' or '_Accum', not 'int'}}
 _Sat _Sat _Fract fract;   // expected-warning{{duplicate '_Sat' declaration specifier}}
 
+
+/* Literals that cannot fit into types */
+signed short _Accum s_short_accum = 256.0hk;// expected-error{{this value is too large for this fixed point type}}
+unsigned short _Accum u_short_accum = 256.0uhk; // expected-e

r334778 - Modules: Fix implicit output file for .cppm to .pcm instead of stdout

2018-06-14 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jun 14 16:09:06 2018
New Revision: 334778

URL: http://llvm.org/viewvc/llvm-project?rev=334778&view=rev
Log:
Modules: Fix implicit output file for .cppm to .pcm instead of stdout

This code was introduced back in r178148, a change to introduce
-module-file-info - which still exists & seems like it's still tested (&
this change didn't cause any of those tests to fail).

It doesn't look like this change was necessary there - since it's about
pcm output, whereas -module-file-info looks like it's for pcm /input/.
So I'm not really sure what the original motivation was.

I'm open to ideas though, if it turns out the original change was
necessary/useful.

Added:
cfe/trunk/test/Driver/clang-translation.cppm
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=334778&r1=334777&r2=334778&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Jun 14 16:09:06 2018
@@ -4013,8 +4013,7 @@ const char *Driver::GetNamedOutputPath(C
   }
 
   // Default to writing to stdout?
-  if (AtTopLevel && !CCGenDiagnostics &&
-  (isa(JA) || JA.getType() == types::TY_ModuleFile))
+  if (AtTopLevel && !CCGenDiagnostics && isa(JA))
 return "-";
 
   // Is this the assembly listing for /FA?

Added: cfe/trunk/test/Driver/clang-translation.cppm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.cppm?rev=334778&view=auto
==
--- cfe/trunk/test/Driver/clang-translation.cppm (added)
+++ cfe/trunk/test/Driver/clang-translation.cppm Thu Jun 14 16:09:06 2018
@@ -0,0 +1,2 @@
+// RUN: %clang %s --precompile -### 2>&1 | FileCheck %s
+// CHECK: "-o" "{{[^"]*}}clang-translation.pcm"


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


r334780 - [cmake] Add linker detection for Apple platforms

2018-06-14 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jun 14 16:26:33 2018
New Revision: 334780

URL: http://llvm.org/viewvc/llvm-project?rev=334780&view=rev
Log:
[cmake] Add linker detection for Apple platforms

LLVM currently assumes that Apple platforms will always use ld64. In the
future, LLD Mach-O might also be supported, so add the beginnings of
linker detection support. ld64 is currently the only detected linker,
since `ld64.lld -v` doesn't yield any useful version output, but we can
add that detection later, and in the meantime it's still useful to have
the ld64 identification.

Switch clang's order file check to use this new detection rather than
just checking for the presence of an ld64 executable.

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

Modified:
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=334780&r1=334779&r2=334780&view=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Thu Jun 14 16:26:33 2018
@@ -99,10 +99,10 @@ if (APPLE)
 endif()
 
 if(CLANG_ORDER_FILE AND
-   (LD64_EXECUTABLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
+(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
   include(CheckLinkerFlag)
 
-  if (LD64_EXECUTABLE)
+  if (LLVM_LINKER_IS_LD64)
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
   elseif (LLVM_LINKER_IS_GOLD)
 set(LINKER_ORDER_FILE_OPTION 
"-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")


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


[PATCH] D47393: [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 📜

2018-06-14 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added a comment.

Sorry, I missed that.
LGTM, I would consider adding ObjC method expression tests (multiline string as 
an argument). Will look into that next week.


Repository:
  rL LLVM

https://reviews.llvm.org/D47393



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


[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware, 
eraman.

`ExprWithCleanups` that cleans up function arguments (or any other stuff) at 
the end of the full-expression may break AST pattern-matching for figuring out 
that a null pointer was produced by the inlined function during 
`trackNullOrUndefValue()`. Because this expression doesn't do anything, skip it 
during `getDerefExpr()`.


Repository:
  rC Clang

https://reviews.llvm.org/D48204

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/inlining/inline-defensive-checks.cpp


Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -84,3 +84,18 @@
   int &x = b->x; // no-warning
   x = 5;
 }
+
+namespace get_deref_expr_with_cleanups {
+struct S {
+~S();
+};
+S *conjure();
+S *get_conjured(S _) {
+  S *s = conjure();
+  if (s) {}
+  return s;
+}
+void test_conjured() {
+  S &s = *get_conjured(S()); // no-warning
+}
+} // namespace get_deref_expr_with_cleanups
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -140,6 +140,8 @@
   E = AE->getBase();
 } else if (const auto *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
+} else if (const auto *EWC = dyn_cast(E)) {
+  E = EWC->getSubExpr();
 } else {
   // Other arbitrary stuff.
   break;


Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -84,3 +84,18 @@
   int &x = b->x; // no-warning
   x = 5;
 }
+
+namespace get_deref_expr_with_cleanups {
+struct S {
+~S();
+};
+S *conjure();
+S *get_conjured(S _) {
+  S *s = conjure();
+  if (s) {}
+  return s;
+}
+void test_conjured() {
+  S &s = *get_conjured(S()); // no-warning
+}
+} // namespace get_deref_expr_with_cleanups
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -140,6 +140,8 @@
   E = AE->getBase();
 } else if (const auto *PE = dyn_cast(E)) {
   E = PE->getSubExpr();
+} else if (const auto *EWC = dyn_cast(E)) {
+  E = EWC->getSubExpr();
 } else {
   // Other arbitrary stuff.
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48204: [analyzer] Make getDerefExpr() skip cleanups.

2018-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This is supposed to suppress a few Inlined-Defensive-Checks-related false 
positives that accidentally spiked up during my testing of copy elision.


Repository:
  rC Clang

https://reviews.llvm.org/D48204



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


[PATCH] D48205: [analyzer] Assert that nonloc::SymbolVal always wraps a non-Loc-type symbol.

2018-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware.

`nonloc::SymbolVal` that contains a pointer-type or reference-type symbol is 
ill-formed; our code isn't prepared to work with such values. The canonical way 
of representing symbolic pointers is `loc::MemRegionVal` that wraps a 
`SymbolicRegion` for the respective symbol. For representing results of casting 
pointers into integers we have `nonloc::LocAsInteger`.

This is the one assertion that i regret accidentally omitting in 
https://reviews.llvm.org/D26837, because it's very fundamental.

The assertion indeed mostly holds on our tests; i found one violation (in my 
own code), but the ill-formed `SVal` was only used in intermediate computations 
and was never put into the program state.

https://bugs.llvm.org/show_bug.cgi?id=37802 contains another example of an 
ill-formed `SVal` of this kind, which causes a crash. This patch doesn't 
address that crash yet.


Repository:
  rC Clang

https://reviews.llvm.org/D48205

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1238,7 +1238,7 @@
 
 SVal VisitSymbolData(const SymbolData *S) {
   if (const llvm::APSInt *I =
-  SVB.getKnownValue(State, nonloc::SymbolVal(S)))
+  SVB.getKnownValue(State, SVB.makeSymbolVal(S)))
 return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I)
 : (SVal)SVB.makeIntVal(*I);
   return SVB.makeSymbolVal(S);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -343,11 +343,14 @@
 
 namespace nonloc {
 
-/// Represents symbolic expression.
+/// Represents symbolic expression that isn't a location.
 class SymbolVal : public NonLoc {
 public:
   SymbolVal() = delete;
-  SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) { assert(sym); }
+  SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) {
+assert(sym);
+assert(!Loc::isLocType(sym->getType()));
+  }
 
   SymbolRef getSymbol() const {
 return (const SymExpr *) Data;


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1238,7 +1238,7 @@
 
 SVal VisitSymbolData(const SymbolData *S) {
   if (const llvm::APSInt *I =
-  SVB.getKnownValue(State, nonloc::SymbolVal(S)))
+  SVB.getKnownValue(State, SVB.makeSymbolVal(S)))
 return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I)
 : (SVal)SVB.makeIntVal(*I);
   return SVB.makeSymbolVal(S);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -343,11 +343,14 @@
 
 namespace nonloc {
 
-/// Represents symbolic expression.
+/// Represents symbolic expression that isn't a location.
 class SymbolVal : public NonLoc {
 public:
   SymbolVal() = delete;
-  SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) { assert(sym); }
+  SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) {
+assert(sym);
+assert(!Loc::isLocType(sym->getType()));
+  }
 
   SymbolRef getSymbol() const {
 return (const SymExpr *) Data;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48206: IRgen: Mark aliases of ctors and dtors as unnamed_addr.

2018-06-14 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added a reviewer: rsmith.

This is not only semantically correct but ensures that they will not
be marked as address-significant once https://reviews.llvm.org/D48155 lands.


https://reviews.llvm.org/D48206

Files:
  clang/lib/CodeGen/CGCXX.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/constructor-alias.cpp
  clang/test/CodeGenCXX/ctor-dtor-alias.cpp
  clang/test/CodeGenCXX/destructors.cpp
  clang/test/CodeGenCXX/dllexport-alias.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
  clang/test/CodeGenCXX/virtual-bases.cpp
  clang/test/CodeGenCXX/virtual-destructor-calls.cpp

Index: clang/test/CodeGenCXX/virtual-destructor-calls.cpp
===
--- clang/test/CodeGenCXX/virtual-destructor-calls.cpp
+++ clang/test/CodeGenCXX/virtual-destructor-calls.cpp
@@ -14,11 +14,11 @@
 };
 
 // Complete dtor: just an alias because there are no virtual bases.
-// CHECK: @_ZN1BD1Ev = alias {{.*}} @_ZN1BD2Ev
+// CHECK: @_ZN1BD1Ev = unnamed_addr alias {{.*}} @_ZN1BD2Ev
 
 // (aliases from C)
-// CHECK: @_ZN1CD2Ev = alias {{.*}}, bitcast {{.*}} @_ZN1BD2Ev
-// CHECK: @_ZN1CD1Ev = alias {{.*}} @_ZN1CD2Ev
+// CHECK: @_ZN1CD2Ev = unnamed_addr alias {{.*}}, bitcast {{.*}} @_ZN1BD2Ev
+// CHECK: @_ZN1CD1Ev = unnamed_addr alias {{.*}} @_ZN1CD2Ev
 
 // Base dtor: actually calls A's base dtor.
 // CHECK-LABEL: define void @_ZN1BD2Ev(%struct.B* %this) unnamed_addr
Index: clang/test/CodeGenCXX/virtual-bases.cpp
===
--- clang/test/CodeGenCXX/virtual-bases.cpp
+++ clang/test/CodeGenCXX/virtual-bases.cpp
@@ -4,7 +4,7 @@
   A();
 };
 
-// CHECK: @_ZN1AC1Ev = alias {{.*}} @_ZN1AC2Ev
+// CHECK: @_ZN1AC1Ev = unnamed_addr alias {{.*}} @_ZN1AC2Ev
 // CHECK-LABEL: define void @_ZN1AC2Ev(%struct.A* %this) unnamed_addr
 A::A() { }
 
Index: clang/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
@@ -22,7 +22,7 @@
 void foo() {
   B b;
 }
-// CHECK-DAG: @"??1B@test2@@UAE@XZ" = dso_local alias void (%"struct.test2::B"*), bitcast (void (%"struct.test2::A"*)* @"??1A@test2@@UAE@XZ" to void (%"struct.test2::B"*)*)
+// CHECK-DAG: @"??1B@test2@@UAE@XZ" = dso_local unnamed_addr alias void (%"struct.test2::B"*), bitcast (void (%"struct.test2::A"*)* @"??1A@test2@@UAE@XZ" to void (%"struct.test2::B"*)*)
 }
 
 namespace test3 {
Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -641,7 +641,7 @@
   A::~A() { }
   B::~B() { }
   // Emit a alias definition of B's constructor.
-  // M32-DAG: @"??1B@UseDtorAlias@@QAE@XZ" = dso_local dllexport alias {{.*}} @"??1A@UseDtorAlias@@QAE@XZ"
+  // M32-DAG: @"??1B@UseDtorAlias@@QAE@XZ" = dso_local dllexport unnamed_addr alias {{.*}} @"??1A@UseDtorAlias@@QAE@XZ"
 }
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
Index: clang/test/CodeGenCXX/dllexport-alias.cpp
===
--- clang/test/CodeGenCXX/dllexport-alias.cpp
+++ clang/test/CodeGenCXX/dllexport-alias.cpp
@@ -14,5 +14,5 @@
 
 A::~A() {}
 
-// CHECK: @_ZN1AC1Ev = dso_local dllexport alias void (%class.A*), void (%class.A*)* @_ZN1AC2Ev
-// CHECK: @_ZN1AD1Ev = dso_local dllexport alias void (%class.A*), void (%class.A*)* @_ZN1AD2Ev
+// CHECK: @_ZN1AC1Ev = dso_local dllexport unnamed_addr alias void (%class.A*), void (%class.A*)* @_ZN1AC2Ev
+// CHECK: @_ZN1AD1Ev = dso_local dllexport unnamed_addr alias void (%class.A*), void (%class.A*)* @_ZN1AD2Ev
Index: clang/test/CodeGenCXX/destructors.cpp
===
--- clang/test/CodeGenCXX/destructors.cpp
+++ clang/test/CodeGenCXX/destructors.cpp
@@ -96,15 +96,15 @@
 
 // complete destructor alias tested above
 
-// CHECK2-LABEL: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK2-LABEL: @_ZN5test01AD1Ev = unnamed_addr alias {{.*}} @_ZN5test01AD2Ev
 // CHECK2-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr
 // CHECK2: invoke void @_ZN5test06MemberD1Ev
 // CHECK2:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
 // CHECK2: invoke void @_ZN5test04BaseD2Ev
 // CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
 // In C++11, the destructors are often known not to throw.
-// CHECK2v11-LABEL: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK2v11-LABEL: @_ZN5test01AD1Ev = unnamed_addr alias {{.*}} @_ZN5test01AD2Ev
 // CHECK2v11-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr
 // CHECK2v11: call void @_ZN5test06MemberD1Ev
 // CHECK2v11: call void @_ZN5test04BaseD2Ev
@@ -153,15 +

[PATCH] D48208: [Fuchsia] Enable static libc++, libc++abi, libunwind

2018-06-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, chrib, mgorny.
Herald added a reviewer: EricWF.

This is needed for building Fuchsia drivers.


Repository:
  rC Clang

https://reviews.llvm.org/D48208

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -77,12 +77,9 @@
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS 
${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 
   set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING 
"")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -77,12 +77,9 @@
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
   set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 
   set(RUNTIMES_${target}-fuchsia-asan_LLVM_USE_SANITIZER Address CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47759: [Format] Do not use a global static value for EOF within ScopedMacroState.

2018-06-14 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG.


Repository:
  rC Clang

https://reviews.llvm.org/D47759



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


[libcxx] r334791 - Creating release candidate rc3 from release_601 branch

2018-06-14 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun 14 22:05:12 2018
New Revision: 334791

URL: http://llvm.org/viewvc/llvm-project?rev=334791&view=rev
Log:
Creating release candidate rc3 from release_601 branch

Added:
libcxx/tags/RELEASE_601/rc3/   (props changed)
  - copied from r334790, libcxx/branches/release_60/

Propchange: libcxx/tags/RELEASE_601/rc3/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Jun 14 22:05:12 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:321963,324153,324855,325147


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


[libcxxabi] r334792 - Creating release candidate rc3 from release_601 branch

2018-06-14 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun 14 22:05:16 2018
New Revision: 334792

URL: http://llvm.org/viewvc/llvm-project?rev=334792&view=rev
Log:
Creating release candidate rc3 from release_601 branch

Added:
libcxxabi/tags/RELEASE_601/rc3/
  - copied from r334791, libcxxabi/branches/release_60/

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


[libunwind] r334798 - Creating release candidate rc3 from release_601 branch

2018-06-14 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun 14 22:05:43 2018
New Revision: 334798

URL: http://llvm.org/viewvc/llvm-project?rev=334798&view=rev
Log:
Creating release candidate rc3 from release_601 branch

Added:
libunwind/tags/RELEASE_601/rc3/
  - copied from r334797, libunwind/branches/release_60/

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


[PATCH] D47759: [Format] Do not use a global static value for EOF within ScopedMacroState.

2018-06-14 Thread David L. Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334801: [Format] Do not use a global static value for EOF 
within ScopedMacroState. (authored by dlj, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47759?vs=149900&id=151458#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47759

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -83,6 +83,8 @@
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
 Token(nullptr), PreviousToken(nullptr) {
+FakeEOF.Tok.startToken();
+FakeEOF.Tok.setKind(tok::eof);
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -102,7 +104,7 @@
 PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
-  return getFakeEOF();
+  return &FakeEOF;
 return Token;
   }
 
@@ -121,17 +123,7 @@
  /*MinColumnToken=*/PreviousToken);
   }
 
-  FormatToken *getFakeEOF() {
-static bool EOFInitialized = false;
-static FormatToken FormatTok;
-if (!EOFInitialized) {
-  FormatTok.Tok.startToken();
-  FormatTok.Tok.setKind(tok::eof);
-  EOFInitialized = true;
-}
-return &FormatTok;
-  }
-
+  FormatToken FakeEOF;
   UnwrappedLine &Line;
   FormatTokenSource *&TokenSource;
   FormatToken *&ResetToken;


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -83,6 +83,8 @@
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
 Token(nullptr), PreviousToken(nullptr) {
+FakeEOF.Tok.startToken();
+FakeEOF.Tok.setKind(tok::eof);
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -102,7 +104,7 @@
 PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
-  return getFakeEOF();
+  return &FakeEOF;
 return Token;
   }
 
@@ -121,17 +123,7 @@
  /*MinColumnToken=*/PreviousToken);
   }
 
-  FormatToken *getFakeEOF() {
-static bool EOFInitialized = false;
-static FormatToken FormatTok;
-if (!EOFInitialized) {
-  FormatTok.Tok.startToken();
-  FormatTok.Tok.setKind(tok::eof);
-  EOFInitialized = true;
-}
-return &FormatTok;
-  }
-
+  FormatToken FakeEOF;
   UnwrappedLine &Line;
   FormatTokenSource *&TokenSource;
   FormatToken *&ResetToken;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334801 - [Format] Do not use a global static value for EOF within ScopedMacroState.

2018-06-14 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Jun 14 23:08:54 2018
New Revision: 334801

URL: http://llvm.org/viewvc/llvm-project?rev=334801&view=rev
Log:
[Format] Do not use a global static value for EOF within ScopedMacroState.

ScopedMacroState injects its own EOF token under certain conditions, and the
returned token may be modified in several different locations. If multiple
reformat operations are started in different threads, then they will both see
the same fake EOF token, and may both try to modify it. This is a data race.

This bug was caught with tsan.

Reviewers: klimek

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=334801&r1=334800&r2=334801&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Jun 14 23:08:54 2018
@@ -83,6 +83,8 @@ public:
   : Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
 PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
 Token(nullptr), PreviousToken(nullptr) {
+FakeEOF.Tok.startToken();
+FakeEOF.Tok.setKind(tok::eof);
 TokenSource = this;
 Line.Level = 0;
 Line.InPPDirective = true;
@@ -102,7 +104,7 @@ public:
 PreviousToken = Token;
 Token = PreviousTokenSource->getNextToken();
 if (eof())
-  return getFakeEOF();
+  return &FakeEOF;
 return Token;
   }
 
@@ -121,17 +123,7 @@ private:
  /*MinColumnToken=*/PreviousToken);
   }
 
-  FormatToken *getFakeEOF() {
-static bool EOFInitialized = false;
-static FormatToken FormatTok;
-if (!EOFInitialized) {
-  FormatTok.Tok.startToken();
-  FormatTok.Tok.setKind(tok::eof);
-  EOFInitialized = true;
-}
-return &FormatTok;
-  }
-
+  FormatToken FakeEOF;
   UnwrappedLine &Line;
   FormatTokenSource *&TokenSource;
   FormatToken *&ResetToken;


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


r334804 - [ASTImporter] Corrected diagnostic client handling in tests.

2018-06-14 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Thu Jun 14 23:45:39 2018
New Revision: 334804

URL: http://llvm.org/viewvc/llvm-project?rev=334804&view=rev
Log:
[ASTImporter] Corrected diagnostic client handling in tests.

ASTImporter tests may produce source file related warnings, the diagnostic
client should be in correct state to handle it. Added 'beginSourceFile' to set
the client state.

Patch by: Balázs Kéri

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


Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=334804&r1=334803&r2=334804&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jun 14 23:45:39 2018
@@ -438,6 +438,15 @@ public:
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
   void setPreprocessor(std::shared_ptr pp);
 
+  /// Enable source-range based diagnostic messages.
+  ///
+  /// If diagnostic messages with source-range information are to be expected
+  /// and AST comes not from file (e.g. after LoadFromCompilerInvocation) this
+  /// function has to be called.
+  /// The function is to be called only once and the AST should be associated
+  /// with the same source file afterwards.
+  void enableSourceFileDiagnostics();
+
   bool hasSema() const { return (bool)TheSema; }
 
   Sema &getSema() const { 

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=334804&r1=334803&r2=334804&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jun 14 23:45:39 2018
@@ -275,6 +275,12 @@ void ASTUnit::setPreprocessor(std::share
   this->PP = std::move(PP);
 }
 
+void ASTUnit::enableSourceFileDiagnostics() {
+  assert(getDiagnostics().getClient() && Ctx &&
+  "Bad context for source file");
+  getDiagnostics().getClient()->BeginSourceFile(Ctx->getLangOpts(), PP.get());
+}
+
 /// Determine the set of code-completion contexts in which this
 /// declaration should be shown.
 static unsigned getDeclShowContexts(const NamedDecl *ND,

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=334804&r1=334803&r2=334804&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Thu Jun 14 23:45:39 2018
@@ -98,6 +98,9 @@ testImport(const std::string &FromCode,
   ASTContext &FromCtx = FromAST->getASTContext(),
   &ToCtx = ToAST->getASTContext();
 
+  FromAST->enableSourceFileDiagnostics();
+  ToAST->enableSourceFileDiagnostics();
+
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
 
@@ -172,7 +175,9 @@ class ASTImporterTestBase : public ::tes
 : Code(Code), FileName(FileName),
   Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
  this->FileName)),
-  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {}
+  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {
+  Unit->enableSourceFileDiagnostics();
+}
   };
 
   // We may have several From contexts and related translation units. In each
@@ -214,6 +219,7 @@ public:
 ToCode = ToSrcCode;
 assert(!ToAST);
 ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+ToAST->enableSourceFileDiagnostics();
 
 ASTContext &FromCtx = FromTU.Unit->getASTContext(),
&ToCtx = ToAST->getASTContext();
@@ -261,6 +267,7 @@ public:
 ToCode = ToSrcCode;
 assert(!ToAST);
 ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+ToAST->enableSourceFileDiagnostics();
 
 return ToAST->getASTContext().getTranslationUnitDecl();
   }
@@ -274,6 +281,7 @@ public:
   // Build the AST from an empty file.
   ToAST =
   tooling::buildASTFromCodeWithArgs(/*Code=*/"", ToArgs, "empty.cc");
+  ToAST->enableSourceFileDiagnostics();
 }
 
 // Create a virtual file in the To Ctx which corresponds to the file from


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


[PATCH] D47445: [ASTImporter] Corrected diagnostic client handling in tests.

2018-06-14 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334804: [ASTImporter] Corrected diagnostic client handling 
in tests. (authored by baloghadamsoftware, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47445?vs=149412&id=151459#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47445

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp
  unittests/AST/ASTImporterTest.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -275,6 +275,12 @@
   this->PP = std::move(PP);
 }
 
+void ASTUnit::enableSourceFileDiagnostics() {
+  assert(getDiagnostics().getClient() && Ctx &&
+  "Bad context for source file");
+  getDiagnostics().getClient()->BeginSourceFile(Ctx->getLangOpts(), PP.get());
+}
+
 /// Determine the set of code-completion contexts in which this
 /// declaration should be shown.
 static unsigned getDeclShowContexts(const NamedDecl *ND,
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -98,6 +98,9 @@
   ASTContext &FromCtx = FromAST->getASTContext(),
   &ToCtx = ToAST->getASTContext();
 
+  FromAST->enableSourceFileDiagnostics();
+  ToAST->enableSourceFileDiagnostics();
+
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
 
@@ -172,7 +175,9 @@
 : Code(Code), FileName(FileName),
   Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
  this->FileName)),
-  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {}
+  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {
+  Unit->enableSourceFileDiagnostics();
+}
   };
 
   // We may have several From contexts and related translation units. In each
@@ -214,6 +219,7 @@
 ToCode = ToSrcCode;
 assert(!ToAST);
 ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+ToAST->enableSourceFileDiagnostics();
 
 ASTContext &FromCtx = FromTU.Unit->getASTContext(),
&ToCtx = ToAST->getASTContext();
@@ -261,6 +267,7 @@
 ToCode = ToSrcCode;
 assert(!ToAST);
 ToAST = tooling::buildASTFromCodeWithArgs(ToCode, ToArgs, OutputFileName);
+ToAST->enableSourceFileDiagnostics();
 
 return ToAST->getASTContext().getTranslationUnitDecl();
   }
@@ -274,6 +281,7 @@
   // Build the AST from an empty file.
   ToAST =
   tooling::buildASTFromCodeWithArgs(/*Code=*/"", ToArgs, "empty.cc");
+  ToAST->enableSourceFileDiagnostics();
 }
 
 // Create a virtual file in the To Ctx which corresponds to the file from
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -438,6 +438,15 @@
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
   void setPreprocessor(std::shared_ptr pp);
 
+  /// Enable source-range based diagnostic messages.
+  ///
+  /// If diagnostic messages with source-range information are to be expected
+  /// and AST comes not from file (e.g. after LoadFromCompilerInvocation) this
+  /// function has to be called.
+  /// The function is to be called only once and the AST should be associated
+  /// with the same source file afterwards.
+  void enableSourceFileDiagnostics();
+
   bool hasSema() const { return (bool)TheSema; }
 
   Sema &getSema() const { 


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -275,6 +275,12 @@
   this->PP = std::move(PP);
 }
 
+void ASTUnit::enableSourceFileDiagnostics() {
+  assert(getDiagnostics().getClient() && Ctx &&
+  "Bad context for source file");
+  getDiagnostics().getClient()->BeginSourceFile(Ctx->getLangOpts(), PP.get());
+}
+
 /// Determine the set of code-completion contexts in which this
 /// declaration should be shown.
 static unsigned getDeclShowContexts(const NamedDecl *ND,
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -98,6 +98,9 @@
   ASTContext &FromCtx = FromAST->getASTContext(),
   &ToCtx = ToAST->getASTContext();
 
+  FromAST->enableSourceFileDiagnostics();
+  ToAST->enableSourceFileDiagnostics();
+
   ASTImporter Importer(ToCtx, ToAST->getFileManager(),
FromCtx, FromAST->getFileManager(), false);
 
@@ -172,7 +175,9 @@
 : Code(Code), FileName(FileName),
   Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
  this->FileName)),
-  TUDecl(U