[PATCH] D36782: [Bash-autocompletion] Add support for static analyzer flags

2017-08-18 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added a comment.

@ruiu 
I addressed your comments in https://reviews.llvm.org/D36820, so please take a 
look at it. Thank you!


https://reviews.llvm.org/D36782



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


[PATCH] D36918: [Sema] Take into account the current context when checking the accessibility of a member function pointer

2017-08-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 111805.
ahatanak added a comment.

Test access to protected member functions.


https://reviews.llvm.org/D36918

Files:
  lib/Sema/SemaAccess.cpp
  test/SemaCXX/access.cpp


Index: test/SemaCXX/access.cpp
===
--- test/SemaCXX/access.cpp
+++ test/SemaCXX/access.cpp
@@ -169,3 +169,38 @@
   }
   void bar() { foo(); }
 }
+
+namespace OverloadedMemberFunctionPointer {
+  template
+  void func0() {}
+
+  template
+  void func1() {}
+
+  template
+  void func2(void(*fn)()) {} // expected-note 2 {{candidate function not 
viable: no overload of 'func}}
+
+  class C {
+  private:
+friend void friendFunc();
+void overloadedMethod();
+  protected:
+void overloadedMethod(int);
+  public:
+void overloadedMethod(int, int);
+void method() {
+  func2();
+  func2();
+}
+  };
+
+  void friendFunc() {
+func2();
+func2();
+  }
+
+  void nonFriendFunc() {
+func2(); // expected-error {{no 
matching function for call to 'func2'}}
+func2(); // expected-error {{no 
matching function for call to 'func2'}}
+  }
+}
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1793,6 +1793,11 @@
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
   /*no instance context*/ QualType());
+
+  EffectiveContext EC(CurScope->getEntity());
+  if (IsAccessible(*this, EC, Entity) == ::AR_accessible)
+return AR_accessible;
+
   Entity.setDiag(diag::err_access)
 << Ovl->getSourceRange();
 


Index: test/SemaCXX/access.cpp
===
--- test/SemaCXX/access.cpp
+++ test/SemaCXX/access.cpp
@@ -169,3 +169,38 @@
   }
   void bar() { foo(); }
 }
+
+namespace OverloadedMemberFunctionPointer {
+  template
+  void func0() {}
+
+  template
+  void func1() {}
+
+  template
+  void func2(void(*fn)()) {} // expected-note 2 {{candidate function not viable: no overload of 'func}}
+
+  class C {
+  private:
+friend void friendFunc();
+void overloadedMethod();
+  protected:
+void overloadedMethod(int);
+  public:
+void overloadedMethod(int, int);
+void method() {
+  func2();
+  func2();
+}
+  };
+
+  void friendFunc() {
+func2();
+func2();
+  }
+
+  void nonFriendFunc() {
+func2(); // expected-error {{no matching function for call to 'func2'}}
+func2(); // expected-error {{no matching function for call to 'func2'}}
+  }
+}
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1793,6 +1793,11 @@
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
   /*no instance context*/ QualType());
+
+  EffectiveContext EC(CurScope->getEntity());
+  if (IsAccessible(*this, EC, Entity) == ::AR_accessible)
+return AR_accessible;
+
   Entity.setDiag(diag::err_access)
 << Ovl->getSourceRange();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36820: [Bash-autocompletion] Add support for -std=

2017-08-18 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 111804.
yamaguchi added a comment.

Update diff. Thank you for your comments!


https://reviews.llvm.org/D36820

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/autocomplete.c
  llvm/utils/TableGen/OptParserEmitter.cpp


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -305,21 +305,22 @@
   OS << "// Option Values\n\n";
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record  = *Opts[I];
-if (!isa(R.getValueInit("ValuesCode"))) {
-  OS << "{\n";
-  OS << R.getValueAsString("ValuesCode");
-  OS << "\n";
-  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
-OS << "Opt.addValues(";
-std::string S = (Pref + R.getValueAsString("Name")).str();
-write_cstring(OS, S);
-OS << ", Values);\n";
-OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
-OS << " \"Couldn't add values to OptTable!\");\n";
+if (isa(R.getValueInit("ValuesCode")))
+  continue;
+OS << "{\n";
+OS << "bool ValuesWereAdded;\n";
+OS << R.getValueAsString("ValuesCode");
+OS << "\n";
+for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+  OS << "ValuesWereAdded = Opt.addValues(";
+  std::string S = (Pref + R.getValueAsString("Name")).str();
+  write_cstring(OS, S);
+  OS << ", Values);\n";
+  OS << "(void)ValuesWereAdded;\n";
+  OS << "assert(ValuesWereAdded && \"Couldn't add values to "
+"OptTable!\");\n";
   }
   OS << "}\n";
-}
   }
   OS << "\n";
   OS << "#endif // OPTTABLE_ARG_INIT\n";
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -95,3 +95,5 @@
 // NOWARNING: -Wno-invalid-pp-token
 // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s 
-check-prefix=ANALYZER
 // ANALYZER: unix.Malloc
+// RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL
+// STDVAL: c99
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2249,7 +2249,14 @@
 def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>;
 def std_default_EQ : Joined<["-"], "std-default=">;
 def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
-  Group, HelpText<"Language standard to compile for">;
+  Group, HelpText<"Language standard to compile for">,
+  ValuesCode<[{
+const char *Values =
+#define LANGSTANDARD(id, name, lang, desc, features) name ","
+#define LANGSTANDARD_ALIAS(id, alias) alias ","
+#include "clang/Frontend/LangStandards.def"
+;
+  }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;


Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -305,21 +305,22 @@
   OS << "// Option Values\n\n";
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record  = *Opts[I];
-if (!isa(R.getValueInit("ValuesCode"))) {
-  OS << "{\n";
-  OS << R.getValueAsString("ValuesCode");
-  OS << "\n";
-  for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
-OS << "bool ValuesWereAdded = ";
-OS << "Opt.addValues(";
-std::string S = (Pref + R.getValueAsString("Name")).str();
-write_cstring(OS, S);
-OS << ", Values);\n";
-OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
-OS << " \"Couldn't add values to OptTable!\");\n";
+if (isa(R.getValueInit("ValuesCode")))
+  continue;
+OS << "{\n";
+OS << "bool ValuesWereAdded;\n";
+OS << R.getValueAsString("ValuesCode");
+OS << "\n";
+for (const std::string  : R.getValueAsListOfStrings("Prefixes")) {
+  OS << "ValuesWereAdded = Opt.addValues(";
+  std::string S = (Pref + R.getValueAsString("Name")).str();
+  write_cstring(OS, S);
+  OS << ", Values);\n";
+  OS << "(void)ValuesWereAdded;\n";
+  OS << "assert(ValuesWereAdded && \"Couldn't add values to "
+"OptTable!\");\n";
   }
   OS << "}\n";
-}
   }
   OS << "\n";
   OS << "#endif // OPTTABLE_ARG_INIT\n";
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -95,3 +95,5 @@
 // NOWARNING: 

[PATCH] D36820: [Bash-autocompletion] Add support for -std=

2017-08-18 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:319-320
 OS << ", Values);\n";
 OS << "(void)ValuesWereAdded;\nassert(ValuesWereAdded &&";
 OS << " \"Couldn't add values to OptTable!\");\n";
   }

ruiu wrote:
> Can you split the string after each "\n"? It seems the current way of 
> splitting is somewhat arbitrary.
Those code are on review in D36782 and I've fixed it, so I think it's fine now 
:)


https://reviews.llvm.org/D36820



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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-18 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete updated this revision to Diff 111801.

https://reviews.llvm.org/D36855

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp


Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' 
with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void 
(X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? 
diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : Extension<
+  "invoking a pointer to a 'const &' member function on an rvalue is a C++2a 
extension">,
+  InGroup, SFINAEFailure;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "invoking a pointer to a 'const &' member function on an rvalue is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;


Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void (X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : 

[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-18 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete updated this revision to Diff 111800.
Rakete added a comment.

Rebased because another commit already added the definitions of the C++20 
groups.


https://reviews.llvm.org/D36855

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp


Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' 
with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void 
(X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? 
diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : Extension<
+  "invoking a pointer to a 'const &' member function on an rvalue is a C++2a 
extension">,
+  InGroup;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "invoking a pointer to a 'const &' member function on an rvalue is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore, SFINAEFailure;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;


Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void (X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can 

[PATCH] D36918: [Sema] Take into account the current context when checking the accessibility of a member function pointer

2017-08-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

Sema::CheckAddressOfMemberAccess was disregarding the context in which the 
member pointer was referenced.

This patch fixes PR32898.

rdar://problem/33737747


https://reviews.llvm.org/D36918

Files:
  lib/Sema/SemaAccess.cpp
  test/SemaCXX/access.cpp


Index: test/SemaCXX/access.cpp
===
--- test/SemaCXX/access.cpp
+++ test/SemaCXX/access.cpp
@@ -169,3 +169,29 @@
   }
   void bar() { foo(); }
 }
+
+namespace OverloadedMemberFunctionPointer {
+  template
+  void func0() {}
+
+  template
+  void func1(void(*fn)()) {} // expected-note {{candidate function not viable: 
no overload of 'func0' matching 'void (*)()' for 1st argument}}
+
+  class C {
+friend void friendFunc();
+void overloadedMethod();
+  public:
+void overloadedMethod(int);
+void method() {
+  func1();
+}
+  };
+
+  void friendFunc() {
+func1();
+  }
+
+  void nonFriendFunc() {
+func1(); // expected-error {{no 
matching function for call to 'func1'}}
+  }
+}
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1793,6 +1793,11 @@
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
   /*no instance context*/ QualType());
+
+  EffectiveContext EC(CurScope->getEntity());
+  if (IsAccessible(*this, EC, Entity) == ::AR_accessible)
+return AR_accessible;
+
   Entity.setDiag(diag::err_access)
 << Ovl->getSourceRange();
 


Index: test/SemaCXX/access.cpp
===
--- test/SemaCXX/access.cpp
+++ test/SemaCXX/access.cpp
@@ -169,3 +169,29 @@
   }
   void bar() { foo(); }
 }
+
+namespace OverloadedMemberFunctionPointer {
+  template
+  void func0() {}
+
+  template
+  void func1(void(*fn)()) {} // expected-note {{candidate function not viable: no overload of 'func0' matching 'void (*)()' for 1st argument}}
+
+  class C {
+friend void friendFunc();
+void overloadedMethod();
+  public:
+void overloadedMethod(int);
+void method() {
+  func1();
+}
+  };
+
+  void friendFunc() {
+func1();
+  }
+
+  void nonFriendFunc() {
+func1(); // expected-error {{no matching function for call to 'func1'}}
+  }
+}
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1793,6 +1793,11 @@
 
   AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
   /*no instance context*/ QualType());
+
+  EffectiveContext EC(CurScope->getEntity());
+  if (IsAccessible(*this, EC, Entity) == ::AR_accessible)
+return AR_accessible;
+
   Entity.setDiag(diag::err_access)
 << Ovl->getSourceRange();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]

2017-08-18 Thread Faisal Vali via Phabricator via cfe-commits
faisalv closed this revision.
faisalv added a comment.

Committed as r311224, on behalf of Hamza.

https://reviews.llvm.org/rL311224


https://reviews.llvm.org/D36572



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


r311222 - Revert "Revert "[clang-diff] Move printing of matches and changes to clang-diff""

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 19:56:35 2017
New Revision: 311222

URL: http://llvm.org/viewvc/llvm-project?rev=311222=rev
Log:
Revert "Revert "[clang-diff] Move printing of matches and changes to 
clang-diff""

Fix build by renaming ChangeKind -> Change

This reverts commit 0c78c5729f29315d7945988efd048c0cb86c07ce.

Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/Tooling/clang-diff-basic.cpp
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311222=311221=311222=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 19:56:35 2017
@@ -25,37 +25,22 @@
 namespace clang {
 namespace diff {
 
-/// This represents a match between two nodes in the source and destination
-/// trees, meaning that they are likely to be related.
-struct Match {
-  NodeId Src, Dst;
-};
-
 enum ChangeKind {
-  Delete, // (Src): delete node Src.
-  Update, // (Src, Dst): update the value of node Src to match Dst.
-  Insert, // (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
-  Move// (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
-};
-
-struct Change {
-  ChangeKind Kind;
-  NodeId Src, Dst;
-  size_t Position;
-
-  Change(ChangeKind Kind, NodeId Src, NodeId Dst, size_t Position)
-  : Kind(Kind), Src(Src), Dst(Dst), Position(Position) {}
-  Change(ChangeKind Kind, NodeId Src) : Kind(Kind), Src(Src) {}
-  Change(ChangeKind Kind, NodeId Src, NodeId Dst)
-  : Kind(Kind), Src(Src), Dst(Dst) {}
+  None,
+  Delete,// (Src): delete node Src.
+  Update,// (Src, Dst): update the value of node Src to match Dst.
+  Insert,// (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
+  Move,  // (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
+  UpdateMove // Same as Move plus Update.
 };
 
 /// Represents a Clang AST node, alongside some additional information.
 struct Node {
   NodeId Parent, LeftMostDescendant, RightMostDescendant;
-  int Depth, Height;
+  int Depth, Height, Shift = 0;
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
+  ChangeKind Change = None;
 
   ast_type_traits::ASTNodeKind getType() const;
   StringRef getTypeLabel() const;
@@ -67,15 +52,8 @@ public:
   ASTDiff(SyntaxTree , SyntaxTree , const ComparisonOptions );
   ~ASTDiff();
 
-  // Returns a list of matches.
-  std::vector getMatches();
-  /// Returns an edit script.
-  std::vector getChanges();
-
-  // Prints an edit action.
-  void printChange(raw_ostream , const Change ) const;
-  // Prints a match between two nodes.
-  void printMatch(raw_ostream , const Match ) const;
+  // Returns the ID of the node that is mapped to the given node in SourceTree.
+  NodeId getMapped(const SyntaxTree , NodeId Id) const;
 
   class Impl;
 
@@ -99,8 +77,14 @@ public:
   const ASTContext () const;
   StringRef getFilename() const;
 
-  const Node (NodeId Id) const;
+  int getSize() const;
   NodeId getRootId() const;
+  using PreorderIterator = NodeId;
+  PreorderIterator begin() const;
+  PreorderIterator end() const;
+
+  const Node (NodeId Id) const;
+  int findPositionInParent(NodeId Id) const;
 
   // Returns the starting and ending offset of the node in its source file.
   std::pair getSourceRangeOffsets(const Node ) const;
@@ -108,7 +92,8 @@ public:
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
-  std::string getNodeValue(const DynTypedNode ) const;
+  std::string getNodeValue(NodeId Id) const;
+  std::string getNodeValue(const Node ) const;
 
   class Impl;
   std::unique_ptr TreeImpl;
@@ -131,8 +116,8 @@ struct ComparisonOptions {
   bool EnableMatchingWithUnmatchableParents = false;
 
   /// Returns false if the nodes should never be matched.
-  bool isMatchingAllowed(const DynTypedNode , const DynTypedNode ) const 
{
-return N1.getNodeKind().isSame(N2.getNodeKind());
+  bool isMatchingAllowed(const Node , const Node ) const {
+return N1.getType().isSame(N2.getType());
   }
 };
 

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h?rev=311222=311221=311222=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h Fri Aug 18 
19:56:35 2017
@@ 

[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-08-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

This patch fixes an assertion failure that occurs when compiling the following 
invalid code:

  struct S {
template
S(T &&) {}
  };
  
  template
  void foo1(int a0, S a1 = [](){ (void) } ) { // a0 cannot be used in the 
default argument for a1
  }
  
  void foo2() {
foo1(1);
  }

$ clang++ -std=c++14 -c -o /dev/null test.cpp

Assertion failed: (isa(D) && "declaration not instantiated in this 
scope"), function findInstantiationOf, file 
llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp, line 2911.

The assertion fails when findInstantiationOf is called to find the instantiated 
decl of a0 when instantiating the lambda expression that is the default 
argument for a1.

To prevent the assertion failure, this patch makes CheckDefaultArgumentVisitor 
visit all subexpressions belonging to a default argument expression and detect 
local variables and parameters (that are external to the default argument) 
referenced in the default argument expression after the template definition is 
parsed. This patch also removes the diagnostic that is printed in test p7.cpp 
when a local variable is referenced inside a unevaluated default argument 
expression, which I think conforms to c++14 or later.

Also, with this patch, clang prints diagnostics when local variables or 
parameters are referenced inside a block expression that is used as a default 
argument. I wasn't 100% sure it is legal to use blocks for default arguments (I 
found that compiling the code below causes clang to segfault), but it seems to 
me that we want to handle blocks in default arguments the same way we handle 
lambdas.

  void logRange(id i = [](){}) {
  }
  
  void foo1() {
logRange();
  }

$ clang++ -std=c++14 -c -o /dev/null -fobjc-arc test.mm

rdar://problem/33239958


https://reviews.llvm.org/D36915

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  test/SemaCXX/default1.cpp
  test/SemaObjCXX/blocks.mm

Index: test/SemaObjCXX/blocks.mm
===
--- test/SemaObjCXX/blocks.mm
+++ test/SemaObjCXX/blocks.mm
@@ -169,3 +169,17 @@
   return b; // expected-error {{no viable conversion from returned value of type 'MoveBlockVariable::B0' to function return type 'MoveBlockVariable::B1'}}
 }
 }
+
+namespace DefaultArg {
+void test() {
+  id x;
+  void func0(id a0, id a1 = ^{ (void) }); // expected-error {{default argument references parameter 'a0'}}
+  void func1(id a0, id a1 = ^{ (void) }); // expected-error {{default argument references local variable 'x' of enclosing function}}
+  void func2(id a0, id a1 = ^{ (void)sizeof(a0); });
+  void func3(id a0 = ^{ (void)sizeof(x); });
+  void func4(id a0, id a1 = ^{
+^{ (void) }(); // expected-error {{default argument references parameter 'a0'}}
+[=](){ (void) }(); // expected-error {{default argument references parameter 'a0'}}
+  });
+}
+}
Index: test/SemaCXX/default1.cpp
===
--- test/SemaCXX/default1.cpp
+++ test/SemaCXX/default1.cpp
@@ -78,3 +78,60 @@
 
 void PR20769_b(int = 1);
 void PR20769_b() { void PR20769_b(int = 2); }
+
+#if __cplusplus >= 201103L // C++11 or later
+struct S2 {
+  template
+  S2(T&&) {}
+};
+
+template
+void func0(int a0, S2 a1 = [](){ (void) }); // expected-error {{default argument references parameter 'a0'}}
+
+template
+void func1(T a0, int a1, S2 a2 = _Generic((a0), default: [](){ (void) }, int: 0)); // expected-error {{default argument references parameter 'a1'}}
+
+template
+void func2(S2 a0 = [](){
+  int t; [](){ (void)}();
+});
+
+template
+void func3(int a0, S2 a1 = [](){
+  [=](){ (void)}(); // expected-error {{default argument references parameter 'a0'}}
+});
+
+double d;
+
+void test1() {
+  int i;
+  float f;
+  void foo0(int a0 = _Generic((f), double: d, float: f)); // expected-error {{default argument references local variable 'f' of enclosing function}}
+  void foo1(int a0 = _Generic((d), double: d, float: f));
+  void foo2(int a0 = _Generic((i), int: d, float: f));
+  void foo3(int a0 = _Generic((i), default: d, float: f));
+
+  void foo4(S2 a0 = [&](){ (void) }); // expected-error {{lambda expression in default argument cannot capture any entity}}
+  void foo5(S2 a0 = [](){
+// No warning about capture list of a lambda expression defined in a block scope.
+int t; [](){ (void)}();
+  });
+  void foo6(int a0, S2 a1 = [](){
+// No warning about local variables or parameters referenced by an
+// unevaluated expression.
+int t = sizeof({i, a0;});
+  });
+  void foo6(S2 a0 = [](){
+int i; // expected-note {{'i' declared here}}
+void foo7(int a0, // expected-note {{'a0' declared here}}
+  S2 a1 = [](){ (void) }); // expected-error {{variable 'a0' cannot be implicitly captured in a lambda with no capture-default specified}} expected-error {{default argument references parameter 'a0'}} expected-note {{lambda 

[PATCH] D36914: Implement CFG construction for __try / __except / __leave.

2017-08-18 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

This makes -Wunreachable-code work for programs containing SEH (except for 
__finally, which  is still missing for now).

__try is modeled like try (but simpler since it can only have a single __except 
or __finally), __except is fairly similar to catch (but simpler, since it can't 
contain declarations). __leave is implemented similarly to break / continue.

Use the existing addTryDispatchBlock infrastructure (which 
FindUnreachableCode() in ReachableCode.cpp uses via cfg->try_blocks_begin()) to 
mark things in the __except blocks as reachable.

Don't add any EH edges to the CFG for SEH. In practice, BuildOpts.AddEHEdges is 
always false in practice from what I can tell, and with SEH every single stmt 
would have to get an EH edge.


https://reviews.llvm.org/D36914

Files:
  lib/Analysis/CFG.cpp
  test/Sema/warn-unreachable-ms.c

Index: test/Sema/warn-unreachable-ms.c
===
--- test/Sema/warn-unreachable-ms.c
+++ test/Sema/warn-unreachable-ms.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fsyntax-only -verify -fms-extensions -Wunreachable-code
+
+void f();
+
+void g1() {
+  __try {
+f();
+__leave;
+f();  // expected-warning{{will never be executed}}
+  } __except(1) {
+f();
+  }
+
+  // Completely empty.
+  __try {
+  } __except(1) {
+  }
+
+  __try {
+f();
+return;
+  } __except(1) {  // Filter expression should not be marked as unreachable.
+// Emtpy __except body.
+  }
+}
+
+void g2() {
+  __try {
+// Nested __try.
+__try {
+  f();
+  __leave;
+  f(); // expected-warning{{will never be executed}}
+} __except(2) {
+}
+f();
+__leave;
+f(); // expected-warning{{will never be executed}}
+  } __except(1) {
+f();
+  }
+}
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -395,13 +395,15 @@
   ASTContext *Context;
   std::unique_ptr cfg;
 
-  CFGBlock *Block;
-  CFGBlock *Succ;
+  CFGBlock *Block;  // Current block.
+  CFGBlock *Succ;  // Block after the current block.
   JumpTarget ContinueJumpTarget;
   JumpTarget BreakJumpTarget;
+  JumpTarget SEHLeaveJumpTarget;
   CFGBlock *SwitchTerminatedBlock;
   CFGBlock *DefaultCaseBlock;
   CFGBlock *TryTerminatedBlock;
+  CFGBlock *SEHTryTerminatedBlock;
 
   // Current position in local scope.
   LocalScope::const_iterator ScopePos;
@@ -436,13 +438,13 @@
 
 public:
   explicit CFGBuilder(ASTContext *astContext,
-  const CFG::BuildOptions ) 
-: Context(astContext), cfg(new CFG()), // crew a new CFG
-  Block(nullptr), Succ(nullptr),
-  SwitchTerminatedBlock(nullptr), DefaultCaseBlock(nullptr),
-  TryTerminatedBlock(nullptr), badCFG(false), BuildOpts(buildOpts),
-  switchExclusivelyCovered(false), switchCond(nullptr),
-  cachedEntry(nullptr), lastLookup(nullptr) {}
+  const CFG::BuildOptions )
+  : Context(astContext), cfg(new CFG()), // crew a new CFG
+Block(nullptr), Succ(nullptr), SwitchTerminatedBlock(nullptr),
+DefaultCaseBlock(nullptr), TryTerminatedBlock(nullptr),
+SEHTryTerminatedBlock(nullptr), badCFG(false), BuildOpts(buildOpts),
+switchExclusivelyCovered(false), switchCond(nullptr),
+cachedEntry(nullptr), lastLookup(nullptr) {}
 
   // buildCFG - Used by external clients to construct the CFG.
   std::unique_ptr buildCFG(const Decl *D, Stmt *Statement);
@@ -501,6 +503,10 @@
   CFGBlock *VisitObjCForCollectionStmt(ObjCForCollectionStmt *S);
   CFGBlock *VisitPseudoObjectExpr(PseudoObjectExpr *E);
   CFGBlock *VisitReturnStmt(ReturnStmt *R);
+  CFGBlock *VisitSEHExceptStmt(SEHExceptStmt *S);
+  CFGBlock *VisitSEHFinallyStmt(SEHFinallyStmt *S);
+  CFGBlock *VisitSEHLeaveStmt(SEHLeaveStmt *S);
+  CFGBlock *VisitSEHTryStmt(SEHTryStmt *S);
   CFGBlock *VisitStmtExpr(StmtExpr *S, AddStmtChoice asc);
   CFGBlock *VisitSwitchStmt(SwitchStmt *S);
   CFGBlock *VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E,
@@ -1716,6 +1722,18 @@
 case Stmt::ReturnStmtClass:
   return VisitReturnStmt(cast(S));
 
+case Stmt::SEHExceptStmtClass:
+  return VisitSEHExceptStmt(cast(S));
+
+case Stmt::SEHFinallyStmtClass:
+  return VisitSEHFinallyStmt(cast(S));
+
+case Stmt::SEHLeaveStmtClass:
+  return VisitSEHLeaveStmt(cast(S));
+
+case Stmt::SEHTryStmtClass:
+  return VisitSEHTryStmt(cast(S));
+
 case Stmt::UnaryExprOrTypeTraitExprClass:
   return VisitUnaryExprOrTypeTraitExpr(cast(S),
asc);
@@ -2447,6 +2465,118 @@
   return VisitStmt(R, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitSEHExceptStmt(SEHExceptStmt *ES) {
+  // SEHExceptStmt are treated like labels, so they are the first statement in a
+  // block.
+
+  // Save local scope position because in case of exception variable ScopePos

[PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-18 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

In https://reviews.llvm.org/D36860#846232, @thakis wrote:

> Many driver tests check in a basic representative directory structure (e.g. 
> test/Driver/Inputs/basic_freebsd_tree/ and its many siblings).
>
> But if you're happy with others breaking this code, I suppose having no tests 
> is ok; I imagine most people won't use this code :-)


I can't check in copies of `cl.exe` and `link.exe` (the former's version is 
inspected, so it can't just be a dummy file). I'm happy without upstream tests 
for this logic. In the long run, I hope that we can eliminate this internal 
directory structure and make it identical to the released directory structure.


https://reviews.llvm.org/D36860



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


[PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-18 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Many driver tests check in a basic representative directory structure (e.g. 
test/Driver/Inputs/basic_freebsd_tree/ and its many siblings).

But if you're happy with others breaking this code, I suppose having no tests 
is ok; I imagine most people won't use this code :-)


https://reviews.llvm.org/D36860



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


r311220 - [clang-diff] Fix test for python 3

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 18:34:24 2017
New Revision: 311220

URL: http://llvm.org/viewvc/llvm-project?rev=311220=rev
Log:
[clang-diff] Fix test for python 3

Modified:
cfe/trunk/test/Tooling/clang-diff-json.cpp

Modified: cfe/trunk/test/Tooling/clang-diff-json.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-json.cpp?rev=311220=311219=311220=diff
==
--- cfe/trunk/test/Tooling/clang-diff-json.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-json.cpp Fri Aug 18 18:34:24 2017
@@ -22,6 +22,6 @@ class A {
 // CHECK: "type": "VarDecl",
 char nl = '\n';
 
-// CHECK: "value": "abc \n\t\u\u001f\u0123 \ub370\ubc15"
-char s[] = "abc \n\t\0\x1f\u0123 데박";
+// CHECK: "value": "abc \n\t\u\u001f"
+char s[] = "abc \n\t\0\x1f";
 


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


r311216 - Revert "Revert "[clang-diff] Move the JSON export function to clang-diff""

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 17:57:38 2017
New Revision: 311216

URL: http://llvm.org/viewvc/llvm-project?rev=311216=rev
Log:
Revert "Revert "[clang-diff] Move the JSON export function to clang-diff""

This reverts commit eac4c13ac9ea8f12bc049e040c7b9c8a517f54e7, the
original commit *should* not have caused the build failure.

Added:
cfe/trunk/test/Tooling/clang-diff-json.cpp
Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311216=311215=311216=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 17:57:38 2017
@@ -57,8 +57,8 @@ struct Node {
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
 
-  ast_type_traits::ASTNodeKind getType() const { return ASTNode.getNodeKind(); 
}
-  const StringRef getTypeLabel() const { return getType().asStringRef(); }
+  ast_type_traits::ASTNodeKind getType() const;
+  StringRef getTypeLabel() const;
   bool isLeaf() const { return Children.empty(); }
 };
 
@@ -96,15 +96,20 @@ public:
   SyntaxTree(SyntaxTree &) = default;
   ~SyntaxTree();
 
+  const ASTContext () const;
+  StringRef getFilename() const;
+
   const Node (NodeId Id) const;
+  NodeId getRootId() const;
+
+  // Returns the starting and ending offset of the node in its source file.
+  std::pair getSourceRangeOffsets(const Node ) const;
 
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
   std::string getNodeValue(const DynTypedNode ) const;
 
-  void printAsJson(raw_ostream );
-
   class Impl;
   std::unique_ptr TreeImpl;
 };

Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311216=311215=311216=diff
==
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original)
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Fri Aug 18 17:57:38 2017
@@ -176,9 +176,6 @@ public:
   void printTree(NodeId Root) const;
   void printTree(raw_ostream , NodeId Root) const;
 
-  void printAsJsonImpl(raw_ostream ) const;
-  void printNodeAsJson(raw_ostream , NodeId Id) const;
-
 private:
   /// Nodes in preorder.
   std::vector Nodes;
@@ -438,28 +435,6 @@ void SyntaxTree::Impl::printNode(raw_ost
   OS << "(" << PostorderIds[Id] << ")";
 }
 
-void SyntaxTree::Impl::printNodeAsJson(raw_ostream , NodeId Id) const {
-  auto N = getNode(Id);
-  OS << R"({"type":")" << N.getTypeLabel() << R"(")";
-  if (getNodeValue(Id) != "")
-OS << R"(,"value":")" << getNodeValue(Id) << R"(")";
-  OS << R"(,"children":[)";
-  if (N.Children.size() > 0) {
-printNodeAsJson(OS, N.Children[0]);
-for (size_t I = 1, E = N.Children.size(); I < E; ++I) {
-  OS << ",";
-  printNodeAsJson(OS, N.Children[I]);
-}
-  }
-  OS << "]}";
-}
-
-void SyntaxTree::Impl::printAsJsonImpl(raw_ostream ) const {
-  OS << R"({"root":)";
-  printNodeAsJson(OS, getRootId());
-  OS << "}\n";
-}
-
 /// Identifies a node in a subtree by its postorder offset, starting at 1.
 struct SNodeId {
   int Id = 0;
@@ -674,6 +649,12 @@ private:
   }
 };
 
+ast_type_traits::ASTNodeKind Node::getType() const {
+  return ASTNode.getNodeKind();
+}
+
+StringRef Node::getTypeLabel() const { return getType().asStringRef(); }
+
 namespace {
 // Compares nodes by their depth.
 struct HeightLess {
@@ -999,7 +980,28 @@ void ASTDiff::printMatch(raw_ostream 
 
 SyntaxTree::~SyntaxTree() = default;
 
-void SyntaxTree::printAsJson(raw_ostream ) { TreeImpl->printAsJsonImpl(OS); 
}
+const ASTContext ::getASTContext() const { return TreeImpl->AST; }
+
+const Node ::getNode(NodeId Id) const {
+  return TreeImpl->getNode(Id);
+}
+
+NodeId SyntaxTree::getRootId() const { return TreeImpl->getRootId(); }
+
+std::pair SyntaxTree::getSourceRangeOffsets(const Node ) 
const {
+  const SourceManager  = TreeImpl->AST.getSourceManager();
+  SourceRange Range = N.ASTNode.getSourceRange();
+  SourceLocation BeginLoc = Range.getBegin();
+  SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+  Range.getEnd(), /*Offset=*/0, SrcMgr, TreeImpl->AST.getLangOpts());
+  if (auto *ThisExpr = N.ASTNode.get()) {
+if (ThisExpr->isImplicit())
+  EndLoc = BeginLoc;
+  }
+  unsigned Begin = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(BeginLoc));
+  unsigned End = 

[PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-18 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT marked an inline comment as done.
STL_MSFT added a comment.

In https://reviews.llvm.org/D36860#845469, @thakis wrote:

> This approach looks good to me.


Thanks!

> Is there any chance we could have a test for this?

Unfortunately, testing this involves having a VS toolset with the 
DevDiv-internal directory structure. Preparing that is a laborious manual 
process, and requires installation of the Windows SDK (I sent repro 
instructions to cfe-dev). Even given a real installation of VS, I don't think I 
could write automated test code to extract a copy with the necessary directory 
structure (doing so would almost involve replicating the codepaths being 
touched here). But now that I know that this code exists and that Clang 
occasionally changes it, especially in response to new VS directory structures, 
I'll watch for new betas/RCs and verify them against our internal builds.


https://reviews.llvm.org/D36860



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


[PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-18 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT updated this revision to Diff 111776.
STL_MSFT edited the summary of this revision.
STL_MSFT added a comment.

This addresses Don Hinton's feedback. It also unifies `IsVS2017OrNewer` and 
`IsDevDivInternal` into a 3-state `enum class ToolsetLayout`.


https://reviews.llvm.org/D36860

Files:
  lib/Driver/ToolChains/MSVC.cpp
  lib/Driver/ToolChains/MSVC.h

Index: lib/Driver/ToolChains/MSVC.h
===
--- lib/Driver/ToolChains/MSVC.h
+++ lib/Driver/ToolChains/MSVC.h
@@ -92,7 +92,12 @@
 return getSubDirectoryPath(Type, getArch());
   }
 
-  bool getIsVS2017OrNewer() const { return IsVS2017OrNewer; }
+  enum class ToolsetLayout {
+OlderVS,
+VS2017OrNewer,
+DevDivInternal,
+  };
+  bool getIsVS2017OrNewer() const { return VSLayout == ToolsetLayout::VS2017OrNewer; }
 
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
@@ -130,7 +135,7 @@
   Tool *buildAssembler() const override;
 private:
   std::string VCToolChainPath;
-  bool IsVS2017OrNewer = false;
+  ToolsetLayout VSLayout = ToolsetLayout::OlderVS;
   CudaInstallationDetector CudaInstallation;
 };
 
Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -76,15 +76,15 @@
 
 // Check various environment variables to try and find a toolchain.
 static bool findVCToolChainViaEnvironment(std::string ,
-  bool ) {
+  MSVCToolChain::ToolsetLayout ) {
   // These variables are typically set by vcvarsall.bat
   // when launching a developer command prompt.
   if (llvm::Optional VCToolsInstallDir =
   llvm::sys::Process::GetEnv("VCToolsInstallDir")) {
 // This is only set by newer Visual Studios, and it leads straight to
 // the toolchain directory.
 Path = std::move(*VCToolsInstallDir);
-IsVS2017OrNewer = true;
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
 return true;
   }
   if (llvm::Optional VCInstallDir =
@@ -94,7 +94,7 @@
 // so this check has to appear second.
 // In older Visual Studios, the VC directory is the toolchain.
 Path = std::move(*VCInstallDir);
-IsVS2017OrNewer = false;
+VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
 return true;
   }
 
@@ -134,9 +134,16 @@
   }
   if (IsBin) {
 llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
-if (llvm::sys::path::filename(ParentPath) == "VC") {
+llvm::StringRef ParentFilename = llvm::sys::path::filename(ParentPath);
+if (ParentFilename == "VC") {
   Path = ParentPath;
-  IsVS2017OrNewer = false;
+  VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
+  return true;
+}
+if (ParentFilename == "x86ret" || ParentFilename == "x86chk"
+  || ParentFilename == "amd64ret" || ParentFilename == "amd64chk") {
+  Path = ParentPath;
+  VSLayout = MSVCToolChain::ToolsetLayout::DevDivInternal;
   return true;
 }
 
@@ -165,7 +172,7 @@
   ToolChainPath = llvm::sys::path::parent_path(ToolChainPath);
 
 Path = ToolChainPath;
-IsVS2017OrNewer = true;
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
 return true;
   }
 
@@ -181,7 +188,7 @@
 // This is the preferred way to discover new Visual Studios, as they're no
 // longer listed in the registry.
 static bool findVCToolChainViaSetupConfig(std::string ,
-  bool ) {
+  MSVCToolChain::ToolsetLayout ) {
 #if !defined(USE_MSVC_SETUP_API)
   return false;
 #else
@@ -263,16 +270,16 @@
 return false;
 
   Path = ToolchainPath.str();
-  IsVS2017OrNewer = true;
+  VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
   return true;
 #endif
 }
 
 // Look in the registry for Visual Studio installs, and use that to get
 // a toolchain path. VS2017 and newer don't get added to the registry.
 // So if we find something here, we know that it's an older version.
 static bool findVCToolChainViaRegistry(std::string ,
-   bool ) {
+   MSVCToolChain::ToolsetLayout ) {
   std::string VSInstallPath;
   if (getSystemRegistryString(R"(SOFTWARE\Microsoft\VisualStudio\$VERSION)",
   "InstallDir", VSInstallPath, nullptr) ||
@@ -284,7 +291,7 @@
   llvm::sys::path::append(VCPath, "VC");
 
   Path = VCPath.str();
-  IsVS2017OrNewer = false;
+  VSLayout = MSVCToolChain::ToolsetLayout::OlderVS;
   return true;
 }
   }
@@ -475,6 +482,7 @@
 // native target bin directory.
 // e.g. when compiling for x86 on an x64 host, PATH should start with:
 // /bin/HostX64/x86;/bin/HostX64/x64
+// This doesn't attempt to handle 

Re: r292458 - Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection

2017-08-18 Thread Dehao Chen via cfe-commits
On Fri, Aug 18, 2017 at 2:46 PM, Hans Wennborg  wrote:

> Should we mention this in the release notes?


> Is the flag documented somewhere?
>

It's documented in the Options.td file, do you think there are other
documents that need to be added/updated?

Thanks,
Dehao


>
> On Wed, Jan 18, 2017 at 4:44 PM, Dehao Chen via cfe-commits
>  wrote:
> > Author: dehao
> > Date: Wed Jan 18 18:44:21 2017
> > New Revision: 292458
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=292458=rev
> > Log:
> > Add -fdebug-info-for-profiling to emit more debug info for sample pgo
> profile collection
> >
> > Summary:
> > SamplePGO uses profile with debug info to collect profile. Unlike the
> traditional debugging purpose, sample pgo needs more accurate debug info to
> represent the profile. We add -femit-accurate-debug-info for this purpose.
> It can be combined with all debugging modes (-g, -gmlt, etc). It makes sure
> that the following pieces of info is always emitted:
> >
> > * start line of all subprograms
> > * linkage name of all subprograms
> > * standalone subprograms (functions that has neither inlined nor been
> inlined)
> >
> > The impact on speccpu2006 binary size (size increase comparing with -g0
> binary, also includes data for -g binary, which does not change with this
> patch):
> >
> >-gmlt(orig) -gmlt(patched) -g
> > 433.milc   4.68%   5.40%  19.73%
> > 444.namd   8.45%   8.93%  45.99%
> > 447.dealII 97.43%  115.21%374.89%
> > 450.soplex 27.75%  31.88% 126.04%
> > 453.povray 21.81%  26.16% 92.03%
> > 470.lbm0.60%   0.67%  1.96%
> > 482.sphinx35.77%   6.47%  26.17%
> > 400.perlbench  17.81%  19.43% 73.08%
> > 401.bzip2  3.73%   3.92%  12.18%
> > 403.gcc31.75%  34.48% 122.75%
> > 429.mcf0.78%   0.88%  3.89%
> > 445.gobmk  6.08%   7.92%  42.27%
> > 456.hmmer  10.36%  11.25% 35.23%
> > 458.sjeng  5.08%   5.42%  14.36%
> > 462.libquantum 1.71%   1.96%  6.36%
> > 464.h264ref15.61%  16.56% 43.92%
> > 471.omnetpp11.93%  15.84% 60.09%
> > 473.astar  3.11%   3.69%  14.18%
> > 483.xalancbmk  56.29%  81.63% 353.22%
> > geomean15.60%  18.30% 57.81%
> >
> > Debug info size change for -gmlt binary with this patch:
> >
> > 433.milc   13.46%
> > 444.namd   5.35%
> > 447.dealII 18.21%
> > 450.soplex 14.68%
> > 453.povray 19.65%
> > 470.lbm6.03%
> > 482.sphinx311.21%
> > 400.perlbench  8.91%
> > 401.bzip2  4.41%
> > 403.gcc8.56%
> > 429.mcf8.24%
> > 445.gobmk  29.47%
> > 456.hmmer  8.19%
> > 458.sjeng  6.05%
> > 462.libquantum 11.23%
> > 464.h264ref5.93%
> > 471.omnetpp31.89%
> > 473.astar  16.20%
> > 483.xalancbmk  44.62%
> > geomean16.83%
> >
> > Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo
> >
> > Reviewed By: dblaikie, echristo
> >
> > Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits,
> probinson, llvm-commits, mehdi_amini
> >
> > Differential Revision: https://reviews.llvm.org/D25435
> >
> > Modified:
> > cfe/trunk/include/clang/Driver/Options.td
> > cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> > cfe/trunk/lib/Driver/Tools.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> > cfe/trunk/test/Driver/clang_f_opts.c
> >
> > Modified: cfe/trunk/include/clang/Driver/Options.td
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=292458=292457=292458=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Driver/Options.td (original)
> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jan 18 18:44:21 2017
> > @@ -516,6 +516,12 @@ def fprofile_sample_use_EQ : Joined<["-"
> >  HelpText<"Enable sample-based profile guided optimizations">;
> >  def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
> >  Alias;
> > +def fdebug_info_for_profiling : Flag<["-"],
> "fdebug-info-for-profiling">, Group,
> > +Flags<[CC1Option]>,
> > +HelpText<"Emit extra debug info to make sample profile more
> accurate.">;
> > +def fno_debug_info_for_profiling : Flag<["-"],
> "fno-debug-info-for-profiling">, Group,
> > +Flags<[DriverOption]>,
> > +HelpText<"Do not emit extra debug info for sample profiler.">;
> >  def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
> >  Group, Flags<[CoreOption]>,
> >  HelpText<"Generate instrumented code to collect execution counts
> into default.profraw file (overridden by '=' form of option or
> LLVM_PROFILE_FILE env var)">;
> >
> > 

r311211 - Revert "[clang-diff] Move the JSON export function to clang-diff"

2017-08-18 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Fri Aug 18 16:21:11 2017
New Revision: 311211

URL: http://llvm.org/viewvc/llvm-project?rev=311211=rev
Log:
Revert "[clang-diff] Move the JSON export function to clang-diff"

This reverts commit r311199, it was causing widespread build failures.

Removed:
cfe/trunk/test/Tooling/clang-diff-json.cpp
Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311211=311210=311211=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 16:21:11 2017
@@ -57,8 +57,8 @@ struct Node {
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
 
-  ast_type_traits::ASTNodeKind getType() const;
-  StringRef getTypeLabel() const;
+  ast_type_traits::ASTNodeKind getType() const { return ASTNode.getNodeKind(); 
}
+  const StringRef getTypeLabel() const { return getType().asStringRef(); }
   bool isLeaf() const { return Children.empty(); }
 };
 
@@ -96,20 +96,15 @@ public:
   SyntaxTree(SyntaxTree &) = default;
   ~SyntaxTree();
 
-  const ASTContext () const;
-  StringRef getFilename() const;
-
   const Node (NodeId Id) const;
-  NodeId getRootId() const;
-
-  // Returns the starting and ending offset of the node in its source file.
-  std::pair getSourceRangeOffsets(const Node ) const;
 
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
   std::string getNodeValue(const DynTypedNode ) const;
 
+  void printAsJson(raw_ostream );
+
   class Impl;
   std::unique_ptr TreeImpl;
 };

Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311211=311210=311211=diff
==
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original)
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Fri Aug 18 16:21:11 2017
@@ -176,6 +176,9 @@ public:
   void printTree(NodeId Root) const;
   void printTree(raw_ostream , NodeId Root) const;
 
+  void printAsJsonImpl(raw_ostream ) const;
+  void printNodeAsJson(raw_ostream , NodeId Id) const;
+
 private:
   /// Nodes in preorder.
   std::vector Nodes;
@@ -435,6 +438,28 @@ void SyntaxTree::Impl::printNode(raw_ost
   OS << "(" << PostorderIds[Id] << ")";
 }
 
+void SyntaxTree::Impl::printNodeAsJson(raw_ostream , NodeId Id) const {
+  auto N = getNode(Id);
+  OS << R"({"type":")" << N.getTypeLabel() << R"(")";
+  if (getNodeValue(Id) != "")
+OS << R"(,"value":")" << getNodeValue(Id) << R"(")";
+  OS << R"(,"children":[)";
+  if (N.Children.size() > 0) {
+printNodeAsJson(OS, N.Children[0]);
+for (size_t I = 1, E = N.Children.size(); I < E; ++I) {
+  OS << ",";
+  printNodeAsJson(OS, N.Children[I]);
+}
+  }
+  OS << "]}";
+}
+
+void SyntaxTree::Impl::printAsJsonImpl(raw_ostream ) const {
+  OS << R"({"root":)";
+  printNodeAsJson(OS, getRootId());
+  OS << "}\n";
+}
+
 /// Identifies a node in a subtree by its postorder offset, starting at 1.
 struct SNodeId {
   int Id = 0;
@@ -649,12 +674,6 @@ private:
   }
 };
 
-ast_type_traits::ASTNodeKind Node::getType() const {
-  return ASTNode.getNodeKind();
-}
-
-StringRef Node::getTypeLabel() const { return getType().asStringRef(); }
-
 namespace {
 // Compares nodes by their depth.
 struct HeightLess {
@@ -980,28 +999,7 @@ void ASTDiff::printMatch(raw_ostream 
 
 SyntaxTree::~SyntaxTree() = default;
 
-const ASTContext ::getASTContext() const { return TreeImpl->AST; }
-
-const Node ::getNode(NodeId Id) const {
-  return TreeImpl->getNode(Id);
-}
-
-NodeId SyntaxTree::getRootId() const { return TreeImpl->getRootId(); }
-
-std::pair SyntaxTree::getSourceRangeOffsets(const Node ) 
const {
-  const SourceManager  = TreeImpl->AST.getSourceManager();
-  SourceRange Range = N.ASTNode.getSourceRange();
-  SourceLocation BeginLoc = Range.getBegin();
-  SourceLocation EndLoc = Lexer::getLocForEndOfToken(
-  Range.getEnd(), /*Offset=*/0, SrcMgr, TreeImpl->AST.getLangOpts());
-  if (auto *ThisExpr = N.ASTNode.get()) {
-if (ThisExpr->isImplicit())
-  EndLoc = BeginLoc;
-  }
-  unsigned Begin = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(BeginLoc));
-  unsigned End = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(EndLoc));
-  return {Begin, End};
-}
+void SyntaxTree::printAsJson(raw_ostream ) { TreeImpl->printAsJsonImpl(OS); 
}
 
 std::string 

Re: r296861 - [PowerPC] Enable -fomit-frame-pointer by default for PPC

2017-08-18 Thread Hans Wennborg via cfe-commits
Should we add a mention of this to the release notes?

On Fri, Mar 3, 2017 at 1:49 AM, Nemanja Ivanovic via cfe-commits
 wrote:
> Author: nemanjai
> Date: Fri Mar  3 03:49:17 2017
> New Revision: 296861
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296861=rev
> Log:
> [PowerPC] Enable -fomit-frame-pointer by default for PPC
>
> As is the case on platforms like Mips, X86 and SystemZ, the 
> -fomit-frame-pointer
> should be enabled by default on PPC when optimizing at -O1 and above. This
> brings the behaviour of LLVM on PPC in line with GCC.
>
> Committing on behalf of Hiroshi Inoue.
>
> Differential Revision: https://reviews.llvm.org/D29750
>
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/frame-pointer.c
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=296861=296860=296861=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar  3 03:49:17 2017
> @@ -2235,6 +2235,9 @@ static bool useFramePointerForTargetByDe
>  case llvm::Triple::mips64el:
>  case llvm::Triple::mips:
>  case llvm::Triple::mipsel:
> +case llvm::Triple::ppc:
> +case llvm::Triple::ppc64:
> +case llvm::Triple::ppc64le:
>  case llvm::Triple::systemz:
>  case llvm::Triple::x86:
>  case llvm::Triple::x86_64:
>
> Modified: cfe/trunk/test/Driver/frame-pointer.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/frame-pointer.c?rev=296861=296860=296861=diff
> ==
> --- cfe/trunk/test/Driver/frame-pointer.c (original)
> +++ cfe/trunk/test/Driver/frame-pointer.c Fri Mar  3 03:49:17 2017
> @@ -17,6 +17,13 @@
>  // RUN: %clang -target s390x-pc-linux -### -S -O0 %s -o %t.s 2>&1 | 
> FileCheck -check-prefix=CHECK0-64 %s
>  // RUN: %clang -target s390x-pc-linux -### -S -O1 %s -o %t.s 2>&1 | 
> FileCheck -check-prefix=CHECK1-64 %s
>
> +// RUN: %clang -target powerpc-unknown-linux-gnu -### -S -O0 %s -o %t.s 2>&1 
> | FileCheck -check-prefix=CHECK0-64 %s
> +// RUN: %clang -target powerpc-unknown-linux-gnu -### -S -O1 %s -o %t.s 2>&1 
> | FileCheck -check-prefix=CHECK1-64 %s
> +// RUN: %clang -target powerpc64-unknown-linux-gnu -### -S -O0 %s -o %t.s 
> 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
> +// RUN: %clang -target powerpc64-unknown-linux-gnu -### -S -O1 %s -o %t.s 
> 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
> +// RUN: %clang -target powerpc64le-unknown-linux-gnu -### -S -O0 %s -o %t.s 
> 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
> +// RUN: %clang -target powerpc64le-unknown-linux-gnu -### -S -O1 %s -o %t.s 
> 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
> +
>  // RUN: %clang -target mips-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | 
> FileCheck -check-prefix=CHECK0-32 %s
>  // RUN: %clang -target mips-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | 
> FileCheck -check-prefix=CHECK1-32 %s
>  // RUN: %clang -target mipsel-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | 
> FileCheck -check-prefix=CHECK0-32 %s
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r292458 - Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection

2017-08-18 Thread Hans Wennborg via cfe-commits
Should we mention this in the release notes?

Is the flag documented somewhere?

On Wed, Jan 18, 2017 at 4:44 PM, Dehao Chen via cfe-commits
 wrote:
> Author: dehao
> Date: Wed Jan 18 18:44:21 2017
> New Revision: 292458
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292458=rev
> Log:
> Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile 
> collection
>
> Summary:
> SamplePGO uses profile with debug info to collect profile. Unlike the 
> traditional debugging purpose, sample pgo needs more accurate debug info to 
> represent the profile. We add -femit-accurate-debug-info for this purpose. It 
> can be combined with all debugging modes (-g, -gmlt, etc). It makes sure that 
> the following pieces of info is always emitted:
>
> * start line of all subprograms
> * linkage name of all subprograms
> * standalone subprograms (functions that has neither inlined nor been inlined)
>
> The impact on speccpu2006 binary size (size increase comparing with -g0 
> binary, also includes data for -g binary, which does not change with this 
> patch):
>
>-gmlt(orig) -gmlt(patched) -g
> 433.milc   4.68%   5.40%  19.73%
> 444.namd   8.45%   8.93%  45.99%
> 447.dealII 97.43%  115.21%374.89%
> 450.soplex 27.75%  31.88% 126.04%
> 453.povray 21.81%  26.16% 92.03%
> 470.lbm0.60%   0.67%  1.96%
> 482.sphinx35.77%   6.47%  26.17%
> 400.perlbench  17.81%  19.43% 73.08%
> 401.bzip2  3.73%   3.92%  12.18%
> 403.gcc31.75%  34.48% 122.75%
> 429.mcf0.78%   0.88%  3.89%
> 445.gobmk  6.08%   7.92%  42.27%
> 456.hmmer  10.36%  11.25% 35.23%
> 458.sjeng  5.08%   5.42%  14.36%
> 462.libquantum 1.71%   1.96%  6.36%
> 464.h264ref15.61%  16.56% 43.92%
> 471.omnetpp11.93%  15.84% 60.09%
> 473.astar  3.11%   3.69%  14.18%
> 483.xalancbmk  56.29%  81.63% 353.22%
> geomean15.60%  18.30% 57.81%
>
> Debug info size change for -gmlt binary with this patch:
>
> 433.milc   13.46%
> 444.namd   5.35%
> 447.dealII 18.21%
> 450.soplex 14.68%
> 453.povray 19.65%
> 470.lbm6.03%
> 482.sphinx311.21%
> 400.perlbench  8.91%
> 401.bzip2  4.41%
> 403.gcc8.56%
> 429.mcf8.24%
> 445.gobmk  29.47%
> 456.hmmer  8.19%
> 458.sjeng  6.05%
> 462.libquantum 11.23%
> 464.h264ref5.93%
> 471.omnetpp31.89%
> 473.astar  16.20%
> 483.xalancbmk  44.62%
> geomean16.83%
>
> Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo
>
> Reviewed By: dblaikie, echristo
>
> Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits, 
> probinson, llvm-commits, mehdi_amini
>
> Differential Revision: https://reviews.llvm.org/D25435
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/Driver/clang_f_opts.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=292458=292457=292458=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jan 18 18:44:21 2017
> @@ -516,6 +516,12 @@ def fprofile_sample_use_EQ : Joined<["-"
>  HelpText<"Enable sample-based profile guided optimizations">;
>  def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
>  Alias;
> +def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
> Group,
> +Flags<[CC1Option]>,
> +HelpText<"Emit extra debug info to make sample profile more accurate.">;
> +def fno_debug_info_for_profiling : Flag<["-"], 
> "fno-debug-info-for-profiling">, Group,
> +Flags<[DriverOption]>,
> +HelpText<"Do not emit extra debug info for sample profiler.">;
>  def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
>  Group, Flags<[CoreOption]>,
>  HelpText<"Generate instrumented code to collect execution counts into 
> default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE 
> env var)">;
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=292458=292457=292458=diff
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jan 18 

[PATCH] D36179: [clang-diff] Move printing of matches and changes to clang-diff

2017-08-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311200: [clang-diff] Move printing of matches and changes to 
clang-diff (authored by krobelus).

Repository:
  rL LLVM

https://reviews.llvm.org/D36179

Files:
  cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
  cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
  cfe/trunk/test/Tooling/clang-diff-basic.cpp
  cfe/trunk/tools/clang-diff/ClangDiff.cpp

Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -129,7 +129,7 @@
   auto Offsets = Tree.getSourceRangeOffsets(N);
   OS << R"(,"begin":)" << Offsets.first;
   OS << R"(,"end":)" << Offsets.second;
-  std::string Value = Tree.getNodeValue(N.ASTNode);
+  std::string Value = Tree.getNodeValue(N);
   if (!Value.empty()) {
 OS << R"(,"value":")";
 printJsonString(OS, Value);
@@ -153,6 +153,52 @@
   OS << "]}";
 }
 
+static void printNode(raw_ostream , diff::SyntaxTree ,
+  diff::NodeId Id) {
+  if (Id.isInvalid()) {
+OS << "None";
+return;
+  }
+  OS << Tree.getNode(Id).getTypeLabel();
+  std::string Value = Tree.getNodeValue(Id);
+  if (!Value.empty())
+OS << ": " << Value;
+  OS << "(" << Id << ")";
+}
+
+static void printDstChange(raw_ostream , diff::ASTDiff ,
+   diff::SyntaxTree , diff::SyntaxTree ,
+   diff::NodeId Dst) {
+  const diff::Node  = DstTree.getNode(Dst);
+  diff::NodeId Src = Diff.getMapped(DstTree, Dst);
+  switch (DstNode.ChangeKind) {
+  case diff::None:
+break;
+  case diff::Delete:
+llvm_unreachable("The destination tree can't have deletions.");
+  case diff::Update:
+OS << "Update ";
+printNode(OS, SrcTree, Src);
+OS << " to " << DstTree.getNodeValue(Dst) << "\n";
+break;
+  case diff::Insert:
+  case diff::Move:
+  case diff::UpdateMove:
+if (DstNode.ChangeKind == diff::Insert)
+  OS << "Insert";
+else if (DstNode.ChangeKind == diff::Move)
+  OS << "Move";
+else if (DstNode.ChangeKind == diff::UpdateMove)
+  OS << "Update and Move";
+OS << " ";
+printNode(OS, DstTree, Dst);
+OS << " into ";
+printNode(OS, DstTree, DstNode.Parent);
+OS << " at " << DstTree.findPositionInParent(Dst) << "\n";
+break;
+  }
+}
+
 int main(int argc, const char **argv) {
   std::string ErrorMessage;
   std::unique_ptr CommonCompilations =
@@ -199,11 +245,26 @@
 Options.MaxSize = MaxSize;
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
-  diff::ASTDiff DiffTool(SrcTree, DstTree, Options);
-  for (const auto  : DiffTool.getMatches())
-DiffTool.printMatch(llvm::outs(), Match);
-  for (const auto  : DiffTool.getChanges())
-DiffTool.printChange(llvm::outs(), Change);
+  diff::ASTDiff Diff(SrcTree, DstTree, Options);
+
+  for (diff::NodeId Dst : DstTree) {
+diff::NodeId Src = Diff.getMapped(DstTree, Dst);
+if (Src.isValid()) {
+  llvm::outs() << "Match ";
+  printNode(llvm::outs(), SrcTree, Src);
+  llvm::outs() << " to ";
+  printNode(llvm::outs(), DstTree, Dst);
+  llvm::outs() << "\n";
+}
+printDstChange(llvm::outs(), Diff, SrcTree, DstTree, Dst);
+  }
+  for (diff::NodeId Src : SrcTree) {
+if (Diff.getMapped(SrcTree, Src).isInvalid()) {
+  llvm::outs() << "Delete ";
+  printNode(llvm::outs(), SrcTree, Src);
+  llvm::outs() << "\n";
+}
+  }
 
   return 0;
 }
Index: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
===
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
@@ -25,37 +25,22 @@
 namespace clang {
 namespace diff {
 
-/// This represents a match between two nodes in the source and destination
-/// trees, meaning that they are likely to be related.
-struct Match {
-  NodeId Src, Dst;
-};
-
 enum ChangeKind {
-  Delete, // (Src): delete node Src.
-  Update, // (Src, Dst): update the value of node Src to match Dst.
-  Insert, // (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
-  Move// (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
-};
-
-struct Change {
-  ChangeKind Kind;
-  NodeId Src, Dst;
-  size_t Position;
-
-  Change(ChangeKind Kind, NodeId Src, NodeId Dst, size_t Position)
-  : Kind(Kind), Src(Src), Dst(Dst), Position(Position) {}
-  Change(ChangeKind Kind, NodeId Src) : Kind(Kind), Src(Src) {}
-  Change(ChangeKind Kind, NodeId Src, NodeId Dst)
-  : Kind(Kind), Src(Src), Dst(Dst) {}
+  None,
+  Delete,// (Src): delete node Src.
+  Update,// (Src, Dst): update the value of node Src to match Dst.
+  Insert,// (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
+  Move,  // (Src, Dst, Pos): move 

[PATCH] D36178: [clang-diff] Move the JSON export function to clang-diff

2017-08-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311199: [clang-diff] Move the JSON export function to 
clang-diff (authored by krobelus).

Repository:
  rL LLVM

https://reviews.llvm.org/D36178

Files:
  cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
  cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
  cfe/trunk/test/Tooling/clang-diff-json.cpp
  cfe/trunk/test/lit.cfg
  cfe/trunk/test/lit.site.cfg.in
  cfe/trunk/tools/clang-diff/ClangDiff.cpp

Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -94,6 +94,65 @@
   return std::move(ASTs[0]);
 }
 
+static char hexdigit(int N) { return N &= 0xf, N + (N < 10 ? '0' : 'a' - 10); }
+
+static void printJsonString(raw_ostream , const StringRef Str) {
+  for (char C : Str) {
+switch (C) {
+case '"':
+  OS << R"(\")";
+  break;
+case '\\':
+  OS << R"(\\)";
+  break;
+case '\n':
+  OS << R"(\n)";
+  break;
+case '\t':
+  OS << R"(\t)";
+  break;
+default:
+  if ('\x00' <= C && C <= '\x1f') {
+OS << R"(\u00)" << hexdigit(C >> 4) << hexdigit(C);
+  } else {
+OS << C;
+  }
+}
+  }
+}
+
+static void printNodeAttributes(raw_ostream , diff::SyntaxTree ,
+diff::NodeId Id) {
+  const diff::Node  = Tree.getNode(Id);
+  OS << R"("id":)" << int(Id);
+  OS << R"(,"type":")" << N.getTypeLabel() << '"';
+  auto Offsets = Tree.getSourceRangeOffsets(N);
+  OS << R"(,"begin":)" << Offsets.first;
+  OS << R"(,"end":)" << Offsets.second;
+  std::string Value = Tree.getNodeValue(N.ASTNode);
+  if (!Value.empty()) {
+OS << R"(,"value":")";
+printJsonString(OS, Value);
+OS << '"';
+  }
+}
+
+static void printNodeAsJson(raw_ostream , diff::SyntaxTree ,
+diff::NodeId Id) {
+  const diff::Node  = Tree.getNode(Id);
+  OS << "{";
+  printNodeAttributes(OS, Tree, Id);
+  OS << R"(,"children":[)";
+  if (N.Children.size() > 0) {
+printNodeAsJson(OS, Tree, N.Children[0]);
+for (size_t I = 1, E = N.Children.size(); I < E; ++I) {
+  OS << ",";
+  printNodeAsJson(OS, Tree, N.Children[I]);
+}
+  }
+  OS << "]}";
+}
+
 int main(int argc, const char **argv) {
   std::string ErrorMessage;
   std::unique_ptr CommonCompilations =
@@ -117,7 +176,11 @@
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
-Tree.printAsJson(llvm::outs());
+llvm::outs() << R"({"filename":")";
+printJsonString(llvm::outs(), SourcePath);
+llvm::outs() << R"(","root":)";
+printNodeAsJson(llvm::outs(), Tree, Tree.getRootId());
+llvm::outs() << "}\n";
 return 0;
   }
 
Index: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
===
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
@@ -57,8 +57,8 @@
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
 
-  ast_type_traits::ASTNodeKind getType() const { return ASTNode.getNodeKind(); }
-  const StringRef getTypeLabel() const { return getType().asStringRef(); }
+  ast_type_traits::ASTNodeKind getType() const;
+  StringRef getTypeLabel() const;
   bool isLeaf() const { return Children.empty(); }
 };
 
@@ -96,15 +96,20 @@
   SyntaxTree(SyntaxTree &) = default;
   ~SyntaxTree();
 
+  const ASTContext () const;
+  StringRef getFilename() const;
+
   const Node (NodeId Id) const;
+  NodeId getRootId() const;
+
+  // Returns the starting and ending offset of the node in its source file.
+  std::pair getSourceRangeOffsets(const Node ) const;
 
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
   std::string getNodeValue(const DynTypedNode ) const;
 
-  void printAsJson(raw_ostream );
-
   class Impl;
   std::unique_ptr TreeImpl;
 };
Index: cfe/trunk/test/lit.site.cfg.in
===
--- cfe/trunk/test/lit.site.cfg.in
+++ cfe/trunk/test/lit.site.cfg.in
@@ -25,6 +25,7 @@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
 config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.
Index: cfe/trunk/test/lit.cfg
===
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -276,6 +276,7 @@
 config.substitutions.append( ('%itanium_abi_triple', 

r311200 - [clang-diff] Move printing of matches and changes to clang-diff

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 14:26:34 2017
New Revision: 311200

URL: http://llvm.org/viewvc/llvm-project?rev=311200=rev
Log:
[clang-diff] Move printing of matches and changes to clang-diff

Summary:
This also changes the output order of the changes. Now the matches are
printed in pre-order, intertwined with insertions, updates, and moves.
Deletions are printed afterwards.

Reviewers: arphaman

Subscribers: klimek

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

Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/Tooling/clang-diff-basic.cpp
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311200=311199=311200=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 14:26:34 2017
@@ -25,37 +25,22 @@
 namespace clang {
 namespace diff {
 
-/// This represents a match between two nodes in the source and destination
-/// trees, meaning that they are likely to be related.
-struct Match {
-  NodeId Src, Dst;
-};
-
 enum ChangeKind {
-  Delete, // (Src): delete node Src.
-  Update, // (Src, Dst): update the value of node Src to match Dst.
-  Insert, // (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
-  Move// (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
-};
-
-struct Change {
-  ChangeKind Kind;
-  NodeId Src, Dst;
-  size_t Position;
-
-  Change(ChangeKind Kind, NodeId Src, NodeId Dst, size_t Position)
-  : Kind(Kind), Src(Src), Dst(Dst), Position(Position) {}
-  Change(ChangeKind Kind, NodeId Src) : Kind(Kind), Src(Src) {}
-  Change(ChangeKind Kind, NodeId Src, NodeId Dst)
-  : Kind(Kind), Src(Src), Dst(Dst) {}
+  None,
+  Delete,// (Src): delete node Src.
+  Update,// (Src, Dst): update the value of node Src to match Dst.
+  Insert,// (Src, Dst, Pos): insert Src as child of Dst at offset Pos.
+  Move,  // (Src, Dst, Pos): move Src to be a child of Dst at offset Pos.
+  UpdateMove // Same as Move plus Update.
 };
 
 /// Represents a Clang AST node, alongside some additional information.
 struct Node {
   NodeId Parent, LeftMostDescendant, RightMostDescendant;
-  int Depth, Height;
+  int Depth, Height, Shift = 0;
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
+  ChangeKind ChangeKind = None;
 
   ast_type_traits::ASTNodeKind getType() const;
   StringRef getTypeLabel() const;
@@ -67,15 +52,8 @@ public:
   ASTDiff(SyntaxTree , SyntaxTree , const ComparisonOptions );
   ~ASTDiff();
 
-  // Returns a list of matches.
-  std::vector getMatches();
-  /// Returns an edit script.
-  std::vector getChanges();
-
-  // Prints an edit action.
-  void printChange(raw_ostream , const Change ) const;
-  // Prints a match between two nodes.
-  void printMatch(raw_ostream , const Match ) const;
+  // Returns the ID of the node that is mapped to the given node in SourceTree.
+  NodeId getMapped(const SyntaxTree , NodeId Id) const;
 
   class Impl;
 
@@ -99,8 +77,14 @@ public:
   const ASTContext () const;
   StringRef getFilename() const;
 
-  const Node (NodeId Id) const;
+  int getSize() const;
   NodeId getRootId() const;
+  using PreorderIterator = NodeId;
+  PreorderIterator begin() const;
+  PreorderIterator end() const;
+
+  const Node (NodeId Id) const;
+  int findPositionInParent(NodeId Id) const;
 
   // Returns the starting and ending offset of the node in its source file.
   std::pair getSourceRangeOffsets(const Node ) const;
@@ -108,7 +92,8 @@ public:
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
-  std::string getNodeValue(const DynTypedNode ) const;
+  std::string getNodeValue(NodeId Id) const;
+  std::string getNodeValue(const Node ) const;
 
   class Impl;
   std::unique_ptr TreeImpl;
@@ -131,8 +116,8 @@ struct ComparisonOptions {
   bool EnableMatchingWithUnmatchableParents = false;
 
   /// Returns false if the nodes should never be matched.
-  bool isMatchingAllowed(const DynTypedNode , const DynTypedNode ) const 
{
-return N1.getNodeKind().isSame(N2.getNodeKind());
+  bool isMatchingAllowed(const Node , const Node ) const {
+return N1.getType().isSame(N2.getType());
   }
 };
 

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h?rev=311200=311199=311200=diff
==

r311199 - [clang-diff] Move the JSON export function to clang-diff

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 14:26:13 2017
New Revision: 311199

URL: http://llvm.org/viewvc/llvm-project?rev=311199=rev
Log:
[clang-diff] Move the JSON export function to clang-diff

Reviewers: arphaman

Subscribers: klimek

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

Added:
cfe/trunk/test/Tooling/clang-diff-json.cpp
Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
cfe/trunk/test/lit.cfg
cfe/trunk/test/lit.site.cfg.in
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311199=311198=311199=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 14:26:13 2017
@@ -57,8 +57,8 @@ struct Node {
   ast_type_traits::DynTypedNode ASTNode;
   SmallVector Children;
 
-  ast_type_traits::ASTNodeKind getType() const { return ASTNode.getNodeKind(); 
}
-  const StringRef getTypeLabel() const { return getType().asStringRef(); }
+  ast_type_traits::ASTNodeKind getType() const;
+  StringRef getTypeLabel() const;
   bool isLeaf() const { return Children.empty(); }
 };
 
@@ -96,15 +96,20 @@ public:
   SyntaxTree(SyntaxTree &) = default;
   ~SyntaxTree();
 
+  const ASTContext () const;
+  StringRef getFilename() const;
+
   const Node (NodeId Id) const;
+  NodeId getRootId() const;
+
+  // Returns the starting and ending offset of the node in its source file.
+  std::pair getSourceRangeOffsets(const Node ) const;
 
   /// Serialize the node attributes to a string representation. This should
   /// uniquely distinguish nodes of the same kind. Note that this function just
   /// returns a representation of the node value, not considering descendants.
   std::string getNodeValue(const DynTypedNode ) const;
 
-  void printAsJson(raw_ostream );
-
   class Impl;
   std::unique_ptr TreeImpl;
 };

Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311199=311198=311199=diff
==
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original)
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Fri Aug 18 14:26:13 2017
@@ -176,9 +176,6 @@ public:
   void printTree(NodeId Root) const;
   void printTree(raw_ostream , NodeId Root) const;
 
-  void printAsJsonImpl(raw_ostream ) const;
-  void printNodeAsJson(raw_ostream , NodeId Id) const;
-
 private:
   /// Nodes in preorder.
   std::vector Nodes;
@@ -438,28 +435,6 @@ void SyntaxTree::Impl::printNode(raw_ost
   OS << "(" << PostorderIds[Id] << ")";
 }
 
-void SyntaxTree::Impl::printNodeAsJson(raw_ostream , NodeId Id) const {
-  auto N = getNode(Id);
-  OS << R"({"type":")" << N.getTypeLabel() << R"(")";
-  if (getNodeValue(Id) != "")
-OS << R"(,"value":")" << getNodeValue(Id) << R"(")";
-  OS << R"(,"children":[)";
-  if (N.Children.size() > 0) {
-printNodeAsJson(OS, N.Children[0]);
-for (size_t I = 1, E = N.Children.size(); I < E; ++I) {
-  OS << ",";
-  printNodeAsJson(OS, N.Children[I]);
-}
-  }
-  OS << "]}";
-}
-
-void SyntaxTree::Impl::printAsJsonImpl(raw_ostream ) const {
-  OS << R"({"root":)";
-  printNodeAsJson(OS, getRootId());
-  OS << "}\n";
-}
-
 /// Identifies a node in a subtree by its postorder offset, starting at 1.
 struct SNodeId {
   int Id = 0;
@@ -674,6 +649,12 @@ private:
   }
 };
 
+ast_type_traits::ASTNodeKind Node::getType() const {
+  return ASTNode.getNodeKind();
+}
+
+StringRef Node::getTypeLabel() const { return getType().asStringRef(); }
+
 namespace {
 // Compares nodes by their depth.
 struct HeightLess {
@@ -999,7 +980,28 @@ void ASTDiff::printMatch(raw_ostream 
 
 SyntaxTree::~SyntaxTree() = default;
 
-void SyntaxTree::printAsJson(raw_ostream ) { TreeImpl->printAsJsonImpl(OS); 
}
+const ASTContext ::getASTContext() const { return TreeImpl->AST; }
+
+const Node ::getNode(NodeId Id) const {
+  return TreeImpl->getNode(Id);
+}
+
+NodeId SyntaxTree::getRootId() const { return TreeImpl->getRootId(); }
+
+std::pair SyntaxTree::getSourceRangeOffsets(const Node ) 
const {
+  const SourceManager  = TreeImpl->AST.getSourceManager();
+  SourceRange Range = N.ASTNode.getSourceRange();
+  SourceLocation BeginLoc = Range.getBegin();
+  SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+  Range.getEnd(), /*Offset=*/0, SrcMgr, TreeImpl->AST.getLangOpts());
+  if (auto *ThisExpr = N.ASTNode.get()) {
+if (ThisExpr->isImplicit())
+  EndLoc = BeginLoc;
+  }
+  unsigned Begin = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(BeginLoc));
+  unsigned End = SrcMgr.getFileOffset(SrcMgr.getExpansionLoc(EndLoc));
+  return {Begin, End};
+}
 
 std::string 

Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-18 Thread Hans Wennborg via cfe-commits
r311197. Thanks!

On Fri, Aug 18, 2017 at 1:43 PM, Eric Fiselier  wrote:
> I'm OK merging it then.
>
> On Fri, Aug 18, 2017 at 2:32 PM, Hans Wennborg  wrote:
>>
>> Eric, sounds like there are no known issues with this, then. What do
>> you think about merging it?
>>
>> On Thu, Aug 17, 2017 at 5:30 PM, Petr Hosek  wrote:
>> > Confirmed, this changes is harmless. The failure we're seeing seems to
>> > have
>> > been introduced by Clang in r310983, sorry about the confusion.
>> >
>> > On Thu, Aug 17, 2017 at 4:35 PM Shoaib Meenai  wrote:
>> >>
>> >> See Petr's follow-up. It doesn't look like this was the responsible
>> >> change.
>> >>
>> >>
>> >>
>> >> From: Eric Fiselier 
>> >> Date: Thursday, August 17, 2017 at 4:02 PM
>> >> To: Petr Hosek 
>> >> Cc: cfe-commits , Marshall Clow
>> >> , Hans Wennborg , Shoaib
>> >> Meenai
>> >> 
>> >> Subject: Re: [libcxx] r309474 - [libc++] Hoist extern template above
>> >> first
>> >> use
>> >>
>> >>
>> >>
>> >> probably shouldn't merge this then.
>> >>
>> >>
>> >>
>> >> On Aug 17, 2017 4:54 PM, "Petr Hosek via cfe-commits"
>> >>  wrote:
>> >>
>> >> This broke our build of WebKit with the following build failure:
>> >>
>> >>
>> >>
>> >> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
>> >> obj/apps/web_view/web_view_test.test_webview.o.d
>> >> -DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
>> >> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
>> >> -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
>> >> -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
>> >> -I../../third_party/webkit/Source/WebKit/fuchsia
>> >> -I../../third_party/boringssl/include -Igen/third_party/cairo
>> >> -I../../third_party/curl/include -Iobj/third_party/curl
>> >> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
>> >> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
>> >> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
>> >> -I../../third_party/libpng -I../../third_party/zlib
>> >> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
>> >>
>> >> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
>> >> --target=x86_64-fuchsia -no-canonical-prefixes
>> >> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall
>> >> -Wextra
>> >> -Wno-unused-parameter -Wno-enum-compare-switch
>> >> -Wno-unused-lambda-capture
>> >> -Wno-user-defined-warnings -fvisibility=hidden -g -Og
>> >> -fsanitize=safe-stack
>> >> -fstack-protector-strong -Werror -Wno-error=deprecated-declarations
>> >> -fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
>> >> -Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
>> >> obj/apps/web_view/web_view_test.test_webview.o
>> >>
>> >> In file included from ../../apps/web_view/test_webview.cpp:1:
>> >>
>> >> In file included from
>> >> ../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
>> >>
>> >> In file included from
>> >>
>> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
>> >>
>> >>
>> >>
>> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
>> >> error: implicit instantiation of undefined template
>> >> 'std::__2::basic_string> >> std::__2::allocator >'
>> >>
>> >>
>> >>
>> >> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
>> >>
>> >>   ^
>> >>
>> >>
>> >>
>> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
>> >> note: expanded from macro '_VSTD'
>> >>
>> >> #define _VSTD std::_LIBCPP_NAMESPACE
>> >>
>> >>   ^
>> >>
>> >>
>> >>
>> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
>> >> note: in instantiation of exception specification for
>> >> '__invoke> >> std::__2::char_traits, std::__2::allocator > (const
>> >> std::__2::basic_string> >> std::__2::allocator > &)> &, const std::__2::basic_string> >> std::__2::char_traits, std::__2::allocator > &>' requested
>> >> here
>> >>
>> >> _VSTD::__invoke(_VSTD::declval<_Fp>(),
>> >> _VSTD::declval<_Args>()...));
>> >>
>> >> ^
>> >>
>> >>
>> >>
>> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
>> >> note: expanded from macro '_VSTD'
>> >>
>> >> #define _VSTD std::_LIBCPP_NAMESPACE
>> >>
>> >>   ^
>> >>
>> >>
>> >>
>> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
>> >> note: in instantiation of template class 'std::__2::__invokable_r> >> 

[libcxx] r311197 - Merging r309474:

2017-08-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Aug 18 13:59:31 2017
New Revision: 311197

URL: http://llvm.org/viewvc/llvm-project?rev=311197=rev
Log:
Merging r309474:

r309474 | smeenai | 2017-07-28 19:54:41 -0700 (Fri, 28 Jul 2017) | 9 lines

[libc++] Hoist extern template above first use

This function template is referenced inside class basic_string as a
friend function. The extern template declaration needs to be above that
friend declaration to actually take effect.

This is important because this function was marked as exported in
r307966, so without the extern template taking effect, it can leak into
other DSOs as a visible symbol.


Modified:
libcxx/branches/release_50/   (props changed)
libcxx/branches/release_50/include/string

Propchange: libcxx/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 18 13:59:31 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:309296,309307,309838,309851,309917,309920
+/libcxx/trunk:309296,309307,309474,309838,309851,309917,309920

Modified: libcxx/branches/release_50/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/string?rev=311197=311196=311197=diff
==
--- libcxx/branches/release_50/include/string (original)
+++ libcxx/branches/release_50/include/string Fri Aug 18 13:59:31 2017
@@ -556,6 +556,8 @@ template
 operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
 
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+(char const*, string const&))
+
 template 
 class _LIBCPP_TEMPLATE_VIS __basic_string_common
 {
@@ -3999,7 +4001,6 @@ basic_string<_CharT, _Traits, _Allocator
 
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
basic_string)
 _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS 
basic_string)
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+(char const*, string const&))
 
 #if _LIBCPP_STD_VER > 11 
 // Literal suffixes for basic_string [basic.string.literals]


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


[PATCH] D36492: [time-report] Add preprocessor timer

2017-08-18 Thread Eddie Elizondo via Phabricator via cfe-commits
eduardo-elizondo added inline comments.



Comment at: include/clang/Lex/PreprocessorOptions.h:165
 public:
-  PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+  PreprocessorOptions() : PPTimer("preprocessor", "Preprocessing"),
+  UsePredefines(true),

Should this be named "Lexing Time" or "Lexing" instead of "Preprocessing"?


https://reviews.llvm.org/D36492



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


Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-18 Thread Eric Fiselier via cfe-commits
I'm OK merging it then.

On Fri, Aug 18, 2017 at 2:32 PM, Hans Wennborg  wrote:

> Eric, sounds like there are no known issues with this, then. What do
> you think about merging it?
>
> On Thu, Aug 17, 2017 at 5:30 PM, Petr Hosek  wrote:
> > Confirmed, this changes is harmless. The failure we're seeing seems to
> have
> > been introduced by Clang in r310983, sorry about the confusion.
> >
> > On Thu, Aug 17, 2017 at 4:35 PM Shoaib Meenai  wrote:
> >>
> >> See Petr's follow-up. It doesn't look like this was the responsible
> >> change.
> >>
> >>
> >>
> >> From: Eric Fiselier 
> >> Date: Thursday, August 17, 2017 at 4:02 PM
> >> To: Petr Hosek 
> >> Cc: cfe-commits , Marshall Clow
> >> , Hans Wennborg , Shoaib
> Meenai
> >> 
> >> Subject: Re: [libcxx] r309474 - [libc++] Hoist extern template above
> first
> >> use
> >>
> >>
> >>
> >> probably shouldn't merge this then.
> >>
> >>
> >>
> >> On Aug 17, 2017 4:54 PM, "Petr Hosek via cfe-commits"
> >>  wrote:
> >>
> >> This broke our build of WebKit with the following build failure:
> >>
> >>
> >>
> >> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
> >> obj/apps/web_view/web_view_test.test_webview.o.d
> >> -DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
> >> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
> >> -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
> >> -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
> >> -I../../third_party/webkit/Source/WebKit/fuchsia
> >> -I../../third_party/boringssl/include -Igen/third_party/cairo
> >> -I../../third_party/curl/include -Iobj/third_party/curl
> >> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
> >> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
> >> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
> >> -I../../third_party/libpng -I../../third_party/zlib
> >> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
> >> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-
> magenta/build-magenta-pc-x86-64/sysroot
> >> --target=x86_64-fuchsia -no-canonical-prefixes
> >> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall
> -Wextra
> >> -Wno-unused-parameter -Wno-enum-compare-switch
> -Wno-unused-lambda-capture
> >> -Wno-user-defined-warnings -fvisibility=hidden -g -Og
> -fsanitize=safe-stack
> >> -fstack-protector-strong -Werror -Wno-error=deprecated-declarations
> >> -fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
> >> -Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
> >> obj/apps/web_view/web_view_test.test_webview.o
> >>
> >> In file included from ../../apps/web_view/test_webview.cpp:1:
> >>
> >> In file included from
> >> ../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
> >>
> >> In file included from
> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:484:
> >>
> >>
> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/type_traits:4323:23:
> >> error: implicit instantiation of undefined template
> >> 'std::__2::basic_string >> std::__2::allocator >'
> >>
> >>
> >> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::
> forward<_Args>(__args)...))
> >>
> >>   ^
> >>
> >>
> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/__config:468:15:
> >> note: expanded from macro '_VSTD'
> >>
> >> #define _VSTD std::_LIBCPP_NAMESPACE
> >>
> >>   ^
> >>
> >>
> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/type_traits:4340:9:
> >> note: in instantiation of exception specification for
> >> '__invoke >> std::__2::char_traits, std::__2::allocator > (const
> >> std::__2::basic_string >> std::__2::allocator > &)> &, const std::__2::basic_string >> std::__2::char_traits, std::__2::allocator > &>' requested
> here
> >>
> >> _VSTD::__invoke(_VSTD::declval<_Fp>(),
> >> _VSTD::declval<_Args>()...));
> >>
> >> ^
> >>
> >>
> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/__config:468:15:
> >> note: expanded from macro '_VSTD'
> >>
> >> #define _VSTD std::_LIBCPP_NAMESPACE
> >>
> >>   ^
> >>
> >>
> >> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/
> include/c++/v1/functional:1601:33:
> >> note: in instantiation of template class 'std::__2::__invokable_r >> std::__2::function std::__2::char_traits,
> >> std::__2::allocator > (const std::__2::basic_string >> std::__2::char_traits, std::__2::allocator > &)> &, const
> >> std::__2::basic_string >> 

Re: [libcxx] r309474 - [libc++] Hoist extern template above first use

2017-08-18 Thread Hans Wennborg via cfe-commits
Eric, sounds like there are no known issues with this, then. What do
you think about merging it?

On Thu, Aug 17, 2017 at 5:30 PM, Petr Hosek  wrote:
> Confirmed, this changes is harmless. The failure we're seeing seems to have
> been introduced by Clang in r310983, sorry about the confusion.
>
> On Thu, Aug 17, 2017 at 4:35 PM Shoaib Meenai  wrote:
>>
>> See Petr's follow-up. It doesn't look like this was the responsible
>> change.
>>
>>
>>
>> From: Eric Fiselier 
>> Date: Thursday, August 17, 2017 at 4:02 PM
>> To: Petr Hosek 
>> Cc: cfe-commits , Marshall Clow
>> , Hans Wennborg , Shoaib Meenai
>> 
>> Subject: Re: [libcxx] r309474 - [libc++] Hoist extern template above first
>> use
>>
>>
>>
>> probably shouldn't merge this then.
>>
>>
>>
>> On Aug 17, 2017 4:54 PM, "Petr Hosek via cfe-commits"
>>  wrote:
>>
>> This broke our build of WebKit with the following build failure:
>>
>>
>>
>> ../../buildtools/linux-x64/clang/bin/clang++ -MD -MF
>> obj/apps/web_view/web_view_test.test_webview.o.d
>> -DTOOLCHAIN_VERSION=4e89c701396412a50a901115ab4a2a09145f3777
>> -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DCAIRO_HAS_FC_FONT=0
>> -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION
>> -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen
>> -I../../third_party/webkit/Source/WebKit/fuchsia
>> -I../../third_party/boringssl/include -Igen/third_party/cairo
>> -I../../third_party/curl/include -Iobj/third_party/curl
>> -Iobj/third_party/curl/curl -I../../third_party/freetype2/include
>> -I../../third_party/harfbuzz/src -I../../third_party/icu/source/common
>> -I../../third_party/icu/source/i18n -I../../third_party/libjpeg-turbo
>> -I../../third_party/libpng -I../../third_party/zlib
>> -I../../third_party/libxml2/include -I../../third_party/sqlite -g
>> --sysroot=/usr/local/google/home/phosek/fuchsia/out/build-magenta/build-magenta-pc-x86-64/sysroot
>> --target=x86_64-fuchsia -no-canonical-prefixes
>> -fdebug-prefix-map=/usr/local/google/home/phosek/fuchsia=. -Wall -Wextra
>> -Wno-unused-parameter -Wno-enum-compare-switch -Wno-unused-lambda-capture
>> -Wno-user-defined-warnings -fvisibility=hidden -g -Og -fsanitize=safe-stack
>> -fstack-protector-strong -Werror -Wno-error=deprecated-declarations
>> -fvisibility-inlines-hidden -std=c++14 -fno-exceptions -fno-rtti
>> -Wthread-safety -c ../../apps/web_view/test_webview.cpp -o
>> obj/apps/web_view/web_view_test.test_webview.o
>>
>> In file included from ../../apps/web_view/test_webview.cpp:1:
>>
>> In file included from
>> ../../third_party/webkit/Source/WebKit/fuchsia/WebView.h:28:
>>
>> In file included from
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:484:
>>
>>
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4323:23:
>> error: implicit instantiation of undefined template
>> 'std::__2::basic_string> std::__2::allocator >'
>>
>>
>> _LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
>>
>>   ^
>>
>>
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
>> note: expanded from macro '_VSTD'
>>
>> #define _VSTD std::_LIBCPP_NAMESPACE
>>
>>   ^
>>
>>
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/type_traits:4340:9:
>> note: in instantiation of exception specification for
>> '__invoke> std::__2::char_traits, std::__2::allocator > (const
>> std::__2::basic_string> std::__2::allocator > &)> &, const std::__2::basic_string> std::__2::char_traits, std::__2::allocator > &>' requested here
>>
>> _VSTD::__invoke(_VSTD::declval<_Fp>(),
>> _VSTD::declval<_Args>()...));
>>
>> ^
>>
>>
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/__config:468:15:
>> note: expanded from macro '_VSTD'
>>
>> #define _VSTD std::_LIBCPP_NAMESPACE
>>
>>   ^
>>
>>
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1601:33:
>> note: in instantiation of template class 'std::__2::__invokable_r> std::__2::function> std::__2::allocator > (const std::__2::basic_string> std::__2::char_traits, std::__2::allocator > &)> &, const
>> std::__2::basic_string> std::__2::allocator > &>' requested here
>>
>> __invokable<_Fp&, _ArgTypes...>::value>
>>
>> ^
>>
>>
>> ../../buildtools/linux-x64/clang/lib/x86_64-fuchsia/include/c++/v1/functional:1626:9:
>> note: in instantiation of default argument for
>> '__callable> 

[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-08-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D36836#845417, @JonasToth wrote:

> Did I run it over clang or athletic like that? I would be interested in an 
> overall output.


No, not yet.
But if it is to be enabled for LLVM repos by default, then the `Threshold` will 
most definitively need adjusting in a `.clang-tidy` :)

> I added my thoughts.

Should be fixed.

> This check seems very valuable.

Thank you :)
I hope others agree...


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-08-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 111731.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

Address review notes:

- `constexpr const` -> `constexpr`
- moved `test/clang-tidy/check_clang_tidy.py` changes into 
https://reviews.llvm.org/D36892


Repository:
  rL LLVM

https://reviews.llvm.org/D36836

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  test/clang-tidy/readability-function-cognitive-complexity.cpp

Index: test/clang-tidy/readability-function-cognitive-complexity.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-function-cognitive-complexity.cpp
@@ -0,0 +1,549 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- -config='{CheckOptions: [{key: readability-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11
+
+// any function should be checked.
+
+extern int ext_func(int x = 0);
+
+int some_func(int x = 0);
+
+static int some_other_func(int x = 0) {}
+
+template void some_templ_func(T x = 0) {}
+
+class SomeClass {
+public:
+  int *begin(int x = 0);
+  int *end(int x = 0);
+  static int func(int x = 0);
+  template void some_templ_func(T x = 0) {}
+};
+
+// nothing ever decreases cognitive complexity, so we can check all the things
+// in one go. none of the following should increase cognitive complexity:
+void unittest_false() {
+  {};
+  ext_func();
+  some_func();
+  some_other_func();
+  some_templ_func();
+  some_templ_func();
+  SomeClass::func();
+  SomeClass C;
+  C.some_templ_func();
+  C.some_templ_func();
+  C.func();
+  C.end();
+  int i = some_func();
+  i = i;
+  i++;
+  --i;
+  i < 0;
+  int j = 0 ?: 1;
+  auto k = new int;
+  delete k;
+  throw i;
+end:
+  return;
+}
+
+////
+//-- B1. Increments --//
+////
+// Check that every thing listed in B1 of the specification does indeed   //
+// recieve the base increment, and that not-body does not increase nesting//
+////
+
+// break does not increase cognitive complexity.
+// only  break LABEL  does, but it is unavaliable in C or C++
+
+// continue does not increase cognitive complexity.
+// only  continue LABEL  does, but it is unavaliable in C or C++
+
+void unittest_b1_00() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_00' has cognitive complexity of 5 (threshold 0) [readability-function-cognitive-complexity]
+  if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:7: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+  } else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:14: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+  } else {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +1, nesting level increased to 1{{$}}
+  }
+}
+
+void unittest_b1_01() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_01' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  int i = (1 ? 1 : 0) ? 1 : 0;
+// CHECK-NOTES: :[[@LINE-1]]:11: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:12: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// FIXME: would be nice to point at the '?' symbol. does not seem to be possible
+}
+
+void unittest_b1_02(int x) {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_02' has cognitive complexity of 5 (threshold 0) [readability-function-cognitive-complexity]
+  switch (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+  case -1:
+return;
+  case 1 ? 1 : 0:
+// CHECK-NOTES: :[[@LINE-1]]:8: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+return;
+  case (1 ? 2 : 0) ... (1 ? 3 : 0):
+// CHECK-NOTES: :[[@LINE-1]]:9: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:25: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+return;
+  default:
+break;
+  }
+}
+
+void unittest_b1_03(int x) {
+// CHECK-NOTES: 

Re: r311115 - PR34161: support evaluation of 'void()' expressions in C++14 onwards.

2017-08-18 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r311194.

On Thu, Aug 17, 2017 at 12:35 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Aug 17 12:35:50 2017
> New Revision: 35
>
> URL: http://llvm.org/viewvc/llvm-project?rev=35=rev
> Log:
> PR34161: support evaluation of 'void()' expressions in C++14 onwards.
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=35=34=35=diff
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Aug 17 12:35:50 2017
> @@ -9787,6 +9787,8 @@ public:
>
>bool Success(const APValue , const Expr *e) { return true; }
>
> +  bool ZeroInitialization(const Expr *E) { return true; }
> +
>bool VisitCastExpr(const CastExpr *E) {
>  switch (E->getCastKind()) {
>  default:
>
> Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=35=34=35=diff
> ==
> --- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
> +++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Thu Aug 17 12:35:50 
> 2017
> @@ -982,3 +982,9 @@ constexpr void PR28739(int n) { // expec
>int *p = 
>p += (__int128)(unsigned long)-1; // expected-note {{cannot refer to 
> element 18446744073709551615 of non-array object in a constant expression}}
>  }
> +
> +constexpr void Void(int n) {
> +  void(n + 1);
> +  void();
> +}
> +constexpr int void_test = (Void(0), 1);
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36892: [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix

2017-08-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, JDevlieghere.

Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with 
`warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to 
be checked.
This was useful for me when developing https://reviews.llvm.org/D36836.


Repository:
  rL LLVM

https://reviews.llvm.org/D36892

Files:
  test/clang-tidy/check_clang_tidy.py


Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -73,9 +73,11 @@
 
   has_check_fixes = input_text.find('CHECK-FIXES') >= 0
   has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  has_check_notes = input_text.find('CHECK-NOTES') >= 0
 
-  if not has_check_fixes and not has_check_messages:
-sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input')
+  if not has_check_fixes and not has_check_messages and not has_check_notes:
+sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES '
+ 'nor CHECK-NOTES found in the input')
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -136,5 +138,18 @@
   print('FileCheck failed:\n' + e.output.decode())
   raise
 
+  if has_check_notes:
+messages_file = temp_file_name + '.msg'
+write_file(messages_file, clang_tidy_output)
+try:
+  subprocess.check_output(
+  ['FileCheck', '-input-file=' + messages_file, input_file_name,
+   '-check-prefix=CHECK-NOTES',
+   '-implicit-check-not={{note|warning|error}}:'],
+  stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+  print('FileCheck failed:\n' + e.output.decode())
+  raise
+
 if __name__ == '__main__':
   main()


Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -73,9 +73,11 @@
 
   has_check_fixes = input_text.find('CHECK-FIXES') >= 0
   has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  has_check_notes = input_text.find('CHECK-NOTES') >= 0
 
-  if not has_check_fixes and not has_check_messages:
-sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input')
+  if not has_check_fixes and not has_check_messages and not has_check_notes:
+sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES '
+ 'nor CHECK-NOTES found in the input')
 
   # Remove the contents of the CHECK lines to avoid CHECKs matching on
   # themselves.  We need to keep the comments to preserve line numbers while
@@ -136,5 +138,18 @@
   print('FileCheck failed:\n' + e.output.decode())
   raise
 
+  if has_check_notes:
+messages_file = temp_file_name + '.msg'
+write_file(messages_file, clang_tidy_output)
+try:
+  subprocess.check_output(
+  ['FileCheck', '-input-file=' + messages_file, input_file_name,
+   '-check-prefix=CHECK-NOTES',
+   '-implicit-check-not={{note|warning|error}}:'],
+  stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+  print('FileCheck failed:\n' + e.output.decode())
+  raise
+
 if __name__ == '__main__':
   main()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311191 - [Sema] Don't emit -Wunguarded-availability for switch cases

2017-08-18 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Aug 18 13:20:56 2017
New Revision: 311191

URL: http://llvm.org/viewvc/llvm-project?rev=311191=rev
Log:
[Sema] Don't emit -Wunguarded-availability for switch cases

This made it awkward to switch over an enum where some entries
are partial and is unlikley to catch any bugs.

Differential revision: https://reviews.llvm.org/D36777

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaObjC/unguarded-availability.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=311191=311190=311191=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Aug 18 13:20:56 2017
@@ -7513,6 +7513,10 @@ public:
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  // for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+  // to any useful diagnostics.
+  bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); 
}
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), 
PRE->getReceiverLocation());

Modified: cfe/trunk/test/SemaObjC/unguarded-availability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability.m?rev=311191=311190=311191=diff
==
--- cfe/trunk/test/SemaObjC/unguarded-availability.m (original)
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m Fri Aug 18 13:20:56 2017
@@ -287,3 +287,27 @@ AVAILABLE_10_12
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // 
expected-note 3 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // 
expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in 
enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  switch (a) {
+  case AK_Dodo...AK_CyborgCat: // expected-warning {{'AK_Dodo' is depr}}
+break;
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on 
macOS 10.12 or newer}} expected-note {{@available}}
+}


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


[PATCH] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases

2017-08-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311191: [Sema] Don't emit -Wunguarded-availability for 
switch cases (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D36777?vs=111528=111727#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36777

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/SemaObjC/unguarded-availability.m


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,10 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  // for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+  // to any useful diagnostics.
+  bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); 
}
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), 
PRE->getReceiverLocation());
Index: cfe/trunk/test/SemaObjC/unguarded-availability.m
===
--- cfe/trunk/test/SemaObjC/unguarded-availability.m
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,27 @@
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // 
expected-note 3 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // 
expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in 
enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  switch (a) {
+  case AK_Dodo...AK_CyborgCat: // expected-warning {{'AK_Dodo' is depr}}
+break;
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on 
macOS 10.12 or newer}} expected-note {{@available}}
+}


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,10 @@
 
   bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
 
+  // for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+  // to any useful diagnostics.
+  bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); }
+
   bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
 if (PRE->isClassReceiver())
   DiagnoseDeclAvailability(PRE->getClassReceiver(), PRE->getReceiverLocation());
Index: cfe/trunk/test/SemaObjC/unguarded-availability.m
===
--- cfe/trunk/test/SemaObjC/unguarded-availability.m
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,27 @@
 @interface BaseClass (CategoryWithNewProtocolRequirement) 
 
 @end
+
+typedef enum {
+  AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // expected-note 3 {{marked deprecated here}}
+  AK_Cat __attribute__((availability(macos, introduced=10.4))),
+  AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+  switch (a) {
+  case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+  case AK_Cat: break;
+  case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in enum}}
+  case AK_CyborgCat: break; // no warn
+  }
+
+  switch (a) {
+  case AK_Dodo...AK_CyborgCat: // expected-warning {{'AK_Dodo' is depr}}
+break;
+  }
+
+  (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+  (void)AK_Cat; // no warning
+  (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on macOS 10.12 or newer}} expected-note {{@available}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36503: [libcxx] [test] Update for C++17 feature removals.

2017-08-18 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Ping?


https://reviews.llvm.org/D36503



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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-18 Thread Blitz Rakete via Phabricator via cfe-commits
Rakete updated this revision to Diff 111719.
Rakete marked 3 inline comments as done.
Rakete added a comment.

Yes please.


https://reviews.llvm.org/D36855

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -803,7 +802,7 @@
 
   const-qualified pointers to members
   http://wg21.link/p0704r1;>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]
Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void (X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5175,9 +5175,16 @@
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4088,6 +4088,13 @@
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : Extension<
+  "invoking a pointer to a 'const &' member function on an rvalue is a C++2a extension">,
+  InGroup;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "invoking a pointer to a 'const &' member function on an rvalue is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore, SFINAEFailure;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -169,6 +169,11 @@
 def CXXPre1zCompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
[CXXPre1zCompat]>;
 
+// Warnings for C++2a code which is not compatible with prior C++ standards.
+def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
+def CXXPre2aCompatPedantic :
+  DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic", [CXXPre2aCompat]>;
+
 def CXX98CompatBindToTemporaryCopy :
   DiagGroup<"c++98-compat-bind-to-temporary-copy">;
 def CXX98CompatLocalTypeTemplateArgs :
@@ -180,7 +185,8 @@
 [CXX98CompatLocalTypeTemplateArgs,
  CXX98CompatUnnamedTypeTemplateArgs,
  CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : 

[PATCH] D36839: [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-18 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311186: [SanitizerCoverage] Add stack depth tracing 
instrumentation. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D36839?vs=111570=111718#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36839

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Driver/fsanitize-coverage.c
  
compiler-rt/trunk/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cc
  llvm/trunk/include/llvm/Transforms/Instrumentation.h
  llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
  llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
  llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth.ll

Index: llvm/trunk/include/llvm/Transforms/Instrumentation.h
===
--- llvm/trunk/include/llvm/Transforms/Instrumentation.h
+++ llvm/trunk/include/llvm/Transforms/Instrumentation.h
@@ -185,6 +185,7 @@
   bool Inline8bitCounters = false;
   bool PCTable = false;
   bool NoPrune = false;
+  bool StackDepth = false;
 
   SanitizerCoverageOptions() = default;
 };
Index: llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth.ll
===
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth.ll
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth.ll
@@ -0,0 +1,50 @@
+; This check verifies that stack depth instrumentation works correctly.
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 \
+; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s --enable-var-scope
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 \
+; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \
+; RUN: -S | FileCheck %s --enable-var-scope
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: @__sancov_lowest_stack = thread_local global i64 -1
+@__sancov_lowest_stack = thread_local global i64 0, align 8
+
+define i32 @foo() {
+entry:
+; CHECK-LABEL: define i32 @foo
+; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
+; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[$intType:i[0-9]+]]
+; CHECK: [[lowestPtr:%[^ \t]+]] = call [[$intType]]* @_ZTW21__sancov_lowest_stack
+; CHECK: [[lowestInt:%[^ \t]+]] = load [[$intType]], [[$intType]]* [[lowestPtr]]
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowestInt]]
+; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
+; CHECK: :[[ifLabel]]:
+; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* [[lowestPtr]]
+; CHECK: ret i32 7
+
+  ret i32 7
+}
+
+define i32 @bar() {
+entry:
+; CHECK-LABEL: define i32 @bar
+; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
+; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[$intType]]
+; CHECK: [[lowestPtr:%[^ \t]+]] = call [[$intType]]* @_ZTW21__sancov_lowest_stack
+; CHECK: [[lowestInt:%[^ \t]+]] = load [[$intType]], [[$intType]]* [[lowestPtr]]
+; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[$intType]] [[frameInt]], [[lowestInt]]
+; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
+; CHECK: :[[ifLabel]]:
+; CHECK: store [[$intType]] [[frameInt]], [[$intType]]* [[lowestPtr]]
+; CHECK: %call = call i32 @foo()
+; CHECK: ret i32 %call
+
+  %call = call i32 @foo()
+  ret i32 %call
+}
+
+define weak_odr hidden i64* @_ZTW21__sancov_lowest_stack() {
+  ret i64* @__sancov_lowest_stack
+}
Index: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -17,12 +17,15 @@
 #include "llvm/Analysis/PostDominators.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/CallSite.h"
+#include "llvm/IR/Constant.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
@@ -73,6 +76,10 @@
 static const char *const SanCovCountersSectionName = "sancov_cntrs";
 static const char *const SanCovPCsSectionName = "sancov_pcs";
 
+static const char *const SanCovLowestStackName = "__sancov_lowest_stack";
+static const char *const SanCovLowestStackTLSWrapperName =
+"_ZTW21__sancov_lowest_stack";
+
 static cl::opt ClCoverageLevel(
 "sanitizer-coverage-level",
 cl::desc("Sanitizer Coverage. 0: none, 

r311186 - [SanitizerCoverage] Add stack depth tracing instrumentation.

2017-08-18 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Fri Aug 18 11:43:30 2017
New Revision: 311186

URL: http://llvm.org/viewvc/llvm-project?rev=311186=rev
Log:
[SanitizerCoverage] Add stack depth tracing instrumentation.

Summary:
Augment SanitizerCoverage to insert maximum stack depth tracing for
use by libFuzzer.  The new instrumentation is enabled by the flag
-fsanitize-coverage=stack-depth and is compatible with the existing
trace-pc-guard coverage.  The user must also declare the following
global variable in their code:
  thread_local uintptr_t __sancov_lowest_stack

https://bugs.llvm.org/show_bug.cgi?id=33857

Reviewers: vitalybuka, kcc

Reviewed By: vitalybuka

Subscribers: kubamracek, hiraditya, cfe-commits, llvm-commits

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

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=311186=311185=311186=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Aug 18 11:43:30 2017
@@ -307,6 +307,9 @@ def fsanitize_coverage_trace_pc_guard
 def fsanitize_coverage_no_prune
 : Flag<["-"], "fsanitize-coverage-no-prune">,
   HelpText<"Disable coverage pruning (i.e. instrument all blocks/edges)">;
+def fsanitize_coverage_stack_depth
+: Flag<["-"], "fsanitize-coverage-stack-depth">,
+  HelpText<"Enable max stack depth tracing">;
 def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">,
 HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, "
  "or none">, Values<"none,clang,llvm">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=311186=311185=311186=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Aug 18 11:43:30 2017
@@ -169,6 +169,7 @@ CODEGENOPT(SanitizeCoverageTracePCGuard,
 CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit 
counters.
 CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table.
 CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
+CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth 
tracing
 CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
 CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.
 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=311186=311185=311186=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Aug 18 11:43:30 2017
@@ -190,6 +190,7 @@ static void addSanitizerCoveragePass(con
   Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
+  Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=311186=311185=311186=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Aug 18 11:43:30 2017
@@ -58,6 +58,7 @@ enum CoverageFeature {
   CoverageNoPrune = 1 << 11,
   CoverageInline8bitCounters = 1 << 12,
   CoveragePCTable = 1 << 13,
+  CoverageStackDepth = 1 << 14,
 };
 
 /// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
@@ -556,10 +557,14 @@ SanitizerArgs::SanitizerArgs(const ToolC
   }
 
   // trace-pc w/o func/bb/edge implies edge.
-  if ((CoverageFeatures &
-   (CoverageTracePC | CoverageTracePCGuard | CoverageInline8bitCounters)) 
&&
-  !(CoverageFeatures & InsertionPointTypes))
-CoverageFeatures |= CoverageEdge;
+  if (!(CoverageFeatures & InsertionPointTypes)) {
+if (CoverageFeatures &
+(CoverageTracePC | CoverageTracePCGuard | CoverageInline8bitCounters))
+  CoverageFeatures |= CoverageEdge;
+
+if (CoverageFeatures & CoverageStackDepth)
+  CoverageFeatures |= CoverageFunc;
+  }
 
   if (AllAddedKinds & Address) {
 

[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.

2017-08-18 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 111716.
vsapsai added a comment.

Address review comments.

Moved `CorrectDelayedTyposInExpr` according to review comment and added
mentioned test case.

Removed the assertion as it didn't catch the expression

  ParenListExpr 0x7f8297060e40 'NULL TYPE'
  `-TypoExpr 0x7f8297060e30 '' lvalue

Didn't remove `CorrectDelayedTyposInExpr` for the case when we disambiguate
between lambda and Obj-C message send because we use corrected expression in
annotation token. Checked that correcting typos the second time returns the
same expression because there are no typos anymore.


https://reviews.llvm.org/D36853

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp


Index: clang/test/SemaCXX/cxx1y-init-captures.cpp
===
--- clang/test/SemaCXX/cxx1y-init-captures.cpp
+++ clang/test/SemaCXX/cxx1y-init-captures.cpp
@@ -206,3 +206,11 @@
   find(weight); // expected-note {{in instantiation of function template 
specialization}}
 }
 }
+
+namespace init_capture_undeclared_identifier {
+  auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}}
+
+  int typo_foo; // expected-note 2 {{'typo_foo' declared here}}
+  auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 
'typo_boo'; did you mean 'typo_foo'}}
+  auto c = [x(typo_boo)]{}; // expected-error{{use of undeclared identifier 
'typo_boo'; did you mean 'typo_foo'}}
+}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -966,6 +966,8 @@
 // that would be an error.
 
 ParsedType InitCaptureType;
+if (!Init.isInvalid())
+  Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 if (Init.isUsable()) {
   // Get the pointer and store it in an lvalue, so we can use it as an
   // out argument.


Index: clang/test/SemaCXX/cxx1y-init-captures.cpp
===
--- clang/test/SemaCXX/cxx1y-init-captures.cpp
+++ clang/test/SemaCXX/cxx1y-init-captures.cpp
@@ -206,3 +206,11 @@
   find(weight); // expected-note {{in instantiation of function template specialization}}
 }
 }
+
+namespace init_capture_undeclared_identifier {
+  auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}}
+
+  int typo_foo; // expected-note 2 {{'typo_foo' declared here}}
+  auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}}
+  auto c = [x(typo_boo)]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}}
+}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -966,6 +966,8 @@
 // that would be an error.
 
 ParsedType InitCaptureType;
+if (!Init.isInvalid())
+  Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 if (Init.isUsable()) {
   // Get the pointer and store it in an lvalue, so we can use it as an
   // out argument.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36882: [clang-proto-fuzzer] Allow user-specified compiler arguments.

2017-08-18 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311185: [clang-proto-fuzzer] Allow user-specified compiler 
arguments. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D36882?vs=111713=111715#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36882

Files:
  cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp


Index: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,25 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include 
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  break;
+}
+  }
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }


Index: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,25 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include 
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  break;
+}
+  }
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311185 - [clang-proto-fuzzer] Allow user-specified compiler arguments.

2017-08-18 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Fri Aug 18 11:34:39 2017
New Revision: 311185

URL: http://llvm.org/viewvc/llvm-project?rev=311185=rev
Log:
[clang-proto-fuzzer] Allow user-specified compiler arguments.

Summary:
Arguments can be specified after -ignore_remaining_args=1 to modify
the compiler invocation.  For example, the following command-line
will fuzz LLVM with a custom optimization level and target triple:
  clang-proto-fuzzer CORPUS/ -ignore_remaining_args -O3 \
  -triple arm64-apple-ios9

Reviewers: vitalybuka, kcc

Reviewed By: vitalybuka

Subscribers: aemerson, cfe-commits, kristof.beyls

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

Modified:
cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp?rev=311185=311184=311185=diff
==
--- cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp Fri Aug 18 
11:34:39 2017
@@ -20,9 +20,25 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include 
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  break;
+}
+  }
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }


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


[PATCH] D36882: [clang-proto-fuzzer] Allow user-specified compiler arguments.

2017-08-18 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 111713.
morehouse added a comment.

- Refactor and use strcmp.


https://reviews.llvm.org/D36882

Files:
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp


Index: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,25 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include 
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  break;
+}
+  }
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }


Index: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,25 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include 
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  break;
+}
+  }
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36851: [analyzer] Fix modeling of ctors

2017-08-18 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311182: [analyzer] Fix modeling of constructors (authored by 
alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D36851?vs=111622=111711#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36851

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
  cfe/trunk/test/Analysis/ctor.mm


Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -409,6 +409,19 @@
 
   // BindDefault is only used to initialize a region with a default value.
   StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer them from offsets/alignments
+// seems to be error-prone and non-trivial because of the trailing padding.
+// As a temporary mitigation we don't create bindings for empty bases.
+if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
+cast(R)->getDecl()->isEmpty())
+  return StoreRef(store, *this);
+
 RegionBindingsRef B = getRegionBindings(store);
 assert(!B.lookup(R, BindingKey::Direct));
 
Index: cfe/trunk/test/Analysis/ctor.mm
===
--- cfe/trunk/test/Analysis/ctor.mm
+++ cfe/trunk/test/Analysis/ctor.mm
@@ -704,3 +704,20 @@
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}


Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -409,6 +409,19 @@
 
   // BindDefault is only used to initialize a region with a default value.
   StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer them from offsets/alignments
+// seems to be error-prone and non-trivial because of the trailing padding.
+// As a temporary mitigation we don't create bindings for empty bases.
+if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
+cast(R)->getDecl()->isEmpty())
+  return StoreRef(store, *this);
+
 RegionBindingsRef B = getRegionBindings(store);
 assert(!B.lookup(R, BindingKey::Direct));
 
Index: cfe/trunk/test/Analysis/ctor.mm
===
--- cfe/trunk/test/Analysis/ctor.mm
+++ cfe/trunk/test/Analysis/ctor.mm
@@ -704,3 +704,20 @@
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311182 - [analyzer] Fix modeling of constructors

2017-08-18 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Fri Aug 18 11:20:43 2017
New Revision: 311182

URL: http://llvm.org/viewvc/llvm-project?rev=311182=rev
Log:
[analyzer] Fix modeling of constructors

This diff fixes analyzer's crash (triggered assert) on the newly added test 
case.
The assert being discussed is assert(!B.lookup(R, BindingKey::Direct))
in lib/StaticAnalyzer/Core/RegionStore.cpp, however the root cause is different.
For classes with empty bases the offsets might be tricky.
For example, let's assume we have
 struct S: NonEmptyBase, EmptyBase {
 ...
 };
In this case Clang applies empty base class optimization and 
the offset of EmptyBase will be 0, it can be verified via
clang -cc1 -x c++ -v -fdump-record-layouts main.cpp -emit-llvm -o /dev/null.
When the analyzer tries to perform zero initialization of EmptyBase
it will hit the assert because that region
has already been "written" by the constructor of NonEmptyBase.

Test plan:
make check-all

Differential revision: https://reviews.llvm.org/D36851

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/ctor.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=311182=311181=311182=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Aug 18 11:20:43 2017
@@ -409,6 +409,19 @@ public: // Part of public interface to c
 
   // BindDefault is only used to initialize a region with a default value.
   StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer them from offsets/alignments
+// seems to be error-prone and non-trivial because of the trailing padding.
+// As a temporary mitigation we don't create bindings for empty bases.
+if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
+cast(R)->getDecl()->isEmpty())
+  return StoreRef(store, *this);
+
 RegionBindingsRef B = getRegionBindings(store);
 assert(!B.lookup(R, BindingKey::Direct));
 

Modified: cfe/trunk/test/Analysis/ctor.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor.mm?rev=311182=311181=311182=diff
==
--- cfe/trunk/test/Analysis/ctor.mm (original)
+++ cfe/trunk/test/Analysis/ctor.mm Fri Aug 18 11:20:43 2017
@@ -704,3 +704,20 @@ namespace PR19579 {
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}


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


[PATCH] D36882: [clang-proto-fuzzer] Allow user-specified compiler arguments.

2017-08-18 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:33
+  for (I = 1; I < *argc; I++)
+if (llvm::StringRef((*argv)[I]).equals("-ignore_remaining_args=1"))
+  break;

maybe just strcmp



Comment at: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:35
+  break;
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);

you can put second loop inside of the if just before the break and avoid top 
level var "I"


https://reviews.llvm.org/D36882



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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, will you need someone to commit this for you?




Comment at: include/clang/Basic/DiagnosticGroups.td:794
+// earlier C++ versions.
+def CXX20 : DiagGroup<"c++20-extensions">;
+

We've historically avoided using precise year numbers until a standard is 
finalized. I would call this `CXX2a` for now, and only provide the 
`c++2a-extensions` spelling, just in case the next standard ships a year late 
(or early).



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4095-4096
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "pointer-to-member function for const& member function on rvalues is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;

Please also update this to match the prior diagnostic's text.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4097
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_ms_deref_template_argument: ExtWarn<

This should now be in a `CXXPre2aCompatPedantic` group, because the 
corresponding extension is a pedantic warning.


https://reviews.llvm.org/D36855



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


[PATCH] D34992: Emit static constexpr member as available_externally definition

2017-08-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I'd like to also see a testcase for the situation where we trigger the emission 
of a declaration with an `available_externally` definition and then find we 
need to promote it to a "full" definition:

  struct A {
static const int Foo = 123;
  };
  int *p = ::Foo; // emit available_externally
  const int A::Foo; // convert to full definition




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2448-2451
+if (InitExpr) {
+  GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
+  GV->setInitializer(EmitConstantInit(*InitDecl));
+}

mehdi_amini wrote:
> rsmith wrote:
> > In order for this transformation to be correct, you need to know that the 
> > variable has static initialization, which means that it needs to formally 
> > have a constant initializer. You can use `D->isInitKnownICE()` to check 
> > this.
> Done! But couldn't find how to express it as a test-case though.
You'd need to use an initializer that we can constant-fold, such as:

```
struct A {
  static const int n;
};
bool check() {
  assert(A::n == 0 && "already initialized!");
  return true;
}
const int A::n = (check() || true) ? 1 : 2;
```



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2445
+!D->hasDefinition() && D->hasInit() &&
+/* C++17 static constexpr are inlined */ !D->isInline() &&
+!D->hasAttr() && D->isInitKnownICE()) {

Do we need to special-case this? Such declarations are definitions.


https://reviews.llvm.org/D34992



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


[PATCH] D36882: [clang-proto-fuzzer] Allow user-specified compiler arguments.

2017-08-18 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse created this revision.
Herald added subscribers: kristof.beyls, aemerson.

Arguments can be specified after -ignore_remaining_args=1 to modify
the compiler invocation.  For example, the following command-line
will fuzz LLVM with a custom optimization level and target triple:

  clang-proto-fuzzer CORPUS/ -ignore_remaining_args -O3 \
  -triple arm64-apple-ios9


https://reviews.llvm.org/D36882

Files:
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp


Index: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,24 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include "llvm/ADT/StringRef.h"
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  int I;
+  for (I = 1; I < *argc; I++)
+if (llvm::StringRef((*argv)[I]).equals("-ignore_remaining_args=1"))
+  break;
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }


Index: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
===
--- clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
+++ clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
@@ -20,9 +20,24 @@
 
 #include "src/libfuzzer/libfuzzer_macro.h"
 
+#include "llvm/ADT/StringRef.h"
+
 using namespace clang_fuzzer;
 
+static std::vector CLArgs;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  CLArgs.push_back("-O2");
+  int I;
+  for (I = 1; I < *argc; I++)
+if (llvm::StringRef((*argv)[I]).equals("-ignore_remaining_args=1"))
+  break;
+  for (I++; I < *argc; I++)
+CLArgs.push_back((*argv)[I]);
+  return 0;
+}
+
 DEFINE_BINARY_PROTO_FUZZER(const Function& input) {
   auto S = FunctionToString(input);
-  HandleCXX(S, {"-O2"});
+  HandleCXX(S, CLArgs);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36876: [IRGen] Evaluate constant static variables referenced through member expressions

2017-08-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprComplex.cpp:156
+auto Constant = tryEmitDeclRefOrMemberExprAsConstant(
+ME, ME->getMemberDecl(), /*AllowSideEffects=*/true);
+if (Constant) {

If we can (correctly) allow side-effects in the initializer here, why can we 
not also do so when emitting a `DeclRefExpr`?



Comment at: lib/CodeGen/CGExprScalar.cpp:1314-1321
+  } else {
+// Fields can evaluate to constants if their base can be evaluated.
+llvm::APSInt Value;
+if (E->EvaluateAsInt(Value, CGF.getContext(), Expr::SE_AllowSideEffects))
+  V = Builder.getInt(Value);
+else
+  V = nullptr;

Can we remove this and just use `tryEmit...` unconditionally?


Repository:
  rL LLVM

https://reviews.llvm.org/D36876



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


r311178 - AMDGPU: Rename r600-mcpu.cl->amdgpu-mcpu.cl

2017-08-18 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Fri Aug 18 10:29:07 2017
New Revision: 311178

URL: http://llvm.org/viewvc/llvm-project?rev=311178=rev
Log:
AMDGPU: Rename r600-mcpu.cl->amdgpu-mcpu.cl

Added:
cfe/trunk/test/Driver/amdgpu-mcpu.cl
Removed:
cfe/trunk/test/Driver/r600-mcpu.cl

Added: cfe/trunk/test/Driver/amdgpu-mcpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-mcpu.cl?rev=311178=auto
==
--- cfe/trunk/test/Driver/amdgpu-mcpu.cl (added)
+++ cfe/trunk/test/Driver/amdgpu-mcpu.cl Fri Aug 18 10:29:07 2017
@@ -0,0 +1,112 @@
+t// Check that -mcpu works for all supported GPUs
+
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=r600 %s -o - 2>&1 | 
FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv630 %s -o - 2>&1 
| FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv635 %s -o - 2>&1 
| FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv610 %s -o - 2>&1 
| FileCheck --check-prefix=RS880-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv620 %s -o - 2>&1 
| FileCheck --check-prefix=RS880-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rs780 %s -o - 2>&1 
| FileCheck --check-prefix=RS880-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rs880 %s -o - 2>&1 
| FileCheck --check-prefix=RS880-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv670 %s -o - 2>&1 
| FileCheck --check-prefix=RV670-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv710 %s -o - 2>&1 
| FileCheck --check-prefix=RV710-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv730 %s -o - 2>&1 
| FileCheck --check-prefix=RV730-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv740 %s -o - 2>&1 
| FileCheck --check-prefix=RV770-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv770 %s -o - 2>&1 
| FileCheck --check-prefix=RV770-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=palm %s -o - 2>&1 | 
FileCheck --check-prefix=CEDAR-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cedar %s -o - 2>&1 
| FileCheck --check-prefix=CEDAR-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=sumo %s -o - 2>&1 | 
FileCheck --check-prefix=SUMO-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=sumo2 %s -o - 2>&1 
| FileCheck --check-prefix=SUMO-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=redwood %s -o - 
2>&1 | FileCheck --check-prefix=REDWOOD-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=juniper %s -o - 
2>&1 | FileCheck --check-prefix=JUNIPER-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=juniper %s -o - 
2>&1 | FileCheck --check-prefix=JUNIPER-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=hemlock %s -o - 
2>&1 | FileCheck --check-prefix=CYPRESS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cypress %s -o - 
2>&1 | FileCheck --check-prefix=CYPRESS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=barts %s -o - 2>&1 
| FileCheck --check-prefix=BARTS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=turks %s -o - 2>&1 
| FileCheck --check-prefix=TURKS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=caicos %s -o - 2>&1 
| FileCheck --check-prefix=CAICOS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cayman %s -o - 2>&1 
| FileCheck --check-prefix=CAYMAN-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=aruba %s -o - 2>&1 
| FileCheck --check-prefix=CAYMAN-CHECK %s
+
+// R600-CHECK:  "-target-cpu" "r600"
+// RS880-CHECK: "-target-cpu" "rs880"
+// RV670-CHECK: "-target-cpu" "rv670"
+// RV710-CHECK: "-target-cpu" "rv710"
+// RV730-CHECK: "-target-cpu" "rv730"
+// RV770-CHECK: "-target-cpu" "rv770"
+// CEDAR-CHECK: "-target-cpu" "cedar"
+// REDWOOD-CHECK: "-target-cpu" "redwood"
+// SUMO-CHECK: "-target-cpu" "sumo"
+// JUNIPER-CHECK: "-target-cpu" "juniper"
+// CYPRESS-CHECK: "-target-cpu" "cypress"
+// BARTS-CHECK: "-target-cpu" "barts"
+// TURKS-CHECK: "-target-cpu" "turks"
+// CAICOS-CHECK: "-target-cpu" "caicos"
+// CAYMAN-CHECK: "-target-cpu" "cayman"
+
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx600 %s -o - 
2>&1 | FileCheck --check-prefix=GFX600-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=tahiti %s -o - 
2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx601 %s -o - 
2>&1 | FileCheck --check-prefix=GFX601-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 
2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
+// RUN: %clang -### 

[PATCH] D36187: [clang-diff] Use the relative name for NamedDecls

2017-08-18 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added inline comments.



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:371
+  std::string ContextPrefix;
+  if (auto *Namespace = dyn_cast(Context))
+ContextPrefix = Namespace->getQualifiedNameAsString();

arphaman wrote:
> You don't need to check both `NamespaceDecl` and `TagDecl`, since you can 
> just do one if with a `NamedDecl`.
FunctionDecl should not be used for example


https://reviews.llvm.org/D36187



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-18 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: include/clang/Basic/DiagnosticOr.h:40
+  /// diagnostic.
+  DiagnosticOr(PartialDiagnosticAt Diagnostic) : HasDiagnostic(true) {
+new (getDiagnosticStorage()) PartialDiagnosticAt(std::move(Diagnostic));

explicit ?



Comment at: include/clang/Basic/DiagnosticOr.h:49
+  OtherT &,
+  typename std::enable_if::value>::type * =
+  nullptr)

 but probably it would be a bit cleaner to enable SFINAE via a template 
parameter (http://en.cppreference.com/w/cpp/types/enable_if , option #4) rather 
than via extra argument.



Comment at: include/clang/Tooling/Refactoring/RefactoringResult.h:27
+
+  RefactoringResult(AtomicChange Change) : Kind(AtomicChanges) {
+Changes.push_back(std::move(Change));

explicit ?


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D36187: [clang-diff] Use the relative name for NamedDecls

2017-08-18 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 111695.
johannes added a comment.

only use Enums as namespace prefix in C++11


https://reviews.llvm.org/D36187

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-ast.cpp
  test/Tooling/clang-diff-basic.cpp
  test/Tooling/clang-diff-html.test
  test/Tooling/clang-diff-topdown.cpp

Index: test/Tooling/clang-diff-topdown.cpp
===
--- test/Tooling/clang-diff-topdown.cpp
+++ test/Tooling/clang-diff-topdown.cpp
@@ -27,8 +27,19 @@
   {{;;}}
 }
 
+int x;
+
+namespace src {
+  int x;
+  int x1 = x + 1;
+  int x2 = ::x + 1;
+}
+
+class A { int x = 1 + 1; void f() { int x1 = x; } };
+
 #else
 
+
 void f1() {
 
   {{;}}
@@ -45,4 +56,28 @@
   ;
 }
 
+int x;
+
+namespace dst {
+  int x;
+  // CHECK: Match DeclRefExpr: :x(17) to DeclRefExpr: :x(22)
+  int x1 = x + 1;
+  // CHECK: Match DeclRefExpr: x(21) to DeclRefExpr: x(26)
+  int x2 = ::x + 1;
+}
+
+class B {
+  // Only the class name changed; it is not included in the field value,
+  // therefore there is no update.
+  // CHECK: Match FieldDecl: :x(int)(24) to FieldDecl: :x(int)(29)
+  // CHECK-NOT: Update FieldDecl: :x(int)(24)
+  int x = 1+1;
+  void f() {
+// CHECK: Match MemberExpr: :x(32) to MemberExpr: :x(37)
+// CHECK-NOT: Update MemberExpr: :x(32)
+int x1 = B::x;
+  }
+
+};
+
 #endif
Index: test/Tooling/clang-diff-html.test
===
--- test/Tooling/clang-diff-html.test
+++ test/Tooling/clang-diff-html.test
@@ -11,12 +11,12 @@
 // match, move
 // CHECK: void foo()
+// CHECK-NEXT: :foo(void ())' class='m'>void foo()
 
 // match
 // CHECK: void main()
+// CHECK-NEXT: :main(void ())'>void main()
 
 // deletion
 // CHECK: (Context))
+ContextPrefix = Namespace->getQualifiedNameAsString();
+  else if (auto *Record = dyn_cast(Context))
+ContextPrefix = Record->getQualifiedNameAsString();
+  else if (AST.getLangOpts().CPlusPlus11)
+if (auto *Tag = dyn_cast(Context))
+  ContextPrefix = Tag->getQualifiedNameAsString();
+  std::string Val = ND->getQualifiedNameAsString();
+  // Strip the qualifier, if Val refers to somthing in the current scope.
+  // But leave one leading ':' in place, so that we know that this is a
+  // relative path.
+  if (!ContextPrefix.empty() && StringRef(Val).startswith(ContextPrefix))
+Val = Val.substr(ContextPrefix.size() + 1);
+  return Val;
+}
+
+std::string SyntaxTree::Impl::getRelativeName(const NamedDecl *ND) const {
+  return getRelativeName(ND, ND->getDeclContext());
+}
+
+static const DeclContext *getEnclosingDeclContext(ASTContext ,
+  const Stmt *S) {
+  while (S) {
+const auto  = AST.getParents(*S);
+if (Parents.empty())
+  return nullptr;
+const auto  = Parents[0];
+if (const auto *D = P.get())
+  return D->getDeclContext();
+S = P.get();
+  }
+  llvm_unreachable("Could not find Decl ancestor.");
+}
+
 std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const {
   return getNodeValue(getNode(Id));
 }
@@ -384,8 +426,7 @@
   TypePP.AnonymousTagLocations = false;
 
   if (auto *V = dyn_cast(D)) {
-Value += V->getQualifiedNameAsString() + "(" +
- V->getType().getAsString(TypePP) + ")";
+Value += getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")";
 if (auto *C = dyn_cast(D)) {
   for (auto *Init : C->inits()) {
 if (!Init->isWritten())
@@ -397,15 +438,15 @@
   Value += C->getNameAsString();
 } else {
   assert(Init->isAnyMemberInitializer());
-  Value += Init->getMember()->getQualifiedNameAsString();
+  Value += getRelativeName(Init->getMember());
 }
 Value += ",";
   }
 }
 return Value;
   }
   if (auto *N = dyn_cast(D))
-Value += N->getQualifiedNameAsString() + ";";
+Value += getRelativeName(N) + ";";
   if (auto *T = dyn_cast(D))
 return Value + T->getUnderlyingType().getAsString(TypePP) + ";";
   if (auto *T = dyn_cast(D))
@@ -429,7 +470,7 @@
   if (auto *B = dyn_cast(S))
 return B->getOpcodeStr();
   if (auto *M = dyn_cast(S))
-return M->getMemberDecl()->getQualifiedNameAsString();
+return getRelativeName(M->getMemberDecl());
   if (auto *I = dyn_cast(S)) {
 SmallString<256> Str;
 I->getValue().toString(Str, /*Radix=*/10, /*Signed=*/false);
@@ -441,7 +482,7 @@
 return Str.str();
   }
   if (auto *D = dyn_cast(S))
-return D->getDecl()->getQualifiedNameAsString();
+return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
   if (auto *String = dyn_cast(S))
 return String->getString();
   if (auto *B = dyn_cast(S))
@@ -950,7 +991,7 @@
   return DiffImpl->getMapped(SourceTree.TreeImpl, Id);
 }
 
-SyntaxTree::SyntaxTree(const ASTContext )
+SyntaxTree::SyntaxTree(ASTContext )
 : TreeImpl(llvm::make_unique(
   this, 

[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-18 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

This is great work and definitely a lot to digest! ;) Some high-level comments 
for the first round.

In general, I really appreciate the high-level interfaces; I am just a bit 
concerned about the implementation which is a bit hard to follow at this point, 
especially with all the template magics. I left some suggestions in the 
comments; hopefully they would help.

I would also appreciate more detailed high-level comments on the major classes 
and their relationships - I found myself constantly going back to the RFC to 
understand their intentions.




Comment at: include/clang/Basic/DiagnosticOr.h:1
+//===--- DiagnosticOr.h - Diagnostic "closures" -*- C++ 
-*-===//
+//

Could you please split changes related to `DiagnosticOr` into a separate patch 
and have owners of clang/Basic/ directory review it? ;)



Comment at: include/clang/Tooling/Refactoring/RefactoringActionRules.h:1
+//===--- RefactoringActionRules.h - Clang refactoring library 
-===//
+//

Code in this file is a bit hard to follow, especially with so many classes and 
template magics :P 

Is it possible to split them into smaller modules, and ideally with more 
detailed documentation for each? 

It seems to me that the following logics could live in their own headers:
- `RefactoringActionRule` interface.
- Base classes for requirements.
- SourceSlection-related requirements.
- Derived/specialized rules.



Comment at: include/clang/Tooling/Refactoring/RefactoringActionRules.h:227
+std::unique_ptr
+apply(Expected (*RefactoringFunction)(
+  typename RequirementTypes::OutputType...),

Why is this called `apply`?  I feel something like `createAction` or 
`generateAction` would be more intuitive.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringOperationController.h:19
+
+/// Encapsulates all of the possible state that an individual refactoring
+/// operation might have. Controls the process of initiation of refactoring

What are all the possible states, for example?



Comment at: 
include/clang/Tooling/Refactoring/RefactoringOperationController.h:22
+/// operations, by feeding the right information to the functions that
+/// evaluate the refactoring action rule requirements.
+class RefactoringOperationController {

Maybe I am missing too much context, but I found it hard to understand the 
comment and couldn't relate the comment to the public interfaces. Could you 
elaborate more? 

It is also unclear to me if this is specific to the source selection.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringOperationController.h:40
+private:
+  const SourceManager 
+  SourceRange SelectionRange;

It's unclear to me what the intentions of these members are. Could you add some 
comments for these members? 



Comment at: include/clang/Tooling/Refactoring/RefactoringResult.h:35
+
+  llvm::MutableArrayRef getChanges() {
+assert(getKind() == AtomicChanges &&

Do we expect the result changes to be modified? Why?



Comment at: include/clang/Tooling/Refactoring/SourceSelectionConstraints.h:21
+/// This constraint is satisfied when any portion of the source text is
+/// selected. It can be used be used to obtain the raw source selection range.
+struct SourceSelectionRange {

nit: redundant `be used`.



Comment at: include/clang/Tooling/Refactoring/SourceSelectionConstraints.h:35
+/// A custom selection requirement.
+class Requirement {
+  /// Subclasses must implement 'T evaluateSelection(SelectionConstraint) 
const'

It might worth explaining the relationship between this and the 
`RequirementBase`. 


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D36176: [clang-diff] Fix some errors and inconsistencies

2017-08-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311172: [clang-diff] Fix some errors and inconsistencies 
(authored by krobelus).

Repository:
  rL LLVM

https://reviews.llvm.org/D36176

Files:
  cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
  cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp

Index: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
===
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
@@ -93,6 +93,7 @@
   template 
   SyntaxTree(T *Node, const ASTContext )
   : TreeImpl(llvm::make_unique(this, Node, AST)) {}
+  SyntaxTree(SyntaxTree &) = default;
   ~SyntaxTree();
 
   const Node (NodeId Id) const;
Index: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
===
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
@@ -11,8 +11,6 @@
 #ifndef LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
 #define LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
 
-#include 
-
 #include "clang/AST/ASTTypeTraits.h"
 
 namespace clang {
Index: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -27,6 +27,7 @@
 namespace clang {
 namespace diff {
 
+namespace {
 /// Maps nodes of the left tree to ones on the right, and vice versa.
 class Mapping {
 public:
@@ -76,6 +77,7 @@
 private:
   std::unique_ptr[]> SrcToDst, DstToSrc;
 };
+} // end anonymous namespace
 
 class ASTDiff::Impl {
 public:
@@ -110,10 +112,6 @@
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
-  // Adds all corresponding subtrees of the two nodes to the mapping.
-  // The two nodes must be identical.
-  void addIsomorphicSubTrees(Mapping , NodeId Id1, NodeId Id2) const;
-
   // Uses an optimal albeit slow algorithm to compute a mapping between two
   // subtrees, but only if both have fewer nodes than MaxSize.
   void addOptimalMapping(Mapping , NodeId Id1, NodeId Id2) const;
@@ -254,7 +252,10 @@
 Parent = PreviousParent;
 --Depth;
 Node  = Tree.getMutableNode(MyId);
-N.RightMostDescendant = Id;
+N.RightMostDescendant = Id - 1;
+assert(N.RightMostDescendant >= 0 &&
+   N.RightMostDescendant < Tree.getSize() &&
+   "Rightmost descendant must be a valid tree node.");
 if (N.isLeaf())
   Tree.Leaves.push_back(MyId);
 N.Height = 1;
@@ -358,9 +359,7 @@
 }
 
 bool SyntaxTree::Impl::isInSubtree(NodeId Id, NodeId SubtreeRoot) const {
-  NodeId Lower = SubtreeRoot;
-  NodeId Upper = getNode(SubtreeRoot).RightMostDescendant;
-  return Id >= Lower && Id <= Upper;
+  return Id >= SubtreeRoot && Id <= getNode(SubtreeRoot).RightMostDescendant;
 }
 
 std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const {
@@ -625,12 +624,11 @@
   }
 
 private:
-  /// Simple cost model for edit actions.
+  /// We use a simple cost model for edit actions, which seems good enough.
+  /// Simple cost model for edit actions. This seems to make the matching
+  /// algorithm perform reasonably well.
   /// The values range between 0 and 1, or infinity if this edit action should
   /// always be avoided.
-
-  /// These costs could be modified to better model the estimated cost of /
-  /// inserting / deleting the current node.
   static constexpr double DeletionCost = 1;
   static constexpr double InsertionCost = 1;
 
@@ -687,6 +685,7 @@
 };
 } // end anonymous namespace
 
+namespace {
 // Priority queue for nodes, sorted descendingly by their height.
 class PriorityList {
   const SyntaxTree::Impl 
@@ -723,6 +722,7 @@
   push(Child);
   }
 };
+} // end anonymous namespace
 
 bool ASTDiff::Impl::identical(NodeId Id1, NodeId Id2) const {
   const Node  = T1.getNode(Id1);
@@ -759,16 +759,6 @@
T2.getNode(Id2).ASTNode);
 }
 
-void ASTDiff::Impl::addIsomorphicSubTrees(Mapping , NodeId Id1,
-  NodeId Id2) const {
-  assert(identical(Id1, Id2) && "Can only be called on identical subtrees.");
-  M.link(Id1, Id2);
-  const Node  = T1.getNode(Id1);
-  const Node  = T2.getNode(Id2);
-  for (size_t Id = 0, E = N1.Children.size(); Id < E; ++Id)
-addIsomorphicSubTrees(M, N1.Children[Id], N2.Children[Id]);
-}
-
 void ASTDiff::Impl::addOptimalMapping(Mapping , NodeId Id1,
   NodeId Id2) const {
   if (std::max(T1.getNumberOfDescendants(Id1),
@@ -805,7 +795,7 @@
 if (M.hasDst(Id2))
   continue;
 double Similarity = getSimilarity(M, Id1, Id2);
-if (Similarity > HighestSimilarity) {
+if (Similarity >= 

[PATCH] D36177: [clang-diff] Add commandline arguments.

2017-08-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311173: [clang-diff] Add commandline arguments. (authored by 
krobelus).

Changed prior to commit:
  https://reviews.llvm.org/D36177?vs=109502=111690#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36177

Files:
  cfe/trunk/test/Tooling/clang-diff-args.test
  cfe/trunk/test/Tooling/clang-diff-basic.cpp
  cfe/trunk/tools/clang-diff/ClangDiff.cpp

Index: cfe/trunk/tools/clang-diff/ClangDiff.cpp
===
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp
@@ -28,12 +28,6 @@
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
-static cl::opt NoCompilationDatabase(
-"no-compilation-database",
-cl::desc(
-"Do not attempt to load build settings from a compilation database"),
-cl::init(false), cl::cat(ClangDiffCategory));
-
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -43,43 +37,83 @@
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static std::unique_ptr getAST(const StringRef Filename) {
+static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
+cl::init(-1), cl::cat(ClangDiffCategory));
+
+static cl::opt BuildPath("p", cl::desc("Build path"), cl::init(""),
+  cl::Optional, cl::cat(ClangDiffCategory));
+
+static cl::list ArgsAfter(
+"extra-arg",
+cl::desc("Additional argument to append to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static cl::list ArgsBefore(
+"extra-arg-before",
+cl::desc("Additional argument to prepend to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static void addExtraArgs(std::unique_ptr ) {
+  if (!Compilations)
+return;
+  auto AdjustingCompilations =
+  llvm::make_unique(
+  std::move(Compilations));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsBefore, ArgumentInsertPosition::BEGIN));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsAfter, ArgumentInsertPosition::END));
+  Compilations = std::move(AdjustingCompilations);
+}
+
+static std::unique_ptr
+getAST(const std::unique_ptr ,
+   const StringRef Filename) {
   std::string ErrorMessage;
   std::unique_ptr Compilations;
-  if (!NoCompilationDatabase)
-Compilations =
-CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
-  if (!Compilations) {
-if (!NoCompilationDatabase)
+  if (!CommonCompilations) {
+Compilations = CompilationDatabase::autoDetectFromSource(
+BuildPath.empty() ? Filename : BuildPath, ErrorMessage);
+if (!Compilations) {
   llvm::errs()
   << "Error while trying to load a compilation database, running "
  "without flags.\n"
   << ErrorMessage;
-Compilations = llvm::make_unique(
-".", std::vector());
+  Compilations =
+  llvm::make_unique(
+  ".", std::vector());
+}
   }
+  addExtraArgs(Compilations);
   std::array Files = {{Filename}};
-  ClangTool Tool(*Compilations, Files);
+  ClangTool Tool(Compilations ? *Compilations : *CommonCompilations, Files);
   std::vector ASTs;
   Tool.buildASTs(ASTs);
   if (ASTs.size() != Files.size())
 return nullptr;
   return std::move(ASTs[0]);
 }
 
 int main(int argc, const char **argv) {
+  std::string ErrorMessage;
+  std::unique_ptr CommonCompilations =
+  FixedCompilationDatabase::loadFromCommandLine(argc, argv, ErrorMessage);
+  if (!CommonCompilations && !ErrorMessage.empty())
+llvm::errs() << ErrorMessage;
   cl::HideUnrelatedOptions(ClangDiffCategory);
   if (!cl::ParseCommandLineOptions(argc, argv)) {
 cl::PrintOptionValues();
 return 1;
   }
 
+  addExtraArgs(CommonCompilations);
+
   if (ASTDump) {
 if (!DestinationPath.empty()) {
   llvm::errs() << "Error: Please specify exactly one filename.\n";
   return 1;
 }
-std::unique_ptr AST = getAST(SourcePath);
+std::unique_ptr AST = getAST(CommonCompilations, SourcePath);
 if (!AST)
   return 1;
 diff::SyntaxTree Tree(AST->getASTContext());
@@ -92,12 +126,14 @@
 return 1;
   }
 
-  std::unique_ptr Src = getAST(SourcePath);
-  std::unique_ptr Dst = getAST(DestinationPath);
+  std::unique_ptr Src = getAST(CommonCompilations, SourcePath);
+  std::unique_ptr Dst = getAST(CommonCompilations, DestinationPath);
   if (!Src || !Dst)
 return 1;
 
   diff::ComparisonOptions Options;
+  if (MaxSize != -1)
+Options.MaxSize = MaxSize;
   diff::SyntaxTree SrcTree(Src->getASTContext());
  

r311173 - [clang-diff] Add commandline arguments.

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 09:34:22 2017
New Revision: 311173

URL: http://llvm.org/viewvc/llvm-project?rev=311173=rev
Log:
[clang-diff] Add commandline arguments.

Summary:
Support command line options for build path and extra arguments
This emulates the options accepted by clang tools that use CommonOptionsParser.

Add a flag for controlling the maximum size parameter for bottom up matching.

Reviewers: arphaman

Subscribers: klimek

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

Added:
cfe/trunk/test/Tooling/clang-diff-args.test
Modified:
cfe/trunk/test/Tooling/clang-diff-basic.cpp
cfe/trunk/tools/clang-diff/ClangDiff.cpp

Added: cfe/trunk/test/Tooling/clang-diff-args.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-args.test?rev=311173=auto
==
--- cfe/trunk/test/Tooling/clang-diff-args.test (added)
+++ cfe/trunk/test/Tooling/clang-diff-args.test Fri Aug 18 09:34:22 2017
@@ -0,0 +1,8 @@
+RUN: echo a > %t.cpp
+
+CHECK: unknown type name 'X'
+
+check adding compiler cflags
+RUN: clang-diff -ast-dump -extra-arg=-Da=X%t.cpp -- 2>&1 | FileCheck %s
+RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s
+RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s

Modified: cfe/trunk/test/Tooling/clang-diff-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-diff-basic.cpp?rev=311173=311172=311173=diff
==
--- cfe/trunk/test/Tooling/clang-diff-basic.cpp (original)
+++ cfe/trunk/test/Tooling/clang-diff-basic.cpp Fri Aug 18 09:34:22 2017
@@ -1,7 +1,6 @@
-// RUN: mkdir -p %t
-// RUN: %clang_cc1 -E %s > %t/src.cpp
-// RUN: %clang_cc1 -E %s > %t/dst.cpp -DDEST
-// RUN: clang-diff -no-compilation-database %t/src.cpp %t/dst.cpp | FileCheck 
%s
+// RUN: %clang_cc1 -E %s > %t.src.cpp
+// RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST
+// RUN: clang-diff %t.src.cpp %t.dst.cpp -- | FileCheck %s
 
 #ifndef DEST
 namespace src {

Modified: cfe/trunk/tools/clang-diff/ClangDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-diff/ClangDiff.cpp?rev=311173=311172=311173=diff
==
--- cfe/trunk/tools/clang-diff/ClangDiff.cpp (original)
+++ cfe/trunk/tools/clang-diff/ClangDiff.cpp Fri Aug 18 09:34:22 2017
@@ -28,12 +28,6 @@ static cl::opt
 cl::desc("Print the internal representation of the AST as JSON."),
 cl::init(false), cl::cat(ClangDiffCategory));
 
-static cl::opt NoCompilationDatabase(
-"no-compilation-database",
-cl::desc(
-"Do not attempt to load build settings from a compilation database"),
-cl::init(false), cl::cat(ClangDiffCategory));
-
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -43,23 +37,56 @@ static cl::opt DestinationP
 cl::Optional,
 cl::cat(ClangDiffCategory));
 
-static std::unique_ptr getAST(const StringRef Filename) {
+static cl::opt MaxSize("s", cl::desc(""), cl::Optional,
+cl::init(-1), cl::cat(ClangDiffCategory));
+
+static cl::opt BuildPath("p", cl::desc("Build path"), 
cl::init(""),
+  cl::Optional, 
cl::cat(ClangDiffCategory));
+
+static cl::list ArgsAfter(
+"extra-arg",
+cl::desc("Additional argument to append to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static cl::list ArgsBefore(
+"extra-arg-before",
+cl::desc("Additional argument to prepend to the compiler command line"),
+cl::cat(ClangDiffCategory));
+
+static void addExtraArgs(std::unique_ptr ) {
+  if (!Compilations)
+return;
+  auto AdjustingCompilations =
+  llvm::make_unique(
+  std::move(Compilations));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsBefore, ArgumentInsertPosition::BEGIN));
+  AdjustingCompilations->appendArgumentsAdjuster(
+  getInsertArgumentAdjuster(ArgsAfter, ArgumentInsertPosition::END));
+  Compilations = std::move(AdjustingCompilations);
+}
+
+static std::unique_ptr
+getAST(const std::unique_ptr ,
+   const StringRef Filename) {
   std::string ErrorMessage;
   std::unique_ptr Compilations;
-  if (!NoCompilationDatabase)
-Compilations =
-CompilationDatabase::autoDetectFromSource(Filename, ErrorMessage);
-  if (!Compilations) {
-if (!NoCompilationDatabase)
+  if (!CommonCompilations) {
+Compilations = CompilationDatabase::autoDetectFromSource(
+BuildPath.empty() ? Filename : BuildPath, ErrorMessage);
+if (!Compilations) {
   llvm::errs()
   << "Error while trying to load a 

r311172 - [clang-diff] Fix some errors and inconsistencies

2017-08-18 Thread Johannes Altmanninger via cfe-commits
Author: krobelus
Date: Fri Aug 18 09:34:15 2017
New Revision: 311172

URL: http://llvm.org/viewvc/llvm-project?rev=311172=rev
Log:
[clang-diff] Fix some errors and inconsistencies

Fix to the computation of the rightmost descendant.

Prevents root nodes from being mapped if they are already mapped.  This
only makes a difference when we compare AST Nodes other than entire
translation units, a feature which still has to be tested.

Reviewers: arphaman

Subscribers: klimek

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

Modified:
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h?rev=311172=311171=311172=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiff.h Fri Aug 18 09:34:15 2017
@@ -93,6 +93,7 @@ public:
   template 
   SyntaxTree(T *Node, const ASTContext )
   : TreeImpl(llvm::make_unique(this, Node, AST)) {}
+  SyntaxTree(SyntaxTree &) = default;
   ~SyntaxTree();
 
   const Node (NodeId Id) const;

Modified: cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h?rev=311172=311171=311172=diff
==
--- cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h (original)
+++ cfe/trunk/include/clang/Tooling/ASTDiff/ASTDiffInternal.h Fri Aug 18 
09:34:15 2017
@@ -11,8 +11,6 @@
 #ifndef LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
 #define LLVM_CLANG_TOOLING_ASTDIFF_ASTDIFFINTERNAL_H
 
-#include 
-
 #include "clang/AST/ASTTypeTraits.h"
 
 namespace clang {

Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311172=311171=311172=diff
==
--- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original)
+++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Fri Aug 18 09:34:15 2017
@@ -27,6 +27,7 @@ using namespace clang;
 namespace clang {
 namespace diff {
 
+namespace {
 /// Maps nodes of the left tree to ones on the right, and vice versa.
 class Mapping {
 public:
@@ -76,6 +77,7 @@ public:
 private:
   std::unique_ptr[]> SrcToDst, DstToSrc;
 };
+} // end anonymous namespace
 
 class ASTDiff::Impl {
 public:
@@ -110,10 +112,6 @@ private:
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
-  // Adds all corresponding subtrees of the two nodes to the mapping.
-  // The two nodes must be identical.
-  void addIsomorphicSubTrees(Mapping , NodeId Id1, NodeId Id2) const;
-
   // Uses an optimal albeit slow algorithm to compute a mapping between two
   // subtrees, but only if both have fewer nodes than MaxSize.
   void addOptimalMapping(Mapping , NodeId Id1, NodeId Id2) const;
@@ -254,7 +252,10 @@ struct PreorderVisitor : public Recursiv
 Parent = PreviousParent;
 --Depth;
 Node  = Tree.getMutableNode(MyId);
-N.RightMostDescendant = Id;
+N.RightMostDescendant = Id - 1;
+assert(N.RightMostDescendant >= 0 &&
+   N.RightMostDescendant < Tree.getSize() &&
+   "Rightmost descendant must be a valid tree node.");
 if (N.isLeaf())
   Tree.Leaves.push_back(MyId);
 N.Height = 1;
@@ -358,9 +359,7 @@ int SyntaxTree::Impl::getNumberOfDescend
 }
 
 bool SyntaxTree::Impl::isInSubtree(NodeId Id, NodeId SubtreeRoot) const {
-  NodeId Lower = SubtreeRoot;
-  NodeId Upper = getNode(SubtreeRoot).RightMostDescendant;
-  return Id >= Lower && Id <= Upper;
+  return Id >= SubtreeRoot && Id <= getNode(SubtreeRoot).RightMostDescendant;
 }
 
 std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const {
@@ -625,12 +624,11 @@ public:
   }
 
 private:
-  /// Simple cost model for edit actions.
+  /// We use a simple cost model for edit actions, which seems good enough.
+  /// Simple cost model for edit actions. This seems to make the matching
+  /// algorithm perform reasonably well.
   /// The values range between 0 and 1, or infinity if this edit action should
   /// always be avoided.
-
-  /// These costs could be modified to better model the estimated cost of /
-  /// inserting / deleting the current node.
   static constexpr double DeletionCost = 1;
   static constexpr double InsertionCost = 1;
 
@@ -687,6 +685,7 @@ struct HeightLess {
 };
 } // end anonymous namespace
 
+namespace {
 // Priority queue for nodes, sorted descendingly by their height.
 class PriorityList {
   const SyntaxTree::Impl 
@@ -723,6 +722,7 @@ public:
   push(Child);
   }
 };
+} // end 

[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-18 Thread Anatol Pomozov via Phabricator via cfe-commits
anatol.pomozov added a comment.

Tim, had you chance to look at this patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D36272



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clangd/ClangdServer.cpp:296
+
+  const int sourceSize = sizeof(DEFAULT_SOURCE_EXTENSIONS) / 
sizeof(DEFAULT_SOURCE_EXTENSIONS[0]);
+  const int headerSize = sizeof(DEFAULT_HEADER_EXTENSIONS) / 
sizeof(DEFAULT_HEADER_EXTENSIONS[0]);

You can use LLVM's function `array_lengthof` here and on the next line instead.



Comment at: clangd/ClangdServer.cpp:302
+  std::string *p;
+  p = std::find(DEFAULT_SOURCE_EXTENSIONS,
+DEFAULT_SOURCE_EXTENSIONS + sourceSize,

It might be better to use a `StringSet` instead of an array of strings and use 
one lowercase/uppercase lookup:

```
llvm::StringSet<> DEFAULT_SOURCE_EXTENSIONS[] = {".cpp", ".c", ".cc", ".cxx", 
".c++", ".m", ".mm"};
// Handles both lower and uppercase extensions and source/header files in one 
if/else construct:
if (DEFAULT_SOURCE_EXTENSIONS.count(llvm::sys::path::extension(path).lower())) {
  ...
  isSourceFile = true;
} else if 
(DEFAULT_HEADER_EXTENSIONS.count(llvm::sys::path::extension(path).lower())) {
  ...
  isSourceFile = false;
}
```


https://reviews.llvm.org/D36150



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


[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]

2017-08-18 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 111681.
hamzasood added a comment.

It's Friday, so hopefully this is good to go.
I don't have svn access, so could someone commit this for me?

I've updated the patch so that it can be applied successfully to the latest 
revision.
I've also renamed cxx1z->cxx17 in the diagnostic id to match @rsmith's recent 
patch 
.


https://reviews.llvm.org/D36572

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaLambda.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
  test/FixIt/fixit-cxx0x.cpp
  test/SemaCXX/cxx2a-lambda-equals-this.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -808,7 +807,7 @@
 
   Allow lambda-capture [=, this]
   http://wg21.link/p0409r2;>P0409R2
-  No
+  SVN
 
 
   __VA_OPT__ for preprocessor comma elision
Index: test/SemaCXX/cxx2a-lambda-equals-this.cpp
===
--- test/SemaCXX/cxx2a-lambda-equals-this.cpp
+++ test/SemaCXX/cxx2a-lambda-equals-this.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+// This test does two things.
+// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object.
+// Accessing a member variable from the lambda ensures that the capture actually works.
+class A {
+  A(const A &) = delete;
+  int i;
+
+  void func() {
+auto L = [=, this]() -> int { return i; };
+L();
+  }
+};
Index: test/FixIt/fixit-cxx0x.cpp
===
--- test/FixIt/fixit-cxx0x.cpp
+++ test/FixIt/fixit-cxx0x.cpp
@@ -54,7 +54,6 @@
 
 void S2::f(int i) {
   (void)[&, , ]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
-  (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be explicitly captured}}
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -8,7 +8,7 @@
 (void)[this, this] () {}; // expected-error {{'this' can appear only once}}
 (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}}
 (void)[=, ] () {};
-(void)[=, this] () {}; // expected-error {{'this' cannot be explicitly captured}}
+(void)[=, this] () {}; // expected-warning {{C++2a extension}}
 (void)[&, foo] () {};
 (void)[&, ] () {}; // expected-error {{'&' cannot precede a capture when}} 
 (void)[&, this] () {};
@@ -23,7 +23,7 @@
 void S2::f(int i) {
   (void)[&, i]{ };
   (void)[&, ]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}}
-  (void)[=, this]{ }; // expected-error{{'this' cannot be explicitly captured}}
+  (void)[=, this]{ }; // expected-warning{{C++2a extension}}
   (void)[=]{ this->g(i); };
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[i(0), i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}}
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -948,17 +948,15 @@
 continue;
   }
 
-  // C++1z [expr.prim.lambda]p8:
-  //  If a lambda-capture includes a capture-default that is =, each
-  //  simple-capture of that lambda-capture shall be of the form "&
-  //  identifier" or "* this". [ Note: The form [&,this] is redundant but
-  //  accepted for compatibility with ISO C++14. --end note ]
-  if (Intro.Default == LCD_ByCopy && C->Kind != LCK_StarThis) {
-Diag(C->Loc, diag::err_this_capture_with_copy_default)
-<< FixItHint::CreateRemoval(
-SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
-continue;
-  }
+  // C++2a [expr.prim.lambda]p8:
+  //  If a lambda-capture includes a capture-default that 

[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

There's also a crash with the `( ... )` initializer:

  namespace init_capture_undeclared_identifier {
auto a = [x = y]{};
  
int typo_foo;
auto b = [x (typo_boo )]{}; 
  }

I think you should move the added correction code before `if (Init.isUsable())` 
to ensure that all paths are covered.


https://reviews.llvm.org/D36853



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


[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.

2017-08-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 111676.
ilya-biryukov added a comment.

- Removed redundant 'private' specifier.
- Added a test for https://bugs.llvm.org/show_bug.cgi?id=33574


https://reviews.llvm.org/D36872

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPLexerChange.cpp
  lib/Lex/Preprocessor.cpp
  lib/Parse/Parser.cpp
  test/Index/preamble-conditionals-crash.cpp
  test/Index/preamble-conditionals.cpp

Index: test/Index/preamble-conditionals.cpp
===
--- /dev/null
+++ test/Index/preamble-conditionals.cpp
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source local %s 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "error:"
+#ifndef FOO_H
+#define FOO_H
+
+void foo();
+
+#endif
Index: test/Index/preamble-conditionals-crash.cpp
===
--- /dev/null
+++ test/Index/preamble-conditionals-crash.cpp
@@ -0,0 +1,12 @@
+#ifndef HEADER_GUARD
+
+#define FOO int aba;
+FOO
+
+#endif
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \
+// RUN:   local -std=c++14 %s 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "libclang: crash detected" \
+// RUN:--implicit-check-not "error:"
+// CHECK: macro expansion=FOO:3:9 Extent=[4:1 - 4:4]
+// CHECK: VarDecl=aba:4:1 (Definition) Extent=[4:1 - 4:4]
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -516,8 +516,6 @@
 
   // Prime the lexer look-ahead.
   ConsumeToken();
-
-  PP.replayPreambleConditionalStack();
 }
 
 void Parser::LateTemplateParserCleanupCallback(void *P) {
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -540,6 +540,8 @@
 void Preprocessor::replayPreambleConditionalStack() {
   // Restore the conditional stack from the preamble, if there is one.
   if (PreambleConditionalStack.isReplaying()) {
+assert(CurPPLexer &&
+   "CurPPLexer is null when calling replayPreambleConditionalStack.");
 CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack());
 PreambleConditionalStack.doneReplaying();
   }
Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -458,10 +458,16 @@
   SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
 }
 
+bool ExitedFromPredefinesFile = false;
 FileID ExitedFID;
-if (Callbacks && !isEndOfMacro && CurPPLexer)
+if (!isEndOfMacro && CurPPLexer) {
   ExitedFID = CurPPLexer->getFileID();
 
+  assert(PredefinesFileID.isValid() &&
+ "HandleEndOfFile is called before PredefinesFileId is set");
+  ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID);
+}
+
 if (LeavingSubmodule) {
   // We're done with this submodule.
   Module *M = LeaveSubmodule(/*ForPragma*/false);
@@ -489,6 +495,11 @@
  PPCallbacks::ExitFile, FileType, ExitedFID);
 }
 
+// Restore conditional stack from the preamble right after exiting from the
+// predefines file.
+if (ExitedFromPredefinesFile)
+  replayPreambleConditionalStack();
+
 // Client should lex another token unless we generated an EOM.
 return LeavingSubmodule;
   }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -1049,10 +1049,6 @@
   /// which implicitly adds the builtin defines etc.
   void EnterMainSourceFile();
 
-  /// \brief After parser warm-up, initialize the conditional stack from
-  /// the preamble.
-  void replayPreambleConditionalStack();
-
   /// \brief Inform the preprocessor callbacks that processing is complete.
   void EndSourceFile();
 
@@ -2026,6 +2022,10 @@
   }
 
 private:
+  /// \brief After processing predefined file, initialize the conditional stack from
+  /// the preamble.
+  void replayPreambleConditionalStack();
+
   // Macro handling.
   void HandleDefineDirective(Token , bool ImmediatelyAfterTopLevelIfndef);
   void HandleUndefDirective();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-18 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:1112
 
+  ParseScope TemplateParamScope(this, Scope::TemplateParamScope);
+  if (getLangOpts().CPlusPlus2a && Tok.is(tok::less)) {

hamzasood wrote:
> faisalv wrote:
> > We always create a template parameter scope here - but it's only the right 
> > scope if we have explicit template parameters, correct?
> > 
> > What I think we should do here is :
> >   - factor out (preferably as a separate patch) the post 
> > explicit-template-parameter-list parsing into a separate function (F1) 
> > which is then called from here.
> >   - then in this patch factor out the explicit template-parameter-list 
> > parsing also into a separate function that then either calls the function 
> > above ('F1'), or sequenced these statements before a call to 'F1'
> >   - also since gcc has had explicit template parameters on their generic 
> > lambdas for a while, can we find out under what options they have it 
> > enabled, and consider enabling it under those options for our gcc emulation 
> > mode? (or add a fixme for it?)
> >   - should we enable these explicit template parameters for pre-C++2a modes 
> > and emit extension/compatibility warnings where appropriate?
> > 
> Good point. It isn’t the “wrong” scope in the sense that is breaks anything, 
> but it is a bit wasteful to unconditionally push a potentially unneeded scope.
> 
> I have another idea that could be less intrusive, which is to replace this 
> line and the start of the if statement with:
> 
>   bool HasExplicitTemplateParams = getLangOpts().CPlusPlus2a && 
> Tok.is(tok::less);
>   ParseScope TemplateParamScope(this, Scope::TemplateParamScope, 
> HasExplicitTemplateParams);
>   if (HasExplicitTemplateParams) {
> // same code as before
>   }
> 
> That way the scope is only entered when needed, but no restructuring is 
> required (which I personally think would make things a bit harder to follow). 
> Could that work?
good idea - i think that should work too.  (Although i do still like the idea 
of refactoring this long function via extract-method - but i can always do that 
refactoring post this patch). 


https://reviews.llvm.org/D36527



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


[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.

2017-08-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

In https://reviews.llvm.org/D36872#845364, @erikjv wrote:

> Can you check if the example in https://bugs.llvm.org/show_bug.cgi?id=33574 
> works correctly?


Works correctly, added an extra test for it.


https://reviews.llvm.org/D36872



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-08-18 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 111675.
Nebiroth added a comment.

Fixed more diff comments.


https://reviews.llvm.org/D36150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h

Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -48,6 +48,8 @@
 JSONOutput ) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput ) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput ) = 0;
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher , JSONOutput ,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,23 @@
   ProtocolCallbacks 
 };
 
+struct SwitchSourceHeaderHandler : Handler {
+  SwitchSourceHeaderHandler(JSONOutput , ProtocolCallbacks )
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentIdentifier::parse(Params);
+if (!TDPP) {
+  return;
+}
+
+Callbacks.onSwitchSourceHeader(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks 
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher ,
@@ -239,4 +256,7 @@
   llvm::make_unique(Out, Callbacks));
   Dispatcher.registerHandler("textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -182,6 +182,9 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged findDefinitions(PathRef File, Position Pos);
 
+  /// Helper function that returns a path to the corresponding source file when given a header file and vice versa.
+  Path switchSourceHeader(PathRef path);
+
   /// Run formatting for \p Rng inside \p File.
   std::vector formatRange(PathRef File, Range Rng);
   /// Run formatting for the whole \p File.
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -15,6 +15,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -286,3 +287,127 @@
   });
   return make_tagged(std::move(Result), TaggedFS.Tag);
 }
+
+Path ClangdServer::switchSourceHeader(PathRef path) {
+
+  std::string DEFAULT_SOURCE_EXTENSIONS[] = {".cpp", ".c", ".cc", ".cxx", ".c++", ".m", ".mm"};
+  std::string DEFAULT_HEADER_EXTENSIONS[] = {".h", ".hh", ".hpp", ".hxx", ".inc"};
+
+  const int sourceSize = sizeof(DEFAULT_SOURCE_EXTENSIONS) / sizeof(DEFAULT_SOURCE_EXTENSIONS[0]);
+  const int headerSize = sizeof(DEFAULT_HEADER_EXTENSIONS) / sizeof(DEFAULT_HEADER_EXTENSIONS[0]);
+
+  bool isSourceFile = false, foundExtension = false;
+  SmallString<128> NewPath;
+  std::string *p;
+  p = std::find(DEFAULT_SOURCE_EXTENSIONS,
+DEFAULT_SOURCE_EXTENSIONS + sourceSize,
+llvm::sys::path::extension(path));
+  if (p != DEFAULT_SOURCE_EXTENSIONS + sourceSize) 
+  {
+std::string fileExtension = *p;
+NewPath = path;
+path = path.substr(0, (path.size() - fileExtension.size()));
+isSourceFile = true;
+foundExtension = true;
+  }
+  else
+  {
+std::string cpy[sourceSize];
+std::copy(DEFAULT_SOURCE_EXTENSIONS, DEFAULT_SOURCE_EXTENSIONS + sourceSize, cpy);
+for (std::string & s : cpy)
+std::transform(s.begin(), s.end(), s.begin(),
+   [](unsigned char c) { return std::toupper(c); });
+
+p = std::find(cpy, cpy + sourceSize, llvm::sys::path::extension(path));
+if (p != cpy + sourceSize) 
+{
+std::string fileExtension = *p;
+NewPath = path;
+path = path.substr(0, (path.size() - fileExtension.size()));
+isSourceFile = true;
+foundExtension = true;
+}
+  }
+
+  if (!foundExtension) {
+p = std::find(DEFAULT_HEADER_EXTENSIONS,
+  DEFAULT_HEADER_EXTENSIONS + headerSize,
+  llvm::sys::path::extension(path));
+if (p != DEFAULT_HEADER_EXTENSIONS + headerSize) 
+{
+  std::string fileExtension = *p;
+  NewPath = path;
+  path = path.substr(0, (path.size() - fileExtension.size()));
+  isSourceFile = false;
+  foundExtension = true;
+}
+else
+{
+  std::string cpy[sourceSize];
+  

[PATCH] D36187: [clang-diff] Use the relative name for NamedDecls

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:371
+  std::string ContextPrefix;
+  if (auto *Namespace = dyn_cast(Context))
+ContextPrefix = Namespace->getQualifiedNameAsString();

You don't need to check both `NamespaceDecl` and `TagDecl`, since you can just 
do one if with a `NamedDecl`.


https://reviews.llvm.org/D36187



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


[PATCH] D36876: [IRGen] Evaluate constant static variables referenced through member expressions

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

C++ allows us to reference static variables through member expressions. Prior 
to this patch, non-integer static variables that were referenced using a member 
expression were always emitted using lvalue loads. The old behaviour introduced 
an inconsistency between regular uses of static variables and member 
expressions uses, for example, the following program compiled and linked 
successfully:

  struct Foo {
 constexpr static const char *name = "foo";
  };
  int main() {
return Foo::name[0] == 'f';
  }

but this program failed to link because "Foo::name" wasn't found:

  struct Foo {
 constexpr static const char *name = "foo";
  };
  int main() {
Foo f;
return f.name[0] == 'f';
  }

This patch ensures that static variables referenced through member expressions 
are emitted in the same way as ordinary static variable references.

rdar://33942261


Repository:
  rL LLVM

https://reviews.llvm.org/D36876

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/member-expr-references-variable.cpp

Index: test/CodeGenCXX/member-expr-references-variable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/member-expr-references-variable.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct Struct {
+   constexpr static const char *name = "foo";
+
+   constexpr static __complex float complexValue = 42.0;
+
+   Struct();
+   Struct(int x);
+};
+
+void use(int n, const char *c);
+
+Struct *getPtr();
+
+// CHECK: @[[STR:.*]] = private unnamed_addr constant [4 x i8] c"foo\00", align 1
+
+void scalarStaticVariableInMemberExpr(Struct *ptr, Struct ) {
+  use(1, Struct::name);
+// CHECK: call void @_Z3useiPKc(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
+  Struct s;
+  use(2, s.name);
+// CHECK: call void @_Z3useiPKc(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
+  use(3, ptr->name);
+// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
+// CHECK: call void @_Z3useiPKc(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
+  use(4, ref.name);
+// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
+// CHECK: call void @_Z3useiPKc(i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
+  use(5, Struct(2).name);
+// CHECK: call void @_ZN6StructC1Ei(%struct.Struct* %{{.*}}, i32 2)
+// CHECK: call void @_Z3useiPKc(i32 5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
+  use(6, getPtr()->name);
+// CHECK: call %struct.Struct* @_Z6getPtrv()
+// CHECK: call void @_Z3useiPKc(i32 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0))
+}
+
+void use(int n, __complex float v);
+
+void complexStaticVariableInMemberExpr(Struct *ptr, Struct ) {
+  use(1, Struct::complexValue);
+// CHECK: store float 4.20e+01, float* %[[coerce0:.*]].{{.*}}, align 4
+// CHECK: store float 0.00e+00, float* %[[coerce0]].{{.*}}, align 4
+// CHECK: %[[cast0:.*]] = bitcast { float, float }* %[[coerce0]] to <2 x float>*
+// CHECK: %[[vector0:.*]] = load <2 x float>, <2 x float>* %[[cast0]], align 4
+// CHECK: call void @_Z3useiCf(i32 1, <2 x float> %[[vector0]])
+  Struct s;
+  use(2, s.complexValue);
+// CHECK: store float 4.20e+01, float* %[[coerce1:.*]].{{.*}}, align 4
+// CHECK: store float 0.00e+00, float* %[[coerce1]].{{.*}}, align 4
+// CHECK: %[[cast1:.*]] = bitcast { float, float }* %[[coerce1]] to <2 x float>*
+// CHECK: %[[vector1:.*]] = load <2 x float>, <2 x float>* %[[cast1]], align 4
+// CHECK: call void @_Z3useiCf(i32 2, <2 x float> %[[vector1]])
+  use(3, ptr->complexValue);
+// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
+// CHECK: store float 4.20e+01, float* %[[coerce2:.*]].{{.*}}, align 4
+// CHECK: store float 0.00e+00, float* %[[coerce2]].{{.*}}, align 4
+// CHECK: %[[cast2:.*]] = bitcast { float, float }* %[[coerce2]] to <2 x float>*
+// CHECK: %[[vector2:.*]] = load <2 x float>, <2 x float>* %[[cast2]], align 4
+// CHECK: call void @_Z3useiCf(i32 3, <2 x float> %[[vector2]])
+  use(4, ref.complexValue);
+// CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8
+// CHECK: store float 4.20e+01, float* %[[coerce3:.*]].{{.*}}, align 4
+// CHECK: store float 0.00e+00, float* %[[coerce3]].{{.*}}, align 4
+// CHECK: %[[cast3:.*]] = bitcast { float, float }* %[[coerce3]] to <2 x float>*
+// CHECK: %[[vector3:.*]] = load <2 x float>, <2 x float>* %[[cast3]], align 4
+// CHECK: call void @_Z3useiCf(i32 4, <2 x float> %[[vector3]])
+  use(5, Struct(2).complexValue);
+// CHECK: call void @_ZN6StructC1Ei(%struct.Struct* %{{.*}}, i32 2)
+// CHECK: store float 4.20e+01, 

[PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This approach looks good to me.

Is there any chance we could have a test for this? See `test/Driver` for 
examples; use `python bin\llvm-lit.py 
../llvm/tools/clang/test/Driver/my_test.cpp` to run a single test, `ninja 
check-clang` to run all of them. You need some unix binaries to run tests -- if 
you don't have those flying around, you can download gnuwin-7.zip from 
http://commondatastorage.googleapis.com/chromium-browser-clang/index.html?path=tools/
 and add them to your %PATH%.


https://reviews.llvm.org/D36860



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


[PATCH] D36857: [Driver] Set linkPath and MSVT version when cl.exe is detected, plus STL's hacking.

2017-08-18 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

In https://reviews.llvm.org/D36857#845465, @thakis wrote:

> Oh, I guess this is superseded by https://reviews.llvm.org/D36860 ?


Yes, please ignore this patch -- it was just for brainstorming...  ;-)




Comment at: lib/Driver/ToolChains/MSVC.cpp:135
+  llvm::SmallString<256> TestPath = PathEntry;
+  while(!TestPath.empty()) {
 TestPath = llvm::sys::path::parent_path(TestPath);

thakis wrote:
> Having a while loop going up the directory tree stating around on every 
> compiler invocation for supporting a fairly narrow use case seems a bit 
> unfortunate. Maybe we could instead add a flag (or just a cc1 flag, even) to 
> override the check instead?
Agreed, this patch was abandoned...


https://reviews.llvm.org/D36857



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


[PATCH] D36857: [Driver] Set linkPath and MSVT version when cl.exe is detected, plus STL's hacking.

2017-08-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Oh, I guess this is superseded by https://reviews.llvm.org/D36860 ?


https://reviews.llvm.org/D36857



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


[PATCH] D36860: [Driver] Recognize DevDiv internal builds of MSVC, with a different directory structure

2017-08-18 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Looks good, but I'll defer to the owners.

Minor nit...




Comment at: lib/Driver/ToolChains/MSVC.cpp:142
   return true;
+} else if (llvm::sys::path::filename(ParentPath) == "x86ret"
+|| llvm::sys::path::filename(ParentPath) == "x86chk"

Perhaps remove the else and grab the subdir name only once before doing 
comparisons.


https://reviews.llvm.org/D36860



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


[PATCH] D36857: [Driver] Set linkPath and MSVT version when cl.exe is detected, plus STL's hacking.

2017-08-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: lib/Driver/ToolChains/MSVC.cpp:135
+  llvm::SmallString<256> TestPath = PathEntry;
+  while(!TestPath.empty()) {
 TestPath = llvm::sys::path::parent_path(TestPath);

Having a while loop going up the directory tree stating around on every 
compiler invocation for supporting a fairly narrow use case seems a bit 
unfortunate. Maybe we could instead add a flag (or just a cc1 flag, even) to 
override the check instead?


https://reviews.llvm.org/D36857



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests

2017-08-18 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Looks good to me too.

Two nits (no new review required): one is inlined, and the other one in the 
summary: ARMv8.2-A => Armv8.2-A   :-/




Comment at: test/Driver/arm-dotprod.c:2
+// RUN: %clang -### -target arm %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.1a %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.2a %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-NONE

Perhaps also test "v8.0" and add -march=armv8a?


https://reviews.llvm.org/D36731



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


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-18 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

I'll commit it, probably next Tuesday.


https://reviews.llvm.org/D35355



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests

2017-08-18 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

I'm happy with the patch, but I'll let @SjoerdMeijer approve.


https://reviews.llvm.org/D36731



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


[PATCH] D36836: [clang-tidy] Implement readability-function-cognitive-complexity check

2017-08-18 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Did I run it over clang or athletic like that? I would be interested in an 
overall output.
I added my thoughts. This check seems very valuable.




Comment at: clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp:23
+  // Limit of 25 is the "upstream"'s default.
+  static constexpr const unsigned DefaultLimit = 25U;
+

Constexpr variables are const as well. I think it's duplicated



Comment at: test/clang-tidy/check_clang_tidy.py:76
   has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  has_check_notes = input_text.find('CHECK-NOTES') >= 0
 

Maybe this one in a separate patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D36836



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-18 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:1112
 
+  ParseScope TemplateParamScope(this, Scope::TemplateParamScope);
+  if (getLangOpts().CPlusPlus2a && Tok.is(tok::less)) {

faisalv wrote:
> We always create a template parameter scope here - but it's only the right 
> scope if we have explicit template parameters, correct?
> 
> What I think we should do here is :
>   - factor out (preferably as a separate patch) the post 
> explicit-template-parameter-list parsing into a separate function (F1) which 
> is then called from here.
>   - then in this patch factor out the explicit template-parameter-list 
> parsing also into a separate function that then either calls the function 
> above ('F1'), or sequenced these statements before a call to 'F1'
>   - also since gcc has had explicit template parameters on their generic 
> lambdas for a while, can we find out under what options they have it enabled, 
> and consider enabling it under those options for our gcc emulation mode? (or 
> add a fixme for it?)
>   - should we enable these explicit template parameters for pre-C++2a modes 
> and emit extension/compatibility warnings where appropriate?
> 
Good point. It isn’t the “wrong” scope in the sense that is breaks anything, 
but it is a bit wasteful to unconditionally push a potentially unneeded scope.

I have another idea that could be less intrusive, which is to replace this line 
and the start of the if statement with:

  bool HasExplicitTemplateParams = getLangOpts().CPlusPlus2a && 
Tok.is(tok::less);
  ParseScope TemplateParamScope(this, Scope::TemplateParamScope, 
HasExplicitTemplateParams);
  if (HasExplicitTemplateParams) {
// same code as before
  }

That way the scope is only entered when needed, but no restructuring is 
required (which I personally think would make things a bit harder to follow). 
Could that work?


https://reviews.llvm.org/D36527



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests

2017-08-18 Thread Sam Parker via Phabricator via cfe-commits
samparker updated this revision to Diff 111664.
samparker added a comment.

Reverted the default cpu v8.2-a to generic, I will update 
https://reviews.llvm.org/D36667 accordingly. Also fixed up the boolean issues.


https://reviews.llvm.org/D36731

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/aarch64-dotprod.c
  test/Driver/aarch64-ras.c
  test/Driver/aarch64-rcpc.s
  test/Driver/arm-cortex-cpus.c
  test/Driver/arm-dotprod.c
  test/Driver/arm-ras.c

Index: test/Driver/arm-ras.c
===
--- test/Driver/arm-ras.c
+++ test/Driver/arm-ras.c
@@ -1,5 +1,7 @@
 // RUN: %clang -target arm-none-none-eabi -march=armv8a+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
 // RUN: %clang -target arm-none-none-eabi -mcpu=generic+ras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
+// RUN: %clang -target arm-none-none-eabi -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-RAS %s
 // CHECK-RAS: "-target-feature" "+ras"
 
 // RUN: %clang -target arm-none-none-eabi -march=armv8a+noras -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NORAS %s
Index: test/Driver/arm-dotprod.c
===
--- /dev/null
+++ test/Driver/arm-dotprod.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### -target arm %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.1a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.2a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -target arm -march=armv8.3a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// CHECK-NONE-NOT: "-target-feature" "+dotprod"
+
+// RUN: %clang -### -target arm -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
+// CHECK: "+dotprod"
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -507,6 +507,12 @@
 // RUN: %clang -target arm -mcpu=exynos-m3 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a55 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a75 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV82A %s
+// CHECK-CPUV82A: "-cc1"{{.*}} "-triple" "armv8.2a-{{.*}}
+
 // RUN: %clang -target armeb -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
@@ -527,6 +533,12 @@
 // RUN: %clang -target arm -mcpu=exynos-m3 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // CHECK-BE-CPUV8A: "-cc1"{{.*}} "-triple" "armebv8-{{.*}}
 
+// RUN: %clang -target armeb -mcpu=cortex-a55 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target armeb -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a55 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a75 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV82A %s
+// CHECK-BE-CPUV82A: "-cc1"{{.*}} "-triple" "armebv8.2a-{{.*}}
+
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r52 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8R %s
 // CHECK-CPUV8R: "-cc1"{{.*}} "-triple" "armv8r-{{.*}}
 
@@ -550,6 +562,12 @@
 // RUN: %clang -target arm -mcpu=exynos-m3 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // CHECK-CPUV8A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a55 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECKCPUV82A-THUMB %s
+// RUN: %clang -target arm -mcpu=cortex-a75 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECKCPUV82A-THUMB %s
+// RUN: %clang -target arm -mcpu=cortex-a55 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECKCPUV82A-THUMB %s
+// RUN: %clang -target arm -mcpu=cortex-a75 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck 

[libcxx] r311156 - Spelling

2017-08-18 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Fri Aug 18 05:57:36 2017
New Revision: 311156

URL: http://llvm.org/viewvc/llvm-project?rev=311156=rev
Log:
Spelling

Modified:
libcxx/trunk/include/__tree

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=311156=311155=311156=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Fri Aug 18 05:57:36 2017
@@ -84,7 +84,7 @@ __tree_is_left_child(_NodePtr __x) _NOEX
 return __x == __x->__parent_->__left_;
 }
 
-// Determintes if the subtree rooted at __x is a proper red black subtree.  If
+// Determines if the subtree rooted at __x is a proper red black subtree.  If
 //__x is a proper subtree, returns the black height (null counts as 1).  If
 //__x is an improper subtree, returns 0.
 template 
@@ -119,7 +119,7 @@ __tree_sub_invariant(_NodePtr __x)
 return __h + __x->__is_black_;  // return black height of this node
 }
 
-// Determintes if the red black tree rooted at __root is a proper red black 
tree.
+// Determines if the red black tree rooted at __root is a proper red black 
tree.
 //__root == nullptr is a proper tree.  Returns true is __root is a proper
 //red black tree, else returns false.
 template 


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


[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.

2017-08-18 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

Can you check if the example in https://bugs.llvm.org/show_bug.cgi?id=33574 
works correctly?




Comment at: include/clang/Lex/Preprocessor.h:2029
+
 private:
   // Macro handling.

Duplicate "private:"


https://reviews.llvm.org/D36872



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


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Here's an alternative fix that moves the `replay...` call into `Preprocessor`: 
https://reviews.llvm.org/D36872.
It also fixes the crash and doesn't add invalid compiler errors about 
non-matching `#ifdefs`.


https://reviews.llvm.org/D36458



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


[PATCH] D36872: Fixed a crash on replaying Preamble's PP conditional stack.

2017-08-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

The crash occurs when the first token after a preamble is a macro
expansion.
Fixed by moving replayPreambleConditionalStack from Parser into
Preprocessor. It is now called right after the predefines file is
processed.


https://reviews.llvm.org/D36872

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPLexerChange.cpp
  lib/Lex/Preprocessor.cpp
  lib/Parse/Parser.cpp
  test/Index/preamble-conditionals-crash.cpp

Index: test/Index/preamble-conditionals-crash.cpp
===
--- /dev/null
+++ test/Index/preamble-conditionals-crash.cpp
@@ -0,0 +1,12 @@
+#ifndef HEADER_GUARD
+
+#define FOO int aba;
+FOO
+
+#endif
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \
+// RUN:   local -std=c++14 %s 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "libclang: crash detected" \
+// RUN:--implicit-check-not "error:"
+// CHECK: macro expansion=FOO:3:9 Extent=[4:1 - 4:4]
+// CHECK: VarDecl=aba:4:1 (Definition) Extent=[4:1 - 4:4]
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -516,8 +516,6 @@
 
   // Prime the lexer look-ahead.
   ConsumeToken();
-
-  PP.replayPreambleConditionalStack();
 }
 
 void Parser::LateTemplateParserCleanupCallback(void *P) {
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -540,6 +540,8 @@
 void Preprocessor::replayPreambleConditionalStack() {
   // Restore the conditional stack from the preamble, if there is one.
   if (PreambleConditionalStack.isReplaying()) {
+assert(CurPPLexer &&
+   "CurPPLexer is null when calling replayPreambleConditionalStack.");
 CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack());
 PreambleConditionalStack.doneReplaying();
   }
Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -458,10 +458,16 @@
   SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
 }
 
+bool ExitedFromPredefinesFile = false;
 FileID ExitedFID;
-if (Callbacks && !isEndOfMacro && CurPPLexer)
+if (!isEndOfMacro && CurPPLexer) {
   ExitedFID = CurPPLexer->getFileID();
 
+  assert(PredefinesFileID.isValid() &&
+ "HandleEndOfFile is called before PredefinesFileId is set");
+  ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID);
+}
+
 if (LeavingSubmodule) {
   // We're done with this submodule.
   Module *M = LeaveSubmodule(/*ForPragma*/false);
@@ -489,6 +495,11 @@
  PPCallbacks::ExitFile, FileType, ExitedFID);
 }
 
+// Restore conditional stack from the preamble right after exiting from the
+// predefines file.
+if (ExitedFromPredefinesFile)
+  replayPreambleConditionalStack();
+
 // Client should lex another token unless we generated an EOM.
 return LeavingSubmodule;
   }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -1049,10 +1049,6 @@
   /// which implicitly adds the builtin defines etc.
   void EnterMainSourceFile();
 
-  /// \brief After parser warm-up, initialize the conditional stack from
-  /// the preamble.
-  void replayPreambleConditionalStack();
-
   /// \brief Inform the preprocessor callbacks that processing is complete.
   void EndSourceFile();
 
@@ -2025,6 +2021,11 @@
 PreambleConditionalStack.setStack(s);
   }
 
+private:
+  /// \brief After processing predefined file, initialize the conditional stack from
+  /// the preamble.
+  void replayPreambleConditionalStack();
+
 private:
   // Macro handling.
   void HandleDefineDirective(Token , bool ImmediatelyAfterTopLevelIfndef);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 tests

2017-08-18 Thread Sam Parker via Phabricator via cfe-commits
samparker added a comment.

Thanks guys, I will sort my logic out.

Renato, the new Decode function is really just there to allow me to double 
check the target features. This is already possible with AArch64 and it just 
felt right to also be able to test ARM in the same way. I've renamed the title 
so others aren't mislead.

cheers,
sam




Comment at: test/Driver/arm-cortex-cpus.c:261
 // RUN: %clang -target arm -mlittle-endian -march=armv8.2-a -mlittle-endian 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A %s
-// CHECK-V82A: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic"
+// CHECK-V82A: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" 
"cortex-a55"
 

SjoerdMeijer wrote:
> Just checking: why has the default cpu changed from generic to cortex-a55, 
> and secondly, is that what we want?
I was thinking about this on the way to work, and no I don't think it is what 
we want! I will change this.


https://reviews.llvm.org/D36731



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 support

2017-08-18 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Ah, my message crossed with Renato's; I only noticed it after submitting mine 
(looks like we agree though:-))


https://reviews.llvm.org/D36731



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 support

2017-08-18 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

"They also implement the RCpc AArch64 extension from ARMv8.3-A."

Perhaps you need to explain why a v8.2 core implements a v8.3 extension?




Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:92
+ std::vector ) {
+  if (CPU != "generic") {
+llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(CPU);

Nit: just for readability I would prefer an early exit:

if (CPU == "generic")
   return false;



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:102
+  return false;
+}
+

Nit: you're not checking the return value (so you could simplify this function, 
but I don't have a strong opinion on this). 



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:348
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
+  } else if (!CPUName.empty() && CPUName != "generic") {
+DecodeARMFeaturesFromCPU(D, CPUName, Features);

rengolin wrote:
> Isn't this conditional redundant with what the function does?
CPUName != "generic" is also checked in function DecodeARMFeaturesFromCPU.



Comment at: test/Driver/arm-cortex-cpus.c:261
 // RUN: %clang -target arm -mlittle-endian -march=armv8.2-a -mlittle-endian 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V82A %s
-// CHECK-V82A: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic"
+// CHECK-V82A: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" 
"cortex-a55"
 

Just checking: why has the default cpu changed from generic to cortex-a55, and 
secondly, is that what we want?


https://reviews.llvm.org/D36731



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


[PATCH] D36731: [ARM][AArch64] Cortex-A75 and Cortex-A55 support

2017-08-18 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

This change seems to have nothing to do with adding core support but exposing 
features from CPU names.

If this was required to "support" the new cores in Clang, why wasn't it needed 
before?

If this is a new, more generic way, of getting support, shouldn't you remove 
the specialist code that already does that for all other cores?

cheers,
--renato




Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:90
 
+static bool DecodeARMFeaturesFromCPU(const Driver , StringRef CPU,
+ std::vector ) {

Why are you returning bool if you're not using the result?



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:348
 Args.MakeArgString((F.second ? "+" : "-") + F.first()));
+  } else if (!CPUName.empty() && CPUName != "generic") {
+DecodeARMFeaturesFromCPU(D, CPUName, Features);

Isn't this conditional redundant with what the function does?


https://reviews.llvm.org/D36731



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


[PATCH] D34992: Emit static constexpr member as available_externally definition

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

FYI, this doesn't compiler after John's constant emitter refactoring (r310964)


https://reviews.llvm.org/D34992



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


[PATCH] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D36777



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-18 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 111647.
yvvan marked 5 inline comments as done.
yvvan added a comment.

Review comments + solved https://bugs.llvm.org/show_bug.cgi?id=34207 issue.
I've also added the extra test for that issue


https://reviews.llvm.org/D36390

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaOverload.cpp
  test/Index/complete-call.cpp

Index: test/Index/complete-call.cpp
===
--- test/Index/complete-call.cpp
+++ test/Index/complete-call.cpp
@@ -94,6 +94,24 @@
   s.foo_7(42,);
 }
 
+struct Bar {
+  static void foo_1();
+  void foo_1(float);
+  static void foo_1(int);
+};
+
+void test() {
+  Bar::foo_1();
+  Bar b;
+  b.foo_1();
+}
+
+struct Bar2 : public Bar {
+  Bar2() {
+Bar::foo_1();
+  }
+};
+
 // RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
 // CHECK-CC1: Completion contexts:
@@ -803,3 +821,46 @@
 // CHECK-CC59-NEXT: Class name
 // CHECK-CC59-NEXT: Nested name specifier
 // CHECK-CC59-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:104:14 %s | FileCheck -check-prefix=CHECK-CC60 %s
+// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1)
+// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC60: Completion contexts:
+// CHECK-CC60-NEXT: Any type
+// CHECK-CC60-NEXT: Any value
+// CHECK-CC60-NEXT: Enum tag
+// CHECK-CC60-NEXT: Union tag
+// CHECK-CC60-NEXT: Struct tag
+// CHECK-CC60-NEXT: Class name
+// CHECK-CC60-NEXT: Nested name specifier
+// CHECK-CC60-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:106:11 %s | FileCheck -check-prefix=CHECK-CC61 %s
+// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1)
+// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC61: Completion contexts:
+// CHECK-CC61-NEXT: Any type
+// CHECK-CC61-NEXT: Any value
+// CHECK-CC61-NEXT: Enum tag
+// CHECK-CC61-NEXT: Union tag
+// CHECK-CC61-NEXT: Struct tag
+// CHECK-CC61-NEXT: Class name
+// CHECK-CC61-NEXT: Nested name specifier
+// CHECK-CC61-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:111:16 %s | FileCheck -check-prefix=CHECK-CC62 %s
+// CHECK-CC62: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC62: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1)
+// CHECK-CC62: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC62: Completion contexts:
+// CHECK-CC62-NEXT: Any type
+// CHECK-CC62-NEXT: Any value
+// CHECK-CC62-NEXT: Enum tag
+// CHECK-CC62-NEXT: Union tag
+// CHECK-CC62-NEXT: Struct tag
+// CHECK-CC62-NEXT: Class name
+// CHECK-CC62-NEXT: Nested name specifier
+// CHECK-CC62-NEXT: Objective-C interface
+
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -6317,24 +6317,36 @@
  OverloadCandidateSet& CandidateSet,
  TemplateArgumentListInfo *ExplicitTemplateArgs,
  bool SuppressUserConversions,
- bool PartialOverloading) {
+ bool PartialOverloading,
+ bool FirstArgumentIsBase) {
   for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) {
 NamedDecl *D = F.getDecl()->getUnderlyingDecl();
 if (FunctionDecl *FD = dyn_cast(D)) {
+  ArrayRef FunctionArgs = Args;
   if (isa(FD) && !cast(FD)->isStatic()) {
 QualType ObjectType;
 Expr::Classification ObjectClassification;
-if (Expr *E = Args[0]) {
-  // Use the explit base to restrict the lookup:
-  ObjectType = E->getType();
-  ObjectClassification = E->Classify(Context);
-} // .. else there is an implit base.
+if (Args.size() > 0) {
+  if (Expr *E = Args[0]) {
+// Use the explit base to restrict the lookup:
+ObjectType = E->getType();
+ObjectClassification = E->Classify(Context);
+  } // .. else there is an implit base.
+  FunctionArgs = Args.slice(1);
+}
 AddMethodCandidate(cast(FD), F.getPair(),
cast(FD)->getParent(), ObjectType,

[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Parse/Parser.cpp:519
   ConsumeToken();
-
-  PP.replayPreambleConditionalStack();
+  if (!PP.isCurrentLexer(nullptr))
+PP.replayPreambleConditionalStack();

ilya-biryukov wrote:
> This certainly fixes the crash, but aren't we breaking other things if we 
> don't run `replayConditionalStack`?
> I.e. won't we get spurious errors on `#endif`?
I get a spurious `#endif without #if` error with your fix. We need to figure 
out the right place to run `replayPreambleConditionalStack`.

@erikjv, any ideas?


https://reviews.llvm.org/D36458



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


[PATCH] D36458: Fix crash when current lexer is nullptr

2017-08-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I've also stumbled upon this crash. Here is an even simpler repro that crashes 
for me (does not involve includes):

  #ifndef HEADER_GUARD
  
  #define FOO(X) int fhjdfhsdjkfhjkshfjk;
  FOO(base)
  
  struct X {
int a;
  };
  
  int test() {
X v;
v.
  }
  #endif




Comment at: lib/Parse/Parser.cpp:519
   ConsumeToken();
-
-  PP.replayPreambleConditionalStack();
+  if (!PP.isCurrentLexer(nullptr))
+PP.replayPreambleConditionalStack();

This certainly fixes the crash, but aren't we breaking other things if we don't 
run `replayConditionalStack`?
I.e. won't we get spurious errors on `#endif`?


https://reviews.llvm.org/D36458



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


[PATCH] D35564: Suppress -pedantic warnings about GNU extension StmtExpr in glibc's assert macro

2017-08-18 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 111634.
sberg added a comment.

(the original diff had inadvertently lacked full -U99 context; uploaded a 
new diff)


https://reviews.llvm.org/D35564

Files:
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/test/SemaCXX/warn-sysheader-macro.cpp


Index: clang/test/SemaCXX/warn-sysheader-macro.cpp
===
--- clang/test/SemaCXX/warn-sysheader-macro.cpp
+++ clang/test/SemaCXX/warn-sysheader-macro.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast -pedantic %s
 
 // Test that macro expansions from system headers don't trigger 'syntactic'
 // warnings that are not actionable.
@@ -12,6 +12,8 @@
 
 #define OLD_STYLE_CAST(a) ((int) (a))
 
+#define ASSERT(a) ({ if (a) {} else {} })
+
 #else
 
 #define IS_SYSHEADER
@@ -32,4 +34,9 @@
   int i = OLD_STYLE_CAST(0);
 }
 
+void testExtension() {
+  ASSERT(true);
+  ASSERT(({ true; })); // expected-warning {{use of GNU statement expression 
extension}}
+}
+
 #endif
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -396,6 +396,14 @@
   return toLevel(getDiagnosticSeverity(DiagID, Loc, Diag));
 }
 
+static bool isSystemFunctionMacroBodyExpansion(SourceLocation Loc,
+   const SourceManager ) {
+  if (!(SM.isInSystemMacro(Loc) && SM.isMacroBodyExpansion(Loc)))
+return false;
+  auto Range = SM.getImmediateExpansionRange(Loc);
+  return Range.first != Range.second;
+}
+
 /// \brief Based on the way the client configured the Diagnostic
 /// object, classify the specified diagnostic ID into a Level, consumable by
 /// the DiagnosticClient.
@@ -469,8 +477,10 @@
   // because we also want to ignore extensions and warnings in -Werror and
   // -pedantic-errors modes, which *map* warnings/extensions to errors.
   if (State->SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid() &&
-  Diag.getSourceManager().isInSystemHeader(
-  Diag.getSourceManager().getExpansionLoc(Loc)))
+  (Diag.getSourceManager().isInSystemHeader(
+  Diag.getSourceManager().getExpansionLoc(Loc)) ||
+   (IsExtensionDiag &&
+isSystemFunctionMacroBodyExpansion(Loc, Diag.getSourceManager()
 return diag::Severity::Ignored;
 
   return Result;


Index: clang/test/SemaCXX/warn-sysheader-macro.cpp
===
--- clang/test/SemaCXX/warn-sysheader-macro.cpp
+++ clang/test/SemaCXX/warn-sysheader-macro.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast -pedantic %s
 
 // Test that macro expansions from system headers don't trigger 'syntactic'
 // warnings that are not actionable.
@@ -12,6 +12,8 @@
 
 #define OLD_STYLE_CAST(a) ((int) (a))
 
+#define ASSERT(a) ({ if (a) {} else {} })
+
 #else
 
 #define IS_SYSHEADER
@@ -32,4 +34,9 @@
   int i = OLD_STYLE_CAST(0);
 }
 
+void testExtension() {
+  ASSERT(true);
+  ASSERT(({ true; })); // expected-warning {{use of GNU statement expression extension}}
+}
+
 #endif
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -396,6 +396,14 @@
   return toLevel(getDiagnosticSeverity(DiagID, Loc, Diag));
 }
 
+static bool isSystemFunctionMacroBodyExpansion(SourceLocation Loc,
+   const SourceManager ) {
+  if (!(SM.isInSystemMacro(Loc) && SM.isMacroBodyExpansion(Loc)))
+return false;
+  auto Range = SM.getImmediateExpansionRange(Loc);
+  return Range.first != Range.second;
+}
+
 /// \brief Based on the way the client configured the Diagnostic
 /// object, classify the specified diagnostic ID into a Level, consumable by
 /// the DiagnosticClient.
@@ -469,8 +477,10 @@
   // because we also want to ignore extensions and warnings in -Werror and
   // -pedantic-errors modes, which *map* warnings/extensions to errors.
   if (State->SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid() &&
-  Diag.getSourceManager().isInSystemHeader(
-  Diag.getSourceManager().getExpansionLoc(Loc)))
+  (Diag.getSourceManager().isInSystemHeader(
+  Diag.getSourceManager().getExpansionLoc(Loc)) ||
+   (IsExtensionDiag &&
+isSystemFunctionMacroBodyExpansion(Loc, Diag.getSourceManager()
 return diag::Severity::Ignored;
 
   return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35562: Support GNU extension StmtExpr in constexpr function

2017-08-18 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 111632.
sberg added a comment.

(the original diff had inadvertently lacked full -U99 context; uploaded a 
new diff)


https://reviews.llvm.org/D35562

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp


Index: clang/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -781,9 +781,8 @@
 return ({ int n; n; }); // expected-note {{object of type 'int' is not 
initialized}}
   }
 
-  // FIXME: We should handle the void statement expression case.
-  constexpr int h() { // expected-error {{never produces a constant}}
-({ if (true) {} }); // expected-note {{not supported}}
+  constexpr int h() {
+({ if (true) {} });
 return 0;
   }
 }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4837,16 +4837,10 @@
 
 for (CompoundStmt::const_body_iterator BI = CS->body_begin(),
BE = CS->body_end();
- /**/; ++BI) {
-  if (BI + 1 == BE) {
-const Expr *FinalExpr = dyn_cast(*BI);
-if (!FinalExpr) {
-  Info.FFDiag((*BI)->getLocStart(),
-diag::note_constexpr_stmt_expr_unsupported);
-  return false;
-}
-return this->Visit(FinalExpr);
-  }
+ BI != BE; ++BI) {
+  if (BI + 1 == BE)
+if (const Expr *FinalExpr = dyn_cast(*BI))
+  return this->Visit(FinalExpr);
 
   APValue ReturnValue;
   StmtResult Result = { ReturnValue, nullptr };
@@ -4862,7 +4856,7 @@
   }
 }
 
-llvm_unreachable("Return from function from the loop above.");
+return true;
   }
 
   /// Visit a value which is evaluated, but whose value is ignored.


Index: clang/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -781,9 +781,8 @@
 return ({ int n; n; }); // expected-note {{object of type 'int' is not initialized}}
   }
 
-  // FIXME: We should handle the void statement expression case.
-  constexpr int h() { // expected-error {{never produces a constant}}
-({ if (true) {} }); // expected-note {{not supported}}
+  constexpr int h() {
+({ if (true) {} });
 return 0;
   }
 }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4837,16 +4837,10 @@
 
 for (CompoundStmt::const_body_iterator BI = CS->body_begin(),
BE = CS->body_end();
- /**/; ++BI) {
-  if (BI + 1 == BE) {
-const Expr *FinalExpr = dyn_cast(*BI);
-if (!FinalExpr) {
-  Info.FFDiag((*BI)->getLocStart(),
-diag::note_constexpr_stmt_expr_unsupported);
-  return false;
-}
-return this->Visit(FinalExpr);
-  }
+ BI != BE; ++BI) {
+  if (BI + 1 == BE)
+if (const Expr *FinalExpr = dyn_cast(*BI))
+  return this->Visit(FinalExpr);
 
   APValue ReturnValue;
   StmtResult Result = { ReturnValue, nullptr };
@@ -4862,7 +4856,7 @@
   }
 }
 
-llvm_unreachable("Return from function from the loop above.");
+return true;
   }
 
   /// Visit a value which is evaluated, but whose value is ignored.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36851: [analyzer] Fix modeling of ctors

2017-08-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Yeah, thanks!

After the FIXME about record layout is addressed, i guess the next action item 
is to make sure the trivial constructor for the empty base is not evaluated 
conservatively (doh!). Because whatever bindings we make, for now they'd be 
blown away immediately during "construction".


Repository:
  rL LLVM

https://reviews.llvm.org/D36851



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


[PATCH] D36851: [analyzer] Fix modeling of ctors

2017-08-18 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 111622.
alexshap added a comment.

Skip the default binding for empty bases.


Repository:
  rL LLVM

https://reviews.llvm.org/D36851

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/ctor.mm


Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -704,3 +704,20 @@
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -409,6 +409,19 @@
 
   // BindDefault is only used to initialize a region with a default value.
   StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer them from offsets/alignments
+// seems to be error-prone and non-trivial because of the trailing padding.
+// As a temporary mitigation we don't create bindings for empty bases.
+if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
+cast(R)->getDecl()->isEmpty())
+  return StoreRef(store, *this);
+
 RegionBindingsRef B = getRegionBindings(store);
 assert(!B.lookup(R, BindingKey::Direct));
 


Index: test/Analysis/ctor.mm
===
--- test/Analysis/ctor.mm
+++ test/Analysis/ctor.mm
@@ -704,3 +704,20 @@
 };
   }
 }
+
+namespace NoCrashOnEmptyBaseOptimization {
+  struct NonEmptyBase {
+int X;
+explicit NonEmptyBase(int X) : X(X) {}
+  };
+
+  struct EmptyBase {};
+
+  struct S : NonEmptyBase, EmptyBase {
+S() : NonEmptyBase(0), EmptyBase() {}
+  };
+
+  void testSCtorNoCrash() {
+S s;
+  }
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -409,6 +409,19 @@
 
   // BindDefault is only used to initialize a region with a default value.
   StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override {
+// FIXME: The offsets of empty bases can be tricky because of
+// of the so called "empty base class optimization".
+// If a base class has been optimized out
+// we should not try to create a binding, otherwise we should.
+// Unfortunately, at the moment ASTRecordLayout doesn't expose
+// the actual sizes of the empty bases
+// and trying to infer them from offsets/alignments
+// seems to be error-prone and non-trivial because of the trailing padding.
+// As a temporary mitigation we don't create bindings for empty bases.
+if (R->getKind() == MemRegion::CXXBaseObjectRegionKind &&
+cast(R)->getDecl()->isEmpty())
+  return StoreRef(store, *this);
+
 RegionBindingsRef B = getRegionBindings(store);
 assert(!B.lookup(R, BindingKey::Direct));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits