Re: r339428 - Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-11 Thread David Chisnall via cfe-commits
Thanks,

That fix looks exactly what is needed - and is something I didn’t realise 
FileCheck could do!  The order of those matters in the linked binary, but not 
in the IR - the linker will arrange them sensibly based on the subsection name.

Thanks again,

David

> On 11 Aug 2018, at 04:12,   
> wrote:
> 
> Hi David,
>  
> I made an attempt to fix the Windows bot test failures in r339494 by making 
> the checks for the section boundaries not depend on the order they were 
> emitted.
>  
> It seems that when using Visual Studio to build clang, the compiler that is 
> generated emits the __stop_ section boundaries before the __start_ ones, thus 
> causing your checks to fail. For example, you were checking for the following:
>  
> @__start___objc_selectors = linkonce_odr hidden global 
> %.objc_section_sentinel zeroinitializer, section "__objc_selectors$a", 
> comdat, align 1
> @__stop__objc_selectors = linkonce_odr hidden global %.objc_section_sentinel 
> zeroinitializer, section "__objc_selectors$z", comdat, align 1
> @__start___objc_classes = linkonce_odr hidden global %.objc_section_sentinel 
> zeroinitializer, section "__objc_classes$a", comdat, align 1
> @__stop__objc_classes = linkonce_odr hidden global %.objc_section_sentinel 
> zeroinitializer, section "__objc_classes$z", comdat, align 1
>  
> However the Visual Studio built clang was producing the following output:
>  
> @__stop__objc_selectors = linkonce_odr hidden global %.objc_section_sentinel 
> zeroinitializer, section "__objc_selectors$z", comdat, align 1
> @__start___objc_selectors = linkonce_odr hidden global 
> %.objc_section_sentinel zeroinitializer, section "__objc_selectors$a", 
> comdat, align 1
> @__stop__objc_classes = linkonce_odr hidden global %.objc_section_sentinel 
> zeroinitializer, section "__objc_classes$z", comdat, align 1
> @__start___objc_classes = linkonce_odr hidden global %.objc_section_sentinel 
> zeroinitializer, section "__objc_classes$a", comdat, align 1
>  
> I don’t think that the order matters, only that they are actually emitted, 
> but if I am wrong, I apologize, and please revert my change and look into the 
> problem.
>  
> Douglas Yung
>  
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
> Tom Weaver via cfe-commits
> Sent: Friday, August 10, 2018 10:01
> To: David Chisnall
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: r339428 - Add Windows support for the GNUstep Objective-C ABI V2.
>  
> Hi David,
>  
> revision 339428 seems to have caused failing tests on a couple of windows 
> build bots, any chance you can take a look please?
>  
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/18985
>  
> 
> Failing Tests (1):
> Clang :: CodeGenObjC/gnu-init.m
>  
>   Expected Passes: 30627
>   Expected Failures  : 65
>   Unsupported Tests  : 12223
>   Unexpected Failures: 1
>  
> Thanks
>  
> Tom Weaver
>  
> On 10 August 2018 at 13:53, David Chisnall via cfe-commits 
>  wrote:
> Author: theraven
> Date: Fri Aug 10 05:53:13 2018
> New Revision: 339428
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=339428&view=rev
> Log:
> Add Windows support for the GNUstep Objective-C ABI V2.
> 
> Summary:
> Introduces funclet-based unwinding for Objective-C and fixes an issue
> where global blocks can't have their isa pointers initialised on
> Windows.
> 
> After discussion with Dustin, this changes the name mangling of
> Objective-C types to prevent a C++ catch statement of type struct X*
> from catching an Objective-C object of type X*.
> 
> Reviewers: rjmccall, DHowett-MSFT
> 
> Reviewed By: rjmccall, DHowett-MSFT
> 
> Subscribers: mgrang, mstorsjo, smeenai, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D50144
> 
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/lib/CodeGen/CGException.cpp
> cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
> cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
> cfe/trunk/lib/CodeGen/CGObjCRuntime.h
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/test/CodeGenObjC/gnu-init.m
> cfe/trunk/test/CodeGenObjC/gnustep2-proto.m
> cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
> cfe/trunk/test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
> cfe/trunk/test/CodeGenObjCXX/msabi-objc-extensions.mm
> cfe/trunk/test/CodeGenObjCXX/msabi-objc-types.mm
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=339428&r1=339427&r2=339428&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Fri Aug 10 05:53:13 2018
> @@ -1488,7 +1488,7 @@ def fobjc_weak : Flag<["-"], "fobjc-weak
>HelpText<"Enable ARC-style weak referen

[PATCH] D41217: [Concepts] Concept Specialization Expressions

2018-08-11 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 160237.
saar.raz added a comment.

Removed unused "note_in_concept_specialization" diagnostic ID.


Repository:
  rC Clang

https://reviews.llvm.org/D41217

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/CMakeLists.txt
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx-concept-declaration.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -231,6 +231,7 @@
   case Stmt::TypeTraitExprClass:
   case Stmt::CoroutineBodyStmtClass:
   case Stmt::CoawaitExprClass:
+  case Stmt::ConceptSpecializationExprClass:
   case Stmt::DependentCoawaitExprClass:
   case Stmt::CoreturnStmtClass:
   case Stmt::CoyieldExprClass:
Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ test/Parser/cxx-concept-declaration.cpp
@@ -9,8 +9,6 @@
 
 template concept D1 = true; // expected-error {{expected template parameter}}
 
-template concept C2 = 0.f; // expected-error {{constraint expression must be 'bool'}}
-
 struct S1 {
   template concept C1 = true; // expected-error {{concept declarations may only appear in global or namespace scope}}
 };
@@ -29,3 +27,22 @@
 
 // TODO: Add test to prevent explicit specialization, partial specialization
 // and explicit instantiation of concepts.
+
+template concept C7 = 2; // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
+template concept C8 = 2 && x; // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
+template concept C9 = x || 2 || x; // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
+template concept C10 = 8ull && x || x; // expected-error {{atomic constraint must be of type 'bool' (found 'unsigned long long')}}
+template concept C11 = sizeof(T); // expected-error {{atomic constraint must be of type 'bool' (found 'unsigned long')}}
+template concept C12 = T{};
+template concept C13 = (bool&&)true;
+template concept C14 = (const bool&)true;
+template concept C15 = (const bool)true;
+
+template
+struct integral_constant { static constexpr T value = v; };
+
+template  concept C16 = integral_constant::value && true;
+template  concept C17 = integral_constant::value;
+
+bool a = C16;
+bool b = C17;
Index: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
===
--- test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
+++ test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
@@ -1,5 +1,136 @@
 // RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
-// expected-no-diagnostics
 
-template concept C = true;
-static_assert(C);
+template concept C1 = true;
+static_assert(C1);
+
+template concept C2 = sizeof(T) == 4;
+static_assert(C2);
+static_assert(!C2);
+static_assert(C2);
+static_assert(!C2);
+
+template concept C3 = sizeof(*T{}) == 4;
+static_assert(C3);
+static_assert(!C3);
+
+struct A {
+  static constexpr int add(int a, int b) {
+return a + b;
+  }
+};
+struct B {
+  static int add(int a, int b) {
+return a + b;
+  }
+};
+template
+concept C4 = U::add(1, 2) == 3; // expected-error {{substitution into constraint expression resulted in a non-constant expression}}
+static_assert(C4);
+static_assert(!C4); // expected-note {{while checking the satisfaction of concept 'C4' requested here}}
+
+template
+constexpr bool is_same_v = false;
+
+template
+constexpr bool is_same_v = true;
+
+template
+concept Same = is_same_v;
+
+static_assert(Same);
+static_assert(Same);
+static_assert(!Same);
+static_assert(!Same);
+static_assert(Same);
+
+static_assert(Same)>);
+static_assert(Same)>);
+static_assert(Same)>);
+static_assert(Same)>);
+
+template concept C5 = T{}; // expected-error {{atomic constraint must be of type 'bool' (found 'int')}}
+constexpr bool x = C5; // expected-note {{while checking the satisfaction of concept 'C5' requested here}}
+
+template
+concept IsEven = (x % 2) == 0;
+
+static_assert(IsEven<20>);
+static_assert(!IsEven<11>);
+
+template typename P>
+conc

[PATCH] D50542: [clang-tidy] Add abseil-no-internal-deps check

2018-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

No concerns except the small nits from my side.




Comment at: clang-tidy/abseil/NoInternalDepsCheck.cpp:24
+
+  // TODO(hugoeg): refactor matcher to be configurable or just match on any 
internal access from outside the enclosing namespace.
+  

Nit: This comment is very long, pls break the line



Comment at: docs/clang-tidy/checks/abseil-no-internal-deps.rst:6
+
+Gives a warning if code using Abseil depends on internal details. If something 
is in a namespace or filename/path that includes the word “internal”, code is 
not allowed to depend upon it beaucse it’s an implementation detail. They 
cannot friend it, include it, you mention it or refer to it in any way. Doing 
so violtaes Abseil's compatibility guidelines and may result in breakage.
+

s/violtaes/violates/



Comment at: docs/clang-tidy/checks/abseil-no-internal-deps.rst:8
+
+The folowing cases will result in warnings:
+

s/folowing/following/


https://reviews.llvm.org/D50542



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Always the same with the templates ;) So uninstantiated templates should
just be ignored.

I think it would be better to have it in the ExprMutAnalyzer, because
that part can not decide on const-ness. Fixing it here would just
circumvent the problem but not fix it, would you agree?

Am 10.08.2018 um 22:12 schrieb Shuai Wang via Phabricator:

> shuaiwang added a comment.
> 
> In https://reviews.llvm.org/D45444#1191874, @JonasToth wrote:
> 
>>> lCould you give a concrete example of this?
>> 
>> vi llvm/lib/Demangle/ItaniumDemangle.cpp +1762
>> 
>> /home/jonas/opt/llvm/lib/Demangle/ItaniumDemangle.cpp:1762:7: warning:
>> 
>>   variable 'num' of type 'char [FloatData::max_demangled_size]' can
>>   be declared 'const' [cppcoreguidelines-const-correctness]
>>     char num[FloatData::max_demangled_size] = {0};
>>    ^
>>   /home/jonas/opt/llvm/lib/Demangle/ItaniumDemangle.cpp:1763:7: warning:
>>   variable 'n' of type 'int' can be declared 'const'
>>   [cppcoreguidelines-const-correctness]
>>         int n = snprintf(num, sizeof(num), FloatData::spec, value);
>>    ^
> 
> Looks like related to template.
>  the exact type of `num` depends on `Float`
>  and the `CallExpr` is not even resolved because we don't know the type of 
> the arguments yet (adl, overload resolution, etc.)
>  So the AST doesn't contain any array to pointer decay.
> 
> I guess we should suppress the check in such cases.
> 
> Repository:
> 
>   rCTE Clang Tools Extra
> 
> https://reviews.llvm.org/D45444


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D50447: [clang-tidy] Omit cases where loop variable is not used in loop body in performance-for-range-copy.

2018-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Could there even be a false positive? In a sense, the variable is never
used, so it does not matter, not?

Am 10.08.2018 um 22:17 schrieb Shuai Wang via Phabricator:

> shuaiwang added a comment.
> 
> In https://reviews.llvm.org/D50447#1194967, @JonasToth wrote:
> 
>> Do you think it is a bad idea? If the variable is not used it is ok to
>> 
>>   ignore it in this particular circumstance. Other warnings/check should
>>   deal with such a situation IMHO.
>> 
>> Am 10.08.2018 um 10:29 schrieb Roman Lebedev via Phabricator:
>> 
>>> lebedev.ri added a comment.
>>> 
>>> It seems this ended up silently being a catch-all, with no option to 
>>> control this behavior, and i don't see any comments discussing this..
>>> 
>>> Repository:
>>> 
>>>   rL LLVM
>>> 
>>> https://reviews.llvm.org/D50447
> 
> Not sure whether hokein have done that already but I did run through our code 
> base and AFAICT there's no false negative.
> 
> Repository:
> 
>   rL LLVM
> 
> https://reviews.llvm.org/D50447


Repository:
  rL LLVM

https://reviews.llvm.org/D50447



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


[PATCH] D50580: [clang-tidy] Abseil: no namespace check

2018-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Could it happen that some template specializations or so need to land in `absl`?




Comment at: clang-tidy/abseil/NoNamespaceCheck.cpp:28
+void NoNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *decl = Result.Nodes.getNodeAs("absl_namespace");
+

Please follow LLVM naming convention (Capitalize, and Decl should crash with a 
type)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50580



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 160239.
JonasToth added a comment.

- explicitly ignore lambdas in VarDecls


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,563 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+// Lambdas should be ignored, because they do not follow the normal variable
+// semantic (e.g. the type is only known to the compiler).
+void lambdas() {
+  auto Lambda = [](int i) { return i < 0; };
+}
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared 'const'
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  const int *const p0_p_local1 = &p_local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared 'const'
+  function_in_pointer(&p_local2);
+}
+
+void function_inout_ref(int &inout);
+void function_in_ref(const int &in);
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int &r0_np_local0 = np_local0;
+  int &r1_np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int &r2_np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared 'const'
+  const int &r0_p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared 'const'
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be de

[PATCH] D50559: [gnu-objc] Make selector order deterministic.

2018-08-11 Thread David Chisnall via Phabricator via cfe-commits
theraven added inline comments.



Comment at: lib/CodeGen/CGObjCGNU.cpp:3547
+  allSelectors.push_back(entry.first);
+llvm::sort(allSelectors.begin(), allSelectors.end());
 

bmwiedemann wrote:
> compilation failed here:
> ../tools/clang/lib/CodeGen/CGObjCGNU.cpp:2444:11: error: 'sort' is not a 
> member of 'llvm'
> 
> it suggested std::sort
I'm not sure `llvm::sort` was part of the 6.0 release, it was added in April 
and so should be in 7.0.  I don't expect a patch against the 8 branch to apply 
cleanly to 6...


Repository:
  rC Clang

https://reviews.llvm.org/D50559



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


[PATCH] D48714: [clang-tidy] fix PR37913, templated exception factory diagnosed correctly

2018-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 160242.
JonasToth added a comment.

- update to current master of clang introduce CHECK-NOTES
- use new BeginLoc api


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48714

Files:
  clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
  test/clang-tidy/hicpp-exception-baseclass.cpp

Index: test/clang-tidy/hicpp-exception-baseclass.cpp
===
--- test/clang-tidy/hicpp-exception-baseclass.cpp
+++ test/clang-tidy/hicpp-exception-baseclass.cpp
@@ -2,6 +2,7 @@
 
 namespace std {
 class exception {};
+class invalid_argument : public exception {};
 } // namespace std
 
 class derived_exception : public std::exception {};
@@ -35,6 +36,7 @@
 
   try {
 throw non_derived_exception();
+
 // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
 // CHECK-NOTES: 9:1: note: type defined here
   } catch (non_derived_exception &e) {
@@ -50,24 +52,24 @@
   try {
 throw bad_inheritance();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 10:1: note: type defined here
+// CHECK MESSAGES: 11:1: note: type defined here
 throw no_good_inheritance();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-// CHECK MESSAGES: 11:1: note: type defined here
+// CHECK MESSAGES: 12:1: note: type defined here
 throw really_creative();
 // CHECK MESSAGES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-// CHECK MESSAGES: 12:1: note: type defined here
+// CHECK MESSAGES: 13:1: note: type defined here
   } catch (...) {
   }
   throw bad_inheritance();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 10:1: note: type defined here
+  // CHECK MESSAGES: 11:1: note: type defined here
   throw no_good_inheritance();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
-  // CHECK MESSAGES: 11:1: note: type defined here
+  // CHECK MESSAGES: 12:1: note: type defined here
   throw really_creative();
   // CHECK MESSAGES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
-  // CHECK MESSAGES: 12:1: note: type defined here
+  // CHECK MESSAGES: 13:1: note: type defined here
 #endif
 }
 
@@ -91,7 +93,7 @@
   throw deep_hierarchy(); // Ok
 
   try {
-throw terrible_idea(); // Ok, but multiple inheritance isn't clean
+throw terrible_idea();  // Ok, but multiple inheritance isn't clean
   } catch (std::exception &e) { // Can be caught as std::exception, even with multiple inheritance
   }
   throw terrible_idea(); // Ok, but multiple inheritance
@@ -128,7 +130,7 @@
   // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
   THROW_EXCEPTION(non_derived_exception);
   // CHECK MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-  // CHECK MESSAGES: 9:1: note: type defined here
+  // CHECK MESSAGES: 10:1: note: type defined here
   THROW_EXCEPTION(std::exception);// Ok
   THROW_EXCEPTION(derived_exception); // Ok
   THROW_EXCEPTION(deep_hierarchy);// Ok
@@ -180,3 +182,21 @@
   // CHECK-NOTES: 169:1: note: type defined here
   throw UsingGood(); // Ok
 }
+
+// Fix PR37913
+struct invalid_argument_maker {
+  ::std::invalid_argument operator()() const;
+};
+struct int_maker {
+  int operator()() const;
+};
+template 
+void templated_thrower() { throw T{}(); }
+// CHECK-MESSAGES: [[@LINE-1]]:34: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
+
+void exception_created_with_function() {
+  templated_thrower();
+  templated_thrower();
+
+  throw invalid_argument_maker{}();
+}
Index: clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
===
--- clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
+++ clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
@@ -22,24 +22,39 @@
 return;
 
   Finder->addMatcher(
-  cxxThrowExpr(allOf(has(expr(unless(hasType(qualType(hasCanonicalType(
- hasDeclaration(cxxRecordDecl(isSameOrDerivedFrom(
- hasName("std::exception")),
- has(expr(unless(cxxUnresolvedConstructExpr(,
- eachOf(has(expr(hasType(namedDecl().bind("decl",
-anything(
+  cxxThrowExpr(
+  allOf(
+  ha

[PATCH] D50451: [ASTImporter] Fix import of class templates partial specialization

2018-08-11 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,

While importing methods looks harmless, importing fields can be a breaking 
change. Do you have any test results on this?




Comment at: lib/AST/ASTImporter.cpp:2872
 Importer.MapImported(D, FoundField);
+// In case of a FieldDecl of a ClassTemplateSpecializationDecl, the
+// initializer of a FieldDecl might not had been instantiated in the

Honestly speaking, I wonder about this behaviour because it doesn't look 
similar to instantiation of only methods that are used. Is it a common rule?



Comment at: lib/AST/ASTImporter.cpp:4550
+  // in the "From" context, but not in the "To" context.
+  for (auto *FromField : D->fields())
+Importer.Import(FromField);

Importing additional fields can change the layout of the specialization. For 
CSA, this usually results in strange assertions hard to debug. Could you please 
share the results of testing of this change?
This change also doesn't seem to have related tests in this patch.



Comment at: lib/AST/ASTImporter.cpp:4551
+  for (auto *FromField : D->fields())
+Importer.Import(FromField);
+

The result of import is unchecked here and below. Is it intentional?



Comment at: unittests/AST/ASTImporterTest.cpp:2722
+  ASSERT_FALSE(ToFun->hasBody());
+   auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+   ASSERT_TRUE(ImportedSpec);

3-space indentation.



Comment at: unittests/AST/ASTImporterTest.cpp:2763
+  ASSERT_FALSE(ToCtor->hasBody());
+   auto *ImportedSpec = Import(FromSpec, Lang_CXX11);
+  ASSERT_TRUE(ImportedSpec);

Broken indent.


Repository:
  rC Clang

https://reviews.llvm.org/D50451



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


[PATCH] D46940: [ASTImporter] make sure that ACtx::getParents still works

2018-08-11 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hello Richard,

Thank you for clarification. However, I think that moving ParentMap into 
libTooling is out of scope for this patch. Are you OK if this change will be 
committed with adding a TODO or FIXME for this move?


https://reviews.llvm.org/D46940



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


[PATCH] D41217: [Concepts] Concept Specialization Expressions

2018-08-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: include/clang/Sema/Sema.h:7134
+  // We are substituting template arguments into a constraint expression.
+  ConstraintSubstitution
 } Kind;

Missing a trailing comma here.



Comment at: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp:121
+template
+concept C7 = sizeof(T) == 1 || sizeof(typename T3::type) == 1; // 
expected-note{{while substituting template arguments into constraint expression 
here}} expected-note{{in instantiation of template class 'T3' requested 
here}}
+

Nit: You could use `// expected-note@-1{{...}}`, `// expected-note@-2{{...}}` 
to make lines like this more readable.



Comment at: test/Parser/cxx-concept-declaration.cpp:48
+bool a = C16;
+bool b = C17;

Should you static-assert the expected results?
```
static_assert(!C12);
static_assert(C13);
static_assert(C14);
static_assert(C15);
static_assert(C16);
static_assert(C16);
static_assert(C17);
static_assert(!C17);
```


Repository:
  rC Clang

https://reviews.llvm.org/D41217



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


[PATCH] D49798: [ASTImporter] Adding some friend function related unittests.

2018-08-11 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Balazs,

The patch looks mostly fine.




Comment at: unittests/AST/ASTImporterTest.cpp:2256
+FirstDeclMatcher().match(FromTU, cxxRecordDecl());
+auto lookup_res = Class->noload_lookup(FromName);
+ASSERT_EQ(lookup_res.size(), 0u);

LLVM naming conventions require it to be `LookupRes`.



Comment at: unittests/AST/ASTImporterTest.cpp:2258
+ASSERT_EQ(lookup_res.size(), 0u);
+lookup_res = cast(FromTU)->noload_lookup(FromName);
+ASSERT_EQ(lookup_res.size(), 1u);

getTuDecl() already return `TranslationUnitDecl *`. We should just declare 
`FromTU` as `auto *`, so no cast is needed here.



Comment at: unittests/AST/ASTImporterTest.cpp:2279
+  EXPECT_TRUE(To0->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend));
+  EXPECT_TRUE(!To0->isInIdentifierNamespace(Decl::IDNS_Ordinary));
+}

EXPECT_FALSE can be used instead of negations.



Comment at: unittests/AST/ASTImporterTest.cpp:2294
+Lang_CXX, "input0.cc");
+  auto From0 = FirstDeclMatcher().match(FromTU, Pattern);
+  auto From1 = LastDeclMatcher().match(FromTU, Pattern);

Names like FromFriendFunc/FromNormalFunc will make the test more readable.


Repository:
  rC Clang

https://reviews.llvm.org/D49798



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


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-08-11 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- updated this revision to Diff 160243.
0x8000- added a comment.

Rebased on curent master.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tidy/readability/MagicNumbersCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-magic-numbers.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-magic-numbers.rst
  test/clang-tidy/readability-magic-numbers.cpp

Index: test/clang-tidy/readability-magic-numbers.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-magic-numbers.cpp
@@ -0,0 +1,199 @@
+// RUN: %check_clang_tidy %s readability-magic-numbers %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: readability-magic-numbers.IgnoredIntegerValues, value: "0;1;2;10;100;"}, \
+// RUN:   {key: readability-magic-numbers.IgnoredFloatingPointValues, value: "3.14;2.71828;9.81;1.0;101.0;0x1.2p3"}, \
+// RUN:   {key: readability-magic-numbers.IgnorePowersOf2IntegerValues, value: 1}]}' \
+// RUN: --
+
+template 
+struct ValueBucket {
+  T value[V];
+};
+
+int BadGlobalInt = 5;
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+int IntSquarer(int param) {
+  return param * param;
+}
+
+void BuggyFunction() {
+  int BadLocalInt = 6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  (void)IntSquarer(7);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int LocalArray[15];
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  for (int ii = 0; ii < 22; ++ii)
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 22 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+  {
+LocalArray[ii] = 3 * ii;
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+  }
+
+  ValueBucket Bucket;
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 66 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+}
+
+class TwoIntContainer {
+public:
+  TwoIntContainer(int val) : anotherMember(val * val), yetAnotherMember(6), anotherConstant(val + val) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:73: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int getValue() const;
+
+private:
+  int oneMember = 9;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int anotherMember;
+
+  int yetAnotherMember;
+
+  const int oneConstant = 2;
+
+  const int anotherConstant;
+};
+
+int ValueArray[] = {3, 5};
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+float FloatPiVariable = 3.1415926535f;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 3.1415926535f is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+double DoublePiVariable = 6.283185307;
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 6.283185307 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+float SomeFloats[] = {0.5, 0x1.2p4};
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 0.5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: 0x1.2p4 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+int getAnswer() {
+  if (ValueArray[0] < ValueArray[1])
+return ValueArray[1];
+
+  return -3; // FILENOTFOUND
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+}
+
+/*
+ * Clean code
+ */
+
+#define INT_MACRO 5
+
+const int GoodGlobalIntConstant = 42;
+
+constexpr int AlsoGoodGlobalIntConstant = 42;
+
+int InitializedByMacro = INT_MACRO;
+
+void SolidFunction() {
+  const int GoodLocalIntConstant = 43;
+
+  (void)IntSquarer(GoodLocalIntConstant);
+
+  int LocalArray[INT_MACRO];
+
+  ValueBucket Bucket;
+}
+
+const int ConstValueArray[] = {7, 9};
+
+const int ConstValueArray2D[2][2] = {{7, 9}, {13, 15}};
+
+/*
+ * no warnings for ignored values (specified in th

[PATCH] D41217: [Concepts] Concept Specialization Expressions

2018-08-11 Thread Saar Raz via Phabricator via cfe-commits
saar.raz added inline comments.



Comment at: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp:121
+template
+concept C7 = sizeof(T) == 1 || sizeof(typename T3::type) == 1; // 
expected-note{{while substituting template arguments into constraint expression 
here}} expected-note{{in instantiation of template class 'T3' requested 
here}}
+

Quuxplusone wrote:
> Nit: You could use `// expected-note@-1{{...}}`, `// expected-note@-2{{...}}` 
> to make lines like this more readable.
😮😳 Well you learn something every day 



Comment at: test/Parser/cxx-concept-declaration.cpp:48
+bool a = C16;
+bool b = C17;

Quuxplusone wrote:
> Should you static-assert the expected results?
> ```
> static_assert(!C12);
> static_assert(C13);
> static_assert(C14);
> static_assert(C15);
> static_assert(C16);
> static_assert(C16);
> static_assert(C17);
> static_assert(!C17);
> ```
That's not the point of these tests but it couldn't hurt, I guess 


Repository:
  rC Clang

https://reviews.llvm.org/D41217



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


[libcxxabi] r339503 - Add missing _LIBCXXABI_FUNC_VIS to __gxx_personality_seh0

2018-08-11 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Sat Aug 11 12:36:06 2018
New Revision: 339503

URL: http://llvm.org/viewvc/llvm-project?rev=339503&view=rev
Log:
Add missing _LIBCXXABI_FUNC_VIS to __gxx_personality_seh0

This was missed in SVN r337754.

Modified:
libcxxabi/trunk/src/cxa_personality.cpp

Modified: libcxxabi/trunk/src/cxa_personality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=339503&r1=339502&r2=339503&view=diff
==
--- libcxxabi/trunk/src/cxa_personality.cpp (original)
+++ libcxxabi/trunk/src/cxa_personality.cpp Sat Aug 11 12:36:06 2018
@@ -1038,7 +1038,7 @@ __gxx_personality_v0
 }
 
 #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
-extern "C" EXCEPTION_DISPOSITION
+extern "C" _LIBCXXABI_FUNC_VIS EXCEPTION_DISPOSITION
 __gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
 {


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


[PATCH] D50559: [gnu-objc] Make selector order deterministic.

2018-08-11 Thread Bernhard M. Wiedemann via Phabricator via cfe-commits
bmwiedemann added a comment.

I got it compiled with std::sort on top of 6.0.1 and found that it indeed 
removes the indeterminism: When I compiled libobjc2-1.8.1/arc.m 25 times, I got 
the same md5sum every time - and the same result with and without ASLR.


Repository:
  rC Clang

https://reviews.llvm.org/D50559



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


[PATCH] D50516: [ASTImporter] Improved import of friend templates.

2018-08-11 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added inline comments.
This revision is now accepted and ready to land.



Comment at: unittests/AST/ASTImporterTest.cpp:2721
+  EXPECT_EQ(ToFriendClass->getDefinition(), ToClass);
+  ASSERT_EQ(ToFriendClass->getPreviousDecl(), ToClass);
+  ASSERT_EQ(

Should we use EXPECT_EQ for "To" checks?


Repository:
  rC Clang

https://reviews.llvm.org/D50516



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


[PATCH] D50552: [ASTImporter] Added test case for CXXConversionDecl importing

2018-08-11 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D50552



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


[PATCH] D50550: [ASTImporter] Added test case for opaque enums

2018-08-11 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D50550



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment.

In https://reviews.llvm.org/D45444#1196271, @JonasToth wrote:

> Always the same with the templates ;) So uninstantiated templates should
>  just be ignored.
>
> I think it would be better to have it in the ExprMutAnalyzer, because
>  that part can not decide on const-ness. Fixing it here would just
>  circumvent the problem but not fix it, would you agree?


Agreed :)
I'll create a diff handling various template related cases in 
ExprMutationAnalyzer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


r339505 - [ASTImporter] Added test case for CXXConversionDecl importing

2018-08-11 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Sat Aug 11 16:43:02 2018
New Revision: 339505

URL: http://llvm.org/viewvc/llvm-project?rev=339505&view=rev
Log:
[ASTImporter] Added test case for CXXConversionDecl importing

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

Added:
cfe/trunk/test/Import/conversion-decl/
cfe/trunk/test/Import/conversion-decl/Inputs/
cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
cfe/trunk/test/Import/conversion-decl/test.cpp

Added: cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp?rev=339505&view=auto
==
--- cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp Sat Aug 11 16:43:02 2018
@@ -0,0 +1,10 @@
+class Y {
+  int M;
+};
+
+class X {
+  int N, M;
+
+public:
+  operator Y();
+};

Added: cfe/trunk/test/Import/conversion-decl/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/conversion-decl/test.cpp?rev=339505&view=auto
==
--- cfe/trunk/test/Import/conversion-decl/test.cpp (added)
+++ cfe/trunk/test/Import/conversion-decl/test.cpp Sat Aug 11 16:43:02 2018
@@ -0,0 +1,5 @@
+// RUN: clang-import-test -import %S/Inputs/F.cpp -expression %s
+void expr() {
+  X X1;
+  Y Y1 = X1;
+}


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


[PATCH] D50552: [ASTImporter] Added test case for CXXConversionDecl importing

2018-08-11 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339505: [ASTImporter] Added test case for CXXConversionDecl 
importing (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50552?vs=160060&id=160247#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50552

Files:
  cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
  cfe/trunk/test/Import/conversion-decl/test.cpp


Index: cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
===
--- cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
+++ cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
@@ -0,0 +1,10 @@
+class Y {
+  int M;
+};
+
+class X {
+  int N, M;
+
+public:
+  operator Y();
+};
Index: cfe/trunk/test/Import/conversion-decl/test.cpp
===
--- cfe/trunk/test/Import/conversion-decl/test.cpp
+++ cfe/trunk/test/Import/conversion-decl/test.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-import-test -import %S/Inputs/F.cpp -expression %s
+void expr() {
+  X X1;
+  Y Y1 = X1;
+}


Index: cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
===
--- cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
+++ cfe/trunk/test/Import/conversion-decl/Inputs/F.cpp
@@ -0,0 +1,10 @@
+class Y {
+  int M;
+};
+
+class X {
+  int N, M;
+
+public:
+  operator Y();
+};
Index: cfe/trunk/test/Import/conversion-decl/test.cpp
===
--- cfe/trunk/test/Import/conversion-decl/test.cpp
+++ cfe/trunk/test/Import/conversion-decl/test.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-import-test -import %S/Inputs/F.cpp -expression %s
+void expr() {
+  X X1;
+  Y Y1 = X1;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339506 - [ASTImporter] Added test case for opaque enums

2018-08-11 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Sat Aug 11 16:43:46 2018
New Revision: 339506

URL: http://llvm.org/viewvc/llvm-project?rev=339506&view=rev
Log:
[ASTImporter] Added test case for opaque enums

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, martong, cfe-commits

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

Modified:
cfe/trunk/test/Import/enum/Inputs/S.cpp
cfe/trunk/test/Import/enum/test.cpp

Modified: cfe/trunk/test/Import/enum/Inputs/S.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/enum/Inputs/S.cpp?rev=339506&r1=339505&r2=339506&view=diff
==
--- cfe/trunk/test/Import/enum/Inputs/S.cpp (original)
+++ cfe/trunk/test/Import/enum/Inputs/S.cpp Sat Aug 11 16:43:46 2018
@@ -2,3 +2,5 @@ enum E {
   a = 1,
   b = 2
 };
+
+enum OpaqueWithType : long;

Modified: cfe/trunk/test/Import/enum/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/enum/test.cpp?rev=339506&r1=339505&r2=339506&view=diff
==
--- cfe/trunk/test/Import/enum/test.cpp (original)
+++ cfe/trunk/test/Import/enum/test.cpp Sat Aug 11 16:43:46 2018
@@ -1,4 +1,8 @@
-// RUN: clang-import-test -import %S/Inputs/S.cpp -expression %s
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+
+// CHECK: OpaqueWithType 'long'
+
 void expr() {
   static_assert(E::a + E::b == 3);
+  static_assert(sizeof(OpaqueWithType) == sizeof(long));
 }


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


[PATCH] D50550: [ASTImporter] Added test case for opaque enums

2018-08-11 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339506: [ASTImporter] Added test case for opaque enums 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50550?vs=160057&id=160248#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50550

Files:
  cfe/trunk/test/Import/enum/Inputs/S.cpp
  cfe/trunk/test/Import/enum/test.cpp


Index: cfe/trunk/test/Import/enum/Inputs/S.cpp
===
--- cfe/trunk/test/Import/enum/Inputs/S.cpp
+++ cfe/trunk/test/Import/enum/Inputs/S.cpp
@@ -2,3 +2,5 @@
   a = 1,
   b = 2
 };
+
+enum OpaqueWithType : long;
Index: cfe/trunk/test/Import/enum/test.cpp
===
--- cfe/trunk/test/Import/enum/test.cpp
+++ cfe/trunk/test/Import/enum/test.cpp
@@ -1,4 +1,8 @@
-// RUN: clang-import-test -import %S/Inputs/S.cpp -expression %s
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | 
FileCheck %s
+
+// CHECK: OpaqueWithType 'long'
+
 void expr() {
   static_assert(E::a + E::b == 3);
+  static_assert(sizeof(OpaqueWithType) == sizeof(long));
 }


Index: cfe/trunk/test/Import/enum/Inputs/S.cpp
===
--- cfe/trunk/test/Import/enum/Inputs/S.cpp
+++ cfe/trunk/test/Import/enum/Inputs/S.cpp
@@ -2,3 +2,5 @@
   a = 1,
   b = 2
 };
+
+enum OpaqueWithType : long;
Index: cfe/trunk/test/Import/enum/test.cpp
===
--- cfe/trunk/test/Import/enum/test.cpp
+++ cfe/trunk/test/Import/enum/test.cpp
@@ -1,4 +1,8 @@
-// RUN: clang-import-test -import %S/Inputs/S.cpp -expression %s
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+
+// CHECK: OpaqueWithType 'long'
+
 void expr() {
   static_assert(E::a + E::b == 3);
+  static_assert(sizeof(OpaqueWithType) == sizeof(long));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50605: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr

2018-08-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50605

Files:
  include/clang/AST/ExprCXX.h
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -406,16 +406,35 @@
   auto HasArgumentY = hasAnyArgument(
   ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y"));
   StatementMatcher CallArgumentY = callExpr(HasArgumentY);
+  StatementMatcher CtorArgumentY = cxxConstructExpr(HasArgumentY);
+  StatementMatcher UnresolvedCtorArgumentY =
+  cxxUnresolvedConstructExpr(HasArgumentY);
   StatementMatcher ObjCCallArgumentY = objcMessageExpr(HasArgumentY);
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
+  EXPECT_TRUE(matches("struct Y { Y(int, int); };"
+  "void x() { int y; (void)Y(1, y); }",
+  CtorArgumentY));
+  EXPECT_TRUE(matches("struct Y { Y(int, int); };"
+  "void x() { int y; (void)Y(y, 42); }",
+  CtorArgumentY));
+  EXPECT_TRUE(matches("template  void x() { int y; (void)Y(1, y); }",
+  UnresolvedCtorArgumentY));
+  EXPECT_TRUE(matches("template  void x() { int y; (void)Y(y, 42); }",
+  UnresolvedCtorArgumentY));
   EXPECT_TRUE(matchesObjC("@interface I -(void)f:(int) y; @end "
   "void x(I* i) { int y; [i f:y]; }",
   ObjCCallArgumentY));
   EXPECT_FALSE(matchesObjC("@interface I -(void)f:(int) z; @end "
"void x(I* i) { int z; [i f:z]; }",
ObjCCallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  EXPECT_TRUE(notMatches("struct Y { Y(int, int); };"
+ "void x() { int y; (void)Y(1, 2); }",
+ CtorArgumentY));
+  EXPECT_TRUE(notMatches("template "
+ "void x() { int y; (void)Y(1, 2); }",
+ UnresolvedCtorArgumentY));
 
   StatementMatcher ImplicitCastedArgument = callExpr(
 hasAnyArgument(implicitCastExpr()));
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3537,9 +3537,9 @@
 /// objcMessageExpr(hasAnyArgument(integerLiteral(equals(12
 ///   matches [i f:12]
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
-  AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
-  CXXConstructExpr,
-  ObjCMessageExpr),
+  AST_POLYMORPHIC_SUPPORTED_TYPES(
+  CallExpr, CXXConstructExpr,
+  CXXUnresolvedConstructExpr, ObjCMessageExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -3426,16 +3426,22 @@
   unsigned arg_size() const { return NumArgs; }
 
   using arg_iterator = Expr **;
+  using arg_range = llvm::iterator_range;
 
   arg_iterator arg_begin() { return getTrailingObjects(); }
   arg_iterator arg_end() { return arg_begin() + NumArgs; }
+  arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
 
   using const_arg_iterator = const Expr* const *;
+  using arg_const_range = llvm::iterator_range;
 
   const_arg_iterator arg_begin() const { return getTrailingObjects(); }
   const_arg_iterator arg_end() const {
 return arg_begin() + NumArgs;
   }
+  arg_const_range arguments() const {
+return arg_const_range(arg_begin(), arg_end());
+  }
 
   Expr *getArg(unsigned I) {
 assert(I < NumArgs && "Argument index out-of-range");


Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -406,16 +406,35 @@
   auto HasArgumentY = hasAnyArgument(
   ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y"));
   StatementMatcher CallArgumentY = callExpr(HasArgumentY);
+  StatementMatcher CtorArgumentY = cxxConstructExpr(HasArgumentY);
+  StatementMatcher UnresolvedCtorArgumentY =
+  cxxUnresolvedConstructExpr(HasArgumentY);
   StatementMatcher ObjCCallArgum