[PATCH] D27091: Add the way to extract SVals of arguments used in a call for a given StackFrameCtx

2016-12-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Chatted about this a bit more. Because `CallEvent` is an API designed mostly 
for convenience, and `ProgramState` is a core API that needs to stay as clean 
and separate from other entities and easy to understand as possible, it would 
be the best to

1. construct a `CallEvent` in the checker (which is cheap) and query that,
2. and also allow constructing `CallEvent`s for the top frame (with 
`StackFrameContext::inTopFrame()`, with null call site ("origin") expression), 
and
3. add a branch to the `CallEvent::getArgSVal()` method (and similar methods 
for obtaining implicit arguments like C++ `this`, ObjC `self`, ObjC `super`) to 
handle the top frame case.

If this sounds hard, handling this completely on the checker side is fine, 
because few checker are using this at the moment.


https://reviews.llvm.org/D27091



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


[PATCH] D27299: [Sema] C++11 opaque enums should avoid the "case value not in enumerated type" switch warning

2016-12-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaStmt.cpp:1165
 
   if (!hasCasesNotInSwitch)
 SS->setAllEnumCasesCovered();

This function used to call setAllEnumCasesCovered() when parsing a switch 
statement with an opaque enum condition, but this patch changes the behavior. I 
couldn't tell whether isAllEnumCasesCovered should return true or false for 
such switch statements, but was this change intentional?


Repository:
  rL LLVM

https://reviews.llvm.org/D27299



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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move out of alpha

2016-12-01 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.

Looks great!
Thank you.


https://reviews.llvm.org/D26768



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


r288478 - clang/test/Driver/defsym.s: Appease targeting msc. It is incapable of external assembler in trunk.

2016-12-01 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Dec  1 23:09:21 2016
New Revision: 288478

URL: http://llvm.org/viewvc/llvm-project?rev=288478=rev
Log:
clang/test/Driver/defsym.s: Appease targeting msc. It is incapable of external 
assembler in trunk.

Modified:
cfe/trunk/test/Driver/defsym.s

Modified: cfe/trunk/test/Driver/defsym.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/defsym.s?rev=288478=288477=288478=diff
==
--- cfe/trunk/test/Driver/defsym.s (original)
+++ cfe/trunk/test/Driver/defsym.s Thu Dec  1 23:09:21 2016
@@ -2,7 +2,7 @@
 // RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
 
-// RUN: %clang -### -c -no-integrated-as %s \
+// RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
 // RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
 


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


[PATCH] D27332: With LTO and profile-use, enable hotness info in opt remarks

2016-12-01 Thread Adam Nemet via Phabricator via cfe-commits
anemet created this revision.
anemet added reviewers: hfinkel, mehdi_amini.
anemet added a subscriber: cfe-commits.

This is to match the behavior of non-LTO; when -fsave-optmization-record
is passed and PGO is available we enable the generation of hotness
information in the optimization records.


https://reviews.llvm.org/D27332

Files:
  lib/Driver/Tools.cpp
  test/Driver/darwin-ld.c


Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -332,7 +332,12 @@
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### -o foo/bar.out 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log
 // PASS_REMARKS_OUTPUT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" 
"foo/bar.out.opt.yaml"
+// PASS_REMARKS_OUTPUT-NOT: -lto-pass-remarks-with-hotness
 
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log
 // PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-lto-pass-remarks-output" "-mllvm" 
"a.out.opt.yaml"
+
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-fprofile-instr-use=blah -### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_HOTNESS %s < %t.log
+// PASS_REMARKS_WITH_HOTNESS: "-mllvm" "-lto-pass-remarks-output" "-mllvm" 
"foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-with-hotness"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3641,6 +3641,19 @@
   return VersionTuple();
 }
 
+static Arg *getLastProfileUseArg(const ArgList ) {
+  auto *ProfileUseArg = Args.getLastArg(
+  options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ,
+  options::OPT_fprofile_use, options::OPT_fprofile_use_EQ,
+  options::OPT_fno_profile_instr_use);
+
+  if (ProfileUseArg &&
+  ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use))
+ProfileUseArg = nullptr;
+
+  return ProfileUseArg;
+}
+
 static void addPGOAndCoverageFlags(Compilation , const Driver ,
const InputInfo , const ArgList 
,
ArgStringList ) {
@@ -3665,13 +3678,7 @@
 D.Diag(diag::err_drv_argument_not_allowed_with)
 << PGOGenerateArg->getSpelling() << ProfileGenerateArg->getSpelling();
 
-  auto *ProfileUseArg = Args.getLastArg(
-  options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ,
-  options::OPT_fprofile_use, options::OPT_fprofile_use_EQ,
-  options::OPT_fno_profile_instr_use);
-  if (ProfileUseArg &&
-  ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use))
-ProfileUseArg = nullptr;
+  auto *ProfileUseArg = getLastProfileUseArg(Args);
 
   if (PGOGenerateArg && ProfileUseArg)
 D.Diag(diag::err_drv_argument_not_allowed_with)
@@ -8433,6 +8440,11 @@
 F = Output.getFilename();
 F += ".opt.yaml";
 CmdArgs.push_back(Args.MakeArgString(F));
+
+if (getLastProfileUseArg(Args)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-lto-pass-remarks-with-hotness");
+}
   }
 
   // It seems that the 'e' option is completely ignored for dynamic executables


Index: test/Driver/darwin-ld.c
===
--- test/Driver/darwin-ld.c
+++ test/Driver/darwin-ld.c
@@ -332,7 +332,12 @@
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### -o foo/bar.out 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log
 // PASS_REMARKS_OUTPUT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml"
+// PASS_REMARKS_OUTPUT-NOT: -lto-pass-remarks-with-hotness
 
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log
 // PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "a.out.opt.yaml"
+
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -fprofile-instr-use=blah -### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_HOTNESS %s < %t.log
+// PASS_REMARKS_WITH_HOTNESS: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-with-hotness"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3641,6 +3641,19 @@
   return VersionTuple();
 }
 
+static Arg *getLastProfileUseArg(const ArgList ) {
+  auto *ProfileUseArg = Args.getLastArg(
+  options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ,
+  options::OPT_fprofile_use, options::OPT_fprofile_use_EQ,
+  options::OPT_fno_profile_instr_use);
+
+  if (ProfileUseArg &&
+  

[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

2016-12-01 Thread ZiXuan Wu via Phabricator via cfe-commits
Zeson added a comment.

In https://reviews.llvm.org/D27251#610629, @kbarton wrote:

> Please make explicit the signed for the parameters to the functions you are 
> changing and remove unnecessary casts. I marked the first few that I found, 
> but stopped marking them after the first several.


I think it does not need to make explicit signed for the parameters such as 
making `vector int` to `vector signed int`, making `vector short` to `vector 
signed short`.
The whole file containing lots of such issues can be modified or fixed in 
another single patch to avoid introducing noise in this patch.


https://reviews.llvm.org/D27251



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


[libcxx] r288469 - Creating release candidate rc2 from release_391 branch

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 21:45:52 2016
New Revision: 288469

URL: http://llvm.org/viewvc/llvm-project?rev=288469=rev
Log:
Creating release candidate rc2 from release_391 branch

Added:
libcxx/tags/RELEASE_391/rc2/   (props changed)
  - copied from r288468, libcxx/branches/release_39/

Propchange: libcxx/tags/RELEASE_391/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Dec  1 21:45:52 2016
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:278282,278357,278387,278904,279008


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


[libunwind] r288476 - Creating release candidate rc2 from release_391 branch

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 21:46:03 2016
New Revision: 288476

URL: http://llvm.org/viewvc/llvm-project?rev=288476=rev
Log:
Creating release candidate rc2 from release_391 branch

Added:
libunwind/tags/RELEASE_391/rc2/   (props changed)
  - copied from r288475, libunwind/branches/release_39/

Propchange: libunwind/tags/RELEASE_391/rc2/
--
svn:mergeinfo = /libunwind/trunk:276128,277868,278029


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


[libcxxabi] r288470 - Creating release candidate rc2 from release_391 branch

2016-12-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  1 21:45:53 2016
New Revision: 288470

URL: http://llvm.org/viewvc/llvm-project?rev=288470=rev
Log:
Creating release candidate rc2 from release_391 branch

Added:
libcxxabi/tags/RELEASE_391/rc2/   (props changed)
  - copied from r288469, libcxxabi/branches/release_39/

Propchange: libcxxabi/tags/RELEASE_391/rc2/
--
svn:mergeinfo = /libcxxabi/trunk:278030,278579


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


[PATCH] D27187: [clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop

2016-12-01 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

Do you have any more comments, Alex?


https://reviews.llvm.org/D27187



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


[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

2016-12-01 Thread ZiXuan Wu via Phabricator via cfe-commits
Zeson updated this revision to Diff 80021.
Zeson marked 3 inline comments as done.
Zeson added a comment.

Remove some unnecessary cast


https://reviews.llvm.org/D27251

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-p8vector.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -1592,11 +1592,11 @@
 // CHECK: @llvm.ppc.altivec.vsl
 // CHECK-LE: @llvm.ppc.altivec.vsl
 
-res_vull = vec_sll(vull, vuc);
+  res_vull = vec_sll(vull, vuc);
 // CHECK: @llvm.ppc.altivec.vsl
 // CHECK-LE: @llvm.ppc.altivec.vsl
 
-res_vsll = vec_slo(vsll, vsc);
+  res_vsll = vec_slo(vsll, vsc);
 // CHECK: @llvm.ppc.altivec.vslo
 // CHECK-LE: @llvm.ppc.altivec.vslo
 
@@ -1636,59 +1636,134 @@
 // CHECK: @llvm.ppc.altivec.vsro
 // CHECK-LE: @llvm.ppc.altivec.vsro
 
-res_vsll = vec_xl(sll, asll);
+  res_vsll = vec_xl(sll, asll);
 // CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
 // CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
 
-res_vull = vec_xl(sll, aull);
+  res_vull = vec_xl(sll, aull);
 // CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
 // CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
 
-res_vd = vec_xl(sll, ad);
+  res_vd = vec_xl(sll, ad);
 // CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
 // CHECK-LE: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
 
-vec_xst(vsll, sll, asll);
+  vec_xst(vsll, sll, asll);
 // CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
 // CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
 
-vec_xst(vull, sll, aull);
+  vec_xst(vull, sll, aull);
 // CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
 // CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
 
-vec_xst(vd, sll, ad);
+  vec_xst(vd, sll, ad);
 // CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
 // CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
 
-res_vsll = vec_xl_be(sll, asll);
-// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
-
-res_vull = vec_xl_be(sll, aull);
-// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
-
-res_vd = vec_xl_be(sll, ad);
-// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
-// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
-
-vec_xst_be(vsll, sll, asll);
-// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
-
-vec_xst_be(vull, sll, aull);
-// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
-// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
-
-vec_xst_be(vd, sll, ad);
-// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
-// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})
-
   res_vf = vec_neg(vf);
 // CHECK: fsub <4 x float> , {{%[0-9]+}}
 // CHECK-LE: fsub <4 x float> , {{%[0-9]+}}
 
   res_vd = vec_neg(vd);
 // CHECK: fsub <2 x double> , {{%[0-9]+}}
 // CHECK-LE: fsub <2 x double> , {{%[0-9]+}}
 }
+
+
+/* - vec_xl_be -- */
+void test2() {
+  // CHECK-LABEL: define void @test2
+  // CHECK-LE-LABEL: define void @test2
+  vec_xl_be(sll, asc);
+  // CHECK: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 16
+  // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+  // CHECK-LE: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> 
+
+  vec_xl_be(sll, auc);
+  // CHECK: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 16
+  // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+  // CHECK-LE: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> 
+
+  vec_xl_be(sll, ass);
+  // CHECK: load <8 x i16>, <8 x i16>* %{{[0-9]+}}, align 16
+  // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+  // CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> 
+
+  vec_xl_be(sll, aus);
+  // CHECK: load <8 x i16>, <8 x i16>* %{{[0-9]+}}, align 16
+  // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
+  // CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> 
+
+  vec_xl_be(sll, asi);
+  // CHECK: load <4 x i32>, <4 x i32>* %{{[0-9]+}}, align 16
+  // CHECK-LE: call <4 x i32> @llvm.ppc.vsx.lxvw4x.be(i8* %{{[0-9]+}})
+
+  vec_xl_be(sll, aui);
+  // CHECK: load <4 x i32>, <4 x i32>* %{{[0-9]+}}, align 16
+  // CHECK-LE: call <4 x i32> @llvm.ppc.vsx.lxvw4x.be(i8* %{{[0-9]+}})
+
+  

[libcxxabi] r288457 - Update implementation of ABI support for throwing noexcept function pointers

2016-12-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec  1 20:06:53 2016
New Revision: 288457

URL: http://llvm.org/viewvc/llvm-project?rev=288457=rev
Log:
Update implementation of ABI support for throwing noexcept function pointers
and catching as non-noexcept to match the final design per discusson on
cxx-abi-dev.

Modified:
libcxxabi/trunk/src/private_typeinfo.cpp
libcxxabi/trunk/src/private_typeinfo.h
libcxxabi/trunk/test/catch_function_03.pass.cpp
libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp
libcxxabi/trunk/test/libcxxabi/test/config.py

Modified: libcxxabi/trunk/src/private_typeinfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=288457=288456=288457=diff
==
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Thu Dec  1 20:06:53 2016
@@ -105,45 +105,6 @@ __function_type_info::~__function_type_i
 {
 }
 
-// __qualified_function_type_info
-
-__qualified_function_type_info::~__qualified_function_type_info()
-{
-}
-
-// Determine if a function pointer conversion can convert a pointer (or pointer
-// to member) to type x into a pointer (or pointer to member) to type y.
-static bool is_function_pointer_conversion(const std::type_info* x,
-   const std::type_info* y)
-{
-const unsigned int discardable_quals =
-__qualified_function_type_info::__noexcept_mask |
-__qualified_function_type_info::__transaction_safe_mask |
-__qualified_function_type_info::__noreturn_mask;
-
-// If x has only discardable qualifiers and y is unqualified, then
-// conversion is permitted.
-const __qualified_function_type_info* qual_x =
-dynamic_cast(x);
-if (!qual_x)
-return false;
-if ((qual_x->__qualifiers & ~discardable_quals) == 0 &&
-is_equal(qual_x->__base_type, y, false))
-return true;
-
-// Otherwise, x's qualifiers must be the same as y's, plus some discardable
-// ones.
-const __qualified_function_type_info* qual_y =
-dynamic_cast(y);
-if (!qual_y)
-return false;
-if (qual_y->__qualifiers & ~qual_x->__qualifiers)
-return false;
-if (qual_x->__qualifiers & ~qual_y->__qualifiers & ~discardable_quals)
-return false;
-return is_equal(qual_x->__base_type, qual_y->__base_type, false);
-}
-
 // __enum_type_info
 
 __enum_type_info::~__enum_type_info()
@@ -429,15 +390,13 @@ __pointer_type_info::can_catch(const __s
 // Do the dereference adjustment
 if (adjustedPtr != NULL)
 adjustedPtr = *static_cast(adjustedPtr);
-// bullet 3B
-if (thrown_pointer_type->__flags & ~__flags)
+// bullet 3B and 3C
+if (thrown_pointer_type->__flags & ~__flags & __no_remove_flags_mask)
+return false;
+if (__flags & ~thrown_pointer_type->__flags & __no_add_flags_mask)
 return false;
 if (is_equal(__pointee, thrown_pointer_type->__pointee, false))
 return true;
-// bullet 3C
-if (is_function_pointer_conversion(thrown_pointer_type->__pointee,
-   __pointee))
-  return true;
 // bullet 3A
 if (is_equal(__pointee, (void), false)) {
 // pointers to functions cannot be converted to void*.
@@ -543,11 +502,11 @@ bool __pointer_to_member_type_info::can_
 dynamic_cast(thrown_type);
 if (thrown_pointer_type == 0)
 return false;
-if (thrown_pointer_type->__flags & ~__flags)
+if (thrown_pointer_type->__flags & ~__flags & __no_remove_flags_mask)
+return false;
+if (__flags & ~thrown_pointer_type->__flags & __no_add_flags_mask)
 return false;
-if (!is_equal(__pointee, thrown_pointer_type->__pointee, false) &&
-!is_function_pointer_conversion(thrown_pointer_type->__pointee,
-__pointee))
+if (!is_equal(__pointee, thrown_pointer_type->__pointee, false))
 return false;
 if (is_equal(__context, thrown_pointer_type->__context, false))
 return true;

Modified: libcxxabi/trunk/src/private_typeinfo.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.h?rev=288457=288456=288457=diff
==
--- libcxxabi/trunk/src/private_typeinfo.h (original)
+++ libcxxabi/trunk/src/private_typeinfo.h Thu Dec  1 20:06:53 2016
@@ -49,33 +49,6 @@ public:
void *&) const;
 };
 
-// This implements the following proposal from cxx-abi-dev (not yet part of the
-// ABI document):
-//
-//   http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002988.html
-//
-// This is necessary for support of http://wg21.link/p0012, which permits 
throwing
-// noexcept function and member function pointers and catching them as 
non-noexcept
-// pointers.
-class 

r288453 - [CUDA] Fix faulty test from rL288448

2016-12-01 Thread Jason Henline via cfe-commits
Author: jhen
Date: Thu Dec  1 20:04:43 2016
New Revision: 288453

URL: http://llvm.org/viewvc/llvm-project?rev=288453=rev
Log:
[CUDA] Fix faulty test from rL288448

Summary:
The test introduced by rL288448 is currently failing because
unimportant but unexpected errors appear as output from a test compile
line. This patch looks for a more specific error message, in order to
avoid false positives.

Reviewers: jlebar

Subscribers: cfe-commits

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

Switch to more specific error

Modified:
cfe/trunk/test/Driver/cuda-no-sanitizers.cu

Modified: cfe/trunk/test/Driver/cuda-no-sanitizers.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-no-sanitizers.cu?rev=288453=288452=288453=diff
==
--- cfe/trunk/test/Driver/cuda-no-sanitizers.cu (original)
+++ cfe/trunk/test/Driver/cuda-no-sanitizers.cu Thu Dec  1 20:04:43 2016
@@ -6,7 +6,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 
-fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
-// CHECK-NOT: error:
+// CHECK-NOT: error: unsupported option '-fsanitize=address'
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"


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


r288452 - p0012r1: define corresponding feature test macro

2016-12-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec  1 20:02:23 2016
New Revision: 288452

URL: http://llvm.org/viewvc/llvm-project?rev=288452=rev
Log:
p0012r1: define corresponding feature test macro

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Lexer/cxx-features.cpp

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=288452=288451=288452=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Dec  1 20:02:23 2016
@@ -510,7 +510,7 @@ static void InitializeCPlusPlusFeatureTe
   if (LangOpts.CPlusPlus1z) {
 Builder.defineMacro("__cpp_hex_float", "201603");
 Builder.defineMacro("__cpp_inline_variables", "201606");
-//Builder.defineMacro("__cpp_noexcept_function_type", "201510");
+Builder.defineMacro("__cpp_noexcept_function_type", "201510");
 Builder.defineMacro("__cpp_capture_star_this", "201603");
 Builder.defineMacro("__cpp_if_constexpr", "201606");
 Builder.defineMacro("__cpp_template_auto", "201606");

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=288452=288451=288452=diff
==
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Thu Dec  1 20:02:23 2016
@@ -34,8 +34,7 @@
 #error "wrong value for __cpp_aligned_new"
 #endif
 
-#if check(noexcept_function_type, 0, 0, 0, 0)
-// FIXME: value shuld be 201510 for cxx1z once implemented
+#if check(noexcept_function_type, 0, 0, 0, 201510)
 #error "wrong value for __cpp_noexcept_function_type"
 #endif
 


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


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

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

Thank you very much for the reviews, @alexfh.


https://reviews.llvm.org/D27284



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


[PATCH] D27328: Remove faulty test from rL288448

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen updated this revision to Diff 80012.
jhen added a comment.

- Switch to more specific error


https://reviews.llvm.org/D27328

Files:
  test/Driver/cuda-no-sanitizers.cu


Index: test/Driver/cuda-no-sanitizers.cu
===
--- test/Driver/cuda-no-sanitizers.cu
+++ test/Driver/cuda-no-sanitizers.cu
@@ -6,7 +6,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 
-fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
-// CHECK-NOT: error:
+// CHECK-NOT: error: unsupported option '-fsanitize=address'
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"


Index: test/Driver/cuda-no-sanitizers.cu
===
--- test/Driver/cuda-no-sanitizers.cu
+++ test/Driver/cuda-no-sanitizers.cu
@@ -6,7 +6,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
-// CHECK-NOT: error:
+// CHECK-NOT: error: unsupported option '-fsanitize=address'
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

2016-12-01 Thread Justin Lebar via Phabricator via cfe-commits
jlebar updated this revision to Diff 80011.
jlebar added a comment.

Suggest std::foo instead of ::foof.

I spoke with rtrieu IRL and he suggested I do this to match what he did in
SemaChecking.cpp for calls to "abs".  Seems reasonable to me.  This also lets
me sidestep the question of lexing the qualifiers, which is nice.


https://reviews.llvm.org/D27284

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
  clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp

Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
@@ -0,0 +1,314 @@
+// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t
+
+double acos(double);
+double acosh(double);
+double asin(double);
+double asinh(double);
+double atan2(double, double);
+double atan(double);
+double atanh(double);
+double cbrt(double);
+double ceil(double);
+double copysign(double, double);
+double cos(double);
+double cosh(double);
+double erfc(double);
+double erf(double);
+double exp2(double);
+double exp(double);
+double expm1(double);
+double fabs(double);
+double fdim(double, double);
+double floor(double);
+double fma(double, double, double);
+double fmax(double, double);
+double fmin(double, double);
+double fmod(double, double);
+double frexp(double, int *);
+double hypot(double, double);
+double ilogb(double);
+double ldexp(double, double);
+double lgamma(double);
+long long llrint(double);
+double log10(double);
+double log1p(double);
+double log2(double);
+double logb(double);
+double log(double);
+long lrint(double);
+double modf(double);
+double nearbyint(double);
+double nextafter(double, double);
+double nexttoward(double, long double);
+double pow(double, double);
+double remainder(double, double);
+double remquo(double, double, int *);
+double rint(double);
+double round(double);
+double scalbln(double, long);
+double scalbn(double, int);
+double sin(double);
+double sinh(double);
+double sqrt(double);
+double tan(double);
+double tanh(double);
+double tgamma(double);
+double trunc(double);
+long long llround(double);
+long lround(double);
+
+void check_all_fns() {
+  float a, b, c;
+  int i;
+  long l;
+  int *int_ptr;
+
+  acos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn]
+  // CHECK-FIXES: {{^}}  std::acos(a);{{$}}
+  acosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh'
+  // CHECK-FIXES: {{^}}  std::acosh(a);{{$}}
+  asin(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin'
+  // CHECK-FIXES: {{^}}  std::asin(a);{{$}}
+  asinh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh'
+  // CHECK-FIXES: {{^}}  std::asinh(a);{{$}}
+  atan2(a, b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2'
+  // CHECK-FIXES: {{^}}  std::atan2(a, b);{{$}}
+  atan(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan'
+  // CHECK-FIXES: {{^}}  std::atan(a);{{$}}
+  atanh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh'
+  // CHECK-FIXES: {{^}}  std::atanh(a);{{$}}
+  cbrt(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt'
+  // CHECK-FIXES: {{^}}  std::cbrt(a);{{$}}
+  ceil(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil'
+  // CHECK-FIXES: {{^}}  std::ceil(a);{{$}}
+  copysign(a, b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign'
+  // CHECK-FIXES: {{^}}  std::copysign(a, b);{{$}}
+  cos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos'
+  // CHECK-FIXES: {{^}}  std::cos(a);{{$}}
+  cosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh'
+  // CHECK-FIXES: {{^}}  std::cosh(a);{{$}}
+  erf(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf'
+  // CHECK-FIXES: {{^}}  std::erf(a);{{$}}
+  erfc(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc'
+  // CHECK-FIXES: {{^}}  std::erfc(a);{{$}}
+  exp2(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2'
+  // CHECK-FIXES: {{^}}  std::exp2(a);{{$}}
+  exp(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp'
+  // CHECK-FIXES: {{^}}  std::exp(a);{{$}}
+  expm1(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1'
+  // CHECK-FIXES: {{^}}  std::expm1(a);{{$}}
+  fabs(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fabs'
+  // CHECK-FIXES: {{^}}  std::fabs(a);{{$}}
+  fdim(a, b);
+  // CHECK-MESSAGES: 

[PATCH] D27328: Remove faulty test from rL288448

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen created this revision.
jhen added a reviewer: jlebar.
jhen added a subscriber: cfe-commits.

The test introduced by https://reviews.llvm.org/rL288448 is currently failing 
because
unimportant but unexpected errors appear as output from a test compile
line. This patch removes the faulty test for now. Tomorrow I will come
back and figure out how to put it back in a safe way.


https://reviews.llvm.org/D27328

Files:
  test/Driver/cuda-no-sanitizers.cu


Index: test/Driver/cuda-no-sanitizers.cu
===
--- test/Driver/cuda-no-sanitizers.cu
+++ test/Driver/cuda-no-sanitizers.cu
@@ -6,7 +6,6 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 
-fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
-// CHECK-NOT: error:
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"


Index: test/Driver/cuda-no-sanitizers.cu
===
--- test/Driver/cuda-no-sanitizers.cu
+++ test/Driver/cuda-no-sanitizers.cu
@@ -6,7 +6,6 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
-// CHECK-NOT: error:
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288449 - Recover better from an incompatible .pcm file being provided by -fmodule-file=.

2016-12-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec  1 19:52:28 2016
New Revision: 288449

URL: http://llvm.org/viewvc/llvm-project?rev=288449=rev
Log:
Recover better from an incompatible .pcm file being provided by -fmodule-file=.
We try to include the headers of the module textually in this case, still
enforcing the modules semantic rules. In order to make that work, we need to
still track that we're entering and leaving the module. Also, if the module was
also marked as unavailable (perhaps because it was missing a file), we
shouldn't mark the module unavailable -- we don't need the module to be
complete if we're going to enter it textually.

Added:
cfe/trunk/test/Modules/config-mismatch.cpp
Modified:
cfe/trunk/include/clang/Lex/ModuleLoader.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/ModuleLoader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleLoader.h?rev=288449=288448=288449=diff
==
--- cfe/trunk/include/clang/Lex/ModuleLoader.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleLoader.h Thu Dec  1 19:52:28 2016
@@ -31,13 +31,22 @@ typedef ArrayRefgetName()))
+.findModule(II->getName())) {
   M->HasIncompatibleModuleFile = true;
+
+  // Mark module as available if the only reason it was unavailable
+  // was missing headers.
+  SmallVector Stack;
+  Stack.push_back(M);
+  while (!Stack.empty()) {
+Module *Current = Stack.pop_back_val();
+if (Current->IsMissingRequirement) continue;
+Current->IsAvailable = true;
+Stack.insert(Stack.end(),
+ Current->submodule_begin(), Current->submodule_end());
+  }
+}
   }
   LoadedModules.clear();
 }
@@ -1498,7 +1511,7 @@ CompilerInstance::loadModule(SourceLocat
   if (Module && Module->HasIncompatibleModuleFile) {
 // We tried and failed to load a module file for this module. Fall
 // back to textual inclusion for its headers.
-return ModuleLoadResult(nullptr, /*missingExpected*/true);
+return ModuleLoadResult::ConfigMismatch;
   }
 
   getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled)
@@ -1705,7 +1718,7 @@ CompilerInstance::loadModule(SourceLocat
 << Module->getFullModuleName()
 << SourceRange(Path.front().second, Path.back().second);
 
-  return ModuleLoadResult(nullptr, true);
+  return ModuleLoadResult::MissingExpected;
 }
 
 // Check whether this module is available.
@@ -1739,7 +1752,7 @@ CompilerInstance::loadModule(SourceLocat
   }
 
   LastModuleImportLoc = ImportLoc;
-  LastModuleImportResult 

r288448 - [CUDA] "Support" ASAN arguments in CudaToolChain

2016-12-01 Thread Jason Henline via cfe-commits
Author: jhen
Date: Thu Dec  1 19:42:54 2016
New Revision: 288448

URL: http://llvm.org/viewvc/llvm-project?rev=288448=rev
Log:
[CUDA] "Support" ASAN arguments in CudaToolChain

This fixes a bug that was introduced in rL287285. The bug made it
illegal to pass -fsanitize=address during CUDA compilation because the
CudaToolChain class was switched from deriving from the Linux toolchain
class to deriving directly from the ToolChain toolchain class. When
CudaToolChain derived from Linux, it used Linux's getSupportedSanitizers
method, and that method allowed ASAN, but when it switched to deriving
directly from ToolChain, it inherited a getSupportedSanitizers method
that didn't allow for ASAN.

This patch fixes that bug by creating a getSupportedSanitizers method
for CudaToolChain that supports ASAN.

This patch also fixes the test that checks that -fsanitize=address is
passed correctly for CUDA builds. That test didn't used to notice if an
error message was emitted, and that's why it didn't catch this bug when
it was first introduced. With the fix from this patch, that test will
now catch any similar bug in the future.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/cuda-no-sanitizers.cu

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=288448=288447=288448=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Dec  1 19:42:54 2016
@@ -4973,6 +4973,15 @@ void CudaToolChain::AddIAMCUIncludeArgs(
   HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
 }
 
+SanitizerMask CudaToolChain::getSupportedSanitizers() const {
+  // The CudaToolChain only supports address sanitization in the sense that it
+  // allows ASAN arguments on the command line. It must not error out on these
+  // command line arguments because the host code compilation supports them.
+  // However, it doesn't actually do any address sanitization for device code;
+  // instead, it just ignores any ASAN command line arguments it sees.
+  return SanitizerKind::Address;
+}
+
 /// XCore tool chain
 XCoreToolChain::XCoreToolChain(const Driver , const llvm::Triple ,
const ArgList )

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=288448=288447=288448=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Dec  1 19:42:54 2016
@@ -912,6 +912,8 @@ public:
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
+  SanitizerMask getSupportedSanitizers() const override;
+
   const ToolChain 
   CudaInstallationDetector CudaInstallation;
 

Modified: cfe/trunk/test/Driver/cuda-no-sanitizers.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-no-sanitizers.cu?rev=288448=288447=288448=diff
==
--- cfe/trunk/test/Driver/cuda-no-sanitizers.cu (original)
+++ cfe/trunk/test/Driver/cuda-no-sanitizers.cu Thu Dec  1 19:42:54 2016
@@ -6,6 +6,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 
-fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
+// CHECK-NOT: error:
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"


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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

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

This takes it back to how it used to be before I regressed it, which I think is 
good enough for now.  If we want to revisit how we make this work for 
offloading toolchains in general, we can do that separately.


https://reviews.llvm.org/D27316



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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen updated this revision to Diff 80003.
jhen added a comment.

- "Support" ASAN in CudaToolChain


https://reviews.llvm.org/D27316

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/cuda-no-sanitizers.cu


Index: test/Driver/cuda-no-sanitizers.cu
===
--- test/Driver/cuda-no-sanitizers.cu
+++ test/Driver/cuda-no-sanitizers.cu
@@ -6,6 +6,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 
-fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
+// CHECK-NOT: error:
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -912,6 +912,8 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
+  SanitizerMask getSupportedSanitizers() const override;
+
   const ToolChain 
   CudaInstallationDetector CudaInstallation;
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4973,6 +4973,15 @@
   HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
 }
 
+SanitizerMask CudaToolChain::getSupportedSanitizers() const {
+  // The CudaToolChain only supports address sanitization in the sense that it
+  // allows ASAN arguments on the command line. It must not error out on these
+  // command line arguments because the host code compilation supports them.
+  // However, it doesn't actually do any address sanitization for device code;
+  // instead, it just ignores any ASAN command line arguments it sees.
+  return SanitizerKind::Address;
+}
+
 /// XCore tool chain
 XCoreToolChain::XCoreToolChain(const Driver , const llvm::Triple ,
const ArgList )


Index: test/Driver/cuda-no-sanitizers.cu
===
--- test/Driver/cuda-no-sanitizers.cu
+++ test/Driver/cuda-no-sanitizers.cu
@@ -6,6 +6,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \
 // RUN:   FileCheck %s
 
+// CHECK-NOT: error:
 // CHECK-DAG: "-fcuda-is-device"
 // CHECK-NOT: "-fsanitize=address"
 // CHECK-DAG: "-triple" "x86_64--linux-gnu"
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -912,6 +912,8 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
+  SanitizerMask getSupportedSanitizers() const override;
+
   const ToolChain 
   CudaInstallationDetector CudaInstallation;
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4973,6 +4973,15 @@
   HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
 }
 
+SanitizerMask CudaToolChain::getSupportedSanitizers() const {
+  // The CudaToolChain only supports address sanitization in the sense that it
+  // allows ASAN arguments on the command line. It must not error out on these
+  // command line arguments because the host code compilation supports them.
+  // However, it doesn't actually do any address sanitization for device code;
+  // instead, it just ignores any ASAN command line arguments it sees.
+  return SanitizerKind::Address;
+}
+
 /// XCore tool chain
 XCoreToolChain::XCoreToolChain(const Driver , const llvm::Triple ,
const ArgList )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288447 - [WebAssembly] Add an -mdirect flag for the direct wasm object feature.

2016-12-01 Thread Dan Gohman via cfe-commits
Author: djg
Date: Thu Dec  1 19:12:40 2016
New Revision: 288447

URL: http://llvm.org/viewvc/llvm-project?rev=288447=rev
Log:
[WebAssembly] Add an -mdirect flag for the direct wasm object feature.

Add a target flag for enabling the new direct wasm object emission
feature.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=288447=288446=288447=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Dec  1 19:12:40 2016
@@ -1613,6 +1613,8 @@ def ffixed_x18 : Flag<["-"], "ffixed-x18
 
 def msimd128 : Flag<["-"], "msimd128">, Group;
 def mno_simd128 : Flag<["-"], "mno-simd128">, Group;
+def mdirect : Flag<["-"], "mdirect">, Group;
+def mno_direct : Flag<["-"], "mno-direct">, Group;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=288447=288446=288447=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Dec  1 19:12:40 2016
@@ -8019,6 +8019,10 @@ private:
 SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1));
 continue;
   }
+  if (Feature == "+direct")
+continue;
+  if (Feature == "-direct")
+continue;
 
   Diags.Report(diag::err_opt_not_valid_with_opt) << Feature
  << "-target-feature";


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


[PATCH] D26955: Fix bitwidth for x87 extended-precision floating-point type

2016-12-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

There's nothing wrong with this change, as far as I can tell.  That said, if 
you're planning to use getRealTypeByWidth anywhere other than AddModeAttr, it's 
probably a bug; the behavior of getRealTypeByWidth isn't useful for any other 
purpose given that clang supports multiple 128-bit floating-point types.


https://reviews.llvm.org/D26955



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


r288444 - Delete tautological assertion.

2016-12-01 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Thu Dec  1 18:51:58 2016
New Revision: 288444

URL: http://llvm.org/viewvc/llvm-project?rev=288444=rev
Log:
Delete tautological assertion.

After r256463, both the LHS and RHS now refer to the same variable. Before,
they referred to the member, the parameter respectively. Now GCC6's
-Wtautological-compare complains.

Modified:
cfe/trunk/lib/AST/DeclTemplate.cpp

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=288444=288443=288444=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Dec  1 18:51:58 2016
@@ -36,7 +36,6 @@ TemplateParameterList::TemplateParameter
   : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
 NumParams(Params.size()), ContainsUnexpandedParameterPack(false),
 HasRequiresClause(static_cast(RequiresClause)) {
-  assert(this->NumParams == NumParams && "Too many template parameters");
   for (unsigned Idx = 0; Idx < NumParams; ++Idx) {
 NamedDecl *P = Params[Idx];
 begin()[Idx] = P;


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


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2),
+   hasBuiltinTyParam(0, DoubleTy),
+   hasBuiltinTyParam(1, DoubleTy))),
+   hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy))
+  .bind("call"),

jlebar wrote:
> alexfh wrote:
> > I guess, functions with arbitrary number of parameters can all be handled 
> > using `forEachArgumentWithParam`. Roughly like this:
> > 
> >   forEachArgumentWithParam(
> >  hasType(isBuiltinType(FloatTy)),
> >  parmVarDecl(hasType(isBuiltinType(DoubleTy)))
> > 
> > One difference to your existing implementation will be that it will match 
> > calls where at least one parameter is double and argument is float, not all 
> > of them. Do you expect this to make the check more noisy? 
> > Do you expect this to make the check more noisy?
> 
> Yes, to the point of not being worth doing, I think.
> 
> Specifically, I think there is nothing wrong with calling a two-arg function 
> double function with one float and one double arg and expecting the float arg 
> to be promoted: `::hypot(3.f, 4.)` probably *should* call the double version.
> 
> So checking that the arg types are all `float` is important, I think.  
> Checking that the parameter types are all `double` is less important but also 
> worth doing, I think, so if you declare some bizarre function in the global 
> namespace called e.g. `::hypot`, we won't suggest changing that to `::hypotf`.
Fair enough. I don't like the verbosity of the code here, but it may really be 
valuable to be strict here.



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145
+  // Skip the "::" following the qualifier.
+  FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2);
+}

jlebar wrote:
> alexfh wrote:
> > `getLocWithOffset` makes the code quite brittle. Imagine whitespace around 
> > `::`, for example. Same below. In order to make this kind of code more 
> > robust, you can operate on tokens (using Lexer).
> > 
> > Same below.
> Hm.  I agree this is super-brittle.  But I am having a lot of difficulty 
> using the Lexer successfully.
> 
> For one thing, there may be comments basically anywhere in this stream, and I 
> have to skip over them.  I see getPreviousNonCommentToken, but it doesn't 
> quite work if I need to go *forward* in the stream.  I looked at a bunch of 
> other uses of the Lexer in clang-tidy and they all looked pretty different 
> from what I'm trying to do here, which also suggested that maybe I'm doing 
> the wrong thing.
> 
> Is there no way to get the source location of "sin" out of the DeclRefExpr 
> for "::sin"?  I don't see it, but it seems bizarre that it wouldn't be there.
> 
> Any tips would be much appreciated.
Skipping from `::` to the next identifier should be straightforward using 
Lexer::getRawToken and Lexer::getLocForEndOfToken. Tell me if you need more 
details.


https://reviews.llvm.org/D27284



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


[PATCH] D27140: Allow clang to write compilation database records

2016-12-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg updated the summary for this revision.
joerg set the repository for this revision to rL LLVM.
joerg updated this revision to Diff 79997.
joerg added a comment.

Add test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D27140

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/compilation_database.c

Index: test/Driver/compilation_database.c
===
--- test/Driver/compilation_database.c
+++ test/Driver/compilation_database.c
@@ -0,0 +1,10 @@
+// RUN: %clang -MD -MP -c -x c %s -xc++ %s -Wall -MJ - 2>&1 | FileCheck %s
+// RUN: not %clang -c -x c %s -MJ %s/non-existant 2>&1 | FileCheck --check-prefix=ERROR %s
+
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc", "[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// CHECK: { "directory": "[[CWD:[^"]+]]",  "file": "[[SRC:[^"]+[/|\\]compilation_database.c]]", "output": "compilation_database.o", "arguments": ["{{[^"]*}}clang{{[^"]*}}", "-xc++", "[[SRC]]", "-c", "-Wall", "--target={{[^"]+}}"]},
+// ERROR: error: compilation database '{{.*}}/non-existant' could not be opened:
+
+int main(void) {
+  return 0;
+}
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -17,6 +17,7 @@
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {
@@ -101,6 +102,12 @@
 
   mutable std::unique_ptr CLFallback;
 
+  mutable std::unique_ptr CompilationDatabase = nullptr;
+  void DumpCompilationDatabase(Compilation , StringRef Filename,
+   StringRef Target,
+   const InputInfo , const InputInfo ,
+   const llvm::opt::ArgList ) const;
+
 public:
   // CAUTION! The first constructor argument ("clang") is not arbitrary,
   // as it is for other tools. Some operations on a Tool actually test
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -40,9 +40,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/YAMLParser.h"
 
 #ifdef LLVM_ON_UNIX
 #include  // For getuid().
@@ -4005,6 +4005,60 @@
 CmdArgs.push_back("-KPIC");
 }
 
+void Clang::DumpCompilationDatabase(Compilation , StringRef Filename,
+StringRef Target, const InputInfo ,
+const InputInfo , const ArgList ) const {
+  // If this is a dry run, do not create the compilation database file.
+  if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
+return;
+
+  using llvm::yaml::escape;
+  const Driver  = getToolChain().getDriver();
+
+  if (!CompilationDatabase) {
+std::error_code EC;
+auto File = llvm::make_unique(Filename, EC, llvm::sys::fs::F_Text);
+if (EC) {
+  D.Diag(clang::diag::err_drv_compilationdatabase) << Filename
+   << EC.message();
+  return;
+}
+CompilationDatabase = std::move(File);
+  }
+  auto  = *CompilationDatabase;
+  SmallString<128> Buf;
+  if (llvm::sys::fs::current_path(Buf))
+Buf = ".";
+  CDB << "{ \"directory\": \"" << escape(Buf) << "\"";
+  CDB << ", \"file\": \"" << escape(Input.getFilename()) << "\"";
+  CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
+  CDB << ", \"arguments\": [\"" << escape(D.ClangExecutable) << "\"";
+  Buf = "-x";
+  Buf += types::getTypeName(Input.getType());
+  CDB << ", \"" << escape(Buf) << "\"";
+  CDB << ", \"" << escape(Input.getFilename()) << "\"";
+  for (auto : Args) {
+auto  = A->getOption();
+// Skip language selection, which is positional.
+if (O.getID() == options::OPT_x)
+  continue;
+// Skip writing dependency output and the compilation database itself.
+if (O.getGroup().isValid() && O.getGroup().getID() == options::OPT_M_Group)
+  continue;
+// Skip inputs.
+if (O.getKind() == Option::InputClass)
+  continue;
+// All other arguments are quoted and appended.
+ArgStringList ASL;
+A->render(Args, ASL);
+for (auto : ASL)
+  CDB << ", \"" << escape(it) << "\"";
+  }
+  Buf = "--target=";
+  Buf += Target;
+  CDB << ", \"" << escape(Buf) << "\"]},\n";
+}
+
 void Clang::ConstructJob(Compilation , const JobAction ,
  const InputInfo , const InputInfoList ,
  const ArgList , const char *LinkingOutput) 

[PATCH] D26955: Fix bitwidth for x87 extended-precision floating-point type

2016-12-01 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 79996.
ddcc added a comment.

Change definition


https://reviews.llvm.org/D26955

Files:
  lib/Basic/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3388,7 +3388,7 @@
   DestWidth = 64;
   break;
 case 'X':
-  DestWidth = 96;
+  DestWidth = 80;
   break;
 case 'T':
   DestWidth = 128;
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -226,7 +226,7 @@
 return Double;
 
   switch (BitWidth) {
-  case 96:
+  case 80:
 if (() == ::APFloat::x87DoubleExtended)
   return LongDouble;
 break;


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3388,7 +3388,7 @@
   DestWidth = 64;
   break;
 case 'X':
-  DestWidth = 96;
+  DestWidth = 80;
   break;
 case 'T':
   DestWidth = 128;
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -226,7 +226,7 @@
 return Double;
 
   switch (BitWidth) {
-  case 96:
+  case 80:
 if (() == ::APFloat::x87DoubleExtended)
   return LongDouble;
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288440 - Struct GEPs must use i32, not whatever size_t is. It should be safe

2016-12-01 Thread John McCall via cfe-commits
Author: rjmccall
Date: Thu Dec  1 17:51:30 2016
New Revision: 288440

URL: http://llvm.org/viewvc/llvm-project?rev=288440=rev
Log:
Struct GEPs must use i32, not whatever size_t is.  It should be safe
to do this unconditionally, given that the indices will always be small
constant integers anyway.

Modified:
cfe/trunk/lib/CodeGen/ConstantBuilder.h

Modified: cfe/trunk/lib/CodeGen/ConstantBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ConstantBuilder.h?rev=288440=288439=288440=diff
==
--- cfe/trunk/lib/CodeGen/ConstantBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/ConstantBuilder.h Thu Dec  1 17:51:30 2016
@@ -248,11 +248,13 @@ public:
   // Otherwise, add an index to drill into the first level of pointer. 
   } else {
 assert(indices.empty());
-indices.push_back(llvm::ConstantInt::get(Builder.CGM.SizeTy, 0));
+indices.push_back(llvm::ConstantInt::get(Builder.CGM.Int32Ty, 0));
   }
 
   assert(position >= Begin);
-  indices.push_back(llvm::ConstantInt::get(Builder.CGM.SizeTy,
+  // We have to use i32 here because struct GEPs demand i32 indices.
+  // It's rather unlikely to matter in practice.
+  indices.push_back(llvm::ConstantInt::get(Builder.CGM.Int32Ty,
position - Begin));
 }
   };


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


r288438 - [libclang] Add APIs to check the result of an integer expression in CXEvalResult without overflow

2016-12-01 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Dec  1 17:41:27 2016
New Revision: 288438

URL: http://llvm.org/viewvc/llvm-project?rev=288438=rev
Log:
[libclang] Add APIs to check the result of an integer expression in 
CXEvalResult without overflow

Patch by Emilio Cobos Álvarez!
See https://reviews.llvm.org/D26788

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/evaluate-cursor.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=288438=288437=288438=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Dec  1 17:41:27 2016
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 36
+#define CINDEX_VERSION_MINOR 37
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -5266,6 +5266,25 @@ CINDEX_LINKAGE CXEvalResultKind clang_Ev
 CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
 
 /**
+ * \brief Returns the evaluation result as a long long integer if the
+ * kind is Int. This prevents overflows that may happen if the result is
+ * returned with clang_EvalResult_getAsInt.
+ */
+CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
+
+/**
+ * \brief Returns a non-zero value if the kind is Int and the evaluation
+ * result resulted in an unsigned integer.
+ */
+CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
+
+/**
+ * \brief Returns the evaluation result as an unsigned integer if
+ * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
+ */
+CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult 
E);
+
+/**
  * \brief Returns the evaluation result as double if the
  * kind is double.
  */

Modified: cfe/trunk/test/Index/evaluate-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/evaluate-cursor.cpp?rev=288438=288437=288438=diff
==
--- cfe/trunk/test/Index/evaluate-cursor.cpp (original)
+++ cfe/trunk/test/Index/evaluate-cursor.cpp Thu Dec  1 17:41:27 2016
@@ -15,6 +15,12 @@ void goo() {
   int a = __LINE__;
 }
 
+unsigned long long foo_int = 1ull << 60;
+
+unsigned long long HUGE = 1ull << 63;
+
+long long HUGE_NEG = -(1ll << 35);
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -28,3 +34,11 @@ void goo() {
 // CHECK-MACRO: [function macro]
 // CHECK-MACRO: [function macro]
 // CHECK-MACRO: [builtin macro]
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:22:11 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-LONG %s
+// CHECK-LONG: unsigned, Value: 1152921504606846976
+// CHECK-LONG: unsigned, Value: 9223372036854775808
+// CHECK-LONG: Value: -34359738368

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=288438=288437=288438=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Dec  1 17:41:27 2016
@@ -2462,8 +2462,14 @@ static void display_evaluate_results(CXE
   switch (clang_EvalResult_getKind(result)) {
 case CXEval_Int:
 {
-  int val = clang_EvalResult_getAsInt(result);
-  printf("Kind: Int , Value: %d", val);
+  printf("Kind: Int, ");
+  if (clang_EvalResult_isUnsignedInt(result)) {
+unsigned long long val = clang_EvalResult_getAsUnsigned(result);
+printf("unsigned, Value: %llu", val);
+  } else {
+long long val = clang_EvalResult_getAsLongLong(result);
+printf("Value: %lld", val);
+  }
   break;
 }
 case CXEval_Float:

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=288438=288437=288438=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Dec  1 17:41:27 2016
@@ -3518,10 +3518,12 @@ static StringLiteral* getCFSTR_value(Cal
 struct ExprEvalResult {
   CXEvalResultKind EvalType;
   union {
-int intVal;
+unsigned long long unsignedVal;
+long long intVal;
 double floatVal;
 char *stringVal;
   } EvalData;
+  bool IsUnsignedInt;
   ~ExprEvalResult() {
 if (EvalType != CXEval_UnExposed && EvalType != 

[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move out of alpha

2016-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin marked 2 inline comments as done.
dcoughlin added a comment.

In https://reviews.llvm.org/D26768#607157, @zaks.anna wrote:

> Not sure if we should make pure vs not an option so that users could turn the 
> checking off. Is there a way to suppress the warning?


There is not a way to suppress this. I've added an analyzer-config option to 
limit diagnostics to pure-virtual calls only.


https://reviews.llvm.org/D26768



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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move out of alpha

2016-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin updated this revision to Diff 79992.
dcoughlin added a comment.

- Add a PureOnly analyzer-config option that, when set, will limit diagnostics 
to calls to only pure virtual functions.

This should have gone in with the prevision updated diff; my apologies for the 
noise.


https://reviews.llvm.org/D26768

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/dtor.cpp
  test/Analysis/virtualcall.cpp
  test/Analysis/virtualcall.h

Index: test/Analysis/virtualcall.h
===
--- test/Analysis/virtualcall.h
+++ test/Analysis/virtualcall.h
@@ -18,7 +18,15 @@
   class A {
   public:
 A() {
-  foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
 }
 
 virtual int foo();
Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,36 +1,79 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.VirtualCall -analyzer-store region -analyzer-config cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.VirtualCall -analyzer-store region -analyzer-config cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
+
+/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
+   from a constructor or destructor. If it is not set, we expect diagnostics
+   only in the constructor or destructor.
+
+   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
+   functions not to non-pure virtual functions.
+*/
 
 class A {
 public:
   A();
+  A(int i);
+
   ~A() {};
   
-  virtual int foo() = 0;
+  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
   virtual void bar() = 0;
   void f() {
-foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+foo();
+#if INTERPROCEDURAL
+// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
+#endif
   }
 };
 
 class B : public A {
 public:
   B() {
-foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
   }
   ~B();
   
   virtual int foo();
-  virtual void bar() { foo(); }  // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  virtual void bar() { foo(); }
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
+#endif
 };
 
 A::A() {
   f();
 }
 
+A::A(int i) {
+  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
+#else
+  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
+#endif
+}
+
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  this->foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}}
+#endif
+#endif
+
 }
 
 class C : public B {
@@ -43,7 +86,14 @@
 };
 
 C::C() {
-  f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  f(foo());

r288436 - Extend CompilationDatabase by a field for the output filename

2016-12-01 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Thu Dec  1 17:37:45 2016
New Revision: 288436

URL: http://llvm.org/viewvc/llvm-project?rev=288436=rev
Log:
Extend CompilationDatabase by a field for the output filename

In bigger projects like an Operating System, the same source code is
often compiled in slightly different ways. This could be the difference
between PIC and non-PIC code for static vs dynamic libraries, it could
also be the difference between size optimised versions of tools for
ramdisk images. At the moment, the compilation database has no way to
distinguish such cases. As first step, add a field in the JSON format
for it and process it accordingly.

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

Modified:
cfe/trunk/docs/JSONCompilationDatabase.rst
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/docs/JSONCompilationDatabase.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/JSONCompilationDatabase.rst?rev=288436=288435=288436=diff
==
--- cfe/trunk/docs/JSONCompilationDatabase.rst (original)
+++ cfe/trunk/docs/JSONCompilationDatabase.rst Thu Dec  1 17:37:45 2016
@@ -80,6 +80,9 @@ The contracts for each field in the comm
supported.
 -  **arguments:** The compile command executed as list of strings.
Either **arguments** or **command** is required.
+-  **output:** The name of the output created by this compilation step.
+   This field is optional. It can be used to distinguish different processing
+   modes of the same input file.
 
 Build System Integration
 

Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=288436=288435=288436=diff
==
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Thu Dec  1 17:37:45 
2016
@@ -43,10 +43,11 @@ namespace tooling {
 struct CompileCommand {
   CompileCommand() {}
   CompileCommand(Twine Directory, Twine Filename,
- std::vector CommandLine)
+ std::vector CommandLine, Twine Output)
   : Directory(Directory.str()),
 Filename(Filename.str()),
-CommandLine(std::move(CommandLine)) {}
+CommandLine(std::move(CommandLine)),
+Output(Output.str()){}
 
   /// \brief The working directory the command was executed from.
   std::string Directory;
@@ -57,6 +58,9 @@ struct CompileCommand {
   /// \brief The command line that was executed.
   std::vector CommandLine;
 
+  /// The output file associated with the command.
+  std::string Output;
+
   /// \brief An optional mapping from each file's path to its content for all
   /// files needed for the compilation that are not available via the file
   /// system.

Modified: cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h?rev=288436=288435=288436=diff
==
--- cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h Thu Dec  1 
17:37:45 2016
@@ -103,15 +103,17 @@ private:
   /// failed.
   bool parse(std::string );
 
-  // Tuple (directory, filename, commandline) where 'commandline' points to the
-  // corresponding scalar nodes in the YAML stream.
+  // Tuple (directory, filename, commandline, output) where 'commandline'
+  // points to the corresponding scalar nodes in the YAML stream.
   // If the command line contains a single argument, it is a shell-escaped
   // command line.
   // Otherwise, each entry in the command line vector is a literal
   // argument to the compiler.
+  // The output field may be a nullptr.
   typedef std::tuple> CompileCommandRef;
+ std::vector,
+ llvm::yaml::ScalarNode *> CompileCommandRef;
 
   /// \brief Converts the given array of CompileCommandRefs to CompileCommands.
   void getCommands(ArrayRef CommandsRef,

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=288436=288435=288436=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Thu Dec  1 17:37:45 2016
@@ -300,7 +300,8 @@ FixedCompilationDatabase(Twine Directory
   ToolCommandLine.insert(ToolCommandLine.end(),

[PATCH] D27138: Extend CompilationDatabase by a field for the output filename

2016-12-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288436: Extend CompilationDatabase by a field for the output 
filename (authored by joerg).

Changed prior to commit:
  https://reviews.llvm.org/D27138?vs=79320=79993#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27138

Files:
  cfe/trunk/docs/JSONCompilationDatabase.rst
  cfe/trunk/include/clang/Tooling/CompilationDatabase.h
  cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
  cfe/trunk/lib/Tooling/CompilationDatabase.cpp
  cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
  cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Index: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp
@@ -300,7 +300,8 @@
   ToolCommandLine.insert(ToolCommandLine.end(),
  CommandLine.begin(), CommandLine.end());
   CompileCommands.emplace_back(Directory, StringRef(),
-   std::move(ToolCommandLine));
+   std::move(ToolCommandLine),
+   StringRef());
 }
 
 std::vector
Index: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
@@ -257,10 +257,13 @@
   for (int I = 0, E = CommandsRef.size(); I != E; ++I) {
 SmallString<8> DirectoryStorage;
 SmallString<32> FilenameStorage;
+SmallString<32> OutputStorage;
+auto Output = std::get<3>(CommandsRef[I]);
 Commands.emplace_back(
 std::get<0>(CommandsRef[I])->getValue(DirectoryStorage),
 std::get<1>(CommandsRef[I])->getValue(FilenameStorage),
-nodeToCommandLine(Syntax, std::get<2>(CommandsRef[I])));
+nodeToCommandLine(Syntax, std::get<2>(CommandsRef[I])),
+Output ? Output->getValue(OutputStorage) : "");
   }
 }
 
@@ -289,6 +292,7 @@
 llvm::yaml::ScalarNode *Directory = nullptr;
 llvm::Optional Command;
 llvm::yaml::ScalarNode *File = nullptr;
+llvm::yaml::ScalarNode *Output = nullptr;
 for (auto& NextKeyValue : *Object) {
   llvm::yaml::ScalarNode *KeyString =
   dyn_cast(NextKeyValue.getKey());
@@ -331,6 +335,8 @@
   Command = std::vector(1, ValueString);
   } else if (KeyValue == "file") {
 File = ValueString;
+  } else if (KeyValue == "output") {
+Output = ValueString;
   } else {
 ErrorMessage = ("Unknown key: \"" +
 KeyString->getRawValue() + "\"").str();
@@ -361,7 +367,7 @@
 } else {
   llvm::sys::path::native(FileName, NativeFilePath);
 }
-auto Cmd = CompileCommandRef(Directory, File, *Command);
+auto Cmd = CompileCommandRef(Directory, File, *Command, Output);
 IndexByFile[NativeFilePath].push_back(Cmd);
 AllCommands.push_back(Cmd);
 MatchTrie.insert(NativeFilePath);
Index: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -44,6 +44,7 @@
   expectFailure("[{\"directory\":\"\",\"command\":[],\"file\":\"\"}]", "Command not string");
   expectFailure("[{\"directory\":\"\",\"arguments\":[[]],\"file\":\"\"}]",
 "Arguments contain non-string");
+  expectFailure("[{\"output\":[]}]", "Expected strings as value.");
 }
 
 static std::vector getAllFiles(StringRef JSONDatabase,
@@ -105,16 +106,19 @@
   StringRef Directory1("//net/dir1");
   StringRef FileName1("file1");
   StringRef Command1("command1");
+  StringRef Output1("file1.o");
   StringRef Directory2("//net/dir2");
   StringRef FileName2("file2");
   StringRef Command2("command2");
+  StringRef Output2("");
 
   std::vector Commands = getAllCompileCommands(
   JSONCommandLineSyntax::Gnu,
   ("[{\"directory\":\"" + Directory1 + "\"," + "\"command\":\"" + Command1 +
"\","
"\"file\":\"" +
-   FileName1 + "\"},"
+   FileName1 + "\", \"output\":\"" +
+   Output1 + "\"},"
" {\"directory\":\"" +
Directory2 + "\"," + "\"command\":\"" + Command2 + "\","
   "\"file\":\"" +
@@ -124,10 +128,12 @@
   EXPECT_EQ(2U, Commands.size()) << ErrorMessage;
   EXPECT_EQ(Directory1, Commands[0].Directory) << ErrorMessage;
   EXPECT_EQ(FileName1, Commands[0].Filename) << ErrorMessage;
+  EXPECT_EQ(Output1, Commands[0].Output) << ErrorMessage;
   ASSERT_EQ(1u, Commands[0].CommandLine.size());
   EXPECT_EQ(Command1, Commands[0].CommandLine[0]) << ErrorMessage;
   EXPECT_EQ(Directory2, Commands[1].Directory) << ErrorMessage;
   EXPECT_EQ(FileName2, Commands[1].Filename) << 

[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen added a comment.

In https://reviews.llvm.org/D27316#611162, @kcc wrote:

> I am not sure this is going to work. 
>  You essentially break on the first iteration in the beginning of the loop. 
>  Why not exit the function before the loop? 
>  Also, the loop "claims" the args and by breaking early you leave the args 
> unclaimed.
>
> I don't remember this code well enough to argue about it w/o tests. :(


Thanks for taking a look. I just wanted to make sure nobody knew of a simple 
solution for this problem before I dug in further. Since none of us seems too 
familiar with this code, I'll do more investigation to try to find the right 
way to fix this. Once I do that I'll post it to this review (with a test or two 
to make sure it's working).


https://reviews.llvm.org/D27316



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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

I am not sure this is going to work. 
You essentially break on the first iteration in the beginning of the loop. 
Why not exit the function before the loop? 
Also, the loop "claims" the args and by breaking early you leave the args 
unclaimed.

I don't remember this code well enough to argue about it w/o tests. :(


https://reviews.llvm.org/D27316



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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

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

In https://reviews.llvm.org/D27316#611160, @kcc wrote:

> at the very least this requires a test... Let me thing about the logic a bit 
> more...


I think we just need to fix the test from the previous CL, which is buggy and 
didn't catch this regression.


https://reviews.llvm.org/D27316



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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

at the very least this requires a test... Let me thing about the logic a bit 
more...


https://reviews.llvm.org/D27316



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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move out of alpha

2016-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin updated this revision to Diff 79981.
dcoughlin added a comment.

- Update the diagnostic to be explicit about whether the issue occurs during 
construction or destruction
- Add test for pure, intraprocedural case (Sema also catches this).


https://reviews.llvm.org/D26768

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/dtor.cpp
  test/Analysis/virtualcall.cpp
  test/Analysis/virtualcall.h

Index: test/Analysis/virtualcall.h
===
--- test/Analysis/virtualcall.h
+++ test/Analysis/virtualcall.h
@@ -18,7 +18,12 @@
   class A {
   public:
 A() {
-  foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  foo();
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-4 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
 }
 
 virtual int foo();
Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,36 +1,65 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.VirtualCall -analyzer-store region -analyzer-config cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
 
 class A {
 public:
   A();
+  A(int i);
+
   ~A() {};
   
-  virtual int foo() = 0;
+  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
   virtual void bar() = 0;
   void f() {
-foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+foo();
+#if INTERPROCEDURAL
+// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
+#endif
   }
 };
 
 class B : public A {
 public:
   B() {
-foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+foo();
+#if INTERPROCEDURAL
+// expected-warning-re@-2 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+// expected-warning-re@-4 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
   }
   ~B();
   
   virtual int foo();
-  virtual void bar() { foo(); }  // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  virtual void bar() { foo(); }
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
+#endif
 };
 
 A::A() {
   f();
 }
 
+A::A(int i) {
+  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
+#else
+  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
+#endif
+}
+
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  this->foo();
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-4 ^}}Call to virtual function during destruction will not dispatch to derived class}}
+#endif
+
 }
 
 class C : public B {
@@ -43,7 +72,12 @@
 };
 
 C::C() {
-  f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  f(foo());
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-4 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
 }
 
 class D : public B {
Index: test/Analysis/dtor.cpp
===
--- test/Analysis/dtor.cpp
+++ test/Analysis/dtor.cpp
@@ -184,25 +184,25 @@
 virtual int get() { return 1; }
 
 ~A() {
-  *out1 = get();
+  *out1 = get(); // expected-warning {{Call to virtual 

[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

The frontend is the wrong place as it doesn't even know if the register is ever 
going to be used. E.g. if it is a static function, all instances could be 
inlined away.


https://reviews.llvm.org/D27304



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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

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

> where would be the right place for me to put a test to check that it is 
> working (i.e. ASAN still works for CUDA host code).

I just ran the test from https://reviews.llvm.org/rL281680, and it passes 
because it doesn't notice clang raising the "unsupported option 
'-fsanitize=address" error.  :)

> I don't understand this part of the driver code very well

What I would probably do (other than ask Kostya, who may just Know) is first 
identify which commit caused the regression.  That will probably give us some 
idea of whether or not this is the right fix (and whether or not the check in 
https://reviews.llvm.org/rL281680 is still necessary).




Comment at: lib/Driver/SanitizerArgs.cpp:214
+  break;
+}
 const auto *Arg = *I;

Nit, remove braces.


https://reviews.llvm.org/D27316



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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The logic to compute whether a calling convention uses SSE registers does exist 
in clang/lib/CodeGen/TargetInfo.cpp, so it might be possible to reuse that... 
but I'm not sure that's better than just detecting it in the backend.


https://reviews.llvm.org/D27304



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


[PATCH] D27180: Testbed and skeleton of a new expression parser

2016-12-01 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Thanks for working on this Sean!

Since long time we are planning to propose a patch moving some parts of cling 
(eg. libInterpreter) mainline.

Now I should have a little more time to do this and it'd be great if we can 
share some code between cling and lldb. This testing infrastructure is an ideal 
candidate for this.


Repository:
  rL LLVM

https://reviews.llvm.org/D27180



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


[PATCH] D25686: [Driver] Support "hardfloat" vendor triples used by Gentoo

2016-12-01 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D25686#571894, @mgorny wrote:

> In https://reviews.llvm.org/D25686#571857, @hfinkel wrote:
>
> > It seems like we should teach Triple how to parse this triples correctly 
> > (i.e. to recognize that the vendor is ARM), and then canonicalize the 
> > environment to GNUEABIHF (or whatever)?
>
>
> I've attempted that but altering the triple resulted in clang being unable to 
> find gcc files (since the triple didn't match anymore). My previous patch is 
> available here: https://595834.bugs.gentoo.org/attachment.cgi?id=450004. If 
> you think that I've did something stupid-wrong there and there's a better way 
> of doing this via Triple API, I'll gladly update the patch.


I think that you should update the triple class to return meaningful results 
and then also enhance Clang's search logic to find the GCC installation 
directory.


https://reviews.llvm.org/D25686



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via cfe-commits
On 1 Dec 2016 8:37 p.m., "Mads Ravn"  wrote:
> I see the idea for the fixit clearly for case 3 & 4. Just erase
.compare(str2) and replace 0 with str2. I have a quick question though:
Given the declRefExpr().bind("str2"), how do I read the name of it in
clang-tidy? Or should I just bind 0 as well and then create replacement
with str where const auto str = Result.Nodes.getNodeAs("str2") ?

You could use
FixItHint::CreateInsertionFromRange to copy str2 to 0, or leave str2 where
it is, remove the binary operator and create a new one between the strings.

> Where I seem to find a little trouble is how to fixit case 1 & 2 now that
they are reduced to one case. How do I check whether or not there is a
unary operator in front of the implicitCast?

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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen added a reviewer: kcc.
jhen added a comment.

Before this patch, the following command would fail:

  clang++ -fsanitize=address --cuda-gpu-arch=sm_20 -c example.cu

with error:

  clang-4.0: error: unsupported option '-fsanitize=address' for target 
'nvptx64-nvidia-cuda'

After this patch, there is no such compilation error.

I don't understand this part of the driver code very well, so I would 
appreciate any advice on whether this is the right way to fix this bug, and 
where would be the right place for me to put a test to check that it is working 
(i.e. ASAN still works for CUDA host code).


https://reviews.llvm.org/D27316



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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D27304#610944, @thegameg wrote:

> In https://reviews.llvm.org/D27304#610697, @joerg wrote:
>
> > I think this is the absolutely wrong place to put such logic. It really can 
> > not be anywhere but the backend.
>
>
> I am aware of this. But the way the backend informs the Diagnostics looks 
> like a crash, and asks for a bug report.
>
> Are there any proper ways to inform the frontend about backend errors?


Instead of checking the return type in SemaChecking.cpp, is defining a virtual 
function in TargetInfo and overriding it in X86TargetInfo an option?


https://reviews.llvm.org/D27304



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


[PATCH] D26922: [ObjC++] Don't enter a C++ declarator context when the current context is an Objective-C declaration

2016-12-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

I think this is fine.

I guess we can print a more helpful error message than "error: property 
requires fields to be named", but we can probably do it later.


Repository:
  rL LLVM

https://reviews.llvm.org/D26922



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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D27304#610944, @thegameg wrote:

> In https://reviews.llvm.org/D27304#610697, @joerg wrote:
>
> > I think this is the absolutely wrong place to put such logic. It really can 
> > not be anywhere but the backend.
>
>
> I am aware of this. But the way the backend informs the Diagnostics looks 
> like a crash, and asks for a bug report.
>
> Are there any proper ways to inform the frontend about backend errors?


Yes. Look at how we report inline asm errors, etc. grep for 
DiagnosticInfoStackSize (used in PEI) or DiagnosticInfoResourceLimit (used by 
the AMDGPU backend).


https://reviews.llvm.org/D27304



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via cfe-commits
Hi Malcolm,

Thanks for the suggestions, I have been reading up on the fixits.
My initial four cases has been reduced to two a little more general cases:
1 & 2: implicitCast to bool str1.compare(str2). This case covers both
!str1.compare(str2) and str1.compare(str2)
3 & 4: str1.compare(str2) == 0 and str1.compare(str2) != 0.

I see the idea for the fixit clearly for case 3 & 4. Just erase
.compare(str2) and replace 0 with str2. I have a quick question though:
Given the declRefExpr().bind("str2"), how do I read the name of it in
clang-tidy? Or should I just bind 0 as well and then create replacement
with str where const auto str = Result.Nodes.getNodeAs("str2") ?

Where I seem to find a little trouble is how to fixit case 1 & 2 now that
they are reduced to one case. How do I check whether or not there is a
unary operator in front of the implicitCast?

Thank you,
Mads Ravn

On Thu, Dec 1, 2016 at 8:53 PM Mads Ravn via Phabricator <
revi...@reviews.llvm.org> wrote:

> madsravn updated this revision to Diff 79961.
> madsravn added a comment.
>
> Fixed broken tests.
>
>
> https://reviews.llvm.org/D27210
>
> Files:
>   clang-tidy/misc/CMakeLists.txt
>   clang-tidy/misc/MiscTidyModule.cpp
>   clang-tidy/misc/StringCompareCheck.cpp
>   clang-tidy/misc/StringCompareCheck.h
>   docs/ReleaseNotes.rst
>   docs/clang-tidy/checks/list.rst
>   docs/clang-tidy/checks/misc-string-compare.rst
>   test/clang-tidy/misc-string-compare.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Visoiu Mistrih Francis via Phabricator via cfe-commits
thegameg added a comment.

In https://reviews.llvm.org/D27304#610697, @joerg wrote:

> I think this is the absolutely wrong place to put such logic. It really can 
> not be anywhere but the backend.


I am aware of this. But the way the backend informs the Diagnostics looks like 
a crash, and asks for a bug report.

Are there any proper ways to inform the frontend about backend errors?


https://reviews.llvm.org/D27304



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


r288414 - Add a space in a run line. NFC.

2016-12-01 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Dec  1 14:16:56 2016
New Revision: 288414

URL: http://llvm.org/viewvc/llvm-project?rev=288414=rev
Log:
Add a space in a run line. NFC.

Modified:
cfe/trunk/test/CodeGenCXX/enable_if.cpp

Modified: cfe/trunk/test/CodeGenCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/enable_if.cpp?rev=288414=288413=288414=diff
==
--- cfe/trunk/test/CodeGenCXX/enable_if.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/enable_if.cpp Thu Dec  1 14:16:56 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu| FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu | FileCheck 
%s
 
 // Test address-of overloading logic
 int test5(int);


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


[PATCH] D27316: [CUDA] Filter out dirver sanitizer args for NVPTX

2016-12-01 Thread Jason Henline via Phabricator via cfe-commits
jhen created this revision.
jhen added a reviewer: jlebar.
jhen added a subscriber: cfe-commits.

This adds to the work from https://reviews.llvm.org/rL281680. This patch
takes care of another execution path in which sanitizer arguments can be
considered for NVPTX because they are used for the corresponding host
code.


https://reviews.llvm.org/D27316

Files:
  lib/Driver/SanitizerArgs.cpp


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -206,6 +206,12 @@
 
   for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend();
I != E; ++I) {
+// NVPTX doesn't currently support sanitizers, but sanitizer arguments can
+// still appear on the command line for host code. This means that we must
+// explicitly ignore sanitizer flags here for device code compilation.
+if (TC.getTriple().isNVPTX()) {
+  break;
+}
 const auto *Arg = *I;
 if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) {
   Arg->claim();


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -206,6 +206,12 @@
 
   for (ArgList::const_reverse_iterator I = Args.rbegin(), E = Args.rend();
I != E; ++I) {
+// NVPTX doesn't currently support sanitizers, but sanitizer arguments can
+// still appear on the command line for host code. This means that we must
+// explicitly ignore sanitizer flags here for device code compilation.
+if (TC.getTriple().isNVPTX()) {
+  break;
+}
 const auto *Arg = *I;
 if (Arg->getOption().matches(options::OPT_fsanitize_EQ)) {
   Arg->claim();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via Phabricator via cfe-commits
madsravn updated this revision to Diff 79961.
madsravn added a comment.

Fixed broken tests.


https://reviews.llvm.org/D27210

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringCompareCheck.cpp
  clang-tidy/misc/StringCompareCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-compare.rst
  test/clang-tidy/misc-string-compare.cpp

Index: test/clang-tidy/misc-string-compare.cpp
===
--- test/clang-tidy/misc-string-compare.cpp
+++ test/clang-tidy/misc-string-compare.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-string-compare %t -- -- -std=c++11
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  int compare(const basic_string );
+  bool empty();
+};
+bool operator==(const basic_string , const basic_string );
+bool operator!=(const basic_string , const basic_string );
+typedef basic_string string;
+}
+
+void func(bool b);
+
+void Test() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+
+  if (str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings; use the string equality operator instead [misc-string-compare]
+  if (!str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  if (0 == str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  if (0 != str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use compare to test equality of strings;
+  func(str1.compare(str2));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: do not use compare to test equality of strings;
+  if (str2.empty() || str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:23: warning: do not use compare to test equality of strings;
+}
+
+void Valid() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+  if (str1 == str2) {
+  }
+  if (str1 != str2) {
+  }
+  if (str1.compare(str2) == 1) {
+  }
+  if (str1.compare(str2) == str1.compare(str2)) {
+  }
+  if (0 == 0) {
+  }
+  if (1 == str1.compare(str2)) {
+  }
+  if (str1.compare(str2) > 0) {
+  }
+}
Index: docs/clang-tidy/checks/misc-string-compare.rst
===
--- docs/clang-tidy/checks/misc-string-compare.rst
+++ docs/clang-tidy/checks/misc-string-compare.rst
@@ -0,0 +1,47 @@
+.. title:: clang-tidy - misc-string-compare
+
+misc-string-compare
+===
+
+Finds string comparisons using the compare method.
+
+A common mistake is to use the string's ``compare`` method instead of using the 
+equality or inequality operators. The compare method is intended for sorting
+functions and thus returns ``-1``, ``0`` or ``1`` depending on the lexicographical 
+relationship between the strings compared. If an equality or inequality check
+can suffice, that is recommended.
+
+Examples:
+
+.. code-block:: c++
+
+  std::string str1{"a"};
+  std::string str2{"b"};
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (!str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (str1.compare(str2) == 0) {
+  }
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2) != 0) {
+  }
+
+  // use str1 == str2 instead.
+  if (0 == str1.compare(str2)) {
+  }
+
+  // use str1 != str2 instead.
+  if (0 != str1.compare(str2)) {
+  }
+
+The above code examples shows the list of if-statements that this check will
+give a warning for. All of them uses ``compare`` to check if equality or 
+inequality of two strings instead of using the correct operators.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -80,6 +80,7 @@
misc-sizeof-container
misc-sizeof-expression
misc-static-assert
+   misc-string-compare
misc-string-constructor
misc-string-integer-assignment
misc-string-literal-with-embedded-nul
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -75,6 +75,11 @@
 
 - `misc-pointer-and-integral-operation` check was removed.
 
+- New `misc-string-compare
+  `_ check
+
+  Warns about using ``compare`` to test for string 

[PATCH] D27068: Improve string::find

2016-12-01 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: include/__string:543
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+_RandomAccessIterator
+__search_substring(_RandomAccessIterator __first1, _RandomAccessIterator 
__last1,

A character traits class need only accept pointers, so the name 
`_RandomAccessIterator` is misleading when you are passing them directly to 
`_Traits::find`/`_Traits::compare`. Why not just `const _CharT*`? Then you can 
strip out all the `iterator_traits` circumlocution as well.



Comment at: include/__string:548
+using __iterator_traits = iterator_traits<_RandomAccessIterator>;
+typedef typename __iterator_traits::difference_type __difference_type;
+

For example, since `_RandomAccessIterator` must be a pointer type, this can't 
possibly be anything other than `ptrdiff_t`.



Comment at: include/__string:568
+  __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
+  if (__first1 == _RandomAccessIterator(0))
+return __last1;

The function-style cast is redundant.


https://reviews.llvm.org/D27068



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


r288406 - Send compiler output to /dev/null in defsym.s test.

2016-12-01 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Dec  1 13:34:35 2016
New Revision: 288406

URL: http://llvm.org/viewvc/llvm-project?rev=288406=rev
Log:
Send compiler output to /dev/null in defsym.s test.

Fixes test failures if tests are run in a read-only source tree.

Modified:
cfe/trunk/test/Driver/defsym.s

Modified: cfe/trunk/test/Driver/defsym.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/defsym.s?rev=288406=288405=288406=diff
==
--- cfe/trunk/test/Driver/defsym.s (original)
+++ cfe/trunk/test/Driver/defsym.s Thu Dec  1 13:34:35 2016
@@ -11,12 +11,12 @@
 // CHECK-DEFSYM1: "-defsym"
 // CHECK-DEFSYM1: "xyz=0xa"
 
-// RUN: not %clang -c -integrated-as %s \
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc= \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
 // CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc=
 
-// RUN: not %clang -c -integrated-as %s \
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc=1a2b3c \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
 // CHECK-DEFSYM-ERR2: error: Value is not an integer: 1a2b3c


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


r288404 - [CodeGen][ARM] Make sure the value and type used to create a bitcast

2016-12-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Dec  1 13:25:14 2016
New Revision: 288404

URL: http://llvm.org/viewvc/llvm-project?rev=288404=rev
Log:
[CodeGen][ARM] Make sure the value and type used to create a bitcast
have the same size.

This fixes an asset that is triggered when an address of a boolean
variable is passed to __builtin_arm_ldrex or __builtin_arm_strex.

rdar://problem/29269006

Added:
cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=288404=288403=288404=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec  1 13:25:14 2016
@@ -4438,19 +4438,21 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 
 QualType Ty = E->getType();
 llvm::Type *RealResTy = ConvertType(Ty);
-llvm::Type *IntResTy = llvm::IntegerType::get(getLLVMContext(),
-  
getContext().getTypeSize(Ty));
-LoadAddr = Builder.CreateBitCast(LoadAddr, IntResTy->getPointerTo());
+llvm::Type *PtrTy = llvm::IntegerType::get(
+getLLVMContext(), getContext().getTypeSize(Ty))->getPointerTo();
+LoadAddr = Builder.CreateBitCast(LoadAddr, PtrTy);
 
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_ldaex
? Intrinsic::arm_ldaex
: Intrinsic::arm_ldrex,
-   LoadAddr->getType());
+   PtrTy);
 Value *Val = Builder.CreateCall(F, LoadAddr, "ldrex");
 
 if (RealResTy->isPointerTy())
   return Builder.CreateIntToPtr(Val, RealResTy);
 else {
+  llvm::Type *IntResTy = llvm::IntegerType::get(
+  getLLVMContext(), CGM.getDataLayout().getTypeSizeInBits(RealResTy));
   Val = Builder.CreateTruncOrBitCast(Val, IntResTy);
   return Builder.CreateBitCast(Val, RealResTy);
 }
@@ -4491,7 +4493,10 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 if (StoreVal->getType()->isPointerTy())
   StoreVal = Builder.CreatePtrToInt(StoreVal, Int32Ty);
 else {
-  StoreVal = Builder.CreateBitCast(StoreVal, StoreTy);
+  llvm::Type *IntTy = llvm::IntegerType::get(
+  getLLVMContext(),
+  CGM.getDataLayout().getTypeSizeInBits(StoreVal->getType()));
+  StoreVal = Builder.CreateBitCast(StoreVal, IntTy);
   StoreVal = Builder.CreateZExtOrBitCast(StoreVal, Int32Ty);
 }
 
@@ -5265,19 +5270,21 @@ Value *CodeGenFunction::EmitAArch64Built
 
 QualType Ty = E->getType();
 llvm::Type *RealResTy = ConvertType(Ty);
-llvm::Type *IntResTy = llvm::IntegerType::get(getLLVMContext(),
-  
getContext().getTypeSize(Ty));
-LoadAddr = Builder.CreateBitCast(LoadAddr, IntResTy->getPointerTo());
+llvm::Type *PtrTy = llvm::IntegerType::get(
+getLLVMContext(), getContext().getTypeSize(Ty))->getPointerTo();
+LoadAddr = Builder.CreateBitCast(LoadAddr, PtrTy);
 
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_ldaex
? Intrinsic::aarch64_ldaxr
: Intrinsic::aarch64_ldxr,
-   LoadAddr->getType());
+   PtrTy);
 Value *Val = Builder.CreateCall(F, LoadAddr, "ldxr");
 
 if (RealResTy->isPointerTy())
   return Builder.CreateIntToPtr(Val, RealResTy);
 
+llvm::Type *IntResTy = llvm::IntegerType::get(
+getLLVMContext(), CGM.getDataLayout().getTypeSizeInBits(RealResTy));
 Val = Builder.CreateTruncOrBitCast(Val, IntResTy);
 return Builder.CreateBitCast(Val, RealResTy);
   }
@@ -5316,7 +5323,10 @@ Value *CodeGenFunction::EmitAArch64Built
 if (StoreVal->getType()->isPointerTy())
   StoreVal = Builder.CreatePtrToInt(StoreVal, Int64Ty);
 else {
-  StoreVal = Builder.CreateBitCast(StoreVal, StoreTy);
+  llvm::Type *IntTy = llvm::IntegerType::get(
+  getLLVMContext(),
+  CGM.getDataLayout().getTypeSizeInBits(StoreVal->getType()));
+  StoreVal = Builder.CreateBitCast(StoreVal, IntTy);
   StoreVal = Builder.CreateZExtOrBitCast(StoreVal, Int64Ty);
 }
 

Added: cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp?rev=288404=auto
==
--- cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/builtins-arm-exclusive.cpp Thu Dec  1 13:25:14 
2016
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -Wall -Werror -triple thumbv8-linux-gnueabi 
-fno-signed-char -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -Wall 

[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via Phabricator via cfe-commits
madsravn updated this revision to Diff 79958.
madsravn marked 5 inline comments as done.
madsravn added a comment.

Updated according to comments. Still missing fixit.


https://reviews.llvm.org/D27210

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringCompareCheck.cpp
  clang-tidy/misc/StringCompareCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-compare.rst
  test/clang-tidy/misc-string-compare.cpp

Index: test/clang-tidy/misc-string-compare.cpp
===
--- test/clang-tidy/misc-string-compare.cpp
+++ test/clang-tidy/misc-string-compare.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s misc-string-compare %t -- -- -std=c++11
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  int compare(const basic_string );
+  bool empty();
+};
+bool operator==(const basic_string , const basic_string );
+bool operator!=(const basic_string , const basic_string );
+typedef basic_string string;
+}
+
+void func(bool b);
+
+void Test() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+
+  if (str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings; use the string equality operator instead [misc-string-compare]
+  if (!str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  if (str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  if (0 == str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  if (0 != str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: do not use compare to test equality of strings;
+  func(str1.compare(str2));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: do not use compare to test equality of strings;
+  if (str2.empty() || str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: do not use compare to test equality of strings;
+}
+
+void Valid() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+  if (str1 == str2) {
+  }
+  if (str1 != str2) {
+  }
+  if (str1.compare(str2) == 1) {
+  }
+  if (str1.compare(str2) == str1.compare(str2)) {
+  }
+  if (0 == 0) {
+  }
+  if (1 == str1.compare(str2)) {
+  }
+  if (str1.compare(str2) > 0) {
+  }
+}
Index: docs/clang-tidy/checks/misc-string-compare.rst
===
--- docs/clang-tidy/checks/misc-string-compare.rst
+++ docs/clang-tidy/checks/misc-string-compare.rst
@@ -0,0 +1,47 @@
+.. title:: clang-tidy - misc-string-compare
+
+misc-string-compare
+===
+
+Finds string comparisons using the compare method.
+
+A common mistake is to use the string's ``compare`` method instead of using the 
+equality or inequality operators. The compare method is intended for sorting
+functions and thus returns ``-1``, ``0`` or ``1`` depending on the lexicographical 
+relationship between the strings compared. If an equality or inequality check
+can suffice, that is recommended.
+
+Examples:
+
+.. code-block:: c++
+
+  std::string str1{"a"};
+  std::string str2{"b"};
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (!str1.compare(str2)) {
+  }
+
+  // use str1 == str2 instead.
+  if (str1.compare(str2) == 0) {
+  }
+
+  // use str1 != str2 instead.
+  if (str1.compare(str2) != 0) {
+  }
+
+  // use str1 == str2 instead.
+  if (0 == str1.compare(str2)) {
+  }
+
+  // use str1 != str2 instead.
+  if (0 != str1.compare(str2)) {
+  }
+
+The above code examples shows the list of if-statements that this check will
+give a warning for. All of them uses ``compare`` to check if equality or 
+inequality of two strings instead of using the correct operators.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -80,6 +80,7 @@
misc-sizeof-container
misc-sizeof-expression
misc-static-assert
+   misc-string-compare
misc-string-constructor
misc-string-integer-assignment
misc-string-literal-with-embedded-nul
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -75,6 +75,11 @@
 
 - `misc-pointer-and-integral-operation` check was removed.
 
+- New `misc-string-compare
+  

[PATCH] D26691: [analyzer] Run clang-format and fix style

2016-12-01 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D26691#610292, @zaks.anna wrote:

> I am not a big fan of loosing svn blame only to fix formatting, but since you 
> are modifying this code anyway, it's fine by me.
>
> Artem and Devin, what is your opinion on this?


I agree that in general it is not good to lose the annotation information, but 
if you're fine with it I'm fine with it.


https://reviews.llvm.org/D26691



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


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

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



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:62-67
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2),
+   hasBuiltinTyParam(0, DoubleTy),
+   hasBuiltinTyParam(1, DoubleTy))),
+   hasBuiltinTyArg(0, FloatTy), hasBuiltinTyArg(1, FloatTy))
+  .bind("call"),

alexfh wrote:
> I guess, functions with arbitrary number of parameters can all be handled 
> using `forEachArgumentWithParam`. Roughly like this:
> 
>   forEachArgumentWithParam(
>  hasType(isBuiltinType(FloatTy)),
>  parmVarDecl(hasType(isBuiltinType(DoubleTy)))
> 
> One difference to your existing implementation will be that it will match 
> calls where at least one parameter is double and argument is float, not all 
> of them. Do you expect this to make the check more noisy? 
> Do you expect this to make the check more noisy?

Yes, to the point of not being worth doing, I think.

Specifically, I think there is nothing wrong with calling a two-arg function 
double function with one float and one double arg and expecting the float arg 
to be promoted: `::hypot(3.f, 4.)` probably *should* call the double version.

So checking that the arg types are all `float` is important, I think.  Checking 
that the parameter types are all `double` is less important but also worth 
doing, I think, so if you declare some bizarre function in the global namespace 
called e.g. `::hypot`, we won't suggest changing that to `::hypotf`.



Comment at: 
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp:145
+  // Skip the "::" following the qualifier.
+  FnNameStart = D->getQualifierLoc().getEndLoc().getLocWithOffset(2);
+}

alexfh wrote:
> `getLocWithOffset` makes the code quite brittle. Imagine whitespace around 
> `::`, for example. Same below. In order to make this kind of code more 
> robust, you can operate on tokens (using Lexer).
> 
> Same below.
Hm.  I agree this is super-brittle.  But I am having a lot of difficulty using 
the Lexer successfully.

For one thing, there may be comments basically anywhere in this stream, and I 
have to skip over them.  I see getPreviousNonCommentToken, but it doesn't quite 
work if I need to go *forward* in the stream.  I looked at a bunch of other 
uses of the Lexer in clang-tidy and they all looked pretty different from what 
I'm trying to do here, which also suggested that maybe I'm doing the wrong 
thing.

Is there no way to get the source location of "sin" out of the DeclRefExpr for 
"::sin"?  I don't see it, but it seems bizarre that it wouldn't be there.

Any tips would be much appreciated.


https://reviews.llvm.org/D27284



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


[PATCH] D27284: [ClangTidy] Add new performance-type-promotion-in-math-fn check.

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

Update test, use "auto".  Still need to figure out how to lex these function 
calls properly.


https://reviews.llvm.org/D27284

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-type-promotion-in-math-fn.rst
  clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp

Index: clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
@@ -0,0 +1,326 @@
+// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t
+
+double acos(double);
+double acosh(double);
+double asin(double);
+double asinh(double);
+double atan2(double);
+double atan(double);
+double atanh(double);
+double cbrt(double);
+double ceil(double);
+double copysign(double, double);
+double cos(double);
+double cosh(double);
+double erfc(double);
+double erf(double);
+double exp2(double);
+double exp(double);
+double expm1(double);
+double fabs(double);
+double fdim(double, double);
+double floor(double);
+double fma(double, double, double);
+double fmax(double, double);
+double fmin(double, double);
+double fmod(double, double);
+double frexp(double, int *);
+double hypot(double, double);
+double ilogb(double);
+double ldexp(double, double);
+double lgamma(double);
+long long llrint(double);
+double log10(double);
+double log1p(double);
+double log2(double);
+double logb(double);
+double log(double);
+long lrint(double);
+double modf(double);
+double nearbyint(double);
+double nextafter(double, double);
+double nexttoward(double, long double);
+double pow(double, double);
+double remainder(double, double);
+double remquo(double, double, int *);
+double rint(double);
+double round(double);
+double scalbln(double, long);
+double scalbn(double, int);
+double sin(double);
+double sinh(double);
+double sqrt(double);
+double tan(double);
+double tanh(double);
+double tgamma(double);
+double trunc(double);
+long long llround(double);
+long lround(double);
+
+void check_all_fns() {
+  float a, b, c;
+  int i;
+  long l;
+  int *int_ptr;
+
+  acos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn]
+  // CHECK-FIXES: {{^}}  acosf(a);{{$}}
+  acosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh'
+  // CHECK-FIXES: {{^}}  acoshf(a);{{$}}
+  asin(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin'
+  // CHECK-FIXES: {{^}}  asinf(a);{{$}}
+  asinh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh'
+  // CHECK-FIXES: {{^}}  asinhf(a);{{$}}
+  atan2(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2'
+  // CHECK-FIXES: {{^}}  atan2f(a);{{$}}
+  atan(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan'
+  // CHECK-FIXES: {{^}}  atanf(a);{{$}}
+  atanh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh'
+  // CHECK-FIXES: {{^}}  atanhf(a);{{$}}
+  cbrt(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt'
+  // CHECK-FIXES: {{^}}  cbrtf(a);{{$}}
+  ceil(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil'
+  // CHECK-FIXES: {{^}}  ceilf(a);{{$}}
+  copysign(a, b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign'
+  // CHECK-FIXES: {{^}}  copysignf(a, b);{{$}}
+  cos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos'
+  // CHECK-FIXES: {{^}}  cosf(a);{{$}}
+  cosh(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh'
+  // CHECK-FIXES: {{^}}  coshf(a);{{$}}
+  erf(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf'
+  // CHECK-FIXES: {{^}}  erff(a);{{$}}
+  erfc(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc'
+  // CHECK-FIXES: {{^}}  erfcf(a);{{$}}
+  exp2(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2'
+  // CHECK-FIXES: {{^}}  exp2f(a);{{$}}
+  exp(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp'
+  // CHECK-FIXES: {{^}}  expf(a);{{$}}
+  expm1(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1'
+  // CHECK-FIXES: {{^}}  expm1f(a);{{$}}
+  fabs(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fabs'
+  // CHECK-FIXES: {{^}}  fabsf(a);{{$}}
+  fdim(a, b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fdim'
+  // CHECK-FIXES: {{^}}  fdimf(a, b);{{$}}
+  floor(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'floor'
+  // CHECK-FIXES: {{^}}  floorf(a);{{$}}
+  fma(a, b, c);
+ 

r288397 - [clang] Implement support for -defsym assembler option

2016-12-01 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Thu Dec  1 12:42:16 2016
New Revision: 288397

URL: http://llvm.org/viewvc/llvm-project?rev=288397=rev
Log:
[clang] Implement support for -defsym assembler option

Summary:
Adds support for -Wa,-defsym,abc=1 option.

Related llvm patch: https://reviews.llvm.org/D26214

Reviewers: rafael, t.p.northover, colinl, echristo, compnerd, rengolin

Subscribers: mehdi_amini

Tags: #clang-c

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

Added:
cfe/trunk/test/Driver/defsym.s
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=288397=288396=288397=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Dec  1 12:42:16 2016
@@ -743,4 +743,6 @@ def show_inst : Flag<["-"], "show-inst">
 def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
   HelpText<"The string to embed in the Dwarf debug AT_producer record.">;
 
+def defsym : Separate<["-"], "defsym">,
+  HelpText<"Define a value for a symbol">;
 } // let Flags = [CC1AsOption]

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=288397=288396=288397=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec  1 12:42:16 2016
@@ -3115,6 +3115,9 @@ static void CollectArgsForIntegratedAsse
   } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") ||
  Value.startswith("-mhwdiv") || Value.startswith("-march")) {
 // Do nothing, we'll validate it later.
+  } else if (Value == "-defsym") {
+  CmdArgs.push_back(Value.data());
+  TakeNextArg = true;
   } else {
 D.Diag(diag::err_drv_unsupported_option_argument)
 << A->getOption().getName() << Value;

Added: cfe/trunk/test/Driver/defsym.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/defsym.s?rev=288397=auto
==
--- cfe/trunk/test/Driver/defsym.s (added)
+++ cfe/trunk/test/Driver/defsym.s Thu Dec  1 12:42:16 2016
@@ -0,0 +1,22 @@
+// RUN: %clang -### -c -integrated-as %s \
+// RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+
+// RUN: %clang -### -c -no-integrated-as %s \
+// RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+
+// CHECK-DEFSYM1: "-defsym"
+// CHECK-DEFSYM1: "abc=5"
+// CHECK-DEFSYM1: "-defsym"
+// CHECK-DEFSYM1: "xyz=0xa"
+
+// RUN: not %clang -c -integrated-as %s \
+// RUN: -Wa,-defsym,abc= \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
+// CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc=
+
+// RUN: not %clang -c -integrated-as %s \
+// RUN: -Wa,-defsym,abc=1a2b3c \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
+// CHECK-DEFSYM-ERR2: error: Value is not an integer: 1a2b3c

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=288397=288396=288397=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Dec  1 12:42:16 2016
@@ -77,6 +77,9 @@ struct AssemblerInvocation {
   /// be a list of strings starting with '+' or '-'.
   std::vector Features;
 
+  /// The list of symbol definitions.
+  std::vector SymbolDefs;
+
   /// @}
   /// @name Language Options
   /// @{
@@ -252,6 +255,7 @@ bool AssemblerInvocation::CreateFromArgs
   Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
   Opts.IncrementalLinkerCompatible =
   Args.hasArg(OPT_mincremental_linker_compatible);
+  Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym);
 
   return Success;
 }
@@ -420,6 +424,14 @@ static bool ExecuteAssembler(AssemblerIn
   if (!TAP)
 Failed = Diags.Report(diag::err_target_unknown_triple) << Opts.Triple;
 
+  // Set values for symbols, if any.
+  for (auto  : Opts.SymbolDefs) {
+if (Ctx.setSymbolValue(Parser->getStreamer(), S)) {
+  Failed = true;
+  break;
+}
+  }
+
   if (!Failed) {
 Parser->setTargetParser(*TAP.get());
 Failed = Parser->Run(Opts.NoInitialTextSection);


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


[PATCH] D27298: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path

2016-12-01 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D27298



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


[PATCH] D27310: Handle tests for noexcept that expect a false value

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in 
the usual setting to return false. Wrap these tests in a convenience macro.


https://reviews.llvm.org/D27310

Files:
  test/libcxx/strings/iterators.exceptions.pass.cpp


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // 
 
 // __libcpp_is_trivial_iterator
@@ -26,6 +25,17 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+// Wrapper for tests that expect a false noexcept. Usually a no-op but
+// see comment after #else.
+#define TEST_FOR_FALSE(x) (x)
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true, so we negate the result.
+#define TEST_FOR_FALSE(x) (!(x))
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +53,17 @@
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator > ::value), "");
 
 //  iterators in the libc++ test suite
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 
 #if TEST_STD_VER >= 11
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");
 #else
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
 #endif
 
 //


Index: test/libcxx/strings/iterators.exceptions.pass.cpp
===
--- test/libcxx/strings/iterators.exceptions.pass.cpp
+++ test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // 
 
 // __libcpp_is_trivial_iterator
@@ -26,6 +25,17 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+// Wrapper for tests that expect a false noexcept. Usually a no-op but
+// see comment after #else.
+#define TEST_FOR_FALSE(x) (x)
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true, so we negate the result.
+#define TEST_FOR_FALSE(x) (!(x))
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +53,17 @@
 static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), "");
 
 //  iterators in the libc++ test suite
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(TEST_FOR_FALSE(!std::__libcpp_string_gets_noexcept_iterator

r288394 - swiftcc: Add an api to query whether a target ABI stores swifterror in a register

2016-12-01 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Thu Dec  1 12:07:38 2016
New Revision: 288394

URL: http://llvm.org/viewvc/llvm-project?rev=288394=rev
Log:
swiftcc: Add an api to query whether a target ABI stores swifterror in a 
register

Modified:
cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
cfe/trunk/lib/CodeGen/ABIInfo.h
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=288394=288393=288394=diff
==
--- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original)
+++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Thu Dec  1 12:07:38 2016
@@ -160,6 +160,9 @@ ABIArgInfo classifyArgumentType(CodeGenM
 /// private interface for Clang.
 void computeABIInfo(CodeGenModule , CGFunctionInfo );
 
+/// Is swifterror lowered to a register by the target ABI.
+bool isSwiftErrorLoweredInRegister(CodeGenModule );
+
 } // end namespace swiftcall
 } // end namespace CodeGen
 } // end namespace clang

Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=288394=288393=288394=diff
==
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Thu Dec  1 12:07:38 2016
@@ -142,6 +142,8 @@ namespace swiftcall {
llvm::Type *eltTy,
unsigned elts) const;
 
+virtual bool isSwiftErrorInRegister() const = 0;
+
 static bool classof(const ABIInfo *info) {
   return info->supportsSwift();
 }

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=288394=288393=288394=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Thu Dec  1 12:07:38 2016
@@ -828,3 +828,8 @@ void swiftcall::computeABIInfo(CodeGenMo
 argInfo.info = classifyArgumentType(CGM, argInfo.type);
   }
 }
+
+// Is swifterror lowered to a register by the target ABI.
+bool swiftcall::isSwiftErrorLoweredInRegister(CodeGenModule ) {
+  return getSwiftABIInfo(CGM).isSwiftErrorInRegister();
+}

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=288394=288393=288394=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Dec  1 12:07:38 2016
@@ -958,6 +958,11 @@ public:
 // scalar registers.
 return occupiesMoreThan(CGT, scalars, /*total*/ 3);
   }  
+
+  bool isSwiftErrorInRegister() const override {
+// x86-32 lowering does not support passing swifterror in a register.
+return false;
+  }
 };
 
 class X86_32TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -2012,6 +2017,9 @@ public:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }  
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 /// WinX86_64ABIInfo - The Windows X86_64 ABI information.
@@ -2043,6 +2051,10 @@ public:
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
 
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
+
 private:
   ABIArgInfo classify(QualType Ty, unsigned ,
   bool IsReturnType) const;
@@ -4628,6 +4640,9 @@ private:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -5181,6 +5196,9 @@ private:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
@@ -5949,6 +5967,9 @@ public:
 bool asReturnValue) const override {
 return occupiesMoreThan(CGT, scalars, /*total*/ 4);
   }
+  bool isSwiftErrorInRegister() const override {
+return true;
+  }
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {


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


Re: Upgrade and fix clang-format-vs

2016-12-01 Thread Hans Wennborg via cfe-commits
Committed in r288393.

Cheers,
Hans

On Thu, Dec 1, 2016 at 9:22 AM, Hans Wennborg  wrote:
> Looks good to me!
>
> Do you have commit access, or would you like me to commit it for you?
>
> Thanks,
> Hans
>
> On Wed, Nov 30, 2016 at 8:10 PM, Antonio Maiorano  wrote:
>> Updated version of patch attached with the changes you suggested. Let me
>> know if there's anything else you'd like.
>>
>>
>> On Tue, 29 Nov 2016 at 15:38 Hans Wennborg  wrote:
>>>
>>> On Tue, Nov 29, 2016 at 12:01 PM, Antonio Maiorano 
>>> wrote:
>>> > On Tue, 29 Nov 2016 at 13:42 Hans Wennborg  wrote:
>>> >>
>>> >> Very nice! I've tried this out and confirmed that the built plugin
>>> >> also works with older Visual Studio versions.
>>> >>
>>> >> Some comments below:
>>> >>
>>> >> > --- /dev/null
>>> >> > +++ b/tools/clang-format-vs/.gitignore
>>> >> > @@ -0,0 +1,11 @@
>>> >> > +# Visual Studio files
>>> >> > +.vs/
>>> >> > +/packages/
>>> >> > +/ClangFormat/obj/
>>> >> > +/ClangFormat/bin/
>>> >>
>>> >> Should there really be a leading slash in these paths? Same below.
>>> >
>>> >
>>> > Without the leading slash, then it would match "ClangFormat/obj"
>>> > anywhere in
>>> > the tree, rather than explicitly the one and only folder from the root.
>>> > In
>>> > this case, it wouldn't matter much. If you prefer, I could just ignore
>>> > "obj/" and "bin/", etc, although I'd rather be explicit for Key.snk,
>>> > license.txt, etc.
>>>
>>> Interesting. I was just comparing with LLVM's root .gitignore, which
>>> doesn't have leading slashes for many dirs. Checking the gitignore
>>> doc, it sounds like you've got it right :-)
>>>
>>>
>>> >> > +# Generated and copied files
>>> >> > +/ClangFormat/Key.snk
>>> >> > +/ClangFormat/license.txt
>>> >> > +/ClangFormat/clang-format.exe
>>> >> > +/ClangFormat/source.extension.vsixmanifest
>>> >> > diff --git a/tools/clang-format-vs/CMakeLists.txt
>>> >> > b/tools/clang-format-vs/CMakeLists.txt
>>> >> > index fd0d6b0..90f89d8 100644
>>> >> > --- a/tools/clang-format-vs/CMakeLists.txt
>>> >> > +++ b/tools/clang-format-vs/CMakeLists.txt
>>> >> > @@ -18,8 +18,13 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
>>> >> >configure_file("source.extension.vsixmanifest.in"
>>> >> >
>>> >> >
>>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
>>> >> >
>>> >> > -  add_custom_target(clang_format_vsix ALL
>>> >> > -  devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build
>>> >> > Release
>>> >> > +  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_PATH})
>>> >> > +  if (NOT NUGET_EXE)
>>> >> > + message(FATAL_ERROR "Could not find nuget.exe. Download from
>>> >> > https://www.nuget.org/nuget.exe and add to PATH or pass path via
>>> >> > NUGET_EXE_PATH var")
>>> >>
>>> >> Can you break this string over multiple lines? I know there are pretty
>>> >> long lines in this file already, but it would be good to not make it
>>> >> worse.
>>> >
>>> >
>>> > Sure thing, I'll see what I can do :)
>>> >
>>> >>
>>> >>
>>> >> Maybe it could be clarified that NUGET_EXE_PATH is the path to a
>>> >> directory containing nuget.exe, not to the file itself (I ran into
>>> >> this). Maybe NUGET_EXE_DIR would be a better name?
>>> >
>>> >
>>> > That would be a better name, will make that change.
>>> >
>>> >>
>>> >>
>>> >> > +  endif()
>>> >> > +
>>> >> > +  add_custom_target(clang_format_vsix ALL
>>> >> > +  ${NUGET_EXE} restore "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
>>> >> > &
>>> >> > devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
>>> >>
>>> >> Is '&' a CMake thing, or should that be '&&'? Also, any chance of
>>> >> breaking these long lines?
>>> >
>>> >
>>> > '&' is a cmd.exe thing, but I can use '&&' - in fact, the latter only
>>> > runs
>>> > the 2nd command if the first succeeds, while using '&' always runs both.
>>> > I'll make the change, and will try to shorten this line as well.
>>> >
>>> >>
>>> >>
>>> >> >DEPENDS clang_format_exe_for_vsix
>>> >> >
>>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
>>> >> >COMMAND ${CMAKE_COMMAND} -E copy_if_different
>>> >> >
>>> >> >
>>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
>>> >> > diff --git a/tools/clang-format-vs/README.txt
>>> >> > b/tools/clang-format-vs/README.txt
>>> >> > index b23355d..44a071b 100644
>>> >> > --- a/tools/clang-format-vs/README.txt
>>> >> > +++ b/tools/clang-format-vs/README.txt
>>> >> > @@ -2,13 +2,23 @@ This directory contains a VSPackage project to
>>> >> > generate a Visual Studio extensio
>>> >> >  for clang-format.
>>> >> >
>>> >> >  Build prerequisites are:
>>> >> > -- Visual Studio 2013 Professional
>>> >> > -- Visual Studio 2013 SDK
>>> >> > -- Visual Studio 2010 Professional (?)
>>> >> > -- Visual Studio 2010 SDK (?)
>>> >> > +- Visual Studio 2015
>>> >> > +- Extensions SDK (you'll be prompted to install it if you open
>>> >> > 

r288393 - Fix VS2015 build of clang-format-vsix by using NuGet to pull in required assemblies

2016-12-01 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Dec  1 12:05:41 2016
New Revision: 288393

URL: http://llvm.org/viewvc/llvm-project?rev=288393=rev
Log:
Fix VS2015 build of clang-format-vsix by using NuGet to pull in required 
assemblies

Also added a gitignore to help track the right items to commit.

Patch by Antonio Maiorano !

Added:
cfe/trunk/tools/clang-format-vs/.gitignore
cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config
Modified:
cfe/trunk/tools/clang-format-vs/CMakeLists.txt
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
cfe/trunk/tools/clang-format-vs/README.txt

Added: cfe/trunk/tools/clang-format-vs/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/.gitignore?rev=288393=auto
==
--- cfe/trunk/tools/clang-format-vs/.gitignore (added)
+++ cfe/trunk/tools/clang-format-vs/.gitignore Thu Dec  1 12:05:41 2016
@@ -0,0 +1,11 @@
+# Visual Studio files
+.vs/
+/packages/
+/ClangFormat/obj/
+/ClangFormat/bin/
+
+# Generated and copied files
+/ClangFormat/Key.snk
+/ClangFormat/license.txt
+/ClangFormat/clang-format.exe
+/ClangFormat/source.extension.vsixmanifest

Modified: cfe/trunk/tools/clang-format-vs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/CMakeLists.txt?rev=288393=288392=288393=diff
==
--- cfe/trunk/tools/clang-format-vs/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-format-vs/CMakeLists.txt Thu Dec  1 12:05:41 2016
@@ -18,8 +18,15 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
   configure_file("source.extension.vsixmanifest.in"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
 
+  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_DIR})
+  if (NOT NUGET_EXE)
+message(FATAL_ERROR "Could not find nuget.exe. Download from 
https://www.nuget.org/nuget.exe;
+" and add parent directory to PATH or pass it via 
NUGET_EXE_DIR var.")
+  endif()
+
   add_custom_target(clang_format_vsix ALL
-  devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
+  COMMAND ${NUGET_EXE} restore 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
+  COMMAND devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build 
Release
   DEPENDS clang_format_exe_for_vsix 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
   COMMAND ${CMAKE_COMMAND} -E copy_if_different
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj?rev=288393=288392=288393=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj Thu Dec  1 
12:05:41 2016
@@ -35,6 +35,7 @@
 false
 false
 true
+
   
   
 true
@@ -44,6 +45,7 @@
 DEBUG;TRACE
 prompt
 4
+false
   
   
 pdbonly
@@ -53,27 +55,87 @@
 prompt
 4
 true
+false
   
   
+
+  ..\packages\VSSDK.DTE.7.0.3\lib\net20\envdte.dll
+  False
+
 
-
-
-
-
-
-
+
+  
..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll
+  False
+
+
+  
..\packages\VSSDK.Editor.10.0.4\lib\net40\Microsoft.VisualStudio.Editor.dll
+  False
+
+
+  
..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll
+  True
+  False
+
+
+  
..\packages\VSSDK.Shell.10.10.0.3\lib\net40\Microsoft.VisualStudio.Shell.10.0.dll
+  False
+
+
+  
..\packages\VSSDK.Shell.Immutable.10.10.0.3\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll
+  True
+
+
+  
..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll
+  True
+  False
+
+
+  
..\packages\VSSDK.Shell.Interop.8.8.0.3\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll
+  True
+  False
+
 
-
-
-  false
-
-
-
-
-
-
-
+
+  
..\packages\VSSDK.Shell.Interop.9.9.0.3\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll
+  True
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Data.dll
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.Logic.dll
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.dll
+  False
+
+
+  
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll
+  False
+
+
+  

[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I think this is the absolutely wrong place to put such logic. It really can not 
be anywhere but the backend.


https://reviews.llvm.org/D27304



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


r288388 - [TableGen] Ignore fake args for parsing-related arg counts.

2016-12-01 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Dec  1 11:52:39 2016
New Revision: 288388

URL: http://llvm.org/viewvc/llvm-project?rev=288388=rev
Log:
[TableGen] Ignore fake args for parsing-related arg counts.

We should complain about the following:

```
void foo() __attribute__((unavailable("a", "b")));
```

Instead, we currently just ignore "b". (...We also end up ignoring "a",
because we assume elsewhere that this attribute can only have 1 or 0
args.)

This happens because `unavailable` has a fake enum arg, and
`AttributeList::{getMinArgs,getMaxArgs}` include fake args in their
counts.

Modified:
cfe/trunk/test/Sema/attr-unavailable-message.c
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/test/Sema/attr-unavailable-message.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-unavailable-message.c?rev=288388=288387=288388=diff
==
--- cfe/trunk/test/Sema/attr-unavailable-message.c (original)
+++ cfe/trunk/test/Sema/attr-unavailable-message.c Thu Dec  1 11:52:39 2016
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // rdar: //6734520
 
+void tooManyArgs() __attribute__((unavailable("a", "b"))); // expected-error 
{{'unavailable' attribute takes no more than 1 argument}}
+
 int foo(int)  __attribute__((__unavailable__("USE IFOO INSTEAD"))); // 
expected-note {{'foo' has been explicitly marked unavailable here}}
 double dfoo(double)  __attribute__((__unavailable__("NO LONGER"))); // 
expected-note 2 {{'dfoo' has been explicitly marked unavailable here}}
 

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=288388=288387=288388=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Thu Dec  1 11:52:39 2016
@@ -2540,6 +2540,10 @@ static void emitArgInfo(const Record ,
   unsigned ArgCount = 0, OptCount = 0;
   bool HasVariadic = false;
   for (const auto *Arg : Args) {
+// If the arg is fake, it's the user's job to supply it: general parsing
+// logic shouldn't need to know anything about it.
+if (Arg->getValueAsBit("Fake"))
+  continue;
 Arg->getValueAsBit("Optional") ? ++OptCount : ++ArgCount;
 if (!HasVariadic && isArgVariadic(*Arg, R.getName()))
   HasVariadic = true;


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


[PATCH] D27298: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path

2016-12-01 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D27298



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


[clang-tools-extra] r288384 - Add a blank line to make sphinx happy.

2016-12-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  1 11:38:54 2016
New Revision: 288384

URL: http://llvm.org/viewvc/llvm-project?rev=288384=rev
Log:
Add a blank line to make sphinx happy.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst?rev=288384=288383=288384=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst 
Thu Dec  1 11:38:54 2016
@@ -1,4 +1,5 @@
 :orphan:
+
 .. title:: clang-tidy - modernize-use-default
 .. meta::
:http-equiv=refresh: 5;URL=modernize-use-equals-default.html


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


[PATCH] D27252: Protect sequences test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288383: Protect sequences test under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27252?vs=79717=79934#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27252

Files:
  
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp


Index: 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
===
--- 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
+++ 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()
Index: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
===
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
@@ -7,19 +7,18 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void push_back(const value_type& x);
 
 #include 
 #include 
 
 #include "asan_testing.h"
+#include "test_macros.h"
 
 // Flag that makes the copy constructor for CMyClass throw an exception
-static bool gCopyConstructorShouldThow = false;
-
+static bool gCopyConstructorShouldThrow = false;
 
 class CMyClass {
 public: CMyClass(int tag);
@@ -52,8 +51,8 @@
 fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
 {
 // If requested, throw an exception _before_ setting fMagicValue to 
kFinishedConstructionMagicValue
-if (gCopyConstructorShouldThow) {
-throw std::exception();
+if (gCopyConstructorShouldThrow) {
+TEST_THROW(std::exception());
 }
 // Signal that the constructor has finished running
 fMagicValue = kFinishedConstructionMagicValue;
@@ -76,12 +75,15 @@
 assert(is_contiguous_container_asan_correct(vec));
 assert(is_contiguous_container_asan_correct(vec2));
 
-gCopyConstructorShouldThow = true;
+#ifndef TEST_HAS_NO_EXCEPTIONS
+gCopyConstructorShouldThrow = true;
 try {
 vec.push_back(instance);
+assert(false);
 }
 catch (...) {
 assert(vec==vec2);
 assert(is_contiguous_container_asan_correct(vec));
 }
+#endif
 }


Index: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
===
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()
Index: libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
===
--- libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
+++ 

[libcxx] r288383 - Protect sequences test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:36:41 2016
New Revision: 288383

URL: http://llvm.org/viewvc/llvm-project?rev=288383=rev
Log:
Protect sequences test under libcpp-no-exceptions

Replace throw with TEST_THROW and protect tests that do throw. Also add missing 
assert(false).

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


Modified:

libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp?rev=288383=288382=288383=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
 Thu Dec  1 11:36:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@ void test() {
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@ void test() {
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp?rev=288383=288382=288383=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
 Thu Dec  1 11:36:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void push_back(const value_type& x);
@@ -16,10 +15,10 @@
 #include 
 
 #include "asan_testing.h"
+#include "test_macros.h"
 
 // Flag that makes the copy constructor for CMyClass throw an exception
-static bool gCopyConstructorShouldThow = false;
-
+static bool gCopyConstructorShouldThrow = false;
 
 class CMyClass {
 public: CMyClass(int tag);
@@ -52,8 +51,8 @@ CMyClass::CMyClass(const CMyClass& iOthe
 fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
 {
 // If requested, throw an exception _before_ setting fMagicValue to 
kFinishedConstructionMagicValue
-if (gCopyConstructorShouldThow) {
-throw std::exception();
+if (gCopyConstructorShouldThrow) {
+TEST_THROW(std::exception());
 }
 // Signal that the constructor has finished running
 fMagicValue = kFinishedConstructionMagicValue;
@@ -76,12 +75,15 @@ int main()
 assert(is_contiguous_container_asan_correct(vec));
 assert(is_contiguous_container_asan_correct(vec2));
 
-gCopyConstructorShouldThow = true;
+#ifndef TEST_HAS_NO_EXCEPTIONS
+gCopyConstructorShouldThrow = true;
 try {
 vec.push_back(instance);
+assert(false);
 }
 catch (...) {
 assert(vec==vec2);
 assert(is_contiguous_container_asan_correct(vec));
 }
+#endif
 }


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


[PATCH] D27253: Protect futures test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288382: Protect futures test under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27253?vs=79718=79933#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27253

Files:
  libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp


Index: libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
===
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);


Index: libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
===
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288382 - Protect futures test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:34:57 2016
New Revision: 288382

URL: http://llvm.org/viewvc/llvm-project?rev=288382=rev
Log:
Protect futures test under libcpp-no-exceptions

Skip tests that expect an exception be thrown.

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


Modified:
libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp?rev=288382=288381=288382=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp 
(original)
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp 
Thu Dec  1 11:34:57 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);


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


[PATCH] D27254: Protect optional test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288379: Protect optional test under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27254?vs=79765=79932#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27254

Files:
  libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp


Index: 
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == 
y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }


Index: libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288379 - Protect optional test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:33:36 2016
New Revision: 288379

URL: http://llvm.org/viewvc/llvm-project?rev=288379=rev
Log:
Protect optional test under libcpp-no-exceptions

Replace throw with TEST_THROW and skip tests that throw exceptions

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


Modified:
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp?rev=288379=288378=288379=diff
==
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp 
(original)
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp 
Thu Dec  1 11:33:36 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@ class Z
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == 
y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@ int main()
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@ int main()
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }


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


[PATCH] D27255: Protect std::ostream::sentry test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288378: Protect std::ostream::sentry test under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D27255?vs=79720=79931#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27255

Files:
  
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp


Index: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
===
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os();
@@ -73,4 +75,5 @@
 }
 assert(sync_called == 1);
 }
+#endif
 }


Index: libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
===
--- libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
+++ libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os();
@@ -73,4 +75,5 @@
 }
 assert(sync_called == 1);
 }
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288378 - Protect std::ostream::sentry test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:31:38 2016
New Revision: 288378

URL: http://llvm.org/viewvc/llvm-project?rev=288378=rev
Log:
Protect std::ostream::sentry test under libcpp-no-exceptions

Skip test that throws an exception.

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


Modified:

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp?rev=288378=288377=288378=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
 Thu Dec  1 11:31:38 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@ int main()
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os();
@@ -73,4 +75,5 @@ int main()
 }
 assert(sync_called == 1);
 }
+#endif
 }


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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

ping.


https://reviews.llvm.org/D26750



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


[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288376: [change-namespace] don't generate replacements for 
files that don't match file… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D27302?vs=79927=79929#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27302

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
  clang-tools-extra/trunk/test/change-namespace/macro.cpp

Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -41,7 +41,7 @@
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,15 +407,15 @@
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
  "base_initializer")) {
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -667,8 +667,7 @@
 return false;
   llvm::StringRef Filename =
   Result.SourceManager->getFilename(ExpansionLoc);
-  llvm::Regex RE(FilePattern);
-  return RE.match(Filename);
+  return FilePatternRE.match(Filename);
 };
 // Don't fix the \p Type if it refers to a type alias decl in the moved
 // namespace since the alias decl will be moved along with the type
@@ -779,6 +778,12 @@
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto  : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace
Index: clang-tools-extra/trunk/test/change-namespace/macro.cpp
===
--- clang-tools-extra/trunk/test/change-namespace/macro.cpp
+++ clang-tools-extra/trunk/test/change-namespace/macro.cpp
@@ -0,0 +1,29 @@
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+//
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
+//
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --i %T/macro.cpp --
+// RUN: FileCheck 

[clang-tools-extra] r288376 - [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Dec  1 11:25:55 2016
New Revision: 288376

URL: http://llvm.org/viewvc/llvm-project?rev=288376=rev
Log:
[change-namespace] don't generate replacements for files that don't match file 
pattern.

Reviewers: hokein

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/test/change-namespace/macro.cpp
Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/change-namespace/ChangeNamespace.h

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=288376=288375=288376=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Dec  1 
11:25:55 2016
@@ -41,7 +41,7 @@ SourceLocation startLocationForType(Type
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@ ChangeNamespaceTool::ChangeNamespaceTool
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,7 +407,7 @@ void ChangeNamespaceTool::run(
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
@@ -415,7 +415,7 @@ void ChangeNamespaceTool::run(
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -667,8 +667,7 @@ void ChangeNamespaceTool::fixTypeLoc(
 return false;
   llvm::StringRef Filename =
   Result.SourceManager->getFilename(ExpansionLoc);
-  llvm::Regex RE(FilePattern);
-  return RE.match(Filename);
+  return FilePatternRE.match(Filename);
 };
 // Don't fix the \p Type if it refers to a type alias decl in the moved
 // namespace since the alias decl will be moved along with the type
@@ -779,6 +778,12 @@ void ChangeNamespaceTool::onEndOfTransla
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto  : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.h?rev=288376=288375=288376=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Thu Dec  1 
11:25:55 2016
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@ private:
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces

Added: clang-tools-extra/trunk/test/change-namespace/macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/change-namespace/macro.cpp?rev=288376=auto
==
--- clang-tools-extra/trunk/test/change-namespace/macro.cpp (added)

[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288375: [clang-tidy] Rename modernize-use-default to 
modernize-use-equals-default (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26511?vs=79919=79928#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26511

Files:
  clang-tools-extra/trunk/clang-tidy/add_new_check.py
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-default.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -0,0 +1,299 @@
+//===--- UseEqualsDefaultCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseEqualsDefaultCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+static const char SpecialFunction[] = "SpecialFunction";
+
+/// \brief Finds all the named non-static fields of \p Record.
+static std::set
+getAllNamedFields(const CXXRecordDecl *Record) {
+  std::set Result;
+  for (const auto *Field : Record->fields()) {
+// Static data members are not in this range.
+if (Field->isUnnamedBitfield())
+  continue;
+Result.insert(Field);
+  }
+  return Result;
+}
+
+/// \brief Returns the names of the direct bases of \p Record, both virtual and
+/// non-virtual.
+static std::set getAllDirectBases(const CXXRecordDecl *Record) {
+  std::set Result;
+  for (auto Base : Record->bases()) {
+// CXXBaseSpecifier.
+const auto *BaseType = Base.getTypeSourceInfo()->getType().getTypePtr();
+Result.insert(BaseType);
+  }
+  return Result;
+}
+
+/// \brief Returns a matcher that matches member expressions where the base is
+/// the variable declared as \p Var and the accessed member is the one declared
+/// as \p Field.
+internal::Matcher accessToFieldInVar(const FieldDecl *Field,
+   const ValueDecl *Var) {
+  return ignoringImpCasts(
+  memberExpr(hasObjectExpression(declRefExpr(to(varDecl(equalsNode(Var),
+ member(fieldDecl(equalsNode(Field);
+}
+
+/// \brief Check that the given constructor has copy signature and that it
+/// copy-initializes all its bases and members.
+static bool isCopyConstructorAndCanBeDefaulted(ASTContext *Context,
+   const CXXConstructorDecl *Ctor) {
+  // An explicitly-defaulted constructor cannot have default arguments.
+  if (Ctor->getMinRequiredArguments() != 1)
+return false;
+
+  const auto *Record = Ctor->getParent();
+  const auto *Param = Ctor->getParamDecl(0);
+
+  // Base classes and members that have to be copied.
+  auto BasesToInit = getAllDirectBases(Record);
+  auto FieldsToInit = getAllNamedFields(Record);
+
+  // Ensure that all the bases are copied.
+  for (const auto *Base : BasesToInit) {
+// The initialization of a base class should be a call to a copy
+// constructor of the base.
+if (match(
+cxxConstructorDecl(forEachConstructorInitializer(cxxCtorInitializer(
+isBaseInitializer(),
+withInitializer(cxxConstructExpr(allOf(
+hasType(equalsNode(Base)),
+hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
+argumentCountIs(1),
+hasArgument(
+   

[clang-tools-extra] r288375 - [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  1 11:24:42 2016
New Revision: 288375

URL: http://llvm.org/viewvc/llvm-project?rev=288375=rev
Log:
[clang-tidy] Rename modernize-use-default to modernize-use-equals-default

Reviewers: angelgarcia, aaron.ballman, alexfh

Subscribers: JDevlieghere, Prazek, mgorny, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h
  - copied, changed from r288258, 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-default.rst
  - copied, changed from r288258, 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=288375=288374=288375=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Thu Dec  1 11:24:42 2016
@@ -226,8 +226,13 @@ def update_checks_list(clang_tidy_path):
   def format_link(doc_file):
 check_name = doc_file.replace('.rst', '')
 with open(os.path.join(docs_dir, doc_file), 'r') as doc:
+  content = doc.read()
+  match = re.search('.*:orphan:.*', content)
+  if match:
+return ''
+
   match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*',
-doc.read())
+content)
   if match:
 return '   %(check)s (redirects to %(target)s) <%(check)s>\n' % {
 'check': check_name,

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=288375=288374=288375=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Dec  1 
11:24:42 2016
@@ -16,8 +16,8 @@ add_clang_library(clangTidyModernizeModu
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp
-  UseDefaultCheck.cpp
   UseEmplaceCheck.cpp
+  UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=288375=288374=288375=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
Dec  1 11:24:42 2016
@@ -22,8 +22,8 @@
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
-#include "UseDefaultCheck.h"
 #include "UseEmplaceCheck.h"
+#include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
@@ -56,8 +56,8 @@ public:
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");

[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26453#592934, @flx wrote:

> In https://reviews.llvm.org/D26453#590720, @malcolm.parsons wrote:
>
> > Add ValuesOnly option to modernize-pass-by-value.
>
>
> Thanks for doing this. Alex, would this work for us?


ping.


https://reviews.llvm.org/D26453



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


[PATCH] D24639: [Sema] Warn when returning a lambda that captures a local variable by reference

2016-12-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D24639



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


[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 79927.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D27302

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  test/change-namespace/macro.cpp

Index: test/change-namespace/macro.cpp
===
--- /dev/null
+++ test/change-namespace/macro.cpp
@@ -0,0 +1,29 @@
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+//
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern "macro.cpp" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-HEADER %s
+//
+// RUN: cp %S/macro.cpp %T/macro.cpp
+// RUN: echo "#define USING using na::nc::X" > %T/macro.h
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" --file_pattern ".*" --i %T/macro.cpp --
+// RUN: FileCheck -input-file=%T/macro.cpp -check-prefix=CHECK-CC %s
+// RUN: FileCheck -input-file=%T/macro.h -check-prefix=CHECK-CHANGED-HEADER %s
+#include "macro.h"
+namespace na { namespace nc { class X{}; } }
+
+namespace na {
+namespace nb {
+USING;
+}
+}
+// CHECK-CC: namespace x {
+// CHECK-CC: namespace y {
+// CHECK-CC: USING;
+// CHECK-CC: } // namespace y
+// CHECK-CC: } // namespace x
+
+// CHECK-HEADER: #define USING using na::nc::X
+
+// CHECK-CHANGED-HEADER: #define USING using ::na::nc::X
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -13,6 +13,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Regex.h"
 #include 
 
 namespace clang {
@@ -131,6 +132,7 @@
   std::string DiffNewNamespace;
   // A regex pattern that matches files to be processed.
   std::string FilePattern;
+  llvm::Regex FilePatternRE;
   // Information about moved namespaces grouped by file.
   // Since we are modifying code in old namespaces (e.g. add namespace
   // spedifiers) as well as moving them, we store information about namespaces
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -41,7 +41,7 @@
   return TLoc.getLocStart();
 }
 
-SourceLocation EndLocationForType(TypeLoc TLoc) {
+SourceLocation endLocationForType(TypeLoc TLoc) {
   // Dig past any namespace or keyword qualifications.
   while (TLoc.getTypeLocClass() == TypeLoc::Elaborated ||
  TLoc.getTypeLocClass() == TypeLoc::Qualified)
@@ -249,7 +249,7 @@
 llvm::StringRef FallbackStyle)
 : FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
   OldNamespace(OldNs.ltrim(':')), NewNamespace(NewNs.ltrim(':')),
-  FilePattern(FilePattern) {
+  FilePattern(FilePattern), FilePatternRE(FilePattern) {
   FileToReplacements->clear();
   llvm::SmallVector OldNsSplitted;
   llvm::SmallVector NewNsSplitted;
@@ -407,15 +407,15 @@
  Result.Nodes.getNodeAs(
  "nested_specifier_loc")) {
 SourceLocation Start = Specifier->getBeginLoc();
-SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
+SourceLocation End = endLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
   } else if (const auto *BaseInitializer =
  Result.Nodes.getNodeAs(
  "base_initializer")) {
 BaseCtorInitializerTypeLocs.push_back(
 BaseInitializer->getTypeSourceInfo()->getTypeLoc());
   } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
-fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
+fixTypeLoc(Result, startLocationForType(*TLoc), endLocationForType(*TLoc),
*TLoc);
   } else if (const auto *VarRef =
  Result.Nodes.getNodeAs("var_ref")) {
@@ -667,8 +667,7 @@
 return false;
   llvm::StringRef Filename =
   Result.SourceManager->getFilename(ExpansionLoc);
-  llvm::Regex RE(FilePattern);
-  return RE.match(Filename);
+  return FilePatternRE.match(Filename);
 };
 // Don't fix the \p Type if it refers to a type alias decl in the moved
 // namespace since the alias decl will be moved along with the type
@@ -779,6 +778,12 @@
 }
 FileToReplacements[FilePath] = *CleanReplacements;
   }
+
+  // Make sure we don't generate replacements for files that do not match
+  // FilePattern.
+  for (auto  : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();
 }
 
 } // namespace change_namespace

Re: Upgrade and fix clang-format-vs

2016-12-01 Thread Hans Wennborg via cfe-commits
Looks good to me!

Do you have commit access, or would you like me to commit it for you?

Thanks,
Hans

On Wed, Nov 30, 2016 at 8:10 PM, Antonio Maiorano  wrote:
> Updated version of patch attached with the changes you suggested. Let me
> know if there's anything else you'd like.
>
>
> On Tue, 29 Nov 2016 at 15:38 Hans Wennborg  wrote:
>>
>> On Tue, Nov 29, 2016 at 12:01 PM, Antonio Maiorano 
>> wrote:
>> > On Tue, 29 Nov 2016 at 13:42 Hans Wennborg  wrote:
>> >>
>> >> Very nice! I've tried this out and confirmed that the built plugin
>> >> also works with older Visual Studio versions.
>> >>
>> >> Some comments below:
>> >>
>> >> > --- /dev/null
>> >> > +++ b/tools/clang-format-vs/.gitignore
>> >> > @@ -0,0 +1,11 @@
>> >> > +# Visual Studio files
>> >> > +.vs/
>> >> > +/packages/
>> >> > +/ClangFormat/obj/
>> >> > +/ClangFormat/bin/
>> >>
>> >> Should there really be a leading slash in these paths? Same below.
>> >
>> >
>> > Without the leading slash, then it would match "ClangFormat/obj"
>> > anywhere in
>> > the tree, rather than explicitly the one and only folder from the root.
>> > In
>> > this case, it wouldn't matter much. If you prefer, I could just ignore
>> > "obj/" and "bin/", etc, although I'd rather be explicit for Key.snk,
>> > license.txt, etc.
>>
>> Interesting. I was just comparing with LLVM's root .gitignore, which
>> doesn't have leading slashes for many dirs. Checking the gitignore
>> doc, it sounds like you've got it right :-)
>>
>>
>> >> > +# Generated and copied files
>> >> > +/ClangFormat/Key.snk
>> >> > +/ClangFormat/license.txt
>> >> > +/ClangFormat/clang-format.exe
>> >> > +/ClangFormat/source.extension.vsixmanifest
>> >> > diff --git a/tools/clang-format-vs/CMakeLists.txt
>> >> > b/tools/clang-format-vs/CMakeLists.txt
>> >> > index fd0d6b0..90f89d8 100644
>> >> > --- a/tools/clang-format-vs/CMakeLists.txt
>> >> > +++ b/tools/clang-format-vs/CMakeLists.txt
>> >> > @@ -18,8 +18,13 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
>> >> >configure_file("source.extension.vsixmanifest.in"
>> >> >
>> >> >
>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
>> >> >
>> >> > -  add_custom_target(clang_format_vsix ALL
>> >> > -  devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build
>> >> > Release
>> >> > +  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_PATH})
>> >> > +  if (NOT NUGET_EXE)
>> >> > + message(FATAL_ERROR "Could not find nuget.exe. Download from
>> >> > https://www.nuget.org/nuget.exe and add to PATH or pass path via
>> >> > NUGET_EXE_PATH var")
>> >>
>> >> Can you break this string over multiple lines? I know there are pretty
>> >> long lines in this file already, but it would be good to not make it
>> >> worse.
>> >
>> >
>> > Sure thing, I'll see what I can do :)
>> >
>> >>
>> >>
>> >> Maybe it could be clarified that NUGET_EXE_PATH is the path to a
>> >> directory containing nuget.exe, not to the file itself (I ran into
>> >> this). Maybe NUGET_EXE_DIR would be a better name?
>> >
>> >
>> > That would be a better name, will make that change.
>> >
>> >>
>> >>
>> >> > +  endif()
>> >> > +
>> >> > +  add_custom_target(clang_format_vsix ALL
>> >> > +  ${NUGET_EXE} restore "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
>> >> > &
>> >> > devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
>> >>
>> >> Is '&' a CMake thing, or should that be '&&'? Also, any chance of
>> >> breaking these long lines?
>> >
>> >
>> > '&' is a cmd.exe thing, but I can use '&&' - in fact, the latter only
>> > runs
>> > the 2nd command if the first succeeds, while using '&' always runs both.
>> > I'll make the change, and will try to shorten this line as well.
>> >
>> >>
>> >>
>> >> >DEPENDS clang_format_exe_for_vsix
>> >> >
>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
>> >> >COMMAND ${CMAKE_COMMAND} -E copy_if_different
>> >> >
>> >> >
>> >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
>> >> > diff --git a/tools/clang-format-vs/README.txt
>> >> > b/tools/clang-format-vs/README.txt
>> >> > index b23355d..44a071b 100644
>> >> > --- a/tools/clang-format-vs/README.txt
>> >> > +++ b/tools/clang-format-vs/README.txt
>> >> > @@ -2,13 +2,23 @@ This directory contains a VSPackage project to
>> >> > generate a Visual Studio extensio
>> >> >  for clang-format.
>> >> >
>> >> >  Build prerequisites are:
>> >> > -- Visual Studio 2013 Professional
>> >> > -- Visual Studio 2013 SDK
>> >> > -- Visual Studio 2010 Professional (?)
>> >> > -- Visual Studio 2010 SDK (?)
>> >> > +- Visual Studio 2015
>> >> > +- Extensions SDK (you'll be prompted to install it if you open
>> >> > ClangFormat.sln)
>> >>
>> >> A very nice simplification :-)
>> >
>> >
>> > Thanks :)
>> >
>> >>
>> >>
>> >> >
>> >> > -The extension is built using CMake by setting
>> >> > BUILD_CLANG_FORMAT_VS_PLUGIN=ON
>> >> > -when configuring a Clang build, 

[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks!


https://reviews.llvm.org/D26511



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


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: docs/clang-tidy/checks/misc-string-compare.rst:21
+  
+  if(str1.compare(str2)) {} // use str1 != str2 instead
+  

Please clang-format this code.



Comment at: test/clang-tidy/misc-string-compare.cpp:15
+};
+  bool operator==(const basic_string lhs, const basic_string rhs);
+  bool operator!=(const basic_string lhs, const basic_string rhs);

Missing 
Please clang-format this file.


https://reviews.llvm.org/D27210



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


r288372 - [analyzer] Drop explicit mention of range constraint solver

2016-12-01 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Thu Dec  1 11:06:39 2016
New Revision: 288372

URL: http://llvm.org/viewvc/llvm-project?rev=288372=rev
Log:
[analyzer] Drop explicit mention of range constraint solver

Summary: The basic constraint solver was dropped in rL162384, leaving the range 
constraint solver as the default and only constraint solver. Explicitly 
specifying it is unnecessary, and makes it difficult to test with other solver 
backends.

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/Analysis/CFDateGC.m
cfe/trunk/test/Analysis/CFNumber.c
cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
cfe/trunk/test/Analysis/CGColorSpace.c
cfe/trunk/test/Analysis/CheckNSError.m
cfe/trunk/test/Analysis/NSPanel.m
cfe/trunk/test/Analysis/NSString.m
cfe/trunk/test/Analysis/NSWindow.m
cfe/trunk/test/Analysis/ObjCProperties.m
cfe/trunk/test/Analysis/PR2599.m
cfe/trunk/test/Analysis/PR3991.m
cfe/trunk/test/Analysis/additive-folding-range-constraints.c
cfe/trunk/test/Analysis/additive-folding.cpp
cfe/trunk/test/Analysis/array-struct-region.c
cfe/trunk/test/Analysis/array-struct.c
cfe/trunk/test/Analysis/cfref_PR2519.c
cfe/trunk/test/Analysis/cfref_rdar6080742.c
cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
cfe/trunk/test/Analysis/complex.c
cfe/trunk/test/Analysis/dead-stores.c
cfe/trunk/test/Analysis/dead-stores.cpp
cfe/trunk/test/Analysis/misc-ps-64.m
cfe/trunk/test/Analysis/misc-ps-eager-assume.m
cfe/trunk/test/Analysis/misc-ps-ranges.m
cfe/trunk/test/Analysis/misc-ps.m

cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
cfe/trunk/test/Analysis/null-deref-ps.c
cfe/trunk/test/Analysis/rdar-6562655.m
cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
cfe/trunk/test/Analysis/reference.cpp
cfe/trunk/test/Analysis/unions-region.m

Modified: cfe/trunk/test/Analysis/CFDateGC.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFDateGC.m?rev=288372=288371=288372=diff
==
--- cfe/trunk/test/Analysis/CFDateGC.m (original)
+++ cfe/trunk/test/Analysis/CFDateGC.m Thu Dec  1 11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount 
-analyzer-store=region -analyzer-constraints=range -verify -fobjc-gc %s  
-Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount 
-analyzer-store=region -verify -fobjc-gc %s  -Wno-implicit-function-declaration
 
 
//===--===//
 // The following code is reduced using delta-debugging from

Modified: cfe/trunk/test/Analysis/CFNumber.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFNumber.c?rev=288372=288371=288372=diff
==
--- cfe/trunk/test/Analysis/CFNumber.c (original)
+++ cfe/trunk/test/Analysis/CFNumber.c Thu Dec  1 11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount 
-analyzer-store=region -analyzer-constraints=range -verify -triple 
x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount 
-analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
 
 typedef signed long CFIndex;
 typedef const struct __CFAllocator * CFAllocatorRef;

Modified: cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m?rev=288372=288371=288372=diff
==
--- cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m (original)
+++ cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m Thu Dec  1 
11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s 
-analyzer-constraints=range -analyzer-store=region
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s 
-analyzer-store=region
 // expected-no-diagnostics
 
 typedef struct objc_selector *SEL;

Modified: cfe/trunk/test/Analysis/CGColorSpace.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CGColorSpace.c?rev=288372=288371=288372=diff
==
--- cfe/trunk/test/Analysis/CGColorSpace.c (original)
+++ cfe/trunk/test/Analysis/CGColorSpace.c Thu Dec  1 11:06:39 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 

[PATCH] D26694: [analyzer] Drop explicit mention of range constraint solver

2016-12-01 Thread Dominic Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288372: [analyzer] Drop explicit mention of range constraint 
solver (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26694?vs=78060=79924#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26694

Files:
  cfe/trunk/test/Analysis/CFDateGC.m
  cfe/trunk/test/Analysis/CFNumber.c
  cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
  cfe/trunk/test/Analysis/CGColorSpace.c
  cfe/trunk/test/Analysis/CheckNSError.m
  cfe/trunk/test/Analysis/NSPanel.m
  cfe/trunk/test/Analysis/NSString.m
  cfe/trunk/test/Analysis/NSWindow.m
  cfe/trunk/test/Analysis/ObjCProperties.m
  cfe/trunk/test/Analysis/PR2599.m
  cfe/trunk/test/Analysis/PR3991.m
  cfe/trunk/test/Analysis/additive-folding-range-constraints.c
  cfe/trunk/test/Analysis/additive-folding.cpp
  cfe/trunk/test/Analysis/array-struct-region.c
  cfe/trunk/test/Analysis/array-struct.c
  cfe/trunk/test/Analysis/cfref_PR2519.c
  cfe/trunk/test/Analysis/cfref_rdar6080742.c
  cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
  cfe/trunk/test/Analysis/complex.c
  cfe/trunk/test/Analysis/dead-stores.c
  cfe/trunk/test/Analysis/dead-stores.cpp
  cfe/trunk/test/Analysis/misc-ps-64.m
  cfe/trunk/test/Analysis/misc-ps-eager-assume.m
  cfe/trunk/test/Analysis/misc-ps-ranges.m
  cfe/trunk/test/Analysis/misc-ps.m
  
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
  cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
  cfe/trunk/test/Analysis/null-deref-ps.c
  cfe/trunk/test/Analysis/rdar-6562655.m
  cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
  cfe/trunk/test/Analysis/reference.cpp
  cfe/trunk/test/Analysis/unions-region.m

Index: cfe/trunk/test/Analysis/CheckNSError.m
===
--- cfe/trunk/test/Analysis/CheckNSError.m
+++ cfe/trunk/test/Analysis/CheckNSError.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -verify -Wno-objc-root-class %s
 
 
 typedef signed char BOOL;
Index: cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
===
--- cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
+++ cfe/trunk/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
 // expected-no-diagnostics
 
 typedef struct Foo { int x; } Bar;
Index: cfe/trunk/test/Analysis/misc-ps-ranges.m
===
--- cfe/trunk/test/Analysis/misc-ps-ranges.m
+++ cfe/trunk/test/Analysis/misc-ps-ranges.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
 
 // 
 // main's 'argc' argument is always > 0
Index: cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
===
--- cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
+++ cfe/trunk/test/Analysis/comparison-implicit-casts.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple i386-apple-darwin9 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple x86_64-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple i386-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple x86_64-apple-darwin9 -verify %s
 
 // This file runs in C++ mode so that the comparison type is 'bool', not 'int'.
 void clang_analyzer_eval(int);
Index: cfe/trunk/test/Analysis/PR2599.m
===
--- cfe/trunk/test/Analysis/PR2599.m
+++ cfe/trunk/test/Analysis/PR2599.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-constraints=range -analyzer-store=region -fobjc-gc -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -verify 

[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

2016-12-01 Thread Kit Barton via Phabricator via cfe-commits
kbarton requested changes to this revision.
kbarton added a comment.
This revision now requires changes to proceed.

Please make explicit the signed for the parameters to the functions you are 
changing and remove unnecessary casts. I marked the first few that I found, but 
stopped marking them after the first several.




Comment at: lib/Headers/altivec.h:13928
   vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
-  (vector unsigned char)__a);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b,
+  (vector signed char)__a);

The cast for  __b is necessary, since it is already a vector signed char. 
I don't know whether this will generate superfluous warnings or not, but it's 
probably best to remove it.



Comment at: lib/Headers/altivec.h:13965
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
   vector short __b) {
+  return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector signed short)__b,

It's better to make the parameter explicitly vector signed short, and remove 
the cast on the next line, for consistency with other builtins. 



Comment at: lib/Headers/altivec.h:14002
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
   vector int __b) {
+  return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector signed int)__b,

same comment - explicitly vector signed int



Comment at: lib/Headers/altivec.h:14042
   vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
-  (vector unsigned long long)__a);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b,
+  (vector signed long long)__a);

No cast needed here



Comment at: lib/Headers/altivec.h:14099
   vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
-  (vector unsigned char)__b);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a,
+  (vector signed char)__b);

No cast needed here 



Comment at: lib/Headers/altivec.h:14136
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
   vector short __b) {
+  return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a,

Make signed explicit here


https://reviews.llvm.org/D27251



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via cfe-commits
On 1 December 2016 at 16:42, Mads Ravn  wrote:
> I have now implemented your suggestions - all but the fixit one. If I have
> added bindings for str1 and str2 in ast matcher, how would I go about
> creating a replacement for the entire implicitCastExpr or binaryOperator? I
> can't find any example in the code for clang-tidy to suggest how I would
> build a new node for the AST. Or I am looking at it from a wrong direction?

You create insertions, removals and replacements that affect the source code.
The AST is not changed.

Fix-it hints are documented here:
http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints

Source locations and ranges are documented here:
http://clang.llvm.org/docs/InternalsManual.html#sourcelocation

To turn str1.compare(str2) into str1 == str2 you need to replace
".compare(" with " == " and remove ")".

You can get the SourceLocation of the . by calling getOperatorLoc() on
the MemberExpr.
You can tell if you have a . or an -> by calling isArrow() on the MemberExpr.
You can get the SourceLocation of the ) by calling getRParenLoc() on
the CXXMemberCallExpr.

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


[PATCH] D27302: [change-namespace] don't generate replacements for files that don't match file pattern.

2016-12-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with two nits.




Comment at: change-namespace/ChangeNamespace.cpp:786
+  for (auto  : FileToReplacements)
+if (!FilePatternRE.match(Entry.first))
+  Entry.second.clear();

How about creating `FilePatternRE` from `FilePattern` here? So that you don't 
need save `FilePatternRE` as a member variable.



Comment at: test/change-namespace/Inputs/macro.h:1
+#define USING using na::nc::X

For the simple file like this, I would use `echo "#define USING using 
na::nc::X" > macro.h` in `macro.cc` instead of creating a new file.


https://reviews.llvm.org/D27302



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


[PATCH] D27304: [PATCH] [Sema][X86] Don't allow floating-point return types when SSE is disabled

2016-12-01 Thread Visoiu Mistrih Francis via Phabricator via cfe-commits
thegameg created this revision.
thegameg added reviewers: craig.topper, majnemer.
thegameg added a subscriber: cfe-commits.

The following program hits a fatal_error in the X86 backend, when the
program is compiled with -mno-sse or -mno-sse2, which is understandable
due to the calling convention:

> float f() { return 0.5f; };

since the error occurs in the backend, there are stack traces and bug
report messages that are generated.

This patch allows the compiler to avoid crashing and check in advance if
the code can be generated properly.

- include/clang/Basic/DiagnosticSemaKinds.td: Add the error.
- lib/Sema/SemaChecking.cpp: Check if the function returns a floating-point 
type.


https://reviews.llvm.org/D27304

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -2474,6 +2474,17 @@
 CheckArgumentWithTypeTag(I, Args.data());
 }
   }
+
+  // Don't allow calls returning floating point scalars when
+  // target == x86_64 && SSE disabled.
+  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64 &&
+  (!Context.getTargetInfo().hasFeature("sse") ||
+   !Context.getTargetInfo().hasFeature("sse2"))) {
+if (auto *ResultType = Proto->getReturnType().getTypePtrOrNull()) {
+  if (ResultType->isRealFloatingType())
+Diag(Loc, diag::err_x86_sse_register);
+}
+  }
 }
 
 /// CheckConstructorCall - Check a constructor call for correctness and safety
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7840,6 +7840,8 @@
   "this builtin is only available on x86-64 targets">;
 def err_x86_builtin_invalid_rounding : Error<
   "invalid rounding argument">;
+def err_x86_sse_register : Error<
+  "SSE register return with SSE disabled">;
 
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -2474,6 +2474,17 @@
 CheckArgumentWithTypeTag(I, Args.data());
 }
   }
+
+  // Don't allow calls returning floating point scalars when
+  // target == x86_64 && SSE disabled.
+  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64 &&
+  (!Context.getTargetInfo().hasFeature("sse") ||
+   !Context.getTargetInfo().hasFeature("sse2"))) {
+if (auto *ResultType = Proto->getReturnType().getTypePtrOrNull()) {
+  if (ResultType->isRealFloatingType())
+Diag(Loc, diag::err_x86_sse_register);
+}
+  }
 }
 
 /// CheckConstructorCall - Check a constructor call for correctness and safety
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7840,6 +7840,8 @@
   "this builtin is only available on x86-64 targets">;
 def err_x86_builtin_invalid_rounding : Error<
   "invalid rounding argument">;
+def err_x86_sse_register : Error<
+  "SSE register return with SSE disabled">;
 
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Mads Ravn via cfe-commits
Hi Alexander,

I have now implemented your suggestions - all but the fixit one. If I have
added bindings for str1 and str2 in ast matcher, how would I go about
creating a replacement for the entire implicitCastExpr or binaryOperator? I
can't find any example in the code for clang-tidy to suggest how I would
build a new node for the AST. Or I am looking at it from a wrong direction?

Could you hint me in the right direction as to how I would make the fixit?

Best regards,
Mads Ravn

On Thu, Dec 1, 2016 at 3:41 PM Alexander Kornienko via Phabricator <
revi...@reviews.llvm.org> wrote:

> alexfh requested changes to this revision.
> alexfh added inline comments.
> This revision now requires changes to proceed.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:29
> +
> +  // First and second case: cast str.compare(str) to boolean
> +  Finder->addMatcher(
> 
> Please add trailing periods here and elsewhere.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:36-50
> +  // Third case: str.compare(str) == 0
> +  Finder->addMatcher(
> +  binaryOperator(hasOperatorName("=="),
> + hasEitherOperand(strCompare),
> +
>  hasEitherOperand(integerLiteral(equals(0
> +  .bind("match"),
> +  this);
> 
> These two matchers can be merged to avoid repetition.
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:55-57
> +diag(Matched->getLocStart(),
> + "do not use compare to test equality of strings; "
> + "use the string equality operator instead");
> 
> It looks like it's relatively straightforward to implement fixit hints.
> WDYT?
>
>
> 
> Comment at: test/clang-tidy/misc-string-compare.cpp:29
> +  if(!str1.compare(str2)) {}
> +  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: do not use compare to test
> equality of strings; use the string equality operator instead
> [misc-string-compare]
> +  if(str1.compare(str2) == 0) {}
> 
> Truncate all CHECK patterns after the first one after `of strings;`
>
>
> https://reviews.llvm.org/D27210
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha added a comment.

I don't have commit access.

Thank you for the review @alexfh


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 79919.
malcolm.parsons added a comment.

Re-remove doubled space in modernize-use-equals-default.rst.


https://reviews.llvm.org/D26511

Files:
  clang-tidy/add_new_check.py
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tidy/modernize/UseDefaultCheck.h
  clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tidy/modernize/UseEqualsDefaultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default.rst
  docs/clang-tidy/checks/modernize-use-equals-default.rst
  test/clang-tidy/modernize-use-default-copy.cpp
  test/clang-tidy/modernize-use-default-delayed.cpp
  test/clang-tidy/modernize-use-default.cpp
  test/clang-tidy/modernize-use-equals-default-copy.cpp
  test/clang-tidy/modernize-use-equals-default-delayed.cpp
  test/clang-tidy/modernize-use-equals-default.cpp

Index: test/clang-tidy/modernize-use-equals-default.cpp
===
--- test/clang-tidy/modernize-use-equals-default.cpp
+++ test/clang-tidy/modernize-use-equals-default.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing  -fexceptions
 
 // Out of line definition.
 class OL {
@@ -8,10 +8,10 @@
 };
 
 OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL() = default;
 OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::~OL() = default;
 
 // Inline definitions.
Index: test/clang-tidy/modernize-use-equals-default-delayed.cpp
===
--- test/clang-tidy/modernize-use-equals-default-delayed.cpp
+++ test/clang-tidy/modernize-use-equals-default-delayed.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
+// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
 // Note: this test expects no diagnostics, but FileCheck cannot handle that,
 // hence the use of | count 0.
 
Index: test/clang-tidy/modernize-use-equals-default-copy.cpp
===
--- test/clang-tidy/modernize-use-equals-default-copy.cpp
+++ test/clang-tidy/modernize-use-equals-default-copy.cpp
@@ -1,19 +1,19 @@
-// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
+// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
 
 // Out of line definition.
 struct OL {
   OL(const OL &);
   OL =(const OL &);
   int Field;
 };
 OL::OL(const OL ) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
 // CHECK-FIXES: OL::OL(const OL )  = default;
 OL ::operator=(const OL ) {
   Field = Other.Field;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default]
 // CHECK-FIXES: OL ::operator=(const OL ) = default;
 
 // Inline.
Index: docs/clang-tidy/checks/modernize-use-equals-default.rst
===
--- docs/clang-tidy/checks/modernize-use-equals-default.rst
+++ docs/clang-tidy/checks/modernize-use-equals-default.rst
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - modernize-use-default
+.. title:: clang-tidy - modernize-use-equals-default
 
-modernize-use-default
-=
+modernize-use-equals-default
+
 
 This check replaces default bodies of special member functions with ``=
 default;``. The explicitly defaulted function declarations enable more
Index: docs/clang-tidy/checks/modernize-use-default.rst
===
--- docs/clang-tidy/checks/modernize-use-default.rst
+++ docs/clang-tidy/checks/modernize-use-default.rst
@@ -1,28 +1,10 @@
+:orphan:

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-01 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha updated this revision to Diff 79917.
Alpha added a comment.

Rebase on top of HEAD.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/DiagnosticsYaml.h
  include/clang/Tooling/ReplacementsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  unittests/Tooling/ReplacementsYamlTest.cpp

Index: unittests/Tooling/ReplacementsYamlTest.cpp
===
--- unittests/Tooling/ReplacementsYamlTest.cpp
+++ unittests/Tooling/ReplacementsYamlTest.cpp
@@ -22,11 +22,10 @@
   TranslationUnitReplacements Doc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Context = "some context";
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
 
   std::string YamlContent;
   llvm::raw_string_ostream YamlContentStream(YamlContent);
@@ -37,7 +36,6 @@
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
"MainSourceFile:  /path/to/source.cpp\n"
-   "Context: some context\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:/path/to/file1.h\n"
"Offset:  232\n"
@@ -54,7 +52,6 @@
 TEST(ReplacementsYamlTest, deserializesReplacements) {
   std::string YamlContent = "---\n"
 "MainSourceFile:  /path/to/source.cpp\n"
-"Context: some context\n"
 "Replacements:\n"
 "  - FilePath:/path/to/file1.h\n"
 "Offset:  232\n"
@@ -71,7 +68,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ(2u, DocActual.Replacements.size());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
-  ASSERT_EQ("some context", DocActual.Context);
   ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
@@ -98,7 +94,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
   ASSERT_EQ(1u, DocActual.Replacements.size());
-  ASSERT_EQ(std::string(), DocActual.Context);
   ASSERT_EQ("target_file.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(1u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,45 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager ,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   Diagnostic::Level DiagLevel, StringRef BuildDirectory)
+: DiagnosticName(DiagnosticName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   DiagnosticMessage ,
+   llvm::StringMap 

  1   2   >